jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
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);
};