whychdw
2021-03-09 909744b8149a8b88c6a7b75e7b94b636e204fded
提交内容
5个文件已修改
1584 ■■■■ 已修改文件
src/assets/js/apis/dataMager/powerMager.js 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/config.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PageHeader.vue 1414 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/dataTest/movingRingSystem/chargerStatus.vue 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/dataTest/movingRingSystem/isolatingDevice.vue 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/apis/dataMager/powerMager.js
@@ -99,6 +99,30 @@
    });
  },
  /**
   * 获取绝缘装置的实时信息
   * @param data
   * @returns {AxiosPromise}
   */
  getIsolatingDeviceData(data) {
    return axios({
      method: 'post',
      url: 'FBS9100InsulateStateAction_action_getDataByDevId',
      data: 'json=' + JSON.stringify(data),
    });
  },
  /**
   * 获取充电机的实时信息
   * @param data
   * @returns {AxiosPromise}
   */
  getChargeDeviceData(data) {
    return axios({
      method: 'post',
      url: 'FBS9100ChargerStateAction_action_getDataByDevId',
      data: 'json=' + JSON.stringify(data),
    });
  },
  /**
   * 查询已经存在的机房站点
   *   @param   {[Object]}  data  电源设备ID
   */
src/assets/js/config.js
@@ -2,16 +2,16 @@
    uKey: {
        label: 'uKey',
        des: "用户需要通过插入uKey才可以登录",
        value: false,
        value: true,
    },
    face: {
        label: "人脸识别",
        des: "用户可以直接通过人脸识别登录",
        value: false
        value: true
    },
    autograph: {
        label: '签名',
        des: '电池信息配置中添加设备的签名,用于充放电测试时验证',
        value: false,
        value: true,
    },
}
src/components/PageHeader.vue
@@ -1,105 +1,106 @@
<template>
  <div class="page-header">
    <div class="page-header-container">
      <flex-layout direction="row">
        <div class="page-header-left" slot="header">
          <img class="header-first-logo" src="../assets/images/gjdw-log.png">
          <!--                    <img class="header-first-logo" src="../assets/images/nfdw-log.png">-->
          <span class="header-carve-up"></span>
            <span>蓄电池监控平台</span>
<!--          <span>综合电力监控平台</span>-->
          <span class="sys-version">V{{ version }}</span>
        </div>
        <div class="page-header-content">
          <div class="header-info-list">
            <el-tooltip class="item" effect="dark" :content="serverInfo.disk.message" placement="bottom">
              <div class="header-info-item">
                <progress-bar v-if="showProgress" :options="options" :value="serverInfo.disk.progress">
                </progress-bar>
              </div>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="serverInfo.cpu.message" placement="bottom">
              <div class="header-info-item">
                <progress-bar v-if="showProgress" :options="options" :value="serverInfo.cpu.progress">
                </progress-bar>
              </div>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="serverInfo.memory.message" placement="bottom">
              <div class="header-info-item">
                <progress-bar v-if="showProgress" :options="options"
                              :value="serverInfo.memory.progress"></progress-bar>
              </div>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="serverInfo.linkNum.message" placement="bottom">
              <div class="header-info-item">
                <progress-bar v-if="showProgress" :options="options"
                              :value="serverInfo.linkNum.progress"></progress-bar>
              </div>
            </el-tooltip>
            <div class="header-info-item" style="margin-left: 60px;">
              <progress-state icon="el-icon-fuwuqi" :state="processInfo.sql" :content="processSqlMsg">
              </progress-state>
              <progress-state icon="el-icon-WIFIwofi" :state="processInfo.link" :content="processLinkMsg">
              </progress-state>
              <progress-state icon="el-icon-dianchi" :state="processInfo.behind"
                              :content="processBehindMsg"></progress-state>
              <progress-state icon="el-icon-gaojing" :state="processInfo.alarm"
                              :content="processAlarmMsg"></progress-state>
              <progress-state icon="el-icon-jihua" :state="processInfo.displan"
                              :content="processDisplanMsg"></progress-state>
              <progress-state icon="el-icon-tingdian" :state="processInfo.power"
                              :content="processPowerMsg"></progress-state>
              <progress-state icon="el-icon-jiankong" :state="processInfo.control"
                              :content="processControlMsg"></progress-state>
              <progress-state icon="el-icon-pifu" :state="1" :content="themeInfo"
                              @handleClick="handleClick"></progress-state>
            </div>
          </div>
          <div class="data-totals">
            <hdw-badge-btn text="电源告警数" :value="numbers.powerWarn" @click="goPages('powerWarn')"></hdw-badge-btn>
            <hdw-badge-btn text="机房停电数" :value="numbers.powerOff" @click="goPages('powerOff')">
            </hdw-badge-btn>
            <hdw-badge-btn text="电池告警数" :value="numbers.battWarn" @click="goPages('battWarn')">
            </hdw-badge-btn>
            <hdw-badge-btn text="设备告警数" :value="numbers.devWarn" @click="goPages('devWarn')">
            </hdw-badge-btn>
            <!--                        <hdw-badge-btn text="容量落后单体数量" :value="numbers.lowMon" @click="goPages('lowMon')"></hdw-badge-btn>-->
            <!--                        <hdw-badge-btn text="未完成放电计划数" :value="numbers.plan" @click="goPages('plan')"></hdw-badge-btn>-->
            <hdw-badge-btn text="核容测试设备" :value="numbers.nuclear" @click="goPages('nuclear')">
            </hdw-badge-btn>
          </div>
          <!--                    <div class="system-tools">-->
          <!--                        <div class="tools-item"><i class="iconfont el-icon-pifu-"></i></div>-->
          <!--                    </div>-->
        </div>
        <div class="page-header-right" slot="footer">
          <div class="hdw-avatar">
    <div class="page-header">
        <div class="page-header-container">
            <flex-layout direction="row">
                <div class="page-header-left" slot="header">
                    <!--          <img class="header-first-logo" src="../assets/images/gjdw-log.png">-->
                    <img class="header-first-logo" src="../assets/images/nfdw-log.png">
                    <span class="header-carve-up"></span>
                    <span>蓄电池监控平台</span>
                    <!--          <span>综合电力监控平台</span>-->
                    <span class="sys-version">V{{ version }}</span>
                </div>
                <div class="page-header-content">
                    <div class="header-info-list">
                        <el-tooltip class="item" effect="dark" :content="serverInfo.disk.message" placement="bottom">
                            <div class="header-info-item">
                                <progress-bar v-if="showProgress" :options="options" :value="serverInfo.disk.progress">
                                </progress-bar>
                            </div>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" :content="serverInfo.cpu.message" placement="bottom">
                            <div class="header-info-item">
                                <progress-bar v-if="showProgress" :options="options" :value="serverInfo.cpu.progress">
                                </progress-bar>
                            </div>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" :content="serverInfo.memory.message" placement="bottom">
                            <div class="header-info-item">
                                <progress-bar v-if="showProgress" :options="options"
                                              :value="serverInfo.memory.progress"></progress-bar>
                            </div>
                        </el-tooltip>
                        <el-tooltip class="item" effect="dark" :content="serverInfo.linkNum.message" placement="bottom">
                            <div class="header-info-item">
                                <progress-bar v-if="showProgress" :options="options"
                                              :value="serverInfo.linkNum.progress"></progress-bar>
                            </div>
                        </el-tooltip>
                        <div class="header-info-item" style="margin-left: 60px;">
                            <progress-state icon="el-icon-fuwuqi" :state="processInfo.sql" :content="processSqlMsg">
                            </progress-state>
                            <progress-state icon="el-icon-WIFIwofi" :state="processInfo.link" :content="processLinkMsg">
                            </progress-state>
                            <progress-state icon="el-icon-dianchi" :state="processInfo.behind"
                                            :content="processBehindMsg"></progress-state>
                            <progress-state icon="el-icon-gaojing" :state="processInfo.alarm"
                                            :content="processAlarmMsg"></progress-state>
                            <progress-state icon="el-icon-jihua" :state="processInfo.displan"
                                            :content="processDisplanMsg"></progress-state>
                            <progress-state icon="el-icon-tingdian" :state="processInfo.power"
                                            :content="processPowerMsg"></progress-state>
                            <progress-state icon="el-icon-jiankong" :state="processInfo.control"
                                            :content="processControlMsg"></progress-state>
                            <progress-state icon="el-icon-pifu" :state="1" :content="themeInfo"
                                            @handleClick="handleClick"></progress-state>
                        </div>
                    </div>
                    <div class="data-totals">
                        <hdw-badge-btn text="电源告警数" :value="numbers.powerWarn"
                                       @click="goPages('powerWarn')"></hdw-badge-btn>
                        <hdw-badge-btn text="机房停电数" :value="numbers.powerOff" @click="goPages('powerOff')">
                        </hdw-badge-btn>
                        <hdw-badge-btn text="电池告警数" :value="numbers.battWarn" @click="goPages('battWarn')">
                        </hdw-badge-btn>
                        <hdw-badge-btn text="设备告警数" :value="numbers.devWarn" @click="goPages('devWarn')">
                        </hdw-badge-btn>
                        <!--                        <hdw-badge-btn text="容量落后单体数量" :value="numbers.lowMon" @click="goPages('lowMon')"></hdw-badge-btn>-->
                        <!--                        <hdw-badge-btn text="未完成放电计划数" :value="numbers.plan" @click="goPages('plan')"></hdw-badge-btn>-->
                        <hdw-badge-btn text="核容测试设备" :value="numbers.nuclear" @click="goPages('nuclear')">
                        </hdw-badge-btn>
                    </div>
                    <!--                    <div class="system-tools">-->
                    <!--                        <div class="tools-item"><i class="iconfont el-icon-pifu-"></i></div>-->
                    <!--                    </div>-->
                </div>
                <div class="page-header-right" slot="footer">
                    <div class="hdw-avatar">
                        <span class="hdw-avatar-icon">
                            <i class="iconfont el-icon-Userselect"></i>
                        </span>
            <el-dropdown @command="commandClick">
                        <el-dropdown @command="commandClick">
                            <span class="hdw-avatar-text">
                                {{ username }}<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="passwordChange">密码修改</el-dropdown-item>
                <el-dropdown-item command="outSystem">安全退出</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <img v-if="showLogo" src="../assets/images/fuguang_logo.jpg" class="fuguang-logo">
          </div>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item command="passwordChange">密码修改</el-dropdown-item>
                                <el-dropdown-item command="outSystem">安全退出</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                        <img v-if="showLogo" src="../assets/images/fuguang_logo.jpg" class="fuguang-logo">
                    </div>
                </div>
            </flex-layout>
        </div>
      </flex-layout>
        <el-drawer title="我是标题" :visible.sync="pifuDrawer" size="360px" :with-header="false">
            <pifu-list></pifu-list>
        </el-drawer>
        <!-- 密码修改 -->
        <el-dialog title="密码修改" width="400px" :visible.sync="pwd.show" :close-on-click-modal="false" top="0"
                   class="dialog-center" :modal-append-to-body="false">
            <pwd-change v-if="pwd.show" :visible.sync="pwd.show"></pwd-change>
        </el-dialog>
    </div>
    <el-drawer title="我是标题" :visible.sync="pifuDrawer" size="360px" :with-header="false">
      <pifu-list></pifu-list>
    </el-drawer>
    <!-- 密码修改 -->
    <el-dialog title="密码修改" width="400px" :visible.sync="pwd.show" :close-on-click-modal="false" top="0"
               class="dialog-center" :modal-append-to-body="false">
      <pwd-change v-if="pwd.show" :visible.sync="pwd.show"></pwd-change>
    </el-dialog>
  </div>
</template>
<script>
@@ -109,717 +110,716 @@
import PifuList from "@/pages/dataTest/PifuList";
import PwdChange from "@/components/PwdChange";
import {
  Timeout
    Timeout
} from '../assets/js/tools'
export default {
  components: {
    HdwBadgeBtn,
    ProgressState,
    PifuList,
    PwdChange
  },
  data() {
    return {
      skinActive: 'science-blue',
      showProgress: false,
      pifuDrawer: false,
      showLogo: false,
      version: config.version,
      username: sessionStorage.getItem('username'),
      options: {
        text: {
          color: '#041F6C',
          shadowEnable: true,
          shadowColor: 'transparent',
          fontSize: 12,
          fontWeight: 'bold',
          fontFamily: 'Helvetica',
          dynamicPosition: false,
          hideText: false
        },
        progress: {
          color: '#f06824',
          backgroundColor: '#FFE329'
        },
        layout: {
          height: 15,
          width: 60,
          verticalTextAlign: 70,
          horizontalTextAlign: 35,
          zeroOffset: 0,
          strokeWidth: 30,
          progressPadding: 0,
          type: 'line'
        }
      },
      numbers: {
        lowMon: 0,
        powerOff: 0,
        battWarn: 0,
        devWarn: 0,
        plan: 0,
        nuclear: 0,
        powerWarn: 0,
      },
      serverInfo: {
        disk: {
          progress: 0,
          message: '服务器数据磁盘总量:未知;剩余:未知'
        },
        cpu: {
          progress: 0,
          message: 'TM:未知'
        },
        memory: {
          progress: 0,
          message: 'FM:未知',
        },
        linkNum: {
          progress: 0,
          message: 'DBC:未知'
        },
      },
      processInfo: {
        // 0:异常         1:正常      2:暂未开启
        alarm: 0, //告警标识位
        behind: 0, //落后标识位
        displan: 0, //放电计划标识位
        power: 0, //机房停电标识位
        control: 0, //线程监控标识位
        sql: 0, //服务器数据实时更新
        link: 0, //服务器连接
      },
      value: 0,
      timer: new Timeout(),
      pwd: {
        show: false,
      }
    }
  },
  methods: {
    handleClick() {
      this.pifuDrawer = true;
    components: {
        HdwBadgeBtn,
        ProgressState,
        PifuList,
        PwdChange
    },
    outSystem() {
      this.$router.push('/login');
    },
    passwordChange() {
      this.pwd.show = true;
    },
    commandClick(name) {
      switch (name) {
        case 'outSystem':
          this.outSystem();
          break;
        case "passwordChange":
          this.passwordChange();
          break;
        default:
          this.$layer.msg('该功能暂未开放!');
          break;
      }
    },
    startSearch() {
      this.timer.start(() => {
        this.$axios.all([
          this.searchAlmNum(), this.searchLowMonNum(),
          this.searchPowerOffNum(), this.searchDevAlarmNum(),
          this.searchNotComplanNum(), this.searchServerState(),
          this.searchProcessState(), this.search61850Nuclear(),
          this.searchPowerWarnNum(),
        ]).then(() => {
          this.timer.open();
        }).catch(error => {
          console.log(error);
        })
      }, 4000);
    },
    // 查询电池告警总数
    searchAlmNum() {
      this.$apis.top.searchAlmNum().then(res => {
        let rs = JSON.parse(res.data.result);
        this.numbers.battWarn = rs.sum;
      }).catch(error => {
        console.log(error);
      })
    },
    // 查询落后单体总数
    searchLowMonNum() {
      this.$apis.top.searchLowMonNum().then(res => {
        let rs = JSON.parse(res.data.result);
        this.numbers.lowMon = rs.sum;
      }).catch(error => {
        console.log(error);
      })
    },
    // 查询机房停电总数
    searchPowerOffNum() {
      this.$apis.top.searchPowerOffNum().then(res => {
        let rs = JSON.parse(res.data.result);
        this.numbers.powerOff = rs.sum;
      }).catch(error => {
        console.log(error);
      });
    },
    // 查询设备实时告警总数
    searchDevAlarmNum() {
      this.$apis.top.searchDevAlarmNum().then(res => {
        let rs = JSON.parse(res.data.result);
        this.numbers.devWarn = rs.sum;
      }).catch(error => {
        console.log(error);
      })
    },
    searchNotComplanNum() {
      this.$apis.top.searchNotComplanNum().then(res => {
        let rs = JSON.parse(res.data.result);
        this.numbers.plan = rs.sum;
      }).catch(error => {
        console.log(error);
      })
    },
    // 查询正在核容测试的信息
    search61850Nuclear() {
      this.$apis.top.search61850Nuclear().then(res => {
        let rs = JSON.parse(res.data.result);
        if (rs.code == 1) {
          let data = rs.data;
          this.numbers.nuclear = data.length;
        } else {
          this.numbers.nuclear = 0;
        }
      }).catch(error => {
      });
    },
    // 查询电源告警个数
    searchPowerWarnNum() {
      this.$apis.top.searchPowerWarnNum().then(res => {
        let rs = JSON.parse(res.data.result);
        if (rs.code == 1) {
          this.numbers.powerWarn = rs.data;
        } else {
          this.numbers.powerWarn = 0;
        }
      }).catch(error => {
      });
    },
    // 查询服务器信息
    searchServerState() {
      this.$apis.top.searchServerState().then(res => {
        let rs = JSON.parse(res.data.result);
        if (rs.code == 1) {
          let data = rs.data[0];
          console.log(data);
          let totalDiscSpace = data.total_disc_space;
          // 设置服务器磁盘信息
          let disc_spance_percent = totalDiscSpace?((data.total_disc_space - data.free_disc_space) * 100 /totalDiscSpace ).toFixed(0):0;
          this.serverInfo.disk.progress = parseInt(disc_spance_percent);
          this.serverInfo.disk.message = '服务器数据磁盘总量' + (data.total_disc_space / 1024).toFixed(1) +
              'GB;剩余:' + (data.free_disc_space /
                  1024).toFixed(1) + 'GB';
          // 设置服务器cpu信息
          let cpu_percent = (data.total_mem * 100 / data.max_mem).toFixed(0);
          this.serverInfo.cpu.progress = parseInt(cpu_percent);
          this.serverInfo.cpu.message = 'TM:' + (data.total_mem / (1024 * 1024 * 1024)).toFixed(2) +
              'GB/' + (data.max_mem /
                  (1024 * 1024 * 1024)).toFixed(2) + 'GB';
          // 设置服务器内存的信息
          let memory_percent = ((data.total_mem - data.free_men) * 100 / data.total_mem).toFixed(0);
          this.serverInfo.memory.progress = parseInt(memory_percent);
          this.serverInfo.memory.message = 'FM:' + ((data.total_mem - data.free_men) / (1024 * 1024))
                  .toFixed(0) + 'MB/' +
              (data.total_mem / (1024 * 1024)).toFixed(0) + "MB";
          // 设置服务器的连接数
          let link_percent = (data.db_conn_count * 100 / data.db_conn_max).toFixed(0);
          this.serverInfo.linkNum.progress = parseInt(link_percent);
          this.serverInfo.linkNum.message = 'DBC:' + data.db_conn_count + '/' + data.db_conn_max;
          // 更新服务器更新和连接状态
          var nowtime = new Date((data.note).replace(/\-/g, "/"));
          var sertime = new Date((data.server_datetime).replace(/\-/g, "/"));
          var timelong = Math.abs(parseInt(sertime - nowtime));
          if ((timelong / (1000 * 60)) > 2) {
            this.processInfo.sql = 0;
          } else {
            this.processInfo.sql = 1;
          }
          this.processInfo.link = 1;
        } else {
          this.processInfo.sql = 0;
          this.processInfo.link = 0;
        }
      }).catch(error => {
        console.log(error);
        this.processInfo.sql = 0;
        this.processInfo.link = 0;
      })
    },
    // 查询线程状态
    searchProcessState() {
      this.$apis.dataMager.threadMager.search().then(res => {
        let rs = JSON.parse(res.data.result);
        if (rs.code == 1) {
          let alarm_batt = false; //电池告警
          let alarm_dev = false; //设备告警
          let alarm_cap = false; //容量告警
          let badmon = false; //落后单体
          //console.log(rs.data);
          // 遍历并处理数据
          rs.data.forEach(item => {
            switch (item.ServerName) {
                // 告警线程
              case 'BMS_FBSDEV_ALARM':
                if (item.ProcessName == 'BMS_FBSDEV_ALARM_BATT') {
                  if (item.ServerFlag == 0) {
                    alarm_batt = 0;
                  } else {
                    alarm_batt = this.checkTimeOut2(item);
                  }
                } else if (item.ProcessName == 'BMS_FBSDEV_ALARM_DEV') {
                  if (item.ServerFlag == 0) {
                    alarm_dev = 0;
                  } else {
                    alarm_dev = this.checkTimeOut2(item);
                  }
    data() {
        return {
            skinActive: 'science-blue',
            showProgress: false,
            pifuDrawer: false,
            showLogo: false,
            version: config.version,
            username: sessionStorage.getItem('username'),
            options: {
                text: {
                    color: '#041F6C',
                    shadowEnable: true,
                    shadowColor: 'transparent',
                    fontSize: 12,
                    fontWeight: 'bold',
                    fontFamily: 'Helvetica',
                    dynamicPosition: false,
                    hideText: false
                },
                progress: {
                    color: '#f06824',
                    backgroundColor: '#FFE329'
                },
                layout: {
                    height: 15,
                    width: 60,
                    verticalTextAlign: 70,
                    horizontalTextAlign: 35,
                    zeroOffset: 0,
                    strokeWidth: 30,
                    progressPadding: 0,
                    type: 'line'
                }
            },
            numbers: {
                lowMon: 0,
                powerOff: 0,
                battWarn: 0,
                devWarn: 0,
                plan: 0,
                nuclear: 0,
                powerWarn: 0,
            },
            serverInfo: {
                disk: {
                    progress: 0,
                    message: '服务器数据磁盘总量:未知;剩余:未知'
                },
                cpu: {
                    progress: 0,
                    message: 'TM:未知'
                },
                memory: {
                    progress: 0,
                    message: 'FM:未知',
                },
                linkNum: {
                    progress: 0,
                    message: 'DBC:未知'
                },
            },
            processInfo: {
                // 0:异常         1:正常      2:暂未开启
                alarm: 0, //告警标识位
                behind: 0, //落后标识位
                displan: 0, //放电计划标识位
                power: 0, //机房停电标识位
                control: 0, //线程监控标识位
                sql: 0, //服务器数据实时更新
                link: 0, //服务器连接
            },
            value: 0,
            timer: new Timeout(),
            pwd: {
                show: false,
            }
        }
    },
    methods: {
        handleClick() {
            this.pifuDrawer = true;
        },
        outSystem() {
            this.$router.push('/login');
        },
        passwordChange() {
            this.pwd.show = true;
        },
        commandClick(name) {
            switch (name) {
                case 'outSystem':
                    this.outSystem();
                    break;
                case "passwordChange":
                    this.passwordChange();
                    break;
                default:
                    this.$layer.msg('该功能暂未开放!');
                    break;
            }
        },
        startSearch() {
            this.timer.start(() => {
                this.$axios.all([
                    this.searchAlmNum(), this.searchLowMonNum(),
                    this.searchPowerOffNum(), this.searchDevAlarmNum(),
                    this.searchNotComplanNum(), this.searchServerState(),
                    this.searchProcessState(), this.search61850Nuclear(),
                    this.searchPowerWarnNum(),
                ]).then(() => {
                    this.timer.open();
                }).catch(error => {
                    console.log(error);
                })
            }, 4000);
        },
        // 查询电池告警总数
        searchAlmNum() {
            this.$apis.top.searchAlmNum().then(res => {
                let rs = JSON.parse(res.data.result);
                this.numbers.battWarn = rs.sum;
            }).catch(error => {
                console.log(error);
            })
        },
        // 查询落后单体总数
        searchLowMonNum() {
            this.$apis.top.searchLowMonNum().then(res => {
                let rs = JSON.parse(res.data.result);
                this.numbers.lowMon = rs.sum;
            }).catch(error => {
                console.log(error);
            })
        },
        // 查询机房停电总数
        searchPowerOffNum() {
            this.$apis.top.searchPowerOffNum().then(res => {
                let rs = JSON.parse(res.data.result);
                this.numbers.powerOff = rs.sum;
            }).catch(error => {
                console.log(error);
            });
        },
        // 查询设备实时告警总数
        searchDevAlarmNum() {
            this.$apis.top.searchDevAlarmNum().then(res => {
                let rs = JSON.parse(res.data.result);
                this.numbers.devWarn = rs.sum;
            }).catch(error => {
                console.log(error);
            })
        },
        searchNotComplanNum() {
            this.$apis.top.searchNotComplanNum().then(res => {
                let rs = JSON.parse(res.data.result);
                if (this.processInfo.alarm == 2 || item.ServerFlag == 2) {
                  this.processInfo.alarm = 2;
                this.numbers.plan = rs.sum;
            }).catch(error => {
                console.log(error);
            })
        },
        // 查询正在核容测试的信息
        search61850Nuclear() {
            this.$apis.top.search61850Nuclear().then(res => {
                let rs = JSON.parse(res.data.result);
                if (rs.code == 1) {
                    let data = rs.data;
                    this.numbers.nuclear = data.length;
                } else {
                  this.processInfo.alarm = alarm_batt && alarm_batt;
                    this.numbers.nuclear = 0;
                }
                break;
                // 电池落后
              case 'BMS_FBSDEV_BADBATT':
                if (item.ProcessName == 'BMS_FBSDEV_BADBATT_MON') {
                  //落后单体线程
                  if (item.ServerFlag == 0) {
                    badmon = 0;
                  } else {
                    badmon = this.checkTimeOut2(item);
                  }
                } else if (item.ProcessName == 'BMS_FBSDEV_BADBATT_CAP') {
                  //容量告警线程
                  if (item.ServerFlag == 0) {
                    alarm_cap = 0;
                  } else {
                    alarm_cap = this.checkTimeOut2(item);
                  }
                }
                if (this.processInfo.behind == 2 || item.ServerFlag == 2) {
                  this.processInfo.behind = 2;
            }).catch(error => {
            });
        },
        // 查询电源告警个数
        searchPowerWarnNum() {
            this.$apis.top.searchPowerWarnNum().then(res => {
                let rs = JSON.parse(res.data.result);
                if (rs.code == 1) {
                    this.numbers.powerWarn = rs.data;
                } else {
                  this.processInfo.behind = badmon && alarm_cap;
                    this.numbers.powerWarn = 0;
                }
                break;
                // 放电计划线程
              case 'BMS_FBSDEV_PLAN':
                if (item.ProcessName == 'BMS_FBSDEV_PLAN') {
                  if (item.ServerFlag == 0) {
                    this.processInfo.displan = 0;
                  } else {
                    this.processInfo.displan = this.checkTimeOut2(item);
                  }
            }).catch(error => {
            });
        },
        // 查询服务器信息
        searchServerState() {
            this.$apis.top.searchServerState().then(res => {
                let rs = JSON.parse(res.data.result);
                if (rs.code == 1) {
                    let data = rs.data[0];
                    let totalDiscSpace = data.total_disc_space;
                    // 设置服务器磁盘信息
                    let disc_spance_percent = totalDiscSpace ? ((data.total_disc_space - data.free_disc_space) * 100 / totalDiscSpace).toFixed(0) : 0;
                    this.serverInfo.disk.progress = parseInt(disc_spance_percent);
                    this.serverInfo.disk.message = '服务器数据磁盘总量' + (data.total_disc_space / 1024).toFixed(1) +
                        'GB;剩余:' + (data.free_disc_space /
                            1024).toFixed(1) + 'GB';
                    // 设置服务器cpu信息
                    let cpu_percent = (data.total_mem * 100 / data.max_mem).toFixed(0);
                    this.serverInfo.cpu.progress = parseInt(cpu_percent);
                    this.serverInfo.cpu.message = 'TM:' + (data.total_mem / (1024 * 1024 * 1024)).toFixed(2) +
                        'GB/' + (data.max_mem /
                            (1024 * 1024 * 1024)).toFixed(2) + 'GB';
                    // 设置服务器内存的信息
                    let memory_percent = ((data.total_mem - data.free_men) * 100 / data.total_mem).toFixed(0);
                    this.serverInfo.memory.progress = parseInt(memory_percent);
                    this.serverInfo.memory.message = 'FM:' + ((data.total_mem - data.free_men) / (1024 * 1024))
                            .toFixed(0) + 'MB/' +
                        (data.total_mem / (1024 * 1024)).toFixed(0) + "MB";
                    // 设置服务器的连接数
                    let link_percent = (data.db_conn_count * 100 / data.db_conn_max).toFixed(0);
                    this.serverInfo.linkNum.progress = parseInt(link_percent);
                    this.serverInfo.linkNum.message = 'DBC:' + data.db_conn_count + '/' + data.db_conn_max;
                    // 更新服务器更新和连接状态
                    var nowtime = new Date((data.note).replace(/\-/g, "/"));
                    var sertime = new Date((data.server_datetime).replace(/\-/g, "/"));
                    var timelong = Math.abs(parseInt(sertime - nowtime));
                    if ((timelong / (1000 * 60)) > 2) {
                        this.processInfo.sql = 0;
                    } else {
                        this.processInfo.sql = 1;
                    }
                    this.processInfo.link = 1;
                } else {
                    this.processInfo.sql = 0;
                    this.processInfo.link = 0;
                }
                if (this.processInfo.displan == 2 || item.ServerFlag == 2) {
                  this.processInfo.displan = 2;
            }).catch(error => {
                console.log(error);
                this.processInfo.sql = 0;
                this.processInfo.link = 0;
            })
        },
        // 查询线程状态
        searchProcessState() {
            this.$apis.dataMager.threadMager.search().then(res => {
                let rs = JSON.parse(res.data.result);
                if (rs.code == 1) {
                    let alarm_batt = false; //电池告警
                    let alarm_dev = false; //设备告警
                    let alarm_cap = false; //容量告警
                    let badmon = false; //落后单体
                    //console.log(rs.data);
                    // 遍历并处理数据
                    rs.data.forEach(item => {
                        switch (item.ServerName) {
                            // 告警线程
                            case 'BMS_FBSDEV_ALARM':
                                if (item.ProcessName == 'BMS_FBSDEV_ALARM_BATT') {
                                    if (item.ServerFlag == 0) {
                                        alarm_batt = 0;
                                    } else {
                                        alarm_batt = this.checkTimeOut2(item);
                                    }
                                } else if (item.ProcessName == 'BMS_FBSDEV_ALARM_DEV') {
                                    if (item.ServerFlag == 0) {
                                        alarm_dev = 0;
                                    } else {
                                        alarm_dev = this.checkTimeOut2(item);
                                    }
                                }
                                if (this.processInfo.alarm == 2 || item.ServerFlag == 2) {
                                    this.processInfo.alarm = 2;
                                } else {
                                    this.processInfo.alarm = alarm_batt && alarm_batt;
                                }
                                break;
                            // 电池落后
                            case 'BMS_FBSDEV_BADBATT':
                                if (item.ProcessName == 'BMS_FBSDEV_BADBATT_MON') {
                                    //落后单体线程
                                    if (item.ServerFlag == 0) {
                                        badmon = 0;
                                    } else {
                                        badmon = this.checkTimeOut2(item);
                                    }
                                } else if (item.ProcessName == 'BMS_FBSDEV_BADBATT_CAP') {
                                    //容量告警线程
                                    if (item.ServerFlag == 0) {
                                        alarm_cap = 0;
                                    } else {
                                        alarm_cap = this.checkTimeOut2(item);
                                    }
                                }
                                if (this.processInfo.behind == 2 || item.ServerFlag == 2) {
                                    this.processInfo.behind = 2;
                                } else {
                                    this.processInfo.behind = badmon && alarm_cap;
                                }
                                break;
                            // 放电计划线程
                            case 'BMS_FBSDEV_PLAN':
                                if (item.ProcessName == 'BMS_FBSDEV_PLAN') {
                                    if (item.ServerFlag == 0) {
                                        this.processInfo.displan = 0;
                                    } else {
                                        this.processInfo.displan = this.checkTimeOut2(item);
                                    }
                                }
                                if (this.processInfo.displan == 2 || item.ServerFlag == 2) {
                                    this.processInfo.displan = 2;
                                }
                                break;
                            case 'BMS_FBSDEV_POWER_FAIL':
                                if (item.ProcessName == 'BMS_FBSDEV_POWER_FAIL') {
                                    if (item.ServerFlag == 0) {
                                        this.processInfo.power = 0;
                                    } else {
                                        this.processInfo.power = this.checkTimeOut2(item);
                                    }
                                }
                                if (this.processInfo.power == 2 || item.ServerFlag == 2) {
                                    this.processInfo.power = 2;
                                }
                                break;
                            // 线程监控线程
                            case 'BMS_FBSDEV_LISTEN':
                                if (item.ProcessName == 'BMS_FBSDEV_LISTEN') {
                                    if (item.ServerFlag == 0) {
                                        this.processInfo.control = 0;
                                    } else {
                                        this.processInfo.control = this.checkTimeOut2(item);
                                    }
                                }
                                if (this.processInfo.control == 2 || item.ServerFlag == 2) {
                                    this.processInfo.control = 2;
                                }
                                break;
                        }
                    });
                }
                break;
              case 'BMS_FBSDEV_POWER_FAIL':
                if (item.ProcessName == 'BMS_FBSDEV_POWER_FAIL') {
                  if (item.ServerFlag == 0) {
                    this.processInfo.power = 0;
                  } else {
                    this.processInfo.power = this.checkTimeOut2(item);
                  }
            }).catch(error => {
                console.log(error);
            });
        },
        checkTimeOut2(temp) {
            var flag = 0;
            if (temp != undefined) {
                let startTime = new Date(temp.ProcessTime);
                let endTime = new Date(temp.note);
                let totalms = (endTime.getTime() - startTime.getTime()) / 1000;
                if (totalms < temp.OutTime) {
                    flag = 1;
                }
                if (this.processInfo.power == 2 || item.ServerFlag == 2) {
                  this.processInfo.power = 2;
                }
                break;
                // 线程监控线程
              case 'BMS_FBSDEV_LISTEN':
                if (item.ProcessName == 'BMS_FBSDEV_LISTEN') {
                  if (item.ServerFlag == 0) {
                    this.processInfo.control = 0;
                  } else {
                    this.processInfo.control = this.checkTimeOut2(item);
                  }
                }
                if (this.processInfo.control == 2 || item.ServerFlag == 2) {
                  this.processInfo.control = 2;
                }
                break;
            }
          });
            return flag;
        },
        goPages(type) {
            let message = {
                cmd: 'syncPage',
                params: {}
            };
            switch (type) {
                case 'powerOff':
                    message.params = {
                        pageInfo: {
                            label: "机房停电查询",
                            name: "powercutMager",
                            src: "#/dataMager/powercut",
                            closable: true
                        }
                    };
                    break;
                case 'battWarn':
                    message.params = {
                        pageInfo: {
                            label: "电池告警实时查询",
                            name: "batteryrTimequery",
                            src: "#/batteryrTimequery",
                            closable: true
                        }
                    };
                    break;
                case 'devWarn':
                    message.params = {
                        pageInfo: {
                            label: "设备告警实时查询",
                            name: "deviceTimequery",
                            src: "#/deviceTimequery",
                            closable: true
                        }
                    };
                    break;
                case "nuclear":
                    message.params = {
                        pageInfo: {
                            label: "核容测试数据",
                            name: "btsStatusTest",
                            src: "#/dataMager/btsStatus?workStauts=2",
                            closable: true
                        }
                    };
                    break;
                case "powerWarn":
                    message.params = {
                        pageInfo: {
                            label: "电源实时告警",
                            name: "powerRealtimeInfo",
                            src: "#/powerRealtimeInfo",
                            closable: true
                        }
                    };
                    break;
                default:
                    message = false;
                    this.$layer.msg('该功能暂未开放!');
                    break;
            }
            if (message) {
                this.$emit('handle-message', message);
            }
        },
        changeSkin() {
            this.$nextTick(() => {
                this.showProgress = true;
                if (this.skinActive == 'science-black') {
                    this.options.progress.color = '#fb8d1a';
                    this.options.progress.backgroundColor = '#1ccfe5';
                } else {
                    this.options.progress.color = '#f06824';
                    this.options.progress.backgroundColor = '#FFE329';
                }
            })
        }
      }).catch(error => {
        console.log(error);
      });
    },
    checkTimeOut2(temp) {
      var flag = 0;
      if (temp != undefined) {
        let startTime = new Date(temp.ProcessTime);
        let endTime = new Date(temp.note);
        let totalms = (endTime.getTime() - startTime.getTime()) / 1000;
        if (totalms < temp.OutTime) {
          flag = 1;
    computed: {
        processAlarmMsg() {
            let result = '未知';
            switch (this.processInfo.alarm) {
                case 0:
                    result = '告警监测线程:异常';
                    break;
                case 1:
                    result = '告警监测线程:正常';
                    break;
                case 2:
                    result = '告警监测线程:未启用';
                    break;
            }
            return result;
        },
        processBehindMsg() {
            let result = '未知';
            switch (this.processInfo.behind) {
                case 0:
                    result = '落后单体监测线程:异常';
                    break;
                case 1:
                    result = '落后单体监测线程:正常';
                    break;
                case 2:
                    result = '落后单体监测线程:未启用';
                    break;
            }
            return result;
        },
        processDisplanMsg() {
            let result = '未知';
            switch (this.processInfo.displan) {
                case 0:
                    result = '放电计划监测线程:异常';
                    break;
                case 1:
                    result = '放电计划监测线程:正常';
                    break;
                case 2:
                    result = '放电计划监测线程:未启用';
                    break;
            }
            return result;
        },
        processPowerMsg() {
            let result = '未知';
            switch (this.processInfo.power) {
                case 0:
                    result = '机房停电监测线程:异常';
                    break;
                case 1:
                    result = '机房停电监测线程:正常';
                    break;
                case 2:
                    result = '机房停电监测线程:未启用';
                    break;
            }
            return result;
        },
        processControlMsg() {
            let result = '未知';
            switch (this.processInfo.control) {
                case 0:
                    result = '线程监控程序运行:异常';
                    break;
                case 1:
                    result = '线程监控程序运行:正常';
                    break;
                case 2:
                    result = '线程监控程序运行:未启用';
                    break;
            }
            return result;
        },
        processSqlMsg() {
            let result = '未知';
            switch (this.processInfo.sql) {
                case 0:
                    result = '服务器实时更新数据:异常';
                    break;
                case 1:
                    result = '服务器实时更新数据:正常';
                    break;
            }
            return result;
        },
        processLinkMsg() {
            let result = '未知';
            switch (this.processInfo.link) {
                case 0:
                    result = '服务器连接:异常';
                    break;
                case 1:
                    result = '服务器连接:正常';
                    break;
            }
            return result;
        },
        themeInfo() {
            return "当前主题:" + this.$store.state.theme.themeName;
        }
      }
      return flag;
    },
    goPages(type) {
      let message = {
        cmd: 'syncPage',
        params: {}
      };
      switch (type) {
        case 'powerOff':
          message.params = {
            pageInfo: {
              label: "机房停电查询",
              name: "powercutMager",
              src: "#/dataMager/powercut",
              closable: true
            }
          };
          break;
        case 'battWarn':
          message.params = {
            pageInfo: {
              label: "电池告警实时查询",
              name: "batteryrTimequery",
              src: "#/batteryrTimequery",
              closable: true
            }
          };
          break;
        case 'devWarn':
          message.params = {
            pageInfo: {
              label: "设备告警实时查询",
              name: "deviceTimequery",
              src: "#/deviceTimequery",
              closable: true
            }
          };
          break;
        case "nuclear":
          message.params = {
            pageInfo: {
              label: "核容测试数据",
              name: "btsStatusTest",
              src: "#/dataMager/btsStatus?workStauts=2",
              closable: true
            }
          };
          break;
        case "powerWarn":
          message.params = {
            pageInfo: {
              label: "电源实时告警",
              name: "powerRealtimeInfo",
              src: "#/powerRealtimeInfo",
              closable: true
            }
          };
          break;
        default:
          message = false;
          this.$layer.msg('该功能暂未开放!');
          break;
      }
      if (message) {
        this.$emit('handle-message', message);
      }
    created() {
        this.skinActive = localStorage.getItem('setSkinItem');
        window.addEventListener('setSkinItem', (e) => {
            this.showProgress = false;
            this.skinActive = e.newValue;
            this.changeSkin();
        });
        this.changeSkin();
    },
    changeSkin() {
      this.$nextTick(() => {
        this.showProgress = true;
        if (this.skinActive == 'science-black') {
          this.options.progress.color = '#fb8d1a';
          this.options.progress.backgroundColor = '#1ccfe5';
        } else {
          this.options.progress.color = '#f06824';
          this.options.progress.backgroundColor = '#FFE329';
        }
      })
    mounted() {
        // 启动请求
        this.startSearch();
    },
    destroyed() {
        this.timer.stop();
    }
  },
  computed: {
    processAlarmMsg() {
      let result = '未知';
      switch (this.processInfo.alarm) {
        case 0:
          result = '告警监测线程:异常';
          break;
        case 1:
          result = '告警监测线程:正常';
          break;
        case 2:
          result = '告警监测线程:未启用';
          break;
      }
      return result;
    },
    processBehindMsg() {
      let result = '未知';
      switch (this.processInfo.behind) {
        case 0:
          result = '落后单体监测线程:异常';
          break;
        case 1:
          result = '落后单体监测线程:正常';
          break;
        case 2:
          result = '落后单体监测线程:未启用';
          break;
      }
      return result;
    },
    processDisplanMsg() {
      let result = '未知';
      switch (this.processInfo.displan) {
        case 0:
          result = '放电计划监测线程:异常';
          break;
        case 1:
          result = '放电计划监测线程:正常';
          break;
        case 2:
          result = '放电计划监测线程:未启用';
          break;
      }
      return result;
    },
    processPowerMsg() {
      let result = '未知';
      switch (this.processInfo.power) {
        case 0:
          result = '机房停电监测线程:异常';
          break;
        case 1:
          result = '机房停电监测线程:正常';
          break;
        case 2:
          result = '机房停电监测线程:未启用';
          break;
      }
      return result;
    },
    processControlMsg() {
      let result = '未知';
      switch (this.processInfo.control) {
        case 0:
          result = '线程监控程序运行:异常';
          break;
        case 1:
          result = '线程监控程序运行:正常';
          break;
        case 2:
          result = '线程监控程序运行:未启用';
          break;
      }
      return result;
    },
    processSqlMsg() {
      let result = '未知';
      switch (this.processInfo.sql) {
        case 0:
          result = '服务器实时更新数据:异常';
          break;
        case 1:
          result = '服务器实时更新数据:正常';
          break;
      }
      return result;
    },
    processLinkMsg() {
      let result = '未知';
      switch (this.processInfo.link) {
        case 0:
          result = '服务器连接:异常';
          break;
        case 1:
          result = '服务器连接:正常';
          break;
      }
      return result;
    },
    themeInfo() {
      return "当前主题:" + this.$store.state.theme.themeName;
    }
  },
  created() {
    this.skinActive = localStorage.getItem('setSkinItem');
    window.addEventListener('setSkinItem', (e) => {
      this.showProgress = false;
      this.skinActive = e.newValue;
      this.changeSkin();
    });
    this.changeSkin();
  },
  mounted() {
    // 启动请求
    this.startSearch();
  },
  destroyed() {
    this.timer.stop();
  }
}
</script>
<style scoped>
.page-header-container {
  height: 70px;
    height: 70px;
}
.page-header-content {
  position: relative;
  height: 100%;
  overflow: hidden;
  padding-top: 5px;
  box-sizing: border-box;
    position: relative;
    height: 100%;
    overflow: hidden;
    padding-top: 5px;
    box-sizing: border-box;
}
.page-header-left {
  height: 100%;
  display: flex;
  align-items: center;
  padding-right: 130px;
    height: 100%;
    display: flex;
    align-items: center;
    padding-right: 130px;
}
.page-header-left img {
  height: 40px;
  vertical-align: middle;
    height: 40px;
    vertical-align: middle;
}
.page-header-left span {
  font-size: 33px;
  font-weight: bold;
  letter-spacing: 4px;
    font-size: 33px;
    font-weight: bold;
    letter-spacing: 4px;
}
.page-header-left span.sys-version {
  font-size: 24px;
  margin-left: 4px;
  font-weight: normal;
  padding-top: 8px;
    font-size: 24px;
    margin-left: 4px;
    font-weight: normal;
    padding-top: 8px;
}
.data-totals {
  padding-left: 18px;
    padding-left: 18px;
}
.data-totals-item {
  margin-right: 18px;
    margin-right: 18px;
}
.header-info-list {
  padding-left: 18px;
  display: flex;
  align-items: center;
    padding-left: 18px;
    display: flex;
    align-items: center;
}
.header-info-item {
  display: inline-block;
  min-width: 85Px;
  padding-top: 4px;
  padding-bottom: 2px;
    display: inline-block;
    min-width: 85Px;
    padding-top: 4px;
    padding-bottom: 2px;
}
.info-banner {
  display: inline-block;
  color: #FFFFFF;
  background-color: blue;
    display: inline-block;
    color: #FFFFFF;
    background-color: blue;
}
.info-banner-text {
  display: inline-block;
  padding-top: 8px;
  padding-bottom: 8px;
    display: inline-block;
    padding-top: 8px;
    padding-bottom: 8px;
}
.hdw-avatar {
  display: inline-block;
  margin-top: 10px;
  margin-right: 16px;
  cursor: pointer;
  color: #e4e3e3;
    display: inline-block;
    margin-top: 10px;
    margin-right: 16px;
    cursor: pointer;
    color: #e4e3e3;
}
.hdw-avatar:hover {
  color: #FFFFFF;
    color: #FFFFFF;
}
.hdw-avatar:hover .el-icon-arrow-down {
  transform: rotate(180deg);
    transform: rotate(180deg);
}
.hdw-avatar-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  justify-content: center;
  background-color: #4ba1fa;
  align-items: center;
  color: #032c8f;
    display: inline-flex;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    justify-content: center;
    background-color: #4ba1fa;
    align-items: center;
    color: #032c8f;
}
.hdw-avatar-icon .iconfont {
  font-size: 16px;
    font-size: 16px;
}
.hdw-avatar-text {
  color: #4ba1fa;
  margin-left: 8px;
    color: #4ba1fa;
    margin-left: 8px;
}
.hdw-avatar-text .el-icon-arrow-down {
  margin-left: 4px;
    margin-left: 4px;
}
.fuguang-logo {
  height: 45px;
  margin-left: 8px;
  vertical-align: middle;
    height: 45px;
    margin-left: 8px;
    vertical-align: middle;
}
.header-first-logo {
  margin-left: 20px;
    margin-left: 20px;
}
.header-carve-up {
  display: inline-block;
  height: 28px;
  width: 1px;
  background-color: #00FEFF;
  margin-left: 12px;
  margin-right: 12px;
    display: inline-block;
    height: 28px;
    width: 1px;
    background-color: #00FEFF;
    margin-left: 12px;
    margin-right: 12px;
}
.system-tools {
  position: absolute;
  top: 8px;
  right: 8px;
    position: absolute;
    top: 8px;
    right: 8px;
}
.tools-item {
  display: inline-block;
  padding: 8px;
  border-radius: 50%;
  background-color: #4ba1fa;
    display: inline-block;
    padding: 8px;
    border-radius: 50%;
    background-color: #4ba1fa;
}
.system-tools .iconfont {
  font-size: 20px;
  color: #041f6c;
    font-size: 20px;
    color: #041f6c;
}
</style>
src/pages/dataTest/movingRingSystem/chargerStatus.vue
@@ -8,7 +8,7 @@
import ContentBox from "@/components/ContentBox";
import ChargerStatusTabPane from "@/pages/dataMager/components/ChargerStatusTabPane";
import getChargerInfo from "@/pages/dataMager/js/getChargerInfo";
import {getWsUrl} from "@/assets/js/tools";
import {getWsUrl, Timeout} from "@/assets/js/tools";
import getIsolatingInfo from "@/pages/dataMager/js/getIsolatingInfo";
export default {
  name: "chargerStatus",
@@ -25,6 +25,7 @@
  },
  data() {
    return {
      timer: new Timeout(),
      isOpen: false,
      powerInfo: {
        powerDeviceId: 0,
@@ -59,52 +60,35 @@
            stationName5: "",
          };
        }
        // 初始化WebSocket
        this.close();
        this.initSocket();
        // 开启查询
        this.startSearch();
      }).catch(error => {
        console.log(error);
      });
    },
    initSocket() {
      // 未被初始化初始化
      if (!this.isOpen) {
        const wsUri = getWsUrl("", 55003);
        this.socket = new WebSocket(wsUri);
        this.socket.onmessage = this.onMessage;
        this.socket.onopen = this.onOpen;
        this.socket.onerror = this.onError;
        this.socket.onclose = this.close;
      }
    startSearch() {
      this.timer.start(()=>{
        this.$axios.all([this.searchData()]).then(()=>{
          this.timer.open();
        }).catch(error=>{
          this.timer.open();
        });
      },4000);
    },
    onMessage(res) {
      let rs = JSON.parse(res.data);
      if(rs.code == 1 && rs.data) {
        this.info = rs.data;
      }else {
        this.info = getChargerInfo()
      }
    },
    onOpen() {
      // 打印关闭信息
      console.log("启动充电机WebSocket");
      // 标识正在运行
      this.isOpen = true;
      console.log()
      // 向后台发送请求数据
      this.socket.send(this.powerInfo.powerDeviceId);
    },
    onError() {
    },
    close() {
      // 关闭websocket
      if (this.isOpen) {
        // 打印关闭信息
        console.log("关闭充电机WebSocket");
        this.isOpen = false;
        this.socket.close();
      }
    searchData() {
      this.$apis.dataMager.powerMager.getChargeDeviceData({
        powerDeviceId: this.powerInfo.powerDeviceId
      }).then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1 && rs.data) {
          this.info = rs.data;
        }else {
          this.info = getChargerInfo()
        }
      }).catch(error=>{
        this.info = getChargerInfo();
        console.log(error);
      })
    },
  },
  computed: {
@@ -127,7 +111,7 @@
    }
  },
  destroyed() {
    this.close();
    this.timer.stop();
  }
}
</script>
src/pages/dataTest/movingRingSystem/isolatingDevice.vue
@@ -7,7 +7,7 @@
<script>
import ContentBox from "@/components/ContentBox";
import IsolatingDeviceTabPane from "@/pages/dataMager/components/IsolatingDeviceTabPane";
import {getWsUrl} from "@/assets/js/tools";
import {getWsUrl, Timeout} from "@/assets/js/tools";
import getIsolatingInfo from "@/pages/dataMager/js/getIsolatingInfo";
export default {
@@ -26,6 +26,7 @@
  data() {
    return {
      isOpen: false,
      timer: new Timeout(),
      powerInfo: {
        powerDeviceId: 0,
        stationId: 0,
@@ -59,52 +60,35 @@
            stationName5: "",
          };
        }
        // 初始化WebSocket
        this.close();
        this.initSocket();
        // 启动查询
        this.startSearch();
      }).catch(error => {
        console.log(error);
      });
    },
    initSocket() {
      // 未被初始化初始化
      if (!this.isOpen) {
        const wsUri = getWsUrl("", 55002);
        this.socket = new WebSocket(wsUri);
        this.socket.onmessage = this.onMessage;
        this.socket.onopen = this.onOpen;
        this.socket.onerror = this.onError;
        this.socket.onclose = this.close;
      }
    startSearch() {
      this.timer.start(()=>{
        this.$axios.all([this.searchData()]).then(()=>{
          this.timer.open();
        }).catch(error=>{
          this.timer.open();
        });
      },4000);
    },
    onMessage(res) {
      let rs = JSON.parse(res.data);
      if(rs.code == 1 && rs.data) {
        this.info = rs.data;
      }else {
        this.info = getIsolatingInfo()
      }
    },
    onOpen() {
      // 打印关闭信息
      console.log("启动绝缘监控WebSocket");
      // 标识正在运行
      this.isOpen = true;
      console.log()
      // 向后台发送请求数据
      this.socket.send(this.powerInfo.powerDeviceId);
    },
    onError() {
    },
    close() {
      // 关闭websocket
      if (this.isOpen) {
        // 打印关闭信息
        console.log("关闭绝缘监控WebSocket");
        this.isOpen = false;
        this.socket.close();
      }
    searchData() {
      this.$apis.dataMager.powerMager.getIsolatingDeviceData({
        powerDeviceId: this.powerInfo.powerDeviceId
      }).then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1 && rs.data) {
          this.info = rs.data;
        }else {
          this.info = getIsolatingInfo();
        }
      }).catch(error=>{
        this.info = getIsolatingInfo();
        console.log(error);
      })
    },
  },
  computed: {
@@ -127,7 +111,7 @@
    }
  },
  destroyed() {
    this.close();
    this.timer.stop();
  }
}
</script>