派生自 wuyushui/SewerAndRainNetwork

XingChuan
2021-05-30 e66121f92a663b0a22dad56aedf388fc79d67258
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
<template>
    <div class="echarts-box">
        <div class="tab-scroll">
            <PublicDataStandard :dataStandard="dataStandard"></PublicDataStandard>
        </div>
        <div class="echarts-form">
            <span class="demonstration">开始时间:</span>
            <el-date-picker v-model="formData.timeStart" value-format="yyyy-MM-dd" type="datetime" size="mini"></el-date-picker>
            <span class="demonstration">结束时间:</span>
            <el-date-picker v-model="formData.timeEnd" value-format="yyyy-MM-dd" type="datetime" size="mini"></el-date-picker>
            <span class="demonstration">采样点数:</span>
            <el-select v-model="formData.region" placeholder="请选择" size="mini">
                <el-option v-for="(item,index) in formData.regionList" :key="index" :label="item" :value="item"></el-option>
            </el-select>
            <el-button @click="querySearch()">查询</el-button>
            <el-popover
                placement="top"
                width="100%"
                popper-class="popoverBoxStyle"
                trigger="click">
              <dynamic-table :tableData="tableData" :tableHeader="tableConfig" v-if="tableData"></dynamic-table>
              <el-button slot="reference">明细表</el-button>
            </el-popover>
        </div>
        <div class="echarts-chart">
            <div ref="echartsDay"></div>
        </div>
        <span class="time-select">{{ formData.timeStart }}日—{{ formData.timeEnd }}日</span>
    </div>
</template>
 
<script>
import dayjs from 'dayjs'
import PublicDataStandard from '../PublicDataStandard'
import mapApi from '@/api/mapApi'
import DynamicTable from '../../../views/popup/DynamicHeader/DynamicTable' // 多级表头
 
export default {
  name: 'WasteWaterDayChart',
  components: {
    PublicDataStandard,
    DynamicTable
  },
  data () {
    return {
      // tab栏传递接收数据
      dataStandard: [],
      tableData: null,
      formData: {
        region: '25',
        regionList: [25, 50, 75, 100],
        timeStart: dayjs().subtract(1, 'month').format('YYYY-MM-DD'),
        timeEnd: dayjs().format('YYYY-MM-DD')
      },
      chart: null,
      dataType: 1,
      jcdID: 1,
      bzz: null,
      bzzList: [],
      // 表头数据
      tableConfig: [
        {
          id: 100,
          label: '排放点',
          prop: 'OnLineMonEmissPointName'
        },
        {
          id: 200,
          label: '监测时间',
          prop: 'MonTimeStr'
        },
        {
          id: 300,
          label: 'COD',
          prop: 'PoltmtrlName',
          children: [
            {
              id: 310,
              label: '实测排放量(kg/h)',
              prop: 'COD_EmissQty'
            },
            {
              id: 320,
              label: '实测浓度(mg/l)',
              prop: 'COD_MonQty'
            },
            {
              id: 330,
              label: '标准值(mg/l)',
              prop: 'COD_StdValue'
            }
          ]
        },
        {
          id: 400,
          label: '氨氮',
          prop: 'PoltmtrlName',
          children: [
            {
              id: 410,
              label: '实测排放量(kg/h)',
              prop: '氨氮_EmissQty'
            },
            {
              id: 420,
              label: '实测浓度(mg/l)',
              prop: '氨氮_MonQty'
            },
            {
              id: 430,
              label: '标准值(mg/l)',
              prop: '氨氮_StdValue'
            }
          ]
        },
        {
          id: 500,
          label: 'PH',
          prop: 'PoltmtrlName',
          children: [
            {
              id: 510,
              label: '实测排放量(kg/h)',
              prop: 'pH_EmissQty'
            },
            {
              id: 520,
              label: '实测浓度(mg/l)',
              prop: 'pH_MonQty'
            },
            {
              id: 530,
              label: '标准值(mg/l)',
              prop: 'pH_StdValue'
            }
          ]
        },
        {
          id: 600,
          label: '废水流量',
          prop: '',
          children: [
            {
              id: 610,
              label: '实测流量(m³/h)',
              prop: '废水流量_MonQty'
            }
          ]
        }
      ]
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.draw24Chart()
    })
  },
  methods: {
    querySearch () {
      this.draw24Chart()
    },
    async draw24Chart () {
      const data = {
        poltSourceId: '',
        poltMtrlId: '',
        emissTypeId: '',
        onLineMonEmissPointId: 23,
        monItemId: '28,31,35', // 监测项  COD、氨氮、PH
        beginTime: this.formData.timeStart,
        endTime: this.formData.timeEnd,
        dataType: this.dataType
      }
      const result = (await mapApi.getQueryOnlineMonData(data)).Result.DataInfo
      this.get24HourDate(result)
    },
    get24HourDate (res) {
      if (res.length > 0) {
        this.dataStandard = []
        this.tableData = this.analysisResult(res) // 小时明细表解析结果
        // 处理数据开始
        const d = res
        const nameList = [] // 存放图例
        const dateList = [] // 存放时间
        const dataList = [] // 存放数据
        let data
        const bzh = []
 
        for (let i = 0; i < d.length; i++) {
          if (d[i].MonItemId === '29') {
            continue
          }
          const MonTimeStr = d[i].MonTimeStr
 
          const d1 = MonTimeStr.split('/')
          // let d2=d1[2].split(' ');
          let strDate
          if (d1[1] > 9) {
            // if(d2[0]>9){
            strDate = MonTimeStr.substring(8, 10) + '日'
            // }else {
            //     strDate=MonTimeStr.substring(8,9)+"日";
            // }
          } else {
            // if(d2[0]>9){
            strDate = MonTimeStr.substring(7, 9) + '日'
            // }else {
            //     strDate=MonTimeStr.substring(7,8)+"日";
            // }
          }
 
          if (nameList.length === 0) {
            nameList.push(d[i].PoltmtrlName.trim())
            dateList.push(strDate)
            this.dataStandard.push({
              current: {
                name: d[i].PoltmtrlName.trim(),
                val: ''
              },
              standard: {
                name: '标准',
                val: ''
              }
            })
            bzh.push(d[i].StdValue)
            data = {
              name: d[i].PoltmtrlName.trim(),
              data: []
            }
            if (d[i].MonQty !== null) {
              data.data.push(d[i].MonQty)
            }
            dataList.push(data)
          } else if (nameList.indexOf(d[i].PoltmtrlName.trim()) < 0) {
            nameList.push(d[i].PoltmtrlName)
            bzh.push(d[i].StdValue)
            this.dataStandard.push({
              current: {
                name: d[i].PoltmtrlName.trim(),
                val: ''
              },
              standard: {
                name: '标准',
                val: ''
              }
            })
            data = {
              name: d[i].PoltmtrlName.trim(),
              data: []
            }
            if (d[i].MonQty !== null) {
              data.data.push(d[i].MonQty)
            }
            dataList.push(data)
          } else {
            if (dateList.indexOf(strDate) < 0) {
              dateList.push(strDate)
            }
            for (let j = 0; j < dataList.length; j++) {
              if (d[i].PoltmtrlName.trim() === dataList[j].name) {
                if (d[i].MonQty !== null)dataList[j].data.push(d[i].MonQty)
              }
            }
          }
        }
        // 处理数据结束
 
        const lengList = []
        let objTemp
 
        for (let l = 0; l < nameList.length; l++) {
          let obj
          let iconurl
          if (nameList[l] === 'COD') {
            iconurl = 'image://../assets/imgs/legend/SO2.png'
          } else if (nameList[l] === '氨氮') {
            iconurl = 'image://../assets/imgs/legend/NOX.png'
          } else if (nameList[l] === '总磷') {
            iconurl = 'image://../assets/imgs/legend/YanChen.png'
          } else if (nameList[l] === '总氮') {
            iconurl = 'image://../assets/imgs/legend/zongdan.png'
          } else {
            iconurl = 'image://../assets/imgs/legend/VOCs.png'
          }
 
          if (nameList[l] === '废水' || nameList[l] === '废水流量') { // 将废水流量排到数组最后
            objTemp = {
              name: nameList[l],
              icon: iconurl,
              textStyle: {
                color: '#ccc'
              },
              itemWidth: 20,
              itemHeight: 5
            }
          } else {
            obj = {
              name: nameList[l],
              icon: iconurl,
              textStyle: {
                color: '#ccc'
              },
              itemWidth: 20,
              itemHeight: 5
            }
            lengList.push(obj)
          }
 
          this.bzz = {
            name: nameList[l],
            bzhui: bzh[l]
          }
          this.bzzList.push(this.bzz)
        }
        lengList.push(objTemp)
 
        const legend = lengList
        const xdata = dateList.reverse()
        const ydatas = []
 
        for (let j = 0; j < nameList.length; j++) {
          let zdcbcolor, zxcolor
          if (nameList[j] === 'COD') {
            zdcbcolor = 'red'
            zxcolor = '#fff21c'
          } else if (nameList[j] === '氨氮') {
            zdcbcolor = 'red'
            zxcolor = '#00B0F0'
          } else if (nameList[j] === '总磷') {
            zdcbcolor = 'red'
            zxcolor = '#f48183'
          } else if (nameList[j] === '总氮') {
            zdcbcolor = 'red'
            zxcolor = '#d9f2f4'
          } else {
            zdcbcolor = 'red'
            zxcolor = '#9ACD32'
          }
 
          let sdata = []
 
          for (let k = 0; k < dataList.length; k++) {
            if (nameList[j].trim() === dataList[k].name.trim()) {
              sdata = dataList[k].data.reverse()
            }
          }
 
          const ydata = {
            name: nameList[j],
            data: sdata,
            zdcbcolor: zdcbcolor,
            zxcolor: zxcolor,
            bzz: bzh[j]
          }
          ydatas.push(ydata)
        }
        for (var t = 0; t < this.dataStandard.length; t++) {
          this.dataStandard[t].current.val = ydatas[t].data[ydatas[t].data.length - 1].toFixed(2)
          this.dataStandard[t].standard.val = ydatas[t].bzz
        }
        const yname = '浓度(mg/l)'
        this.effChartShow(legend, xdata, ydatas, yname, this.jcdID, this.datatype)
      }
    },
    effChartShow (legend, xdata, ydatas, yname, jcdID, datatype) {
      this.chart = this.$echarts.init(this.$refs.echartsDay)
      this.chart.clear()
      // console.log(this.chart)
      this.chart.clear()
      let dataUnit = ''
      if (datatype === 1) {
        dataUnit = '流量(m³/d)'
      } else {
        dataUnit = '流量(m³/h)'
      }
      const bzzList = this.bzzList
      const serLists = []
      for (let i = 0; i < ydatas.length; i++) {
        const zdcbcolor = ydatas[i].zxcolor
        const bz = ydatas[i].bzz
        let obj
        if (bz) {
          obj = {
            name: ydatas[i].name,
            symbol: 'circle', // 折点形状
            symbolSize: 10, // 大小
            smooth: false, // 直线 ,true 为曲线
            itemStyle: {
              normal: {
                color: function (c) { // 根据value 显示不同的折点颜色
                  let biaozhuiz
                  for (let i = 0; i < bzzList.length; i++) {
                    if (bzzList[i].name === c.seriesName) {
                      biaozhuiz = bzzList[i].bzhui
                    }
                  }
                  if (c.value) {
                    if (c.value[1] > biaozhuiz) {
                      return zdcbcolor
                    } else if (c.value[1] > biaozhuiz * 0.9) {
                      return '#FFA500'
                    } else {
                      return '#33c95f'
                    }
                  }
                },
                lineStyle: { // 折线的颜色
                  color: ydatas[i].zxcolor,
                  width: 5
                },
                borderColor: 'black', // 折点边框的颜色
                label: { // 显示值
                  show: false
                }
              }
            },
            type: 'line',
            data: ydatas[i].data,
            markLine: { // 平均值 , 和 指标上限
              symbol: 'none',
              data: [{
                label: {
                  normal: {
                    position: 'end',
                    formatter: ''// ydatas[i].name+'标准值' //+'{c}'
                  }
                },
                name: '标准值',
                yAxis: bz,
                lineStyle: {
                  color: ydatas[i].zxcolor,
                  type: 'dashed',
                  width: 2
                }
              }
              ]
            }
          }
        } else {
          obj = {
            name: ydatas[i].name,
            symbol: 'circle', // 折点形状
            symbolSize: 10, // 大小
            smooth: false, // 直线 ,true 为曲线
            yAxisIndex: 1,
            itemStyle: {
              normal: {
                color: function (c) { // 根据value 显示不同的折点颜色
                  let biaozhuiz
                  for (let i = 0; i < bzzList.length; i++) {
                    if (bzzList[i].name === c.seriesName) {
                      biaozhuiz = bzzList[i].bzhui
                    }
                  }
                  if (c.value[1] > biaozhuiz) {
                    return zdcbcolor
                  } else if (c.value[1] > biaozhuiz * 0.9) {
                    return '#FFA500'
                  } else {
                    return '#33c95f'
                  }
                },
                lineStyle: { // 折线的颜色
                  color: ydatas[i].zxcolor,
                  width: 5
                },
                borderColor: 'black', // 折点边框的颜色
                label: { // 显示值
                  show: false
                }
              }
            },
            type: 'line',
            data: ydatas[i].data
          }
        }
        serLists.push(obj)
      }
      const option = {
        /*  title: {
            text: title,
        }, */
        tooltip: { // 提示框
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              color: '#1a4245'
            }
          },
          formatter: function (params) {
            let s = params[0].name + '<br />'
            for (let i = 0; i < params.length; i++) {
              // let name = params[i].name
              // 图表title名称
              const seriesName = params[i].seriesName
              // 值
              const value = params[i].value
 
              // let valueFliter = formatter(value)
              const valueFliter = parseFloat(value).toFixed(2)
 
              let maker = params[i].marker
              if (seriesName === 'COD') {
                maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#fff21c;"></span>'
              } else if (seriesName === '氨氮') {
                maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#00B0F0;"></span>'
              } else if (seriesName === '总磷') {
                maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#f48183;"></span>'
              } else if (seriesName === '总氮') {
                maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#d9f2f4;"></span>'
              } else {
                maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#9ACD32;"></span>'
              }
              s += maker + seriesName + ':' + valueFliter + '<br />'
            }
            return s
          }
        },
        toolbox: { // 打印等工具
          show: false,
          feature: {
            saveAsImage: {}
          }
        },
        grid: { // 网格
          top: '20%'
          // left: '5%'
        },
        legend: {
          data: legend
        },
        dataZoom: [{
          type: 'inside',
          start: 0,
          end: 100
        }, {
          start: 0,
          end: 100,
          show: false,
          handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
          handleSize: '80%',
          handleStyle: {
            color: '#fff',
            shadowBlur: 3,
            shadowColor: 'rgba(0, 0, 0, 0.6)',
            shadowOffsetX: 2,
            shadowOffsetY: 2
          }
        }],
        xAxis: { // x 轴设置
          type: 'category',
          boundaryGap: false,
          axisLabel: { // x轴全部显示
            // rotate: 20,
            // interval: 0,
            textStyle: {
              color: '#fff'
            }
          },
          splitLine: { // 网格垂直线为 虚线
            show: true,
            lineStyle: {
              type: 'dashed'
            }
          },
          axisTick: { // x 轴刻度显示
            show: false
          },
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              width: 1// 这里是为了突出显示加上的
            }
          },
          data: xdata
        },
        yAxis: [{
          type: 'value',
          name: yname,
          // max: function (value) {
          //   let max_val_list = [] // 所有显示折线的标准值
          //   if (bzzList && bzzList.length > 0) {
          //     $.each(bzzList, function (index, item) {
          //       max_val_list.push(item.bzhui)
          //     })
          //   }
          //   max_val_list = max_val_list.sort(function (a, b) {
          //     return a - b
          //   }) // 排序
          //   let ma = value.max > max_val_list[max_val_list.length - 1] ? value.max + 5 : max_val_list[max_val_list.length - 1]
          //   return parseInt(ma)
          // },
          axisLabel: {
            formatter: '{value}',
            textStyle: {
              color: '#fff'
            }
          },
          axisPointer: {
            snap: true
          },
          splitLine: {
            show: false
          }, // y轴 网格线不显示,
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              width: 1// 这里是为了突出显示加上的
            }
          }
        }, {
          type: 'value',
          name: dataUnit,
          axisLabel: {
            formatter: '{value}',
            textStyle: {
              color: '#fff'
            }
          },
          axisPointer: {
            snap: true
          },
          splitLine: {
            show: false
          }, // y轴 网格线不显示,
          // inverse: true,
          // nameLocation: 'start',
          // max:500,
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              width: 1// 这里是为了突出显示加上的
            }
          }
        }],
        series: serLists
      }
      this.chart.setOption(option)
      window.onresize = this.chart.resize
    },
    analysisResult (result) {
      // 处理表格头
      const json = {}
      const arr = []
      // 处理表格内容
      const bodyDataList = []
      const dataMap = {}
      for (let i = 0; i < result.length; i++) {
        json[result[i].PoltmtrlName] = result[i].PoltmtrlName
        const rgdata = result[i]
        const timeTag = rgdata.MonTimeStr
        if (!dataMap[timeTag]) {
          dataMap[timeTag] = { MonTimeStr: '' + rgdata.MonTimeStr }
        }
        // 往数据中添加属性数据
        const el = dataMap[timeTag]
        el.OnLineMonEmissPointName = rgdata.OnLineMonEmissPointName
        el[rgdata.PoltmtrlName + '_EmissQty'] = rgdata.EmissQty ? rgdata.EmissQty.toFixed(2) : '--'
        el[rgdata.PoltmtrlName + '_MonQty'] = rgdata.MonQty ? rgdata.MonQty.toFixed(2) : '--'
        el[rgdata.PoltmtrlName + '_StdValue'] = rgdata.StdValue ? rgdata.StdValue.toFixed(2) : '--'
      }
      let FSLLtemp = null
      for (var key in json) {
        if (key === '废水流量' || key === '废水') {
          FSLLtemp = key
        } else {
          arr.push(key)
        }
      }
      if (FSLLtemp != null) {
        arr.push(FSLLtemp)
      }
      for (var p in dataMap) {
        bodyDataList.push(dataMap[p])
      }
      return bodyDataList
    }
  }
}
</script>
 
<style scoped lang="less">
 
</style>