var layer = layui.layer; var table; var chartLine; //三维模型中的采集点数据 var gasInfos; var gasData; var depotId; var depotData; var tag; (function() { layui.use([ 'layer', 'laydate', 'table', 'form' ], function() { table = layui.table; layer = layui.layer; var form = layui.form; var layDate = layui.laydate; //日期 layDate.render({ elem : '#checkDate' }); //监听仓库选择 form.on('select(select_depotId)', function(obj) { flushData(); }); }); //初始化坐标 chartLine = initChartLine(); // 初始化WebSocket initWS(deptId, bizType,null, userId); }).call(this); //socket信息返回處理 function socketOnMessage(pocket) { if (pocket.orderResp == "MSG_SUCCESS") {// 信息解析成功刷新当前数据 flushData(null); } window.parent.sysNotify(pocket.data); }; //点击刷新操作 function flushData() { depotId = $("#depotId").val(); var checkDate = $("#checkDate").val(); if (!depotId) { layer.msg("请先选择仓库!"); return; } var data = { depotId : depotId, checkDate : checkDate }; $.ajax({ type : "POST", url : "../../basic/gas/flush-gas", data : JSON.stringify(data), dataType : "json", success : function(result) { if (result.code != "0000") { layer.msg(result.msg); return; } //采集点赋值 gasInfos = result.listPoint; gasData = result; renderGas(); renderGasInfo(); flushChartData(); }, error : function() { layer.msg("根据当前条件获取粮情数据渲染图标失败!!"); } }); }; /** * 展示采集点信息 */ function renderGasInfo() { table.render({ elem : '#tableGasInfo', height : 620, data : gasInfos, page : false, limit : 40, cols : [ [ { field : 'passCode', title : '检测点', align : 'center', }, { field : 'perCo2', title : 'CO2(PPM)', align : 'center' }, { field : 'perO2', title : 'O2(%)', align : 'center' }, { field : 'perPh3', title : 'PH3(PPM)', align : 'center' } ] ] }); }; //填写数据 function renderGas() { $("#strReciveDate").attr("value", gasData.strReceiveDate); $("#remark").attr("value", gasData.remark); $("#perCo2Max").attr("value", gasData.perCo2Max + " PPM"); $("#perCo2Ave").attr("value", gasData.perCo2 + " PPM"); $("#perCo2Min").attr("value", gasData.perCo2Min + " PPM"); $("#perO2Max").attr("value", gasData.perO2Max + " %"); $("#perO2Ave").attr("value", gasData.perO2 + " %"); $("#perO2Min").attr("value", gasData.perO2Min + " %"); $("#perPh3Max").attr("value", gasData.perPh3Max + " PPM"); $("#perPh3Ave").attr("value", gasData.perPh3 + " PPM"); $("#perPh3Min").attr("value", gasData.perPh3Min + " PPM"); var text = $("#depotId").find("option:selected").text(); $("#depotName").attr("value", text); }; //点击采集 function checkGas() { depotId = $("#depotId").val() if (!depotId) { layer.msg("请先选择仓库!"); return; } layer.msg("开始执行气体采集……"); $.ajax({ type : "POST", url : "../../basic/gas/check-single", data : { depotId : depotId }, dataType : "json", success : function(result) { if ("ORDER_SUCCESS" == result.code) { layer.msg("气体采集命令发送完成,其他采集周期较长,请耐心等待……"); } else { layer.msg("执行失败,信息:" + result.msg); } }, error : function() { layer.msg("气体采集失败,后台出现错误!"); } }); }; //定时检测 function timerCheck() { if (!depotId) { layer.msg("请先选择仓库!"); return; } var url = "../../com.ld.depot.timer.Timing.d?type=gas&depotId=" + depotId; window.parent.openUrlInFrameTab2(url, "定时检测配置", "icon-calendar", false); } function initChartLine() { var option = { title : { text : '最近检测走势', show : true }, tooltip : { trigger : 'axis', axisPointer : { type : 'cross', label : { backgroundColor : '#6a7985' } } }, color : [ '#FF00FF', '#0000FF', '#00FFFF', '#00FF00', '#FFFF00', '#FF7D00', '#FF0000', '#4472C5', '#ED7C30', '#80FF80', '#FF8096', '#800080' ], legend : { data : [ 'O2最大', 'O2平均', 'O2最小', 'CO2最大', 'CO2平均', 'CO2最小', 'PH3最大', 'PH3平均', 'PH3最小' ], bottom : '10', top : 'top', selected : { 'O2最大' : false, 'O2平均' : true, 'O2最小' : false, 'CO2最大' : false, 'CO2平均' : true, 'CO2最小' : false, 'PH3最大' : false, 'PH3平均' : true, 'PH3最小' : false } }, grid : { left : '3%', right : '3%', bottom : '3%', containLabel : true }, xAxis : [ { data : [ '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00' ] } ], yAxis : [ { name : 'O2(%)', type : 'value' }, { name : 'CO2/PH3(PPM)', type : 'value' } ], series : [ { name : 'O2平均', type : 'line', itemStyle : { normal : { color : '#FF7D00', borderColor : '#FF7D00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'O2最小', type : 'line', itemStyle : { normal : { color : '#0000FF', borderColor : '#0000FF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'O2最大', type : 'line', itemStyle : { normal : { color : '#00FFFF', borderColor : '#00FFFF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2最大', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#00FF00', borderColor : '#00FF00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2平均', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FF0000', borderColor : '#FF0000' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2最小', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FF00FF', borderColor : '#FF00FF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3最大', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FFFF00', borderColor : '#FFFF00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3平均', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#000000', borderColor : '#000000' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3最小', yAxisIndex : 1, type : 'line', itemStyle : { normal : { color : '#4472C5', borderColor : '#4472C5' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] } ] }; var myChart = echarts.init(document.getElementById("container"), "light"); myChart.setOption(option, true); return { "chart" : myChart, "option" : option }; }; //刷新走势 function flushChartData() { depotId = $("#depotId").val(); if (!depotId) { layer.msg("请先选择仓库!"); return; } if (tag == depotId) return; var data = { "depotId" : depotId, "limit" : 20 }; $.ajax({ type : "GET", url : "../../basic/gas/list-gas", dataType : "json", data : data, success : function(result) { if (result) { renderChart(result); tag = depotId; } else { layer.msg("气体信息获取为空,请确认是否有采集信息!"); } }, error : function(result) { layer.msg("获取数据失败,请重新尝试!"); } }); }; function renderChart(result) { if (!(result && result.listDate)) { return; } var txt = $("#depotId").find("option:selected").text(); chartLine.option.title.text = txt + "检测走势"; chartLine.option.xAxis[0].data = result.listDate; chartLine.option.series[0].data = result.o2Ave; chartLine.option.series[1].data = result.o2Max; chartLine.option.series[2].data = result.o2Min; chartLine.option.series[3].data = result.co2Ave; chartLine.option.series[4].data = result.co2Max; chartLine.option.series[5].data = result.co2Min; chartLine.option.series[6].data = result.ph3Ave; chartLine.option.series[7].data = result.ph3Max; chartLine.option.series[8].data = result.ph3Min; chartLine.chart.setOption(chartLine.option, true); };