廖井涛
2025-05-27 d687ff755f0f3022dcd1f57a03104b0e91536ab3
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
<%@ page language="java" pageEncoding="UTF-8"%>
<script type="text/javascript"
    src="https://fastly.jsdelivr.net/npm/echarts@5.4.2/dist/echarts.min.js"></script>
<!-- 大屏电量显示部分 -->
<style>
.s-title {
    font-size: 25px;
    /*font-weight: bold;
     text-align :center; */
    vertical-align: middle;
    text-align: center
}
 
datetime-local {
    font-size: 25px;
}
</style>
<div class="modal fade" id="div_daping" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="form-horizontal" role="form">
        <div class="modal-dialog" style="width: 75%;height=75%">
            <div class="modal-content" style="">
                <div class="modal-header">
                    <div class="form-group" style="margin: auto; text-align: center">
                        <span id="mdp_title"
                            style="font-size: 30px; font-weight: bold; float: left; margin-left: 5%">
                        </span> <span class="s-title">开始时间</span> <input type="datetime-local"
                            id="starttime" name="starttime" class="s-title" /> &nbsp;&nbsp;<span
                            class="s-title">结束时间</span> <input type="datetime-local"
                            id="endtime" name="endtime" class="s-title" /> &nbsp;&nbsp;
                        <button type="button" class="btn btn-success btn-lg"
                            id="btn_query" onclick="chat_query()">查询</button>
 
                        <button type="button" class="btn btn-primary close"
                            data-dismiss="modal" aria-hidden="true">【关闭】</button>
                    </div>
                </div>
                <div class="modal-body">
                    <!-- <h3>产线每日产量报表</h3> -->
<div style="font-size:25px;display:flex">
                        <div  class="col-lg-3">产线每日产量报表</div>
                        <div  class="col-lg-9"><span id="rf_zl_info"></span></div>
                    </div>
                    <div id="container" style="height: 360px; max-width: 100%"></div>
                    <h3>产线班组每日产量报表</h3>
                    <div id="container1_" style="height: 440px; max-width: 100%"></div>
                    <!-- <div id="container2" style="height: 350px; max-width: 100%"></div> -->
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </form>
</div>
 
 
<script type="text/javascript">
    var dp_url = "/gmms2/mesview/data/_dpxiangqing_manage";
    var p_url = "/gmms2/mesview/data/_public_manage";
    var format = "";
    var dom = document.getElementById('container');
    var myChart = echarts.init(dom, null, {
        renderer : 'canvas',
        useDirtyRect : false
    });
 
    var dom1 = document.getElementById('container1_');
    var myCharts_ = echarts.init(dom1, null, {
        renderer : 'canvas',
        useDirtyRect : false
    });
 
    function getFormat(days) {
        format = "";
        var nTime = new Date();
        nTime.setDate(nTime.getDate() - days);
        format += nTime.getFullYear() + "-";
        format += (nTime.getMonth() + 1) < 10 ? "0" + (nTime.getMonth() + 1)
                : (nTime.getMonth() + 1);
        format += "-";
        format += nTime.getDate() < 10 ? "0" + (nTime.getDate()) : (nTime
                .getDate());
        format += "T";
        format += nTime.getHours() < 10 ? "0" + (nTime.getHours()) : (nTime
                .getHours());
        format += ":";
        format += nTime.getMinutes() < 10 ? "0" + (nTime.getMinutes()) : (nTime
                .getMinutes());
        format += ":00";
    }
 
    var current_gongxu_banzu=[];//当前工序班组
    
    function modalDPShow(gongxu,pT) {
        $("#div_daping").modal('toggle');
        $("#mdp_title").text(pT);
        
        $.ajax({
            type : "post",
            dataType : "Json",
            url : p_url,
            data : {
                caozuo : '查询',
                leixing:'班组列表',
                gongyi : gongxu
            },
            success : function(data) {
                current_gongxu_banzu=[];
                if(data.length>0){
                    for(var i =0;i<data.length;i++)
                        current_gongxu_banzu.push(data[i][0]);
                    getFormat(0);//默认开始时间
                    $("#endtime").val(format);
                    getFormat(6);//默认结束时间
                    $("#starttime").val(format);
                    myChart.resize();
                    myCharts_.resize();
 
                    chat_query();
                }
                else{
                    $("#CZ_Msg").modal('toggle');
                    $("#cz_Ming").html("查询");
                    $("#cz_Zhuangtai").html("");
                    $("#cz_Zhuangtai").attr("style", "color:red;");
                    $("#cz_mingxi").html("班组获取失败!");
                    return;
                }
            }
            
        });
    }
 
    var pageTitle = $("#mdp_title").text();
 
    var app = {};
    //需要日期数组,每日产量数组,每日耗电数组
    //每日班组产量数组
    
    var qDate = [];//查询的日期集合
    var qDianLiang = [];//查询的电量集合
    var qChanLiang = [];//查询的产量集合
    
    var qBanZu_Cl =[];
 
    var total_chanliang =0;//产量总和
    var total_dianliang =0;//电量总和
    
    //班组-每日 产量
    var bz_cl_0=[];
    var bz_cl_1=[];
    var bz_cl_2=[];
    var bz_cl_3=[];
    var bz_cl_4=[];
    var bz_cl_5=[];
    var bz_cl_6=[];
    var bz_cl_7=[];
    var bz_cl_8=[];
    var bz_cl_9=[];
    
    function initArray(){
        qDate=[];
        qChanLiang = [];
        qDianLiang = []
        bz_cl_0=[];
        bz_cl_1=[];
        bz_cl_2=[];
        bz_cl_3=[];
        bz_cl_4=[];
        bz_cl_5=[];
        bz_cl_6=[];
        bz_cl_7=[];
        bz_cl_8=[];
        bz_cl_9=[];
    }
 
    function chat_query() {
        var sTime = $("#starttime").val();
        if (sTime == null || sTime == "") {
            $("#CZ_Msg").modal('toggle');
            $("#cz_Ming").html("查询");
            $("#cz_Zhuangtai").html("");
            $("#cz_Zhuangtai").attr("style", "color:red;");
            $("#cz_mingxi").html("请选择查询开始时间!");
            return;
        }
 
        var sDate = $("#starttime").val().substr(0, 10);
        var eDate = $("#endtime").val().substr(0, 10);
 
        $.ajax({
            type : "post",
            dataType : "Json",
            url : dp_url,
            data : {
                caozuo : '产量2',
                sDate : sDate,
                eDate : eDate,
                lineName : $("#mdp_title").text()
            },
            success : function(data) {
                var d = data;
                if (d.length > 0) {
                    
                    initArray();
                    var cl =0;
total_chanliang =0;
                    total_dianliang=0;
 
                    for (var i = 0; i < d.length; i++) {
                        total_chanliang+=d[i][2];
                        if(qDate.length==0){
                            qDate.push(d[i][0]);
                            cl=d[i][2];
                            
                        }else{
                            if(qDate.indexOf(d[i][0])>=0){
                                cl+=d[i][2];
                                
                        
                            }else{
                                qChanLiang.push(keepTwoDecimalFull(cl));
                                qDate.push(d[i][0]);
                                cl=d[i][2];
                            }
                            
                            if(i==d.length-1){
                                qChanLiang.push(keepTwoDecimalFull(cl));
                            }
                            
                        }
                        
                        switch(current_gongxu_banzu.indexOf(d[i][1])){
                        case 0:
                            bz_cl_0.push(d[i][2]);
                            break;
                        case 1:
                            bz_cl_1.push(d[i][2]);
                            break;
                        case 2:
                            bz_cl_2.push(d[i][2]);
                            break;
                        case 3:
                            bz_cl_3.push(d[i][2]);
                            break;
                        case 4:
                            bz_cl_4.push(d[i][2]);
                            break;
                        case 5:
                            bz_cl_5.push(d[i][2]);
                            break;
                        case 6:
                            bz_cl_6.push(d[i][2]);
                            break;
                        case 7:
                            bz_cl_7.push(d[i][2]);
                            break;
                        case 8:
                            bz_cl_8.push(d[i][2]);
                            break;
                        case 9:
                            bz_cl_9.push(d[i][2]);
                            break;
                        default:
                        
                        }        
                    }
                     /* alert("班组1:"+bz_cl_0+"\r\n班组2:"+bz_cl_1+"\r\n班组3:"+bz_cl_2+"\r\n班组4:"+bz_cl_3
                             +"\r\n工艺班组:"+current_gongxu_banzu+"\r\n每日产量:"+qChanLiang+"\r\n查询日期:"+qDate);
                    return; */
                    
                    $.ajax({
                        type : "post",
                        dataType : "Json",
                        url : dp_url,
                        data : {
                            caozuo : '电量',
                            sDate : sDate,
                            eDate : eDate,
                            lineName : $("#mdp_title").text()
                        },
                        success : function(data) {
                            var d = data;
                            if (d.length > 0) {
                                queryDate = [];
                                queryDL = [];
                                avgDL=[];
                                for (var i = 0; i < d.length; i++) {
total_dianliang+=d[i][1];
                                    qDianLiang.push(d[i][1]);
                                    avgDL.push((d[i][1]/qChanLiang[i]).toFixed(2));
                                }
                                if (qDate.length < 1) {
                                    return;
                                }
                                /* alert("查询日期:" + qDate +" 长度"+qDate.length+
                                        "\r\n电量:" + qDianLiang+" 长度"+qDianLiang.length+
                                        "\r\n产量:" + qChanLiang+" 长度"+qChanLiang.length+
                                        "\r\n平均耗能:"+avgDL+" 长度"+avgDL.length
                                        ); */
 
                                                                $("#rf_zl_info").html("【总产量:"+keepTwoDecimalFull(total_chanliang)+" ㎡ 】【总电量:"+keepTwoDecimalFull(total_dianliang)+" kwh 】【平均耗电量:"+keepTwoDecimalFull(total_dianliang/total_chanliang)+" kwh/㎡】");        
                                            
                                //产线每日产量报表
                                showChats(qDate, qDianLiang, qChanLiang,avgDL);
                                //产线班组每日产量报表
                                showBanZuChats(qDate,current_gongxu_banzu,qDianLiang);
                            }
 
                        },
                        error : function(data) {
 
                        }
                    })
                }
 
            },
            error : function(data) {
 
            }
        })
    }
    
    function showChats(queryDate, queryDL, queryCL,avgDL) {
 
        var option;
        option = {
            /* title : {
                // text : '产线每日产量表', 
                text : '',
                 left : 'center', 
                subtext : '',
                textStyle : {
                    fontSize : 35,
                    // textBorderColor:'red',
                    //textBorderWidth:1 
                }
            }, */
            
            
            toolbox : {
                show : true,
                itemSize : 30,
                /* top:"top", */
                /* left:"rigth", */
                showTitle : false, // 隐藏默认文字,否则两者位置会重叠
                feature : {
                    dataView : {
                        show : true,
                        readOnly : true,
                        title : '数据视图'
                    },
                    //magicType: { show: true, type: ['line', 'bar'] },
                    //restore: { show: true },
                    saveAsImage : {
                        show : true,
                        title : '保存为图片'
                    }
                    ,magicType: { show: true, type: ['line', 'bar'] },
                     restore: { show: true },
                },
                tooltip : { // 和 option.tooltip 的配置项相同
                    show : true,
                    formatter : function(param) {
                        //return '<div>' + param.title + '</div>'; // 自定义的 DOM 结构
                        return param.title; // 自定义的 DOM 结构
                    },
                    textStyle : {
                        fontSize : 20
                    },
                    extraCssText : 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);' // 自定义的 CSS 样式 
                }
            },
            legend:{
                data:['产量(㎡)','单位耗能(kwh/m²)']
            },
            tooltip : {
                trigger : 'axis',
                axisPointer : {
                    type : 'cross',
                    crossStype:{
                        color:'#999'
                        
                    }
                },
                formatter : function(params) {
                    var chanliang = params[0];
                    var nenghao = params[1];
                    if (chanliang.value != 0) {
                        return chanliang.name + '<br/>' + chanliang.seriesName
                                + ' : ' + chanliang.value + ' m²' + '<br/>'
                                +'耗电量:'+nenghao.value+" kwh<br/>"
                                //能耗数据显示
                                //+nenghao.seriesName+' : '+nenghao.value+' kwh<br/>'
                                + '每平方耗电 : '
                                + (nenghao.value / chanliang.value).toFixed(2)
                                + ' kwh/m²';
 
                    } else {
                        return chanliang.name + '<br/>' + chanliang.seriesName
                                + ' : ' + chanliang.value + ' m²' + '<br/>'
 
                                //+nenghao.seriesName+' : '+nenghao.value+' kwh<br/>'
                                + '每平方耗电 : 0 kwh/m²';
                    }
 
                },
                textStyle : {
                    fontSize : 30
                }
            },
            grid : {
                //top:'10%',
                left : '3%',
                right : '5%',
                bottom : '3%',
                containLabel : true
            },
            xAxis : [ {
                type : 'category',
                name : '日期',
                data : queryDate,
                axisTick : {
                    alignWithLabel : true
                },
                axisLabel : {
                    //interval: 50,
                    //rotate: 40,
                    textStyle : {
                        color : "#222222",
                        fontSize : 26
                    }
                },
            } ],
            textStyle : {
                fontSize : 26
            },
            yAxis : [ {
                type : 'value',
                /* name : '产量(m²)', */
                axisLabel : {
                    //interval: 50,
                    //rotate: 40,
                    textStyle : {
                        color : "#222222",
                        fontSize : 26
                    }
                }
            },
            {
                type:'value',
                axisLabel : {
                    //interval: 50,
                    //rotate: 40,
                    textStyle : {
                        /* color : "#222222", */
                        fontSize : 26
                    }
                }
                
            }],
            series : [ {
                name : '产量(㎡)',
                type : 'bar',
                //barWidth: '50%',
                data : queryCL ,
                markPoint : {
                    data : [ 
                         {type : 'max',name : 'Max'}, 
                         {type : 'min',name : 'Min'} 
                    ]
                },
                markLine : {
                    data : [ 
                       {type : 'average',name : 'Avg'} 
                    ]
                }
            }, {
                name : '能耗',
                type : 'bar',
                barWidth : '1%', 
                itemStyle : {
                    borderColor : 'transparent',
                    color : 'transparent'
                },
                emphasis : {
                    itemStyle : {
                        borderColor : 'transparent',
                        color : 'transparent'
                    }
                },
                data : queryDL 
            },{
                name:'单位耗能(kwh/m²)',
                type:'line',
                yAxisIndex:1,
                data:avgDL,
                lineStyle:{
                    width:5,
                    type:'solid'
                }
                
            }]
        };
 
        if (option && typeof option === 'object') {
 
            myChart.setOption(option);
 
        }
        myChart.resize();
    }
    
    
 
    function showBanZuChats(queryDate,gx_banzu, queryDL) {
 
        var option;
        option = {
            /* title : {
                //text : '产线班组每日产量表',
                text : '',
                 left : 'center', 
                subtext : '',
                textStyle : {
                    fontSize : 35
                }
            }, */
            legend:{
                data:gx_banzu
            },
            calculable: true,
            toolbox : {
                show : true,
                itemSize : 30,
                showTitle : false, // 隐藏默认文字,否则两者位置会重叠
                feature : {
                    dataView : {
                        show : true,
                        readOnly : true,
                        title : '数据视图'
                    },
                    saveAsImage : {
                        show : true,
                        title : '保存为图片'
                    }
                     ,magicType: { show: true, type: ['line', 'bar'] },
                     restore: { show: true }
                },
                tooltip : { // 和 option.tooltip 的配置项相同
                    show : true,
                    formatter : function(param) {
                        //return '<div>' + param.title + '</div>'; // 自定义的 DOM 结构
                        return param.title; // 自定义的 DOM 结构
                    },
                    textStyle : {
                        fontSize : 20
                    },
                    extraCssText : 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);' // 自定义的 CSS 样式 
                }
            },
             tooltip: {
                 trigger: 'axis',
                 textStyle : {
                        fontSize : 30
                    }
            }, 
            /* tooltip : {
                trigger : 'axis',
                 axisPointer : {
                    type : ''
                },
                formatter : function(params) {
                    var chanliang = params[0];
                    var nenghao = params[1];
                    if (chanliang.value != 0) {
                        return chanliang.name + '<br/>' + chanliang.seriesName
                                + ' : ' + chanliang.value + ' m²' + '<br/>'
                                
                                //能耗数据显示
                                //+nenghao.seriesName+' : '+nenghao.value+' kwh<br/>'
                                + '每平方耗电 : '
                                + (nenghao.value / chanliang.value).toFixed(2)
                                + ' kwh/m²';
 
                    } else {
                        return chanliang.name + '<br/>' + chanliang.seriesName
                                + ' : ' + chanliang.value + ' m²' + '<br/>'
 
                                //+nenghao.seriesName+' : '+nenghao.value+' kwh<br/>'
                                + '每平方耗电 : 0 kwh/m²';
                    }
 
                }, 
                textStyle : {
                    fontSize : 30
                }
            }, */
             grid : {
                //top:'15%',
                left : '3%',
                right : '4%',
                bottom : '3%', 
                containLabel : true
            },
            xAxis : [ {
                type : 'category',
                name : '日期',
                data : queryDate,
                axisTick : {
                    alignWithLabel : true
                },
                axisLabel : {
                    //interval: 50,
                    //rotate: 40,
                    textStyle : {
                        color : "#222222",
                        fontSize : 26
                    }
                },
            } ],
            textStyle : {
                fontSize : 26
            },
            yAxis : [ {
                type : 'value',
                name : '产量(m²)',
                axisLabel : {
                    //interval: 50,
                    //rotate: 40,
                    textStyle : {
                        color : "#222222",
                        fontSize : 26
                    }
                }
            } ],
            series : [ {
                name : gx_banzu[0],
                type : 'bar',
                //barWidth: '50%',
                data : bz_cl_0 ,
                markPoint : {
                    data : [ 
                         {type : 'max',name : 'Max'}, 
                         {type : 'min',name : 'Min'} 
                    ]
                },
                markLine : {
                    data : [ 
                       {type : 'average',name : 'Avg'} 
                    ]
                }
            }, {
                name : gx_banzu[1],
                type : 'bar',
                //barWidth: '50%',
                data : bz_cl_1 ,
                markPoint : {
                    data : [ 
                         {type : 'max',name : 'Max'}, 
                         {type : 'min',name : 'Min'} 
                    ]
                },
                markLine : {
                    data : [ 
                       {type : 'average',name : 'Avg'} 
                    ]
                }
            }, {
                name : gx_banzu[2],
                type : 'bar',
                //barWidth: '50%',
                data : bz_cl_2 ,
                markPoint : {
                    data : [ 
                         {type : 'max',name : 'Max'}, 
                         {type : 'min',name : 'Min'} 
                    ]
                },
                markLine : {
                    data : [ 
                       {type : 'average',name : 'Avg'} 
                    ]
                }
            }/* , {
                name : '能耗',
                type : 'bar',
                barWidth : '1%',
                itemStyle : {
                    borderColor : 'transparent',
                    color : 'transparent'
                },
                emphasis : {
                    itemStyle : {
                        borderColor : 'transparent',
                        color : 'transparent'
                    }
                },
                data : queryDL ,
                markPoint : {
                    data : [ {
                        name : 'Max',
                        value : 182.2,
                        xAxis : 7,
                        yAxis : 183
                    }, {
                        name : 'Min',
                        value : 2.3,
                        xAxis : 11,
                        yAxis : 3
                    }
                    ]
                },
                markLine : {
                    data : [ {
                        type : 'average',
                        name : 'Avg'
                    } ]
                }
            }  */] 
        };
 
        if (option && typeof option === 'object') {
 
            myCharts_.setOption(option);
        }
        myCharts_.resize();
    }
    
    //保留小数点后两位
    function keepTwoDecimalFull(num) {
        var result = parseFloat(num);
        if (isNaN(result)) {
 
            return;
        }
        result = Math.round(num * 100) / 100;
        var s_x = result.toString();
        var pos_decimal = s_x.indexOf('.');
        if (pos_decimal < 0) {
            pos_decimal = s_x.length;
            s_x += ".";
 
        }
        while (s_x.length <= pos_decimal + 2) {
            s_x += '0';
        }
        return s_x;
 
    }
</script>