whyczyk
2022-03-23 cbd3fb82b1d15c0a82b63496add7b7af37ac8738
src/pages/monitoring/real-monitoring.vue
@@ -100,35 +100,11 @@
         </div>
         <div class="card">
            <div class="commonTitle cardTitle">均衡供电</div>
            <div class="commonTitle cardTitle">数据表格</div>
            <div class="listCon">
               <div class="item">
                  {{otherTable[0].value}}
                  <div class="title">
                     版本号
                  </div>
               </div>
               <div class="item">
                  {{otherTable[1].value}}℃
                  <div class="title">
                     温度(℃)
                  </div>
               </div>
               <div class="item">
                  {{eleTable[0].value}}A
                  <div class="title">
                     总电流(A)
                  </div>
               </div>
               <div class="item">
                  {{totolTable[0].value}}V
                  <div class="title">
                     总电压(V)
                  </div>
               </div>
            </div>
            <div class="chartWarp">
               <progress-block-vertical-bar ref="outputVolList"></progress-block-vertical-bar>
               <el-table stripe size="small" :data="table.datas" height="100%" :row-class-name="setTableRowClass" v-if="table.show">
                  <el-table-column v-for="header in dataHeaders" :key="header.prop" :prop="header.prop" :label="header.label" :width="header.width" :fixed="header.fixed" align="center"></el-table-column>
               </el-table>
            </div>
         </div>
@@ -146,18 +122,30 @@
   searchBattInfo,
   getBattGroupInfo,
   realTimeAlarm,
   realTimePowerOff,
   realTimeSearch,
   realTimeGroup,
   JhStateActionSerchByCondition,
   realTimeLd9Data,
} from "@/pages/monitoring/js/api"
import BarChart from "@/components/chart/BarChart";
import progressBlockVerticalBar from "@/components/chart/progress-block-vertical-bar";
import getMarkLineData from "@/components/chart/js/getMarkLineData";
import getTblHeader from "@/pages/monitoring/js/getTblHeader";
import const_61850 from "@/assets/js/const/const_61850";
import const_9100 from "@/assets/js/const/const_9100";
import const_ld_nine from "@/assets/js/const/const_ld_nine";
let vol, resChart, temp, conduct, currChart, leakVol;
let tblData = [];
export default {
   data() {
      let pageConfig = this.$store.getters["user/realTabsConfig"];
      let stateList = const_61850.stateList;
      let historyStateList = const_61850.historyStateList;
      let lastCapacityTest = const_61850.lastCapacityTest;
      return {
         stateList: stateList,
         historyStateList: historyStateList,
         lastCapacityTest: lastCapacityTest,
         showPopup: false,
         cascaderValue: '',
         fieldValue: '请选择站点',
@@ -175,7 +163,7 @@
            batt_state: 0 /* 电池状态 */
         },
         batt: {},
         timer: new this.$units.Timeout('movingRingSystemRealTime'),
         timer: new this.$units.Timeout(),
         totolTable: [
            {
               key: "input_vol_total",
@@ -264,6 +252,82 @@
               value: "???",
            },
         ],
         table: {
            headers: [
               {
                  prop: "num1",
                  label: "单体编号",
                  width: "",
                  key1: "",
                  fixed: true
               },
               {
                  prop: "vol1",
                  label: "电压(V)",
                  width: "",
                  key1: "vol",
               },
               {
                  prop: "res1",
                  label: "内阻(mΩ)",
                  width: "",
                  key1: "res",
               },
               {
                  prop: "temp1",
                  label: "温度(℃)",
                  width: "",
                  key1: "temp",
               },
               {
                  prop: "conduct1",
                  label: "电导",
                  width: "",
                  key1: "conduct",
               },
               {
                  prop: "monConnRes",
                  label: "链接条阻值",
                  width: "",
                  key1: "monConnRes",
               },
               {
                  prop: "curr1",
                  label: "均衡电流(A)",
                  width: "",
                  key1: "curr"
               },
               {
                  prop: "leakVol1",
                  label: "漏液电压(V)",
                  width: "",
                  key1: "leakVol"
               },
            ],
            datas: [
               {
                  num1: 0,
                  vol1: 0,
                  res1: 0,
                  temp1: 0,
                  conduct1: 0,
                  curr1: 0,
                  leakVol1: 0,
               },
            ],
            show: false
         },
         pageConfig: pageConfig,
         diagram: {
            update: true,
            type: -1,
            desc: "",
            powerCut: 1,
            temp: 0, // 设备温度
            contactRes: 0, // 接触器阻抗
            dropVol: 0, // 导通压降
            devType: 0, // 设备类型
         },
      }
   },
   components: {
@@ -305,7 +369,7 @@
            list.batt_syrl_cap = this.inputs.batt_rest_cap.toFixed(1) + "AH";
         }
         if (this.inputs.batt_state === 3) {
            list.sysc = sethoubeiTime(
            list.sysc = this.$units.sethoubeiTime(
               parseFloat(this.inputs.batt_rest_cap) /
               parseFloat(this.inputs.group_curr)
            );
@@ -314,6 +378,18 @@
         }
         return list;
      },
      dataHeaders() {
         let headers = this.table.headers;
         let tabConfig = this.pageConfig;
         let batt = this.batt;
         return headers.filter(item => {
            let isShow = item.key1 ? tabConfig[item.key1] : true;
            if (item.type) {
               isShow = this.$units.regEquipType(batt.FBSDeviceId, item.type);
            }
            return isShow;
         });
      }
   },
   methods: {
      //定时器
@@ -323,6 +399,7 @@
               .all([
                  this.realTimeSearch(),
                  this.realTimeGroupss(),
                  this.realStateTimeData(),
                  this.search(),
               ])
               .then(() => {
@@ -365,19 +442,19 @@
                  }
               }
               // 设置输出电压柱状图
               this.$refs.outputVolList.setData({
                  title: {
                     show: true,
                     text: "输出电压",
                     x: "center",
                     textStyle: {
                        fontSize: "14",
                        color: '#323233'
                     }
                  },
                  name: "输出电压",
                  list: this.volTable,
               });
               // this.$refs.outputVolList.setData({
               //    title: {
               //       show: true,
               //       text: "输出电压",
               //       x: "center",
               //       textStyle: {
               //          fontSize: "14",
               //          color: '#323233'
               //       }
               //    },
               //    name: "输出电压",
               //    list: this.volTable,
               // });
            })
            .catch((err) => {
               console.log(err);
@@ -399,8 +476,419 @@
      leafClick(data) {
         this.batt = data;
         this.realTimeAlarmss();
         this.table.headers = getTblHeader(data.FBSDeviceId);
         this.table.show = false;
         // 开启循环请求
         this.startTimer();
      },
      realStateTimeData() {
         let batt = this.batt;
         if (this.$units.regEquipType(batt.FBSDeviceId, ["LD9"])) {
            this.realTimeLd9Data();
         } else {
            this.realTimePowerOffs();
         }
      },
      /* 查询电路图开关状态和信息 */
      realTimePowerOffs() {
         let batt = this.batt;
         // 设备为61850显示右侧的面板
         if (this.$units.regEquipType(batt.FBSDeviceId, ["equip61850"])) {
            this.stateListShow = true;
         } else {
            this.stateListShow = false;
         }
         // 查询后台数据
         realTimePowerOff({
            dev_id: batt.FBSDeviceId,
         }).then((res) => {
            let rs = JSON.parse(res.data.result);
            let outTime = 2 * 60; //设备超时时间(2分钟)
            let isOutTime = true; //通讯中断        判断设备是否通讯中断    true:中断    false:正常
            if (rs.code == 1) {
               let data = rs.data[0];
               // 设置版本号
               this.dev_version = data.dev_version;
               // 基础信息
               this.setEquipBase(data);
               // 判断是否超时
               var nowTime = new Date(data.note).getTime(); //当前时间
               var record = new Date(data.record_datetime).getTime();
               if (Math.abs(nowTime - record) / 1000 > outTime) {
                  this.disconnect();
               } else {
                  // 未超时执行逻辑
                  let dev_id = batt.FBSDeviceId;
                  this.diagram.powerCut = 0;
                  // 设备为61850
                  if (this.$units.regEquipType(dev_id, "equip61850")) {
                     this.setEquip61850(data);
                  } else if (
                     this.$units.regEquipType(dev_id, ["BTS", "BTS9110", "BTS9120", "lithium", "LD9"])
                  ) {
                     this.setEquipBTS(data);
                  } else if (this.$units.regEquipType(dev_id, ["BTS9605", "BTS9611"])) {
                     this.setEquip9605(data);
                  } else {
                     this.disconnect();
                  }
               }
            } else {
               // 设置版本号
               this.dev_version = "";
               // 设备处于未连接
               this.disconnect();
            }
         });
      },
      // 设置stateList的值
      setStateList(name, value, type) {
         let stateList = this.stateList;
         for (let i = 0; i < stateList.length; i++) {
            let state = stateList[i];
            if (state.name == name) {
               state.value = value;
               state.type = type ? type : "";
            }
         }
         let historyStateList = this.historyStateList;
         for (let i = 0; i < historyStateList.length; i++) {
            let state = historyStateList[i];
            if (state.name == name) {
               state.value = value;
               state.type = type ? type : "";
            }
         }
         for (let i = 0, list = this.lastCapacityTest, j = list.length; i < j; i++) {
            let state = list[i];
            if (state.name == name) {
               state.value = value;
               state.type = type || "";
            }
         }
      },
      // 9605设备
      setEquip9605(data) {
         let batt = this.batt;
         // 关闭遮罩层
         this.maskShow = false;
         //  电路图类型
         let workstatus = parseInt(data.dev_workstate); //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知'];
         this.diagram.desc = "";
         let battstate = this.inputs.batt_state;
         let alarmstatus = data.dev_alarmstate;
         // 设置停电放电状态
         if (data.dev_onlinevollow) {
            this.inputs.batt_state = 5;
            this.diagram.type = 5;
            this.diagram.desc = "(开关闭合)";
            this.diagram.powerCut = 1;
            // 当前设备是BTS设备
            if (workstatus === 0 && data.dev_res_test_state !== 0) {
               this.diagram.desc += "(内阻测试)";
            }
            return;
         }
         // 判断workstatus
         switch (workstatus) {
            case 0:
               this.diagram.type = 0;
               //this.diagram.desc = '(开关闭合)';
               // 当前设备是BTS设备
               if (data.dev_res_test_state !== 0) {
                  this.diagram.type = 6;
                  this.diagram.desc += "(内阻测试)";
               }
               break;
            case 1:
               this.diagram.type = 1;
               //this.diagram.desc = '(开关断开)';
               break;
            case 2:
               this.diagram.type = 2;
               //this.diagram.desc = '(开关断开)';
               break;
            default:
               this.diagram.type = -1;
               this.maskShow = true;
               break;
         }
      },
      // BTS设备信息
      setEquipBTS(data) {
         let batt = this.batt;
         // 关闭遮罩层
         this.maskShow = false;
         //  电路图类型
         let workstatus = parseInt(data.dev_workstate); //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知'];
         this.diagram.desc = "";
         let battstate = this.inputs.batt_state;
         let alarmstatus = data.dev_alarmstate;
         // 是否为锂电池
         let isLithium = this.$units.regEquipType(batt.FBSDeviceId, "lithium");
         // 设置停电放电状态
         if (data.dev_onlinevollow) {
            this.inputs.batt_state = 5;
            this.diagram.type = 5;
            this.diagram.desc = "(开关闭合)";
            this.diagram.powerCut = 1;
            // 当前设备是BTS设备
            if (workstatus === 0 && data.dev_res_test_state !== 0) {
               this.diagram.desc += "(内阻测试)";
            }
            // 锂电池详细描述为空
            if (isLithium) {
               this.diagram.desc = "";
            }
            return;
         }
         // 判断workstatus
         switch (workstatus) {
            case 0:
               this.diagram.type = 0;
               this.diagram.desc = "(开关闭合)";
               // 当前设备是BTS设备
               if (data.dev_res_test_state !== 0) {
                  this.diagram.desc += "(内阻测试)";
               }
               break;
            case 1:
               if (
                  data.dev_testgroupnum > 0 &&
                  data.dev_testgroupnum === batt.GroupIndexInFBSDevice + 1
               ) {
                  this.diagram.type = 1;
                  this.diagram.desc = "(开关断开)";
               } else {
                  if (battstate === 3) {
                     this.diagram.type = 1;
                     this.diagram.desc = "(开关断开)";
                  } else {
                     this.diagram.type = 0;
                     this.diagram.desc = "(开关闭合)";
                  }
               }
               // 当前设备是BTS设备
               if (data.dev_testtype == 209) {
                  this.diagram.desc += "(KD测试)";
                  this.diagram.type = 3;
               }
               break;
            case 2:
               //辨别当前电池组是否在充电
               if (
                  this.diagram.type == 2 ||
                  (data.dev_testgroupnum > 0 &&
                     data.dev_testgroupnum === batt.GroupIndexInFBSDevice + 1)
               ) {
                  //充电
                  if (
                     alarmstatus === 1 ||
                     alarmstatus === 2 ||
                     alarmstatus === 3 ||
                     alarmstatus === 4 ||
                     alarmstatus === 6
                  ) {
                     //限流充电      -->常闭接触器断开
                     this.diagram.type = 2;
                     this.diagram.desc = "(开关断开)";
                  } else {
                     //直流充电     -->常闭接触器闭合
                     this.diagram.type = 2;
                     this.diagram.desc = "(开关闭合)";
                  }
               } else {
                  this.diagram.type = 0;
                  this.diagram.desc = "(开关闭合)";
               }
               break;
            default:
               this.diagram.type = -1;
               this.maskShow = true;
               break;
         }
         // 锂电池详细描述为空
         if (isLithium) {
            this.diagram.desc = "";
         }
      },
      // 61850设备信息
      setEquip61850(data) {
         //  电路图类型
         let workstatus = parseInt(data.dev_workstate); //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知'];
         this.diagram.desc = "";
         // 关闭遮罩层
         this.maskShow = false;
         // 设置停电放电状态
         if (data.dev_onlinevollow) {
            this.inputs.batt_state = 5;
            this.diagram.type = 5;
            this.diagram.desc = "(开关闭合)";
            this.diagram.powerCut = 1;
            // 当前设备是BTS设备
            if (workstatus === 0 && data.dev_res_test_state !== 0) {
               this.diagram.desc += "(内阻测试)";
            }
            return;
         }
         switch (workstatus) {
            case 0: //浮充状态拓扑图
               this.diagram.type = 0;
               this.diagram.desc = "(开关闭合)";
               break;
            case 4: //浮充状态(内阻测试)拓扑图
               this.diagram.type = 0;
               // 当前设备是否是内阻测试
               this.diagram.desc = "(开关闭合)";
               this.diagram.desc += "(内阻测试)";
               break;
            case 1: //充电状态拓扑图
               this.diagram.type = 2;
               this.diagram.desc = "(开关断开)";
               break;
            case 2: //放电状态拓扑图
               this.diagram.type = 1;
               this.diagram.desc = "(开关断开)";
               break;
            case 3: //放电状态拓扑图
               this.diagram.type = 5;
               break;
            case 5: //放电状态(KD测试)拓扑图
               this.diagram.type = 3;
               this.diagram.desc = "(开关断开)";
               this.diagram.desc += "(KD测试)";
               break;
            case 6: // 离线养护测试
               this.diagram.type = 4;
               this.diagram.desc = "离线养护测试";
               break;
            default:
               //未知
               this.diagram.type = -1;
               this.diagram.desc = "(未知)";
               this.maskShow = true;
               break;
         }
         // 设备工作状态
         let workStates = const_61850.workstates;
         this.setStateList("workState", workStates[data.dev_workstate]);
         // 核容终止原因
         // let stopReasons = const_61850.stopreasons;
         // if (data.dev_workstate == 2) {
         //   this.setStateList("stopReason", "未知");
         // } else {
         //   this.setStateList(
         //     "stopReason",
         //     stopReasons[data.dev_last_captest_stop_type]
         //   );
         // }
         // 操作失败原因
         let failReasons = const_61850.failreasons;
         this.setStateList("failReason", failReasons[data.dev_alarmstate]);
         // 告警信息
         let alarms = data.dev_61850alarms.split(",");
         // alarms = ['false', 'false', 'true', 'false', 'true'];
         // 通讯状态
         if (alarms[1] == "true") {
            this.setStateList("connect", "异常", "table-row-error");
         } else {
            this.setStateList("connect", "正常", "");
         }
         // 温度
         if (alarms[2] == "true") {
            this.setStateList("devTemp", "异常", "table-row-error");
         } else {
            this.setStateList("devTemp", "正常", "");
         }
         // 干接点
         if (alarms[4] == "true") {
            this.setStateList("contact", "异常", "table-row-error");
         } else {
            this.setStateList("contact", "正常", "");
         }
      },
      // 基础信息
      setEquipBase(data) {
         let groupIndex = this.batt.GroupIndexInFBSDevice;
         // 设备的温度
         this.diagram.temp = data.dev_temp;
         let contactRes = (groupIndex != 0
            ? data.dev_conresist1
            : data.dev_conresist
         ).toHold(2);
         let dropVol = (groupIndex != 0
            ? data.dev_condvoldp1
            : data.dev_condvoldp
         ).toHold(2);
         let alarms = data.dev_61850alarms.split(",");
         if (alarms.length) {
            this.diagram.contactRes = alarms[0] == "true" ? "k1异常" : contactRes;
            this.diagram.dropVol = alarms[3] == "true" ? "D1异常" : dropVol;
         } else {
            this.diagram.contactRes = contactRes;
            this.diagram.dropVol = dropVol;
         }
      },
      realTimeLd9Data() {
         let batt = this.batt;
         realTimeLd9Data({
            dev_id: batt.FBSDeviceId,
         }).then(res => {
            let rs = JSON.parse(res.data.result);
            if (rs.code == 1) {
               let data = rs.data[0];
               // 判断是否超时
               let outTime = 2 * 60; //设备超时时间(2分钟)
               let nowTime = new Date(data.note).getTime(); //当前时间
               let record = new Date(data.record_datetime).getTime();
               if (Math.abs(nowTime - record) / 1000 > outTime) {
                  this.disconnect();
               } else {
                  this.diagram.desc = "";
                  // 0-在线监测,1-核容测试,2-测试状态状态停止,3-内阻测试
                  switch (data.sys_state) {
                     case 0:
                        this.diagram.type = 0;
                        break;
                     case 1:
                        this.diagram.type = 1;
                        break;
                     case 2:
                        this.diagram.type = 2;
                        break;
                     case 3:
                        this.diagram.type = 3;
                        this.diagram.desc = "(内阻测试)";
                        break;
                  }
               }
            } else {
               this.disconnect();
            }
         }).catch(error => {
            console.log(error);
            this.disconnect();
         });
      },
      disconnect() {
         // 设备未连接
         this.diagram.type = -1;
      },
      /* 查询电池告警参数 */
      realTimeAlarmss() {
@@ -465,30 +953,37 @@
      /* echars图表 */
      realTimeSearch() {
         var batt = this.batt;
         realTimeSearch({
            BattGroupId: batt.BattGroupId
         }).then(res => {
            let diagramType = this.diagram.type;
            let rs = JSON.parse(res.data.result);
            let data = [];
            if (rs.code == 1) {
            if (rs.code == 1 && diagramType != -1) {
               data = rs.data.map(item => {
                  return {
                     num1: "#" + item.mon_num,
                     vol1: item.mon_vol,
                     res1: item.mon_res,
                     temp1: item.mon_tmp,
                     conduct1: item.mon_res ? (1 / item.mon_res * 1000).toFixed(0) : 0,
                     conduct1: item.mon_res
                        ? ((1 / item.mon_res) * 1000).toFixed(0)
                        : 0,
                     curr1: item.mon_JH_curr,
                     leakVol1: item.mon_LY_vol
                     leakVol1: item.mon_LY_vol,
                     monConnRes: item.mon_conn_res,
                     monCap: item.mon_cap,
                     monTestCap: diagramType == 1 ? item.monTestCap : "---",
                     monResCap: diagramType == 1 ? item.monRestCap : "---",
                     monDisTimeLong: diagramType == 1 ? Math.floor(item.monDisTimeLong / 60) + "时" + (item.monDisTimeLong % 60) + "分" : "---",
                     monState: item.monState,
                  };
               });
            }
            // 更新表格
            if (this.acTabs == 'tblData') {
               this.table.datas = data;
            } else {
               tblData = data;
            }
            this.table.datas = data;
            this.table.show = true;
            // 电压值
            let volTempVol = [];
            if (rs.code == 1) {
@@ -697,7 +1192,6 @@
            let rsa = JSON.parse(res.data.result);
            if (rsa.code == 1) {
               this.inputs = rsa.data[0];
               console.log(this.inputs)
            }
         }).catch(err => {
            console.log(err)
@@ -811,6 +1305,14 @@
         }
         return -1;
      },
      setTableRowClass({ row }) {
         if (row.monState == 1) {
            return "red-row";
         } else if (row.monState == 2) {
            return "green-row";
         }
         return "";
      },
   },
   mounted() {
      this.searchStation();
@@ -879,7 +1381,7 @@
.listCon {
   width: 100%;
   height: 178px;
   height: 500px;
   border-bottom: 2px solid #eeeeee;
   display: flex;
   align-items: center;