he wei
2024-09-21 70edda3b00f2528a473c28ec5a50b739ed160f0f
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
<template>
  <flex-layout no-bg>
    <div class="page-content">
      <div class="page-content-container">
        <el-tabs
          v-model="acTabs"
          type="border-card"
          class="flex-layout flex-layout-tabs noborder"
          @tab-click="tabClick">
          <el-tab-pane
            key="eleLine"
            label="系统拓扑图"
            name="eleLine">
            <ele-operation-line :update="update" :info="info" :state="state" :sys="sys" :is-connect="isConnect">
              <template slot="tools-left">
                <div style="margin-left: 8px;">
                  <div style="margin-top: 16px">
                    <ele-state-panel :type="isConnect?state.battState1:-1" title="Ⅰ段蓄电池组">
                      <el-button v-if="state.battState1 == 0 || !isConnect" slot="footer" type="warning" icon="el-icon-video-play" @click="showDisChargeDialog(1, true)" :disabled="state.battState2!= 0 || !isConnect">开始核容</el-button>
                      <el-button v-else slot="footer" type="success" icon="el-icon-video-pause" @click="stopTest">停止测试</el-button>
                    </ele-state-panel>
                  </div>
 
                  <div style="margin-top: 24px">
                    <ele-state-panel :type="isConnect?state.battState2:-1" title="Ⅱ段蓄电池组">
                      <el-button v-if="state.battState2 == 0 || !isConnect"  slot="footer" type="warning" icon="el-icon-video-play" @click="showDisChargeDialog(2, true)" :disabled="state.battState1 != 0 || !isConnect">开始核容</el-button>
                      <el-button v-else slot="footer" type="success" icon="el-icon-video-pause" @click="stopTest">停止测试</el-button>
                    </ele-state-panel>
                  </div>
                </div>
                <div style="margin-top: 12px; text-align: center;">
                  <el-button type="primary" size="small" @click="switchControlShow" style="margin-right: 8px;">开关控制</el-button>
                  <el-popover
                    placement="top"
                    v-model="popoverVisible">
                    <div class="popover-content">
                      <el-button type="primary" size="small" @click="showDisChargeDialog(1, false)">电池组1</el-button>
                      <el-button type="primary" size="small" @click="showDisChargeDialog(2, false)">电池组2</el-button>
                    </div>
                    <el-button type="primary" size="small" slot="reference">参数设置</el-button>
                  </el-popover>
                </div>
              </template>
            </ele-operation-line>
          </el-tab-pane>
          <el-tab-pane
            v-if="false"
            key="device"
            label="装置"
            name="device">
            <el-table
              stripe
              size="small"
              :data="deviceInfo.data"
              height="100%">
              <el-table-column
                v-for="header in deviceInfo.headers"
                :key="header.prop"
                :prop="header.prop"
                :label="header.label"
                :width="header.width"
                align="center"></el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane
            key="realTimeOverview"
            label="实时总览"
            name="realTimeOverview">
            <div class="real-time-overview-container">
              <el-row :gutter="16">
                <el-col :span="12">
                  <real-time-panel title="1#蓄电池组">
                    <el-row :gutter="16">
                      <el-col :span="12">
                        <table class="real-time-tbl">
                          <tr-item label="电池状态:" :value="state.battState1Text"></tr-item>
                          <tr-item label="组端电压(V):" :value="info.battOutputVol1.toHold(VOL)"></tr-item>
                          <tr-item label="母线电压(V):" :value="info.controlBusVol1.toHold(VOL)"></tr-item>
                          <tr-item label="组端电流(A):" :value="info.battOutputCurr1.toHold(CURR)"></tr-item>
                          <tr-item label="已测时间:" :value="info.battTestTimeLong1Text"></tr-item>
<!--                          <tr-item label="预估容量(AH):" :value="info.battTestCap1"></tr-item>-->
                        </table>
                      </el-col>
                      <el-col :span="12">
                        <table class="real-time-tbl">
                          <tr-item label="电池环境温度(℃):" :value="info.roomTemp1.toHold(TEMP)"></tr-item>
                          <tr-item label="电池环境湿度(%):" :value="info.roomHumid1.toHold(HUM)"></tr-item>
                          <tr-item label="单体平均电压(V):" :value="'number' == typeof group1Info.avgVol ? group1Info.avgVol.toHold(VOL) : group1Info.avgVol"></tr-item>
                          <tr-item label="单体平均温度(℃):" :value="'number' == typeof group1Info.avgTemp ? group1Info.avgTemp.toHold(TEMP) : group1Info.avgTemp"></tr-item>
                          <tr-item label="最大单体电压编号(V):" :value="'number' == typeof group1Info.maxVol ? group1Info.maxVol.toHold(VOL) : group1Info.maxVol"></tr-item>
                          <tr-item label="最小单体电压编号(V):" :value="'number' == typeof group1Info.minVol ? group1Info.minVol.toHold(VOL) : group1Info.minVol"></tr-item>
                          <tr-item label="最大单体温度编号(℃):" :value="'number' == typeof group1Info.maxTemp ? group1Info.maxTemp.toHold(TEMP) : group1Info.maxTemp"></tr-item>
                          <tr-item label="最小单体温度编号(℃):" :value="'number' == group1Info.minTemp ? group1Info.minTemp.toHold(TEMP) : group1Info.minTemp"></tr-item>
                        </table>
                      </el-col>
                    </el-row>
                  </real-time-panel>
                </el-col>
                <el-col :span="12">
                  <real-time-panel title="2#蓄电池组">
                    <el-row :gutter="16">
                      <el-col :span="12">
                        <table class="real-time-tbl">
                          <tr-item label="电池状态:" :value="state.battState2Text"></tr-item>
                          <tr-item label="组端电压(V):" :value="info.battOutputVol2.toHold(VOL)"></tr-item>
                          <tr-item label="母线电压(V):" :value="info.controlBusVol2.toHold(VOL)"></tr-item>
                          <tr-item label="组端电流(A):" :value="info.battOutputCurr2.toHold(CURR)"></tr-item>
                          <tr-item label="已测时间:" :value="info.battTestTimeLong2Text"></tr-item>
<!--                          <tr-item label="预估容量(AH):" :value="info.battTestCap2"></tr-item>-->
                        </table>
                      </el-col>
                      <el-col :span="12">
                        <table class="real-time-tbl">
                          <tr-item label="电池环境温度(℃):" :value="info.roomTemp2.toHold(TEMP)"></tr-item>
                          <tr-item label="电池环境湿度(%):" :value="info.roomHumid2.toHold(HUM)"></tr-item>
                          <tr-item label="单体平均电压(V):" :value="'number' == typeof group2Info.avgVol ? group2Info.avgVol.toHold(VOL) : group2Info.avgVol"></tr-item>
                          <tr-item label="单体平均温度(℃):" :value="'number' == typeof group2Info.avgTemp ? group2Info.avgTemp.toHold(TEMP) : group2Info.avgTemp"></tr-item>
                          <tr-item label="最大单体电压编号(V):" :value="'number' == typeof group2Info.maxVol ? group2Info.maxVol.toHold(VOL) : group2Info.maxVol"></tr-item>
                          <tr-item label="最小单体电压编号(V):" :value="'number' == typeof group2Info.minVol ? group2Info.minVol.toHold(VOL) : group2Info.minVol"></tr-item>
                          <tr-item label="最大单体温度编号(℃):" :value="'number' == typeof group2Info.maxTemp ? group2Info.maxTemp.toHold(TEMP) : group2Info.maxTemp"></tr-item>
                          <tr-item label="最小单体温度编号(℃):" :value="'number' == typeof group2Info.minTemp ? group2Info.minTemp.toHold(TEMP) : group2Info.minTemp"></tr-item>
                        </table>
                      </el-col>
                    </el-row>
                  </real-time-panel>
                </el-col>
              </el-row>
            </div>
          </el-tab-pane>
          <el-tab-pane
            key="monInfo"
            label="单体信息"
            name="monInfo">
            <el-table
              stripe
              size="small"
              :data="table.datas"
              height="100%">
              <el-table-column
                v-for="header in table.headers"
                :key="header.prop"
                :prop="header.prop"
                :label="header.label"
                :width="header.width"
                align="center"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <!-- 放电参数设置 -->
    <el-dialog
      title="放电参数设置"
      width="auto"
      :visible.sync="disChargeDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false">
      <ele-operation-params :is-can-test="isCanTest" :visible.sync="disChargeDialog" v-if="disChargeDialog" :batt="batt" :groupNum="groupNum"></ele-operation-params>
    </el-dialog>
    <!-- 开关控制 -->
    <el-dialog
      title="开关控制"
      width="auto"
      :visible.sync="switchDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false">
      <ele-operation-switch :is-can-control-switch="isCanControlSwitch" :visible.sync="switchDialog" :batt="batt" :state="state"></ele-operation-switch>
    </el-dialog>
  </flex-layout>
</template>
 
<script>
import eleOperationLine from "@/views/dataTest/components/diagrams/eleOperation";
import EleStatePanel from "@/views/dataTest/components/diagrams/eleOperation/eleStatePanel";
import RealTimePanel from "@/views/dataTest/components/diagrams/eleOperation/realTimePanel";
import createWs from "@/assets/js/websocket";
import {getBattGroupInfo} from "@/views/dataMager/js/battGroupMager";
import {stopEleOperation} from "@/views/dataTest/js/realTime";
const WSMixin = createWs("dev60870Inverter");
import dev60870 from "@/views/dataTest/js/dev60870";
import EleOperationParams from "@/views/dataTest/components/EleOperationParams";
import EleOperationSwitch from "@/views/dataTest/components/EleOperationSwitch";
import {formatSeconds} from "@/assets/js/tools";
import TrItem from "@/views/dataTest/components/TrItem";
 
import const_digit from "@/assets/js/const/const_digit";
const {
  cap: CAP,
  vol: VOL,
  curr: CURR,
  res: RES,
  conduct: CONDUCT,
  temp: TEMP,
  hum: HUM,
} = const_digit;
 
export default {
  name: "eleOperation",
  mixins: [WSMixin],
  components: {
    TrItem,
    EleOperationSwitch,
    EleOperationParams,
    RealTimePanel,
    EleStatePanel,
    eleOperationLine,
  },
  data() {
    return {
      CAP,
      VOL,
      CURR,
      RES,
      CONDUCT,
      TEMP,
      HUM,
      acTabs: "eleLine",
      homeListShow: false,
      batt: {},
      groupNum: 1,
      deviceInfo: {
        headers: [
          {
            prop: "num",
            label: "逆变器模块#",
            width: "",
          },
          {
            prop: "outputVol",
            label: "交流输出电压(V)",
            width: "",
          },
          {
            prop: "acPower",
            label: "有功功率(KW)",
            width: "",
          },
          {
            prop: "apPower",
            label: "视在功率(KW)",
            width: "",
          },
          {
            prop: "loadRate",
            label: "负载率(%)",
            width: "",
          },
          {
            prop: "temp",
            label: "模块温度(℃)",
            width: "",
          },
          {
            prop: "outputType",
            label: "输出方式",
            width: "",
          },
          {
            prop: "feedbackCurr",
            label: "当前回馈电流(A)",
            width: "",
          },
        ],
        data: []
      },
      disChargeDialog: false,
      switchDialog: false,
      update: Math.random(),
      info: dev60870.info(),
      state: dev60870.state(),
      sys: dev60870.sys(),
      group1: [],
      group1Info: {
        avgVol: "-",
        avgTemp: "-",
        maxVol: "-",
        minVol: "-",
        maxTemp: "-",
        minTemp: "-"
      },
      group2: [],
      group2Info: {
        avgVol: "-",
        avgTemp: "-",
        maxVol: "-",
        minVol: "-",
        maxTemp: "-",
        minTemp: "-"
      },
      serverTime: new Date().format("yyyy-MM-dd hh:mm:ss"),
      isConnect: false,     // 是否连接
      table: {
        headers: [
          {
            prop: "num1",
            label: "单体编号",
            width: "",
            key1: "",
          },
          {
            prop: "vol1",
            label: "电压(V)",
            width: "",
            key1: "vol",
          },
          {
            prop: "res1",
            label: "内阻(mΩ)",
            width: "",
            key1: "res",
          },
          {
            prop: "temp1",
            label: "温度(℃)",
            width: "",
            key1: "temp",
          },
        ],
        datas: []
      },
      popoverVisible: false,
      isCanTest: false,
    }
  },
  watch: {
    "$route.params.BattGroupId"(battGroupId) {
      this.$nextTick(() => {
        this.getBattGroupInfo(battGroupId);
      });
    },
  },
  methods: {
    tabClick() {
 
    },
    onWSOpen() {
      this.$nextTick(() => {
        this.sendMessage();
      });
    },
    sendMessage() {
      let batt = this.batt;
      if (!batt.battGroupId || !this.isWSOpen) {
        return false;
      }
      this.SOCKET.send(batt.fbsdeviceId);
    },
    onWSMessage(res) {
      let rs = JSON.parse(res.data);
      this.update = Math.random();
      if(rs.code == 1) {
        this.info = {...rs.data};
        console.log(rs.data);
        this.info.battTestTimeLong1Text = formatSeconds(this.info.battTestTimeLong1);
        this.info.battTestTimeLong2Text = formatSeconds(this.info.battTestTimeLong2);
        this.state = {...rs.data2};
        this.state.battState1Text = this.getBattStateText(this.state.battState1);
        this.state.battState2Text = this.getBattStateText(this.state.battState2);
        this.sys = {...rs.data3.fbs9100State};
        this.group1 = rs.data3.battRtDataMap[0];
        this.group2 = rs.data3.battRtDataMap[1];
        let group = this.group1;
        if(this.batt.groupIndexInFBSDevice == 1) {
          group = this.group2;
        }
        if(this.acTabs == "monInfo" || this.table.datas.length ==0) {
          this.table.datas = group.map((item,key)=>{
            return {
              num1: "#"+(key+1),
              vol1: item.monVol.toHold(VOL),
              res1: item.monRes.toHold(RES),
              temp1: item.monTmp.toHold(TEMP),
            }
          });
        }
 
        this.serverTime = rs.msg;
        this.group1Info = this.getGroupInfo(this.group1);
        this.group2Info = this.getGroupInfo(this.group2);
      }
 
      let recordTime = new Date(this.info.recordTime).getTime();
      let serverTime = new Date(this.serverTime).getTime();
 
      let isConnect = true;
      if(serverTime-recordTime>=dev60870.timeout) {
        isConnect = false;
      }
      this.isConnect = isConnect;
    },
    getBattGroupInfo(battGroupId) {
      this.homeListShow = false;
      getBattGroupInfo(battGroupId)
        .then((res) => {
          res = res.data;
          if (res.code) {
            this.leafClick(res.data[0]);
          } else {
            this.$layer.msg("未获取到电池组的信息");
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    leafClick(data) {
      this.batt = data;
      this.$nextTick(()=>{
        this.sendMessage();
      });
    },
    showDisChargeDialog(groupNum, isCanTest) {
      this.isCanTest = isCanTest;
      this.groupNum = groupNum;
      this.disChargeDialog = true;
    },
    stopTest() {
      this.$confirm("确认停止测试?", "系统提示", {}).then(()=>{
        let loading = this.$layer.loading();
        stopEleOperation(this.batt.fbsdeviceId).then(res=>{
          this.$layer.close(loading);
          let rs = res.data;
          if(rs.code == 1 && rs.data) {
            this.$message.success("停止成功!");
          }else {
            this.$message.error("停止失败!");
          }
        }).catch(error=>{
          this.$layer.close(loading);
          this.$message.error("停止失败,请联系管理员!");
          console.log(error);
        });
      }).catch(()=>{});
 
    },
    getBattStateText(state) {
      let rs = "未知";
      switch (Number(state)) {
        case 0:
          rs = "浮充";
          break;
        case 1:
          rs = "放电";
          break;
        case 2:
          rs = "充电";
          break;
        default:
          rs = "未知"
          break;
      }
      return rs;
    },
    getGroupInfo(list) {
      let monNum = list.length;
      let monVol = 0;
      let monTemp = 0;
      let maxVol = {
        label: "-",
        value: "-"
      };
      let minVol = {
        label: "-",
        value: "-"
      };
 
      let maxTemp = {
        label: "-",
        value: "-"
      };
      let minTemp = {
        label: "-",
        value: "-"
      };
      if(list.length != 0) {
        maxVol = {
          label: "#1",
          value: list[0].monVol,
        };
 
        minVol = {
          label: "#1",
          value: list[0].monVol,
        };
 
        maxTemp = {
          label: "#1",
          value: list[0].monTmp,
        };
 
        minTemp = {
          label: "#1",
          value: list[0].monTmp,
        };
 
        list.map((item, key)=>{
          monVol += item.monVol;
          monTemp += item.monTmp;
          if(item.monVol>maxVol.value) {
            maxVol.label = "#"+(key+1);
            maxVol.value = item.monVol;
          }
 
          if(item.monVol<minVol.value) {
            minVol.label = "#"+(key+1);
            minVol.value = item.monVol;
          }
 
          if(item.monTmp>maxTemp.value) {
            maxTemp.label = "#"+(key+1);
            maxTemp.value = item.monTmp;
          }
 
          if(item.monTmp<minTemp.value) {
            minTemp.label = "#"+(key+1);
            minTemp.value = item.monTmp;
          }
        });
      }
 
      let avgVol = monNum==0?0:monVol/monNum;
      let avgTemp = monNum==0?0:monTemp/monNum;
      return {
        avgVol: avgVol.toHold(VOL),
        avgTemp: avgTemp.toHold(TEMP),
        maxVol: maxVol.label+":"+maxVol.value.toHold(VOL),
        minVol: minVol.label+":"+minVol.value.toHold(VOL),
        maxTemp: maxTemp.label+":"+maxTemp.value.toHold(TEMP),
        minTemp: minTemp.label+":"+minTemp.value.toHold(TEMP),
      }
    },
    switchControlShow() {
      let isCanControlSwitch = this.isCanControlSwitch;
      if(isCanControlSwitch.code == 1) {
        this.switchDialog = true
      }else {
        this.$alert(isCanControlSwitch.msg, '系统提示');
      }
    },
  },
  computed: {
    isCanControlSwitch() {
      let result = {
        code: 0,
        msg: "未知"
      };
 
      let devWorkstate = this.sys.devWorkstate;           // 系统状态
      let atresia = this.info.atresia;                    // 闭锁状态[1:闭锁;0:未闭锁]
      let emergencyStop = this.info.emergencyStop;        // 紧急停止 0:正常;1:不正常
      let poweroff = this.info.poweroff;                  // 机房停电标识 0:正常;1:不正常
      if(emergencyStop == 1) {
        result.msg = "紧急停止";
      }else if(atresia != 0) {
        result.msg = "远程闭锁中";
      }else if(poweroff == 1) {
        result.msg = "设备工作中: 机房停电";
      }else if(devWorkstate == 1) {
        result.msg = "设备工作中: 放电测试中";
      }else if(devWorkstate == 2) {
        result.msg = "设备工作中: 充电测试中";
      }else {
        result.code = 1;
      }
 
      return result;
    }
  },
  mounted() {
    let battGroupId = this.$route.params.battGroupId;
    if (battGroupId) {
      this.getBattGroupInfo(battGroupId);
    }
  }
}
</script>
 
<style scoped>
.page-content {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 0 4px;
}
.page-content-container {
  border: 2px solid #143a92;
  box-sizing: border-box;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
}
.flex-layout-tabs {
  box-sizing: border-box;
  height: 100%;
}
.real-time-overview-container {
  padding: 0 16px;
}
 
.real-time-tbl {
  width: 100%;
}
.real-time-tbl td {
  padding: 8px 4px;
}
td.label-text {
  text-align: right;
  padding-right: 0;
}
td.label-value-container {
  text-align: left;
  padding-left: 0;
}
.label-value {
  display: inline-block;
  border: 1px solid #08F7E7;
  border-radius: 4px;
  background-color: #001A54;
  color: #FFF000;
  padding: 4px 16px;
  text-align: center;
  min-width: 40px;
}
.popover-content {
  background-color: #FFFFFF;
  padding: 8px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}
</style>