CZT
2023-09-06 71c4fa1e27f75ae4b765c95c67a3069c84dc72ba
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
var layer;
var form;
var depotId;
var chartTop;
var chartMain;
// 上面的图标数据
var chartTopData = [ {
    name : '有功电能',
    value : 0.0,
    unit : 'kW·h',
    pos : [ '16.6%', '50%' ],
    range : [ 0, 500 ]
}, {
    name : '无功电能',
    value : 0.0,
    unit : 'kW·h',
    pos : [ '49.8%', '50%' ],
    range : [ 0, 500 ]
}, {
    name : '总电能',
    value : 0.0,
    unit : 'kW·h',
    pos : [ '83%', '50%' ],
    range : [ 0, 1000 ]
} ];
 
$(function() {
    layui.use([ 'layer', 'table', 'form', 'laydate' ], function() {
        table = layui.table;
        form = layui.form;
        layer = layui.layer;
        laydate = layui.laydate;
 
        laydate.render({
            elem : '#checkDate',
            theme : '#7b8e9f'
        });
 
        laydate.render({
            elem : '#checkMonth',
            type : 'month',
            theme : '#7b8e9f'
        });
        
        
        chartTop = initChartTop();
        chartMain = initChartMain();
        
        //系统自动调用查询
        query();
    });
});
 
// 根据条件刷新数据
function query() {
    var checkDate = $("#checkDate").val();
    var timeType = $('#timeType input[name="timeType"]:checked ').val();
 
    if (!checkDate) {
        layer.msg("选择时间条件不能为空");
        return;
    }
 
    var index = layer.load();
    $.ajax({
        type : "POST",
        url : "../../basic/es/summary-query",
        data : JSON.stringify({
            checkDate : checkDate,
            timeType : timeType
        }),
        dataType : "json",
        contentType : "application/json;charset=UTF-8",
        success : function(result) {
            layer.close(index);
            if (result.code != "0000") {
                layer.alert(result.msg);
                return;
            }
            // 渲染数据信息
            renderSum(result.data.esSum);
            // 渲染仓库分组统计
            renderList(result.data.esSumList);
        },
        error : function() {
            layer.close(index);
            layer.msg("执行异常,后台出现错误!");
        }
    });
};
 
// 渲染整体统计数据
function renderSum(esSum) {
    var esMax = 10000;
    if(esSum.esCur > esMax){
        chartTopData[0].range =[0,50000];
        chartTopData[1].range =[0,50000];
        chartTopData[2].range =[0,100000];
    }else{
        chartTopData[0].range =[0,2000];
        chartTopData[1].range =[0,2000];
        chartTopData[2].range =[0,8000];
    }
    chartTopData[0].value = esSum.epSum.toFixed(2);
    chartTopData[1].value = esSum.eqSum.toFixed(2);
    chartTopData[2].value = esSum.esSum.toFixed(2);
 
    $("#esCur").text(esSum.esCur.toFixed(2) +" kW·h");
    $("#esMom").text(esSum.esMom.toFixed(2) +" kW·h");
    $("#esYoy").text(esSum.esYoy.toFixed(2) +" kW·h");
 
    initChartTop();
};
 
function renderList(list) {
    var attrData0 = new Array();
    var attrData1 = new Array();
    var attrData2 = new Array();
    var attrX = new Array();
 
    $.each(list, function(index, item) {
        attrData0.push(item.epSum);
        attrData1.push(item.eqSum);
        attrData2.push(item.esSum);
        attrX.push(item.depotName);
    });
    chartMain.option.series[0].data = attrData0;
    chartMain.option.series[1].data = attrData1;
    chartMain.option.series[2].data = attrData2;
    chartMain.option.xAxis[0].data = attrX;
    chartMain.chart.setOption(chartMain.option, true);
};
 
function initChartTop() {
    var highlight = '#03b7c9';
    var option = {
        backgroundColor : '#222939',
        series : (function() {
            var result = [];
            chartTopData.forEach(function(item) {
                result.push(
                // 外围刻度
                {
                    type : 'gauge',
                    center : item.pos,
                    radius : '70%', // 1行3个
                    splitNumber : item.splitNum || 5,
                    min : item.range[0],
                    max : item.range[1],
                    // startAngle : 225,
                    // endAngle : -45,
                    axisLine : {
                        show : true,
                        lineStyle : {
                            width : 2,
                            shadowBlur : 0,
                            color : [ [ 1, highlight ] ]
                        }
                    },
                    axisTick : {
                        show : true,
                        lineStyle : {
                            color : highlight,
                            width : 1
                        },
                        length : -5,
                        splitNumber : 10
                    },
                    splitLine : {
                        show : true,
                        length : -14,
                        lineStyle : {
                            color : highlight,
                        }
                    },
                    axisLabel : {
                        distance : -20,
                        textStyle : {
                            color : highlight,
                            fontSize : '14',
                            fontWeight : 'bold'
                        }
                    },
                    pointer : {
                        show : 0
                    },
                    detail : {
                        show : 0
                    }
                },
 
                // 内侧指针、数值显示
                {
                    name : item.name,
                    type : 'gauge',
                    center : item.pos,
                    radius : '50%',
                    // startAngle : 225,
                    // endAngle : -45,
                    min : item.range[0],
                    max : item.range[1],
                    axisLine : {
                        show : true,
                        lineStyle : {
                            width : 16,
                            color : [ [ 1, 'rgba(255,255,255,.1)' ] ]
                        }
                    },
                    axisTick : {
                        show : 0,
                    },
                    splitLine : {
                        show : 0,
                    },
                    axisLabel : {
                        show : 0
                    },
                    pointer : {
                        show : true,
                        length : '105%'
                    },
                    detail : {
                        show : true,
                        offsetCenter : [ 0, '100%' ],
                        textStyle : {
                            fontSize : 20,
                            color : '#fff'
                        },
                        formatter : [ '{value} ' + (item.unit || ''),
                                '{name|' + item.name + '}' ].join('\n'),
                        rich : {
                            name : {
                                fontSize : 14,
                                lineHeight : 30,
                                color : '#ddd'
                            }
                        }
                    },
                    itemStyle : {
                        normal : {
                            color : highlight,
                        }
                    },
                    data : [ {
                        value : item.value
                    } ]
                });
            });
            return result;
        })()
    };
 
    var myChart = echarts.init(document.getElementById('chart_top'), "light");
    myChart.setOption(option, true);
    return {
        "chart" : myChart,
        "option" : option
    };
};
 
function initChartMain() {
    var option = {
        backgroundColor : '#222939',
        tooltip : {
            trigger : 'axis',
            axisPointer : { // 坐标轴指示器,坐标轴触发有效
                type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
            }
        },
        legend : {
            data : [ '有功电能', '无功电能', '总电能' ],
            textStyle : {
                color : 'rgba(55,255,249,1)'
            }
        },
        grid : {
            left : '3%',
            right : '4%',
            bottom : '3%',
            containLabel : true
        },
        xAxis : [ {
            type : 'category',
            data : [ '35号仓', '36号仓', '37号仓', '38号仓', '39号仓', '40号仓', '41号仓',
                    '42号仓', '43号仓', '44号仓', '45号仓', '46号仓', '47号仓', '48号仓',
                    '49号仓', '50号仓', '51号仓', '52号仓', '53号仓', '54号仓' ],
            splitLine : {
                show : false
            },
            axisLine : {
                lineStyle : {
                    color : 'rgba(55,255,249,1)',
                }
            },
            axisLabel : {
                color : 'rgba(55,255,249,1)'
            }
        } ],
        yAxis : [ {
            type : 'value',
            splitLine : {
                show : false
            },
            axisLine : {
                lineStyle : {
                    color : 'rgba(55,255,249,1)',
                }
            }
        } ],
        series : [
                {
                    name : '有功电能',
                    type : 'bar',
                    barWidth : 15,
                    itemStyle : {
                        barBorderRadius : 15,
                        color : new echarts.graphic.LinearGradient(0, 0, 0, 1,
                                [ {
                                    offset : 0,
                                    color : "rgba(55,255,249,1)"
                                }, {
                                    offset : 1,
                                    color : "rgba(0,222,215,0.2)"
                                } ])
                    },
                    data : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4,
                            3, 2, 1, 0.0 ]
                },
                {
                    name : '无功电能',
                    type : 'bar',
                    barWidth : 15,
                    itemStyle : {
                        barBorderRadius : 15,
                        color : new echarts.graphic.LinearGradient(0, 0, 0, 1,
                                [ {
                                    offset : 0.4,
                                    color : "rgba(255,252,0,1)"
                                }, {
                                    offset : 1,
                                    color : "rgba(8,228,222,0.2)"
                                } ])
                    },
                    data : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4,
                            3, 2, 1, 0.0 ]
                },
                {
                    name : '总电能',
                    type : 'bar',
                    barWidth : 15,
                    itemStyle : {
                        barBorderRadius : 15,
                        color : new echarts.graphic.LinearGradient(0, 0, 0, 1,
                                [ {
                                    offset : 0.4,
                                    color : "rgba(100,252,2,1)"
                                }, {
                                    offset : 1,
                                    color : "rgba(16,100,100,0.2)"
                                } ])
                    },
                    data : [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14,
                            12, 10, 8, 6, 4, 2, 1 ]
                } ]
    }
 
    var myChart = echarts.init(document.getElementById('chart_main'), "light");
    myChart.setOption(option, true);
    return {
        "chart" : myChart,
        "option" : option
    };
}