whychdw
2021-11-11 b4e678bd6e621843b2f3f30eadd8e412765952db
内容提交
3个文件已修改
233 ■■■■■ 已修改文件
src/assets/js/apis/top/index.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PageHeader.vue 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/home.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/apis/top/index.js
@@ -2,6 +2,17 @@
export default {
    /**
     * 查询头部信息
     * 无参
     */
    searchHomePage() {
        return axios({
            method: 'post',
            url: 'HomePageAction!getDataMap',
            data: null
        });
    },
    /**
     * 查询落后单体总数
     * 无参
     */
src/components/PageHeader.vue
@@ -444,16 +444,17 @@
      this.timer.start(() => {
        this.$axios
          .all([
            this.searchAlmNum(),
            this.searchLowMonNum(),
            this.searchPowerOffNum(),
            this.searchDevAlarmNum(),
            this.searchNotComplanNum(),
            this.searchServerState(),
            this.searchProcessState(),
            this.search61850Nuclear(),
            this.searchPowerWarnNum(),
            this.getSeriousAlarmCount(),
              this.searchHomePage(),
            // this.searchAlmNum(),
            // this.searchLowMonNum(),
            // this.searchPowerOffNum(),
            // this.searchDevAlarmNum(),
            // this.searchNotComplanNum(),
            // this.searchServerState(),
            // this.searchProcessState(),
            // this.search61850Nuclear(),
            // this.searchPowerWarnNum(),
            // this.getSeriousAlarmCount(),
          ])
          .then(() => {
            this.timer.open();
@@ -463,6 +464,203 @@
          });
      }, 4*1000);
    },
    // 查询头部信息
    searchHomePage() {
      this.$apis.top.searchHomePage().then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1) {
          let data = rs.data;
          this.setServerData(data["服务器信息"][0]);
          this.setLabelNumber(data);
          this.setProcessState(data["线程状态"]);
        }else {
          this.setServerData();
          this.setLabelNumber();
        }
      }).catch(error=>{
      });
    },
    /**
     * 设置服务器信息
     * @param data 服务器信息
     */
    setServerData(data) {
      if(data) {
        let totalDiscSpace = data.total_disc_space;
        // 设置服务器磁盘信息
        this.serverInfo.disk.progress = data.diskRate;
        this.serverInfo.disk.message =
            "服务器数据磁盘总量" +
            (data.total_disc_space - data.free_disc_space) +
            "G/" +
            data.total_disc_space +
            "G";
        // 设置服务器cpu信息
        this.serverInfo.cpu.progress = data.server_cpu_rate;
        this.serverInfo.cpu.message =
            "CPU使用率:" + data.server_cpu_rate + "/100";
        // 设置服务器内存的信息
        this.serverInfo.memory.progress = data.memRate;
        this.serverInfo.memory.message =
            "服务器内存:" +
            (data.total_mem - data.free_men).toHold(2) +
            "G/" +
            data.total_mem +
            "G";
        // 设置服务器的连接数
        this.serverInfo.linkNum.progress = data.connRate;
        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;
      }
    },
    /**
     * 设置label的值
     * @param data 头部数据信息
     */
    setLabelNumber(data) {
      if(data) {
        this.numbers.plan = data["未放电的计划总数"];
        this.numbers.powerOff = data["机房停电总数-断电实时数"];
        this.numbers.nuclear = data["正在核容测试的信息"].length;
        this.numbers.battWarn = data["电池告警数"];
        this.numbers.powerWarn = data["电源告警个数"];
        this.numbers.levelNum = data["电源紧急告警个数"];
        this.numbers.lowMon = data["落后单体数量"];
        this.numbers.devWarn = data["设备告警数"];
      }else {
        this.numbers.plan = 0;
        this.numbers.powerOff = 0;
        this.numbers.nuclear = 0;
        this.numbers.battWarn = 0;
        this.numbers.powerWarn = 0;
        this.numbers.levelNum = 0;
        this.numbers.lowMon = 0;
        this.numbers.devWarn = 0;
      }
    },
    /**
     * 设置线程状态
     * @param data 线程状态数据
     */
    setProcessState(data) {
      if (data) {
        let alarm_batt = false; //电池告警
        let alarm_dev = false; //设备告警
        let alarm_cap = false; //容量告警
        let badmon = false; //落后单体
        //console.log(rs.data);
        // 遍历并处理数据
        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;
          }
        });
      }
    },
    // 查询电池告警总数
    searchAlmNum() {
      this.$apis.top
src/pages/home.vue
@@ -224,14 +224,14 @@
            clearTimeout(timer);
            timer = setTimeout(() => {
              this.checkUserLogin();
            }, 3000);
            }, 5000);
          }
        })
        .catch((error) => {
          clearTimeout(timer);
          timer = setTimeout(() => {
            this.checkUserLogin();
          }, 3000);
          }, 5000);
        });
    },
  },