whychdw
2024-10-18 200579341f22138ef47f4b998bf54b3aa8c6a3dd
内容提交
6个文件已修改
1个文件已添加
389 ■■■■■ 已修改文件
src/assets/js/config.module.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chart/LineChart.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/alarmMager/powerCabinetSetting.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/alarmMager/powerpaSetting.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dataTest/components/AiHistoryCharts.vue 229 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dataTest/history.vue 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dataTest/js/history.js 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/config.module.js
@@ -135,4 +135,9 @@
    des: "开启数据模拟,实时监控显示为浮充状态",
    value: false,
  },
  ai:{
    label: "AI生成预估数据",      // 需要在安装包同级目录存在分析AI分析工具
    des: "开启可以根据历史放电数据,预估10小时房贷你数据",
    value: true
  }
};
src/components/chart/LineChart.vue
@@ -50,7 +50,7 @@
    },
    showTools: {
      type: Boolean,
      default: true
      default: false
    }
  },
  data() {
@@ -319,4 +319,4 @@
  z-index: -1000;
  pointer-events: none
}
</style>
</style>
src/views/alarmMager/powerCabinetSetting.vue
@@ -315,7 +315,7 @@
              </el-form-item>
            </div>
          </div>
          <div class="table-row" v-if="form.alarmLimitEn != 0">
          <div class="table-row" v-if="form.alarmLimiten != 0">
            <div class="table-cell ar16 a22">
              <el-form-item :label="'告警上限系数值' + highText">
                <el-input v-model="form.alarmLimith"></el-input>
@@ -347,7 +347,7 @@
              </el-form-item>
            </div>
          </div>
          <div class="table-row" v-if="form.alarmLimitEn != 0">
          <div class="table-row" v-if="form.alarmLimiten != 0">
            <div class="table-cell ar16 a22">
              <el-form-item label="告警规则状态">
                <input
@@ -431,7 +431,7 @@
        alarmLimith: "",
        alarmLimitl: "",
        alarmLevel: "",
        alarmLimitEn: "",
        alarmLimiten: "",
        alarmDevtypeText: "",
        useralarmEn: 0,
      },
@@ -670,7 +670,7 @@
      let highId = this.highId;
      let lowId = this.lowId;
      if (this.form.alarmLimitEn) {
      if (this.form.alarmLimiten) {
        if (this.form.alarmLimith < this.form.alarmLimitl) {
          this.$message.error("告警上限系数值大于告警下限系数值!");
          return false;
@@ -732,7 +732,7 @@
          alarmLevel: this.form.alarmLevel,
          alarmLimith: this.form.alarmLimith,
          alarmLimitl: this.form.alarmLimitl,
          alarmLimitEn: this.form.alarmLimitEn,
          alarmLimiten: this.form.alarmLimiten,
          useralarmEn: this.form.useralarmEn ? 1 : 0,
          powerDeviceId: this.powerDeviceId,
        });
@@ -750,11 +750,12 @@
    handleClick(vals) {
      console.log("vals", vals);
      this.form = JSON.parse(JSON.stringify(vals));
      console.log(this.form);
      // this.form.alarmId = JSON.parse(JSON.stringify(vals.alarmId));
      // this.form.alarmLevel = JSON.parse(JSON.stringify(vals.alarmLevel));
      // this.form.alarmLimith = JSON.parse(JSON.stringify(vals.alarmLimith));
      // this.form.alarmLimitl = JSON.parse(JSON.stringify(vals.alarmLimitl));
      // this.form.alarmLimitEn = JSON.parse(JSON.stringify(vals.alarmLimitEn));
      // this.form.alarmLimiten = JSON.parse(JSON.stringify(vals.alarmLimiten));
      // this.form.alarmDevtypeText = JSON.parse(
      //   JSON.stringify(vals.alarmDevtypeText)
      // );
src/views/alarmMager/powerpaSetting.vue
@@ -256,6 +256,7 @@
                </el-form-item>
              </el-col>
              <el-col :span="layout.span">
                <div style="height: 4px"></div>
                <el-form-item label="告警上限使能">
                  <input v-model="form.alarmLimitHEN" type="checkbox" />
                </el-form-item>
@@ -298,6 +299,7 @@
                </el-form-item>
              </el-col>
              <el-col :span="layout.span">
                <div style="height: 4px;"></div>
                <el-form-item label="告警下限使能">
                  <input v-model="form.alarmLimitLEN" type="checkbox" />
                </el-form-item>
src/views/dataTest/components/AiHistoryCharts.vue
New file
@@ -0,0 +1,229 @@
<script>
import ChartWrapper from "@/components/ChartWrapper.vue";
import LineChart from "@/components/chart/LineChart.vue";
import {getAiHistoryAPI,createAiHistoryAPI} from "@/views/dataTest/js/history";
import const_digit from "@/assets/js/const/const_digit";
const {
  cap: CAP,
  vol: VOL,
  curr: CURR,
  res: RES,
  conduct: CONDUCT,
  temp: TEMP,
  hum: HUM,
} = const_digit;
export default {
  name: 'AiHistoryCharts',
  components: {LineChart, ChartWrapper},
  groupVolOption: {
    title: {
      show: true,
      text: "端电压折线图(V)",
      x: "left",
      textStyle: {
        fontSize: "14",
      },
    },
    grid: {
      top: '40px',
      left: '1%',
      right: '2.5%',
      bottom: '2%',
      containLabel: true
    },
    legend: {
      show: false,
      right: 0,
      orient: "vertical",
    },
    series: [
      {
        name: "端电压",
        data: [],
      },
    ],
  },
  monCapOption: {
    title: {
      show: true,
      text: "单体测试容量折线图(V)",
      x: "left",
      textStyle: {
        fontSize: "14",
      },
    },
    grid: {
      top: '40px',
      left: '1%',
      right: '5%',
      bottom: '2%',
      containLabel: true
    },
    legend: {
      show: false,
      right: 0,
      orient: "vertical",
    },
    series: [
      {
        name: "单体测试容量",
        data: [],
      },
    ],
  },
  monVolOption: {
    title: {
      show: true,
      text: "单体电压折线图(V)",
      x: "left",
      textStyle: {
        fontSize: "14",
      },
    },
    grid: {
      top: '40px',
      left: '1%',
      right: '2.5%',
      bottom: '2%',
      containLabel: true
    },
    legend: {
      show: false,
      right: 0,
      orient: "vertical",
    },
    series: [],
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    info: {
      type: Object,
      default() {
        return {
          battGroupId: 0,
          testRecordCount: 0
        }
      }
    }
  },
  data() {
    return {};
  },
  methods: {
    async getAIHistory() {
      let info = this.info;
      let loading = this.$layer.loading();
      try {
        let res = await getAiHistoryAPI(info.battGroupId, info.testRecordCount);
        this.$layer.close(loading);
        let rs = res.data;
        let groupVols = [];
        let monVols = [];
        if(rs.code === 1 && rs.data) {
          let data = rs.data2;
          data.map(item=>{
            if(item.groupVol !== 0 && !this.groupVolIsIn(item.recordTime, groupVols)) {
              groupVols.push([item.recordTime, item.groupVol.toHold(VOL)]);
            }
            // 为单体数据开辟空间
            if(!monVols[item.monNum-1]) {
              monVols[item.monNum-1] = {
                name: "#"+item.monNum,
                data: []
              };
            }
            monVols[item.monNum-1].data.push([item.recordTime, item.monVol.toHold(VOL)]);
          });
        }
        // 端电压
        this.$options.groupVolOption.series[0].data = groupVols;
        // 单体电压
        this.$options.monVolOption.series = monVols;
        this.setOption();
      }catch (e) {
        this.$layer.close(loading);
        console.log(e);
        this.$message.error("读取失败,请检查后台!!!");
        this.setOption();
      }
    },
    groupVolIsIn(time, list) {
      let isIn = false;
      for(let i=0; i<list.length; i++) {
        if(list[i][0] === time) {
          isIn = true;
        }
      }
      return isIn;
    },
    resize() {
      setTimeout(() => {
        this.$G.chartManage.resize("aiGroupVol");
        this.$G.chartManage.resize("aiMonCap");
        this.$G.chartManage.resize("aiMonCap");
      }, 5000);
    },
    setOption() {
      this.$refs.aiGroupVol.setOption(this.$options.groupVolOption);
      this.$refs.aiMonCap.setOption(this.$options.monCapOption);
      this.$refs.aiMonVol.setOption(this.$options.monVolOption);
      this.resize();
    },
    close() {
      this.$emit("update:visible", false);
    }
  },
  mounted() {
    this.getAIHistory();
  }
}
</script>
<template>
  <div class="ai-history-wrapper">
    <flex-layout>
      <div class="chart-layout left">
          <line-chart ref="aiGroupVol" id="aiGroupVol" unit="V"></line-chart>
      </div>
      <div class="chart-layout right" v-show="false">
        <line-chart ref="aiMonCap" id="aiMonCap" unit="AH"></line-chart>
      </div>
      <div class="chart-layout bottom">
        <line-chart ref="aiMonVol" id="aiMonVol" unit="V"></line-chart>
      </div>
    </flex-layout>
  </div>
</template>
<style scoped lang="less">
.ai-history-wrapper {
  width: 1366px;
  height: 768px;
  box-sizing: border-box;
  .chart-layout {
    padding: 4px;
    box-sizing: border-box;
    &.left {
      width: 100%;
      height: 50%;
      float: left;
    }
    &.right {
      width: 50%;
      height: 50%;
      float: right;
    }
    &.bottom {
      clear: both;
      width: 100%;
      height: 50%;
    }
  }
}
</style>
src/views/dataTest/history.vue
@@ -122,6 +122,19 @@
          ></i>
        </el-tooltip>
      </div>
      <div slot="box-tools" class="box-tools" v-if="isShowAi">
        <el-tooltip
          class="item"
          effect="dark"
          content="AI智能预估"
          placement="bottom">
          <div class="tooltip-content">
            <el-button type="success" size="mini" v-if="aiState === -1" @click="startCreateAIHistory">启动AI</el-button>
            <el-button type="success" size="mini" @click="getAIHistory" v-else-if="aiState >= 100">查看AI</el-button>
            <el-button type="primary" size="mini" disabled v-else>AI智能生成中...</el-button>
          </div>
        </el-tooltip>
      </div>
      <flex-layout :no-bg="true">
        <div class="content-header" slot="header">
          <div class="table-layout">
@@ -510,6 +523,16 @@
        :visible.sync="reportParamsDialog"
      ></report-params-setting>
    </el-dialog>
    <el-dialog
      title="AI智能预测"
      width="auto"
      :visible.sync="aiDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false">
      <ai-history-charts v-if="aiDialog" :visible.sync="aiDialog" :info="aiInfo"></ai-history-charts>
    </el-dialog>
  </flex-layout>
</template>
@@ -532,7 +555,7 @@
  getTestParam,
  exportReport,
  clearDirtyDataAPI,
  recoveryDirtyDataAPI,
  recoveryDirtyDataAPI, getAiHistoryAPI, createAiHistoryAPI,
} from "./js/history";
import { searchParam as searchParam1 } from "@/views/pageSetting/js/api";
@@ -560,6 +583,9 @@
import "echarts/lib/component/legend";
//区域缩放
import "echarts/lib/component/dataZoom";
import createWs from "@/assets/js/websocket";
const WSMixin = createWs("analysis");
//markeline
import "echarts/lib/component/markLine";
@@ -608,6 +634,8 @@
import interceptDataByTime from "@/assets/js/tools/interceptDataByTime";
import getExportExcelUrl from "@/assets/js/tools/getExportExcelUrl";
import getXuHang from "@/assets/js/tools/getXuHang";
import AiHistoryCharts from "@/views/dataTest/components/AiHistoryCharts.vue";
import config from "@/assets/js/config";
const {
  cap: CAP,
  vol: VOL,
@@ -623,7 +651,9 @@
let allGraph;
export default {
  name: "history",
  mixins: [WSMixin],
  components: {
    AiHistoryCharts,
    ReportParamsSetting,
    DataDiffter,
    ContentBox,
@@ -639,6 +669,9 @@
    let baseURL = this.$axios.defaults.baseURL;
    baseURL = baseURL ? baseURL : "";
    return {
      isShowAi: config.ai.value,
      aiState: -1,
      aiDialog: false,
      reportParamsDialog: false,
      cutTime: 2,
      dischargeDialogShow: false,
@@ -836,9 +869,72 @@
        title: "单体电压(V)",
        unit: "V",
      },
      aiInfo: {
        battGroupId: 0,
        testRecordCount: 0
      }
    };
  },
  methods: {
    sendMessage(battGroupId, testRecordCount) {
      this.aiState = -1;
      let params = {
        battGroupId,
        testRecordCount
      };
      this.SOCKET.send(JSON.stringify(params));
    },
    onWSMessage(res) {
      let batt = this.batt;
      console.log(batt);
      res = JSON.parse(res.data);
      console.log(res);
      if(res.code === 1 && res.data) {
        if(this.aiState === -1 && res.data2 !== -1 && res.data2 !== batt.monCount) {
          this.loading = false;
          this.$message.success("数据解析中");
        }
        if(res.data2 !== -1) {
          this.aiState = (res.data2/batt.monCount*100).toHold(0);
        }else {
          this.aiState = res.data2;
        }
      }else {
        this.aiState = -1;
      }
    },
    async startCreateAIHistory() {
      let testRecord = this.getTestRecord();
      if(testRecord !== -1) {
        this.aiInfo = {
          battGroupId: testRecord.battGroupId,
          testRecordCount: testRecord.testRecordCount
        };
        try {
          this.loading = true;
          await createAiHistoryAPI(this.aiInfo.battGroupId, this.aiInfo.testRecordCount);
        }catch (e) {
          // this.$layer.close(loading);
          console.log(e);
          this.$message.error("AI数据生成失败,请检查后台!!!");
        }
      }else {
        this.$message.warning("请选择一组放电数据");
      }
    },
    getAIHistory() {
      let testRecord = this.getTestRecord();
      if(testRecord !== -1) {
        this.aiInfo = {
          battGroupId: testRecord.battGroupId,
          testRecordCount: testRecord.testRecordCount
        };
        this.aiDialog = true;
      }else {
        this.$message.warning("请选择一组放电数据");
      }
    },
    changeShow() {
      // 端信息
      allData = {
@@ -1477,6 +1573,8 @@
          num,
          cutFlag
        );
        // 查询当前AI数据解析进度
        this.sendMessage(testRecord.battGroupId, testRecord.testRecordCount);
      }
    },
    // 查询历史信息
src/views/dataTest/js/history.js
@@ -302,3 +302,39 @@
    },
  });
};
/**
 * 生成预估放电数据
 * @param battGroupId
 * @param testRecordCount
 * @returns {AxiosPromise}
 */
export const createAiHistoryAPI = (battGroupId, testRecordCount)=>{
  return axios({
    method: "GET",
    url: "anaysis/createAnaysisXls",
    params: {
      battGroupId,
      testRecordCount,
    },
  });
}
/**
 * 获取智能分析数据
 * @param battGroupId
 * @param testRecordCount
 * @returns {AxiosPromise}
 */
export const getAiHistoryAPI = (battGroupId, testRecordCount)=>{
  return axios({
    method: "GET",
    url: "anaysis/getAnaysisXls",
    params: {
      battGroupId,
      testRecordCount,
    },
  });
}