From 331bbbc6604426763876ef55403b6f60cc22bf04 Mon Sep 17 00:00:00 2001
From: Jay <csj123456>
Date: 星期三, 19 二月 2025 14:08:19 +0800
Subject: [PATCH] 新增指标查询历史值功能

---
 src/views/model/pre/analysis/index.vue |  203 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 141 insertions(+), 62 deletions(-)

diff --git a/src/views/model/pre/analysis/index.vue b/src/views/model/pre/analysis/index.vue
index c7bddd8..dea20fd 100644
--- a/src/views/model/pre/analysis/index.vue
+++ b/src/views/model/pre/analysis/index.vue
@@ -166,7 +166,7 @@
               </el-form>
               <el-form :inline="true" :model="formData" label-width="100px">
                 <el-row>
-                  <el-col :span="12">
+                  <el-col :span="16">
                     <el-form-item label="数据类型">
                       <el-checkbox-group v-model="formData.chartCheck" @change="changeChartCheck">
                         <el-checkbox v-for="item in formData.chartOptions" :label="item"
@@ -225,7 +225,7 @@
   currentStamp60: '',
   predictStamp: '',
   chartCheck: ['T+L', '真实值'],
-  chartOptions: ['T+N', 'T+L', '当时', '真实值', '调整值'],
+  chartOptions: ['T+N', 'T+L', '当时', '真实值', '调整值', '预测累计', '真实累计'],
   checkedItemData: [],
   backItem: '',
   backValue: 0,
@@ -240,8 +240,8 @@
 const calRateFormRef = ref()
 const calRateForm = ref({
   calItem: undefined,
-  IN_DEVIATION: 0,
-  OUT_DEVIATION: 0,
+  IN_DEVIATION: 10,
+  OUT_DEVIATION: 50,
   IN_ACCURACY_RATE: 0,
   OUT_ACCURACY_RATE: 0,
   itemAvg: 0,
@@ -297,6 +297,22 @@
     formData.value.endTime = data.endTime
 
     let xAxisData = data.categories;
+    let defaultYAxis = [
+      {
+        type: 'value',
+        name: "累计值",
+        splitLine: {show: false},
+        axisLine: {show: true},
+        position: 'right'
+      },
+      {
+        type: 'value',
+        name: "",
+        splitLine: {show: false},
+        axisLine: {show: true},
+        position: 'left'
+      }
+    ];
     let yAxisData = [];
     let offset = 0;
     let yAxisIndex = 0;
@@ -327,12 +343,27 @@
       },
     });
     itemDataObject.value = {}
+    yAxisData.push({
+      type: 'value',
+      name: "累计值",
+      position: 'right',
+      splitLine: {
+        show: false
+      },
+      axisLine: {
+        show: true,
+        lineStyle: {}
+      },
+      axisLabel: {
+        formatter: '{value}'
+      }
+    })
     for (let i = 0; i < data.dataViewList.length; i++) {
       let dataView = data.dataViewList[i]
       itemDataObject.value[dataView.outId] = dataView;
       let maxValue = dataView.maxValue;
       let minValue = dataView.minValue;
-      yAxisIndex = formData.value.isMultipleY ? i : 0;
+      yAxisIndex = (formData.value.isMultipleY ? i : 0) + 1;
       let yMax = maxValue;
       if (maxValue < 0) {
         maxValue = 1;
@@ -451,6 +482,50 @@
           }
         });
       }
+
+      if (chartCheckArray.indexOf('预测累计') !== -1) {
+        let legendName = dataView.resultName + '(预测累计)';
+        legendData.push(legendName);
+        let seriesLeiJiData = []
+        if (dataView.cumulantPreData) {
+          seriesLeiJiData = dataView.cumulantPreData
+        }
+        seriesData.push({
+          name: legendName,
+          data: seriesLeiJiData,
+          type: 'line',
+          yAxisIndex: 0,
+          showSymbol: false,
+          connectNulls: true,
+          smooth: false,
+          lineStyle: {
+            width: 2,
+            type: 'dashed'
+          }
+        });
+      }
+
+      if (chartCheckArray.indexOf('真实累计') !== -1) {
+        let legendName = dataView.resultName + '(真实累计)';
+        legendData.push(legendName);
+        let seriesLeiJiData = []
+        if (dataView.cumulantRealData) {
+          seriesLeiJiData = dataView.cumulantRealData
+        }
+        seriesData.push({
+          name: legendName,
+          data: seriesLeiJiData,
+          type: 'line',
+          yAxisIndex: 0,
+          showSymbol: false,
+          connectNulls: true,
+          smooth: false,
+          lineStyle: {
+            width: 2,
+            type: 'dashed'
+          }
+        });
+      }
     }
     //如果最大值相差不大,改成一致大小
     if (yMaxArr.length > 1) {
@@ -462,6 +537,7 @@
         }
       }
     }
+
     myChart = echarts.init(dataAnalysisChart.value);
     let option = {
       title: {
@@ -487,11 +563,7 @@
         boundaryGap: false,
         data: xAxisData
       },
-      yAxis: formData.value.isMultipleY ? yAxisData : {
-        type: 'value',
-        splitLine: {show: false},
-        axisLine: {show: true}
-      },
+      yAxis: formData.value.isMultipleY ? yAxisData : defaultYAxis,
       dataZoom: [
         {
           type: 'inside',
@@ -512,6 +584,8 @@
   } finally {
     loading1.value = false
   }
+
+  calItemBaseVale()
 }
 
 onMounted(() => {
@@ -600,7 +674,13 @@
 function onCheckTree(data, checked, indeterminate) {
   formData.value.checkedItemData = [];
   if (checked.checkedNodes) {
-    formData.value.checkedItemData = [...checked.checkedNodes]
+    let cns = [...checked.checkedNodes]
+    for (let i = 0; i < cns.length; i++) {
+      if (cns[i].id.indexOf('-') !== -1) {
+        continue
+      }
+      formData.value.checkedItemData.push(cns[i])
+    }
   }
   debounce(getList, 1000);
 }
@@ -637,60 +717,59 @@
     calRateForm.value.itemAvg = dataView.hisAvg;
     calRateForm.value.realCumulant = dataView.hisCumulant;
   }
+  calAccuracyRate()
 }
 
 function calAccuracyRate() {
-  this.$refs['calRateForm'].validate((valid) => {
-    if (!valid) {
-      return false
-    }
-    let dataView = itemDataObject[calRateForm.value.calItem]
-    let seriesReaData = dataView.realData;
-    let seriesPreData = dataView.preDataL;
-    if (seriesReaData == null || seriesPreData == null ||
-      seriesReaData.length === 0 || seriesPreData.length === 0) {
-      loading2.value = false;
-      return;
-    }
-    let predictValueMap = {};
-    seriesPreData.forEach(function (item) {
-      predictValueMap[item[0]] = item[1];
-    })
-    let pointValueMap = {};
-    seriesReaData.forEach(function (item) {
-      pointValueMap[item[0]] = item[1];
-    })
-    let inDeviation = Number(calRateForm.value.IN_DEVIATION);
-    let outDeviation = Number(calRateForm.value.OUT_DEVIATION);
-    if (inDeviation === 0 && outDeviation === 0) {
-      loading2.value = false;
-      return;
-    }
-    let inDeviationCount = 0;
-    let outDeviationCount = 0;
-    let totalCount = 0;
-    for (let key in predictValueMap) {
-      let predictValue = predictValueMap[key];
-      let pointValue = pointValueMap[key];
-      if (pointValue == null || "" === pointValue || predictValue == null || "" === predictValue) {
-        continue;
-      }
-      let deviationAbs = (predictValue - pointValue) >= 0 ? (predictValue - pointValue) : (predictValue - pointValue) * -1;
-      if (deviationAbs < inDeviation) {
-        inDeviationCount = inDeviationCount + 1;
-      }
-      if (deviationAbs > outDeviation) {
-        outDeviationCount = outDeviationCount + 1;
-      }
-      totalCount = totalCount + 1;
-    }
+  const valid = calRateFormRef.value.validate()
+  if (!valid) return
 
-    let rateIn = (inDeviationCount / totalCount * 100).toFixed(2);
-    let rateOut = (outDeviationCount / totalCount * 100).toFixed(2);
-    calRateForm.value.IN_ACCURACY_RATE = Number(rateIn);
-    calRateForm.value.OUT_ACCURACY_RATE = Number(rateOut);
+  let dataView = itemDataObject.value[calRateForm.value.calItem]
+  let seriesReaData = dataView.realData;
+  let seriesPreData = dataView.preDataL;
+  if (seriesReaData == null || seriesPreData == null ||
+    seriesReaData.length === 0 || seriesPreData.length === 0) {
     loading2.value = false;
+    return;
+  }
+  let predictValueMap = {};
+  seriesPreData.forEach(function (item) {
+    predictValueMap[item[0]] = item[1];
   })
+  let pointValueMap = {};
+  seriesReaData.forEach(function (item) {
+    pointValueMap[item[0]] = item[1];
+  })
+  let inDeviation = Number(calRateForm.value.IN_DEVIATION);
+  let outDeviation = Number(calRateForm.value.OUT_DEVIATION);
+  if (inDeviation === 0 && outDeviation === 0) {
+    loading2.value = false;
+    return;
+  }
+  let inDeviationCount = 0;
+  let outDeviationCount = 0;
+  let totalCount = 0;
+  for (let key in predictValueMap) {
+    let predictValue = predictValueMap[key];
+    let pointValue = pointValueMap[key];
+    if (pointValue == null || "" === pointValue || predictValue == null || "" === predictValue) {
+      continue;
+    }
+    let deviationAbs = (predictValue - pointValue) >= 0 ? (predictValue - pointValue) : (predictValue - pointValue) * -1;
+    if (deviationAbs < inDeviation) {
+      inDeviationCount = inDeviationCount + 1;
+    }
+    if (deviationAbs > outDeviation) {
+      outDeviationCount = outDeviationCount + 1;
+    }
+    totalCount = totalCount + 1;
+  }
+
+  let rateIn = (inDeviationCount / totalCount * 100).toFixed(2);
+  let rateOut = (outDeviationCount / totalCount * 100).toFixed(2);
+  calRateForm.value.IN_ACCURACY_RATE = Number(rateIn);
+  calRateForm.value.OUT_ACCURACY_RATE = Number(rateOut);
+  loading2.value = false;
 }
 
 function rightSearchDataByRange() {
@@ -730,7 +809,7 @@
     currentStamp60: '',
     predictStamp: '',
     chartCheck: ['T+L', '真实值'],
-    chartOptions: ['T+N', 'T+L', '当时', '真实值', '调整值'],
+    chartOptions: ['T+N', 'T+L', '当时', '真实值', '调整值', '预测累计', '真实累计'],
     checkedItemData: [],
     backItem: '',
     backValue: 0,
@@ -744,8 +823,8 @@
   }
   calRateForm.value = {
     calItem: undefined,
-    IN_DEVIATION: 0,
-    OUT_DEVIATION: 0,
+    IN_DEVIATION: 10,
+    OUT_DEVIATION: 50,
     IN_ACCURACY_RATE: 0,
     OUT_ACCURACY_RATE: 0,
     itemAvg: 0,

--
Gitblit v1.9.3