zhuzhuanzhuan
2023-08-18 e5ba8ad74ed9ebc28b0500cc531fb9bdad516980
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
<template>
  <div id="StatisticsLegend" style="width: 100%; height: 100%; overflow: hidden;display: flex;flex-direction: column;background-color: #f5f4f4">
    <!-- 查询区域 -->
    <div style="width: 100%; height: 44px; background-color: #fff" class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="5" :sm="5" :xs="5">
            <a-form-item label="名称">
              <a-input placeholder="输入设备名称查询" :readOnly="readOnly" v-model="queryParam.tierName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="4" :xs="4">
            <a-form-item label="日期">
              <a-date-picker v-model="queryParams.collectTime" :disabledDate="disabledDate" format='YYYY-MM-DD' @change="dataChange"/>
            </a-form-item>
          </a-col>
          <a-col :md="3" :sm="3" :xs="3">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
          </a-col>
          <a-col :md="2" :sm="2" :xs="2">
            <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!--开机率-->
    <div class="PowerOnRate  Line-box">
      <!--<div class="title">-->
        <!--<div class="circle"></div>-->
        <!--<div class="text">利用率</div>-->
      <!--</div>-->
      <div class="PowerOnRate-box box-bottom">
        <!--<div class="PowerOnRate-left" ref="PowerOnRatePie" id="PowerOnRatePie"></div>-->
        <div class="PowerOnRate_text" style="width: 8%;">
          <p>开机率</p>
          <p>{{UtilizationHeight}}%</p>
          <p>利用率</p>
          <p>{{StatCharUsedRate}}%</p>
        </div>
        <div class="PowerOnRate-right" ref="PowerOnRateLine" id="PowerOnRateLine"></div>
        <div  class="PowerOnRate_text" style="width: 8%">
          <table width="85px;" align="center">
            <tr>
              <td align="right"><div style="width: 15px;height: 15px;background-color: #4169E1;position: static;"/></td>
              <td align="left">开机</td>
            </tr>
            <tr>
              <td align="right"><div style="width: 15px;height: 15px;background-color: #A8A8A8;position: static;"/></td>
              <td align="left">关机</td>
            </tr>
            <tr>
              <td align="right"><div style="width: 15px;height: 15px;background-color: #00ee00"/></td>
              <td align="left">运行</td>
            </tr>
            <tr>
              <td align="right"><div style="width: 15px;height: 15px;background-color: #FCCE10"/></td>
              <td align="left">待机</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <!--利用率和开动率-->
    <div class="UtilizationStartup">
      <div class="Utilization Line-box">
        <div class="title">
          <!--<div class="circle"></div>-->
          <!--<div class="text"></div>-->
        </div>
        <div class="Utilization-box box-bottom">
          <div class="Utilization-right" ref="UtilizationLine" id="UtilizationLine"></div>
        </div>
      </div>
      <div class="Startup Line-box">
        <div class="title">
          <!--<div class="circle"></div>-->
          <!--<div class="text"></div>-->
        </div>
        <div class="Startup-box box-bottom">
          <div class="Startup-right" ref="StartupLine" id="StartupLine"></div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
  import moment from 'moment'
  import { putAction, getAction } from '@/api/manage'
  import $ from 'jquery'
  import AFormItem from 'ant-design-vue/es/form/FormItem'
  import * as echarts from 'echarts'
  export default {
    name: 'StatisticalAnalysisMain',
    components:{
      AFormItem
 
    },
    props: { equip: {} },
    data(){
      return{
        readOnly:true,
        showday:true,
        StatCharOpeningRate:0,
        StatCharUsedRate:0,
        StatCharUsedopeningRate:0,
        openingLong:0,
        waitingLong:0,
        processLong:0,
        closedLong:0,
        totalLong:0,
        UtilizationHeight:0,
        StartupHeight:0,
        quip:{},
        dates: [],
        queryParam: {},
        queryParams:{
          collectTime:undefined,
        },
        shiftSubList: [],
        shiftList: [],
        url: {
          getEquipmentByPid: '/mdc/mdcequipment/getEquipmentByPid',
          dayStatisticalRate:'/mdc/efficiencyReport/dayStatisticalRate',
          getBaseTree: '/mdc/mdcEquipment/queryTreeListByProduction',
        },
      }
    },
    created(){
 
 
      let collectTime = moment(moment().add(-1,'d'),'YYYY-MM-DD');
 
 
      this.queryParams.collectTime = collectTime;
 
      this.queryParams.dateTime = this.queryParams.collectTime.format('YYYYMMDD')
      this.initEquipmentNode()
      this.queryStatistical();
      // this.getTime(37800);
    },
 
    methods:{
      disabledDate(current){
        //Can not slect days before today and today
        return current && current > moment().subtract('days', 1);
      },
      //把秒计算成对应的时分秒的函数
      getTime(time){
        //转换为时分秒
        let h = Math.round(time / 60 / 60)
        h = h <10 ? '0' + h : h
        //作为返回值返回
        // console.log(h);
        return h;
      },
      moment,
      draw(){
        //开始时间\关机时间\运行时间\待机时间
        let PowerOnRateLine = this.$echarts.init(document.getElementById('PowerOnRateLine'), 'macarons');
        let PowerOnRateLine_option = {
          tooltip:{
            trigger: 'axis',
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            top: 60,
            containLabel: true
          },
          toolbox: {
            show : true,
            padding: 15,
            feature : {
              saveAsImage : {show: true,title:'保存图片',name :'设备效率统计报表'}
            }
          },
          xAxis :{
            type : 'category',
            data:['开机时长','关机时长','运行时长','待机时长'],
            axisLabel:{          //坐标轴字体颜色
              textStyle:{
                color: '#000'
              }
            },
            axisLine:{
              lineStyle:{
                color:"#e5e5e5"
              }
            },
            axisTick:{       //y轴刻度线
              show:false
            },
            splitLine:{    //网格
              show: false,
            },
            boundaryGap: true,
          },
          yAxis :{
            name: '时间/小时',
            type : 'value',
            axisLabel:{        //坐标轴字体颜色
              textStyle:{
                color: '#000'
              }
            },
            axisLine:{
              show:false,
            },
            axisTick:{       //y轴刻度线
              show:false
            },
            splitLine:{    //网格
              show: true,
              color:'#dadde4',
              lineStyle:{
                type:"dashed"
              }
            }
          },
          series:[
            // {
            //   name:'曲线',
            //   type: 'line',
            //   smooth:true,
            //   symbol: 'circle',
            //   symbolSize: 8,
            //   label:{
            //     show:true,
            //     position:"top",
            //     textStyle:{
            //       color:'#000',
            //     },
            //     formatter:"时长:{c}H"
            //   },
            //   itemStyle: {
            //     color: "rgb(87, 120, 225)",
            //     borderColor: "#fff",
            //     borderWidth: 2,
            //     shadowColor: 'rgba(0, 0, 0, .3)',
            //   },
            //   lineStyle: {
            //     normal: {
            //       color:"rgb(87, 120, 225)",
            //       shadowColor: 'rgba(87, 120, 225, .4)',
            //       shadowBlur: 8,
            //       shadowOffsetY: 10,
            //       shadowOffsetX: 0,
            //     },
            //   },
            //   areaStyle: {
            //     normal: {
            //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
            //         offset: 0,
            //         color: 'rgba(87, 120, 225, .6)'
            //       }, {
            //         offset: 1,
            //         color: 'rgba(87, 120, 225, .3)'
            //       }]),
            //     }
            //   },
            //   data: [this.openingLong, this.closedLong, this.processLong,this.waitingLong],
            // },
            {
              name:'柱状图',
              type: 'bar',
              data: [this.openingLong, this.closedLong, this.processLong,this.waitingLong],
              barWidth: 25,
              label:{
                show:true,
                position:"top",
                textStyle:{
                  color:'#000',
                },
                formatter:"时长:{c}H"
              },
              itemStyle: {
                normal: {
                  color: function(params) {
                    let colorList = [
                      ["#6496e9","#6bded3"],
                      ["#ffbb65","#fdc68b"],
                      ["#4fe1c5","#4ecee1"],
                      ["#9978fa","#88a1fa"],
                    ];
                    // return colorList[params.dataIndex];
                    let colorItem = colorList[params.dataIndex];
                    return new echarts.graphic.LinearGradient(0,0,0,1,[{
                      offset:0,
                      color:colorItem[0]
                    },
                      {
                        offset:1,
                        color:colorItem[1]
                      }],false)
                  },
                  barBorderRadius: [5, 5, 0, 0],
                }
              },
            }]
        }
        PowerOnRateLine.setOption(PowerOnRateLine_option);
        //开机时间\关机时间
        let UtilizationLine = this.$echarts.init(document.getElementById('UtilizationLine'), 'macarons');
        let  statChartPieOption1 = {
          // title: {
          //   x: 'left',
          //   subtext: '开机效率',
          //   textStyle: {
          //     color: '#268e80',
          //     fontSize: 20,
          //
          //   },
          // },
          tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          legend: {
            orient: 'vertical',
            x: 'left',
            y: 'bottom',
            data: ['开机时间', '关机时间']
          },
          calculable: true,
          series: [{
            name: '开机效率',
            type: 'pie',
            radius: '70%',
            /*center: ['55%', '55%'],*/
            itemStyle: {
              normal: {
                color: function (params) {
                  let colorList = ['#4169E1', '#A8A8A8'];
                  return colorList[params.dataIndex]
                },
                label: {
                  show: true,
                  position: 'top',
                  formatter: '{b}\n{c}'
                }
              }
            },
            data: [{value: this.openingLong, name: '开机时间'},
              {value: this.closedLong, name: '关机时间'}]
          }]
        };
        UtilizationLine.setOption(statChartPieOption1);
 
        //运行时间\待机时间
        let StartupLine = this.$echarts.init(document.getElementById('StartupLine'), 'macarons');
        let statChartPieOption2 = {
          // title: {
          //   x: 'left',
          //   subtext: '运行效率'
          // },
          tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          legend: {
            orient: 'vertical',
            x: 'left',
            y: 'bottom',
            data: ['运行时间', '待机时间']
          },
          calculable: true,
          series: [{
            name: '运行效率',
            type: 'pie',
            radius: '70%',
            center: ['55%', '55%'],
            itemStyle: {
              normal: {
                color: function (params) {
                  var colorList = ['#00ee00', '#FCCE10'];
                  return colorList[params.dataIndex]
                },
                label: {
                  show: true,
                  position: 'top',
                  formatter: '{b}\n{c}'
                }
              }
            },
            data: [{value: this.processLong, name: '运行时间'},
              {value: this.waitingLong, name: '待机时间'}]
          }]
        };
        StartupLine.setOption(statChartPieOption2);
      },
      queryStatistical(){
        getAction(this.url.dayStatisticalRate,this.queryParams).then(res =>{
          if(res.success){
            // console.log(res);
            this.StatCharOpeningRate = res.result.openRate;
            //利用率
            this.StatCharUsedRate = res.result.utilizationRate;
            //开机率
            this.UtilizationHeight = res.result.openRate;
            this.StatCharUsedopeningRate = res.result.StartupHeight;
            this.StartupHeight = res.result.StartupHeight;
            this.openingLong = this.getTime(res.result.openLong)
            this.waitingLong = this.getTime(res.result.waitLong);
            this.processLong = this.getTime(res.result.processLong);
            this.closedLong = this.getTime(res.result.closeLong);
            this.totalLong = parseInt(this.openingLong) + parseInt(this.closedLong);
            this.draw();
          }
        })
      },
      dataChange(val) {
        this.queryParam.collectTime1 = "";
        this.queryParams.dateTime = val.format('YYYYMMDD')
        this.queryParams.collectTime = val.format('YYYY-MM-DD');
 
      },
      initEquipmentNode() {
        let _this = this
        getAction(this.url.getBaseTree).then((res) => {
          if (res.success) {
            // console.log(res.result[0].entity.tierName)
            _this.$set(this.queryParam, 'tierName', res.result[0].title)
            _this.$set(this.queryParams, 'parentId', res.result[0].key)
            _this.queryStatistical()
          } else {
            // this.$message.warn(res.message)
            this.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        }).finally(() => {
          this.loading = false
          this.cardLoading = false
        })
        // getAction(this.url.getEquipmentByPid, { pid: id }).then((res) => {
        //   if (res.success) {
        //     if (res.result) {
        //       _this.$set(this.queryParam, 'tierName', res.result.tierName)
        //       _this.$set(this.queryParam, 'equipmentId', res.result.equipmentId)
        //       // _this.quip = res.result
        //       _this.searchQuery()
        //     } else {
        //       _this.$message.warning('请配置设备!')
        //     }
        //   }
        // })
      },
      searchReset() {
        this.queryParam = {}
        this.queryParams = {}
        // this.dates = []
        this.queryStatistical()
        // this.onClearSelected()
      },
      searchQuery(){
        this.queryStatistical();
      }
    },
    watch: {
      equip(val) {
        // console.log(val);
        if (val && val.equipmentId) {
          this.$set(this.queryParam, 'tierName', val.title)
          this.$set(this.queryParam, 'equipmentId', val.equipmentId)
          this.queryParams.parentId = ''
          this.queryParams.equipmentId = val.equipmentId
          this.searchQuery()
        }else{
          this.queryParams.parentId = val.key
          this.queryParams.equipmentId = ''
          this.$set(this.queryParam, 'tierName', val.title)
          this.searchQuery()
        }
        this.searchQuery()
      }
      // this.searchQuery();
 
 
    }
 
  }
</script>
 
<style scoped>
  .charContent{
    display: flex;
  }
  @media screen and (min-width: 1920px){
    #StatisticsLegend{
      height: 748px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1680px) and (max-width: 1920px){
    #StatisticsLegend{
      height: 748px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1400px) and (max-width: 1680px){
    #StatisticsLegend{
      height: 600px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1280px) and (max-width: 1400px){
    #StatisticsLegend{
      height: 501px!important;
      overflow: scroll;
    }
  }
  @media screen and (max-width: 1280px){
    #StatisticsLegend{
      height: 501px!important;
      overflow: scroll;
    }
  }
  #StatisticsLegend .PowerOnRate{
    flex: 1;
    margin-bottom: 15px;
    background-color: #fff;
  }
  #StatisticsLegend .UtilizationStartup{
    flex: 1;
    display: flex;
  }
  #StatisticsLegend .UtilizationStartup>div{
    flex: 1;
    background-color: #fff;
  }
  #StatisticsLegend .UtilizationStartup .Utilization{
    margin-right: 15px;
  }
  .title{
    display: flex;
    align-items: center;
    padding-left: 15px;
    padding-top: 5px;
  }
  .title .circle{
    width: 15px;
    height: 15px;
    background-color: #7282ec;
    border-radius: 100%;
    margin-right: 10px;
  }
  .title .text{
    font-size: 2vh;
  }
  .Line-box{
    display: flex;
    flex-direction: column;
  }
  .Line-box .box-bottom{
    flex: 1;
  }
  .PowerOnRate-box{
    display: flex;
  }
  .PowerOnRate-box .PowerOnRate-left{
    width: 25%;
  }
  .PowerOnRate-box .PowerOnRate_text{
    width: 10%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
  }
  .PowerOnRate-box .PowerOnRate-right{
    flex: 1;
  }
  .Utilization-box{
    display: flex;
  }
  .Utilization-box .Utilization-left{
    width: 25%;
  }
  .Utilization-box .Utilization-right{
    flex: 1;
  }
  .Startup-box{
    display: flex;
  }
  .Startup-box .Startup-left{
    width: 25%;
  }
  .Startup-box .Startup-right{
    flex: 1;
  }
  .left{
    display: flex;
    align-items: center;
  }
  .left .left-box{
    width: 65%;
    height: 60%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 8px;
 
    /*border: 6px solid red;*/
    /*!*background-color: yellow;*!*/
    /*border-image: linear-gradient(to top, #2bf3c7, #06a8f8) 1;*/
  }
  .left-box-con{
    width: 100%;
    height: 100%;
    position: relative;
    text-align: center;
    border: 6px solid red;
    /*background-color: yellow;*/
    border-image: linear-gradient(to top, #2bf3c7, #06a8f8) 1;
  }
  .left .left-box .Rate-box-kong{
    width: 100%;
    background: -moz-linear-gradient(bottom, #b5dec2 0%, #f4f5ba 100%);
    background: -webkit-gradient(linear, bottom bottom, top top, color-stop(0%,#b5dec2), color-stop(100%,#f4f5ba));
    background: -webkit-linear-gradient(bottom, #b5dec2 0%,#f4f5ba 100%);
    background: -o-linear-gradient(bottom, #b5dec2 0%,#f4f5ba 100%);
    background: -ms-linear-gradient(bottom, #b5dec2 0%,#f4f5ba 100%);
    background: linear-gradient(to top, #b5dec2 0%,#f4f5ba 100%);
  }
  .left .left-box .Rate-box{
    position: absolute;
    text-align: center;
    bottom: 0;
    width: 100%;
    height: 89%;
    /*background-color: green;*/
    background: -moz-linear-gradient(bottom, #06a8f8 0%, #2bf3c7 100%);
    background: -webkit-gradient(linear, bottom bottom, top top, color-stop(0%,#06a8f8), color-stop(100%,#2bf3c7));
    background: -webkit-linear-gradient(bottom, #06a8f8 0%,#2bf3c7 100%);
    background: -o-linear-gradient(bottom, #06a8f8 0%,#2bf3c7 100%);
    background: -ms-linear-gradient(bottom, #06a8f8 0%,#2bf3c7 100%);
    background: linear-gradient(to top, #06a8f8 0%,#2bf3c7 100%);
  }
  .left .left-box .Rate-box p{
    position: absolute;
    bottom: 0;
    color: #fff;
    width: 100%;
    text-align: center;
  }
  .con-left{
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
  }
  .con-left>span{
    flex: 1;
  }
</style>