zhuzhuanzhuan
2023-08-25 487754376a1eb675d430a64b7a4aa9e7ffeb405b
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
<template>
  <a-card :bordered="false" class="device_list">
    <div class="com_box">
      <!-- 查询区域 -->
      <div style="width: 100%; background-color: #fff" class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="4" :sm="4">
              <a-form-item label="设备编号">
                <a-input placeholder="输入设备编号查询" :readOnly="readOnly" v-model="queryParams.equipmentId"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="4" :sm="4">
              <a-form-item label="设备名称">
                <a-input placeholder="输入设备名称查询" :readOnly="readOnly" v-model="queryParams.equipmentName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="5" :xs="5">
              <a-form-item label="时间">
                <a-range-picker @change="dateParamChange" v-model="dates"  format="YYYYMMDD"/>
              </a-form-item>
            </a-col>
            <a-col :md="7" :sm="7" :xs="7">
             <a-form-item label="时间段">
               <a-time-picker :default-value="moment('00:00', 'HH:mm')" format="HH:mm" @change="onChangeStart" />
               至
               <a-time-picker :default-value="moment('08:00', 'HH:mm')" format="HH:mm" @change="onChangeEnd" />
             </a-form-item>
            </a-col>
            <a-col :md="2" :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>
      <!-- table区域-begin -->
      <div id="DeviceList">
 
        <div style="padding: 5px;width: 100%;height: 100%">
          <div style="width: 100%;height: 100%" id="dayAvailBar"></div>
          <!--<div id="dayAvailLine"></div>-->
        </div>
      </div>
      <!-- table区域-end -->
    </div>
  </a-card>
</template>
 
<script>
  import moment from 'moment'
  import $ from 'jquery'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  import JDate from '../../../../../components/jeecg/JDate'
  import {
    requestPut,
    deleteAction,
    getAction
  } from '@/api/manage'
  // import comparativeAnalysisBar from './comparativeAnalysisBar'
  // import comparativeAnalysisGauge from'./comparativeAnalysisGauge'
  // import conparativeAnalysisPie from './conparativeAnalysisPie'
  import '@/components/table2excel/table2excel'
  import JInput from '@/components/jeecg/JInput'
  import JEllipsis from '@/components/jeecg/JEllipsis'
  import Tooltip from 'ant-design-vue/es/tooltip'
  import { ajaxGetDictItems, getDictItemsFromCache, duplicateCheck } from '@/api/api'
  import AFormItem from 'ant-design-vue/es/form/FormItem'
  export default {
    name: 'equipmentAvailCompareMain',
    // mixins: [JeecgListMixin],
    components: {
      AFormItem,
      Tooltip,
      // comparativeAnalysisBar,
      // comparativeAnalysisGauge,
      // conparativeAnalysisPie,
      JDictSelectTag,
      JInput,
      JDate,
      JEllipsis
    },
    props: {  nodeTree: '', Type:'',nodePeople: '' },
    data() {
      return {
        activeKey: '1',
        typeTree:"",
        typeParent:1,
        typeEquipment:1,
        spaceTime:[],
        useingRates:[],
        dates: [],
        xianshi:"",
        readOnly:true,
        queryParam: {
          // dateTime:undefined,
          // timeType:'2'
        },
        queryParams:{},
        queryParamEquip:{},
        queryParamPeople:{},
        dataStartsoucre:[],
        url: {
          dayUtilizationRateContrast:'/mdc/efficiencyReport/dayUtilizationRateContrast',
          getEquipmentByPid: '/mdc/mdcEquipment/getEquipmentByPid',
          getEquipmentByDepPid:'/mdc/mdcEquipment/getEquipmentByDepPid'
        },
        AnalysisList:{}
      }
    },
    watch:{
      Type(valmath){
        this.dataList = [];
        this.queryParams.typeTree = valmath
        // console.log(this.queryParams.typeTree)
      },
      nodeTree(val) { //监听currSelected 变化,将变化后的数值传递给 getCurrSelected 事件
        if (JSON.stringify(val) != '{}') {
          if (val.equipmentId) {
            // this.$set(this.queryParam, 'tierName', val.title)
            this.queryParamEquip.parentId =  ""
            this.queryParams.equipmentId = val.equipmentId
            this.queryParamEquip.equipmentId = val.equipmentId
            this.searchQuery()
          } else {
            // this.$set(this.queryParam, 'tierName', val.title)
            this.queryParamEquip.parentId = val.key
            this.queryParams.equipmentId = ''
            this.initEquipment(val.key)
          }
 
 
        }
      },
      nodePeople(val){
        if (JSON.stringify(val) != '{}') {
          if (val.equipmentId) {
            // this.$set(this.queryParam, 'tierName', val.title)
            this.queryParamEquip.parentId =  ""
            this.queryParams.equipmentId = val.equipmentId
            this.queryParamEquip.equipmentId = val.equipmentId
            this.searchQuery()
          } else {
            // this.$set(this.queryParam, 'tierName', val.title)
            this.queryParamEquip.parentId = val.key
            this.queryParams.equipmentId = ''
            this.initEquipmentDep(val.key)
          }
 
        }
      }
    },
    methods: {
      drawTu(){
        let dayAvailBar = this.$echarts.init(document.getElementById('dayAvailBar'), 'macarons');
        //dayAvailLine = echarts.init(document.getElementById('dayAvailLine'));
        let dayAvailBarOption = {
          title: {
            text: '设备日利用率图',
            x: 'center',
            textStyle: {
              fontSize: 18,
              fontWeight: 'bolder',
              color: "#151414"
            }
          },
          tooltip: {
            trigger: 'axis',
            formatter: "{a} <br/>{b} :({c}%)"
          },
          toolbox: {
            show: true,
            feature: {
              mark: {show: true},
              dataView: {show: true, readOnly: false},
              magicType: {show: true, type: ['line', 'bar']},
              restore: {show: true},
              saveAsImage: {show: true}
            }
          },
          calculable: true, //是否启用拖拽重计算特性
          xAxis: [
            {
              type: 'category',
              name: '时间分段',
              boundaryGap: true,
              data: this.spaceTime
            }
          ],
          yAxis: [
            {
              type: 'value',
              name: '利用率'
            }
          ],
          series: [
            {
              name: '利用率',
              type: 'line',
              barWidth: 50,
              itemStyle: {
                normal: {
                  color: '#4169E1'
                }
              },
              data: this.useingRates,
              markPoint: {
                data: [
                  {type: 'max', name: '最大值', symbolSize: 70},
                  {type: 'min', name: '最小值', symbolSize: 70}
                ]
              }
            }
          ]
        };
        dayAvailBar.setOption(dayAvailBarOption);
      },
      moment,
      onChangeStart(time, timeString) {
        this.queryParam.startTime = timeString
        // console.log(time, timeString);
      },
      onChangeEnd(time, timeString) {
        this.queryParam.endTime = timeString
        // console.log(time, timeString);
      },
      disabledDate(current){
        //Can not slect days before today and today
        return current && current > moment().subtract('days', 1);
      },
      dataChange(val) {
        this.queryParam.dateTime = val.format('YYYYMMDD')
      },
      handleChange(value) {
        this.queryParam.timeType = value
        // console.log(this.queryParam.timeType)
      },
      tabChange(val) {
        this.activeKey = val
      },
      dateParamChange(v1, v2) {
        // console.log(v1,v2)
        this.queryParam.startDate = v2[0]
        this.queryParam.endDate = v2[1]
        // console.log(v2[0],v2[1])
      },
      loadAnalysis(){
        getAction(this.url.dayUtilizationRateContrast,this.queryParam).then(res => {
          if (res.success) {
            this.spaceTime.push(res.result.dataList)
            for(let i = 0;i<res.result.dayRateDto.length;i++){
              this.useingRates.push(res.result.dayRateDto[i].utilizationRate)
            }
            this.drawTu()
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      numFilter(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
        } else {
          return '0'
        }
      },
      searchQuery(){
        this.spaceTime = []
        this.useingRates = []
        if(this.queryParams.typeTree == "1"){
          this.queryParams.parentId =  this.queryParamEquip.parentId
          // this.queryParams.equipmentId =  this.queryParamEquip.equipmentId
 
        }else{
          this.queryParams.parentId = this.queryParamEquip.parentId
 
          // this.queryParams.equipmentId = ""
        }
        this.AnalysisList = [];
        //获取查询条件
        this.queryParam.parentId = this.queryParams.parentId;
        this.queryParam.equipmentId = this.queryParams.equipmentId;
        this.queryParam.typeTree = this.queryParams.typeTree
        getAction(this.url.dayUtilizationRateContrast,this.queryParam).then((res) => {
          if(res.success){
            this.spaceTime=res.result.dateList
            for(let i = 0;i<res.result.dayRateDto.length;i++){
              // res.result[i].useRateDayShift = this.numFilter(res.result[i].useRateDayShift)
              this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
            }
            this.drawTu()
          }else{
            // this.$message.warning(res.message)
            this.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        }).finally(() => {
          this.loading = false
        })
      },
      searchReset() {
        this.spaceTime = []
        this.useingRates = []
        if(this.queryParams.typeTree == "1"){
          this.typeTree = this.queryParams.typeTree
          this.typeParent =  this.queryParams.parentId
          this.typeEquipment = this.queryParams.equipmentId
          this.queryParams = {}
          this.queryParam = {}
          this.queryParams.typeTree = this.typeTree
          this.queryParams.parentId = this.typeParent
          if(this.queryParams.parentId !=  ""){
            this.queryParams.equipmentId =  ""
            this.initEquipment()
          }else{
            if(this.queryParams.equipmentId == this.queryParamEquip.equipmentId){
              this.queryParams.equipmentId =  this.typeEquipment
            }else{
              this.queryParams.equipmentId = this.queryParamEquip.equipmentId
            }
          }
          getAction(this.url.dayUtilizationRateContrast,this.queryParams).then((res) => {
            if(res.success){
              this.spaceTime=res.result.dateList
              for(let i = 0;i<res.result.dayRateDto.length;i++){
                this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
              }
              this.drawTu()
            }else{
              // this.$message.warning(res.message)
              this.$notification.warning({
                message:'消息',
                description:res.message
              });
            }
          }).finally(() => {
            this.loading = false
          })
        }else{
          this.typeTree = this.queryParams.typeTree
          this.typeParent =  this.queryParams.parentId
          this.typeEquipment = this.queryParams.equipmentId
          this.queryParams = {}
          this.queryParam = {}
          this.dates = []
          this.queryParams.typeTree = this.typeTree
          this.queryParams.parentId = this.typeParent
          if(this.queryParams.parentId !=  ""){
            this.queryParams.equipmentId =  ""
            this.initEquipment()
          }else{
            if(this.queryParams.equipmentId == this.queryParamEquip.equipmentId){
              this.queryParams.equipmentId =  this.typeEquipment
            }else{
              this.queryParams.equipmentId = this.queryParamEquip.equipmentId
            }
          }
          getAction(this.url.dayUtilizationRateContrast,this.queryParams).then((res) => {
            if(res.success){
              this.spaceTime=res.result.dateList
              for(let i = 0;i<res.result.dayRateDto.length;i++){
                this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
              }
              this.drawTu()
            }else{
              // this.$message.warning(res.message)
              this.$notification.warning({
                message:'消息',
                description:res.message
              });
            }
          }).finally(() => {
            this.loading = false
          })
        }
 
      },
      initEquipment(id) {
        let _this = this
        getAction(this.url.getEquipmentByPid, { pid: id }).then((res) => {
          if (res.success) {
            if (res.result != null) {
              _this.$set(this.queryParams, 'equipmentName', res.result.equipmentName)
              _this.$set(this.queryParams, 'equipmentId', res.result.equipmentId)
              _this.$set(this.queryParam, 'equipmentId', res.result.equipmentId)
              _this.equipment = res.result
              _this.searchQuery()
            } else {
              this.queryParams = {}
              // this.queryList()
              this.equipment = {}
              // _this.$message.warning('请联系管理员,开放设备权限!')
              _this.$notification.warning({
                message:'消息',
                description:'请联系管理员,开放设备权限!'
              });
            }
          }else{
            // this.$message.warning(res.message)
            _this.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        })
      },
      initEquipmentDep(id) {
        let _this = this
        getAction(this.url.getEquipmentByDepPid, { pid: id }).then((res) => {
          if (res.success) {
            if (res.result != null) {
              _this.$set(this.queryParams, 'equipmentName', res.result.equipmentName)
              _this.$set(this.queryParams, 'equipmentId', res.result.equipmentId)
              _this.$set(this.queryParam, 'equipmentId', res.result.equipmentId)
              _this.equipment = res.result
              _this.searchQuery()
            } else {
              this.queryParams = {}
              // this.queryList()
              this.equipment = {}
              // _this.$message.warning('请联系管理员,开放设备权限!')
              _this.$notification.warning({
                message:'消息',
                description:'请联系管理员,开放设备权限!'
              });
            }
          }else{
            // this.$message.warning(res.message)
            _this.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        })
      }
    },
    created() {
      this.dates = [moment().subtract('days', 7), moment().subtract('days', 0)]
      this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
      this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
      this.queryParam.startTime = '00:00'
      this.queryParam.endTime = "08:00"
      this.queryParams.typeTree = "1";
 
 
    },
    mounted() {
      this.initEquipment()
    },
  }
</script>
 
<style lang="less" scoped>
  /*@import '~@assets/less/common.less';*/
 
  @media screen and (min-width: 1920px){
    .device_list{
      height: 811px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1680px) and (max-width: 1920px){
    .device_list{
      height: 811px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1400px) and (max-width: 1680px){
    .device_list{
      height: 663px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1280px) and (max-width: 1400px){
    .device_list{
      height: 564px!important;
      overflow: scroll;
    }
  }
  @media screen and (max-width: 1280px){
    .device_list{
      height: 564px!important;
      overflow: scroll;
    }
  }
  /*.device_list{*/
  /*display: flex;*/
  /*}*/
  /*.device_list .table-page-search-wrapper{*/
  /**/
  /*}*/
  /deep/ .ant-card-body{
    height: 100%!important;
  }
  .device_list .com_box{
    display: flex!important;
    height: 100%!important;
    flex-direction: column!important;
  }
  .device_list .table-page-search-wrapper{
    height: 6%!important;
  }
  .device_list #DeviceList{
    height: 90%!important;
  }
</style>