Ver código fonte

质量月报 - 裂解炉进料原料质量近一年油品变化曲线最大值、最小值、平均值

wangggziwen 1 ano atrás
pai
commit
4628e68a84

+ 84 - 6
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS0501Controller.java

@@ -1,10 +1,11 @@
 package com.ruoyi.project.production.controller;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+import java.util.*;
 
+import com.ruoyi.project.production.controller.vo.QualityAnalysisVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -22,7 +23,6 @@ import com.ruoyi.project.production.service.ITMonthlyQualityReportS0501Service;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.web.page.TableDataInfo;
 
 /**
  * 质量月报S0501Controller
@@ -50,6 +50,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
         int endYear = endDate.getYear() + 1900;
         int startMonth = startDate.getMonth() + 1;
         int endMonth = endDate.getMonth() + 1;
+        // 趋势图数据
         Map<String, TMonthlyQualityReportS0501> dataMap = new HashMap<>();
         do {
             TMonthlyQualityReportS0501 reportS0501 = new TMonthlyQualityReportS0501();
@@ -66,7 +67,84 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
                 startMonth++;
             }
         } while (startYear != endYear || startMonth != endMonth + 1);
-        return AjaxResult.success(dataMap);
+        // 获取map第一个元素
+        List<String> keys = new ArrayList<>(dataMap.keySet());
+        String firstKey = keys.get(0);
+        TMonthlyQualityReportS0501 firstValue = dataMap.get(firstKey);
+        // 最大值
+        BigDecimal pMax = new BigDecimal(firstValue.getP());
+        BigDecimal iMax = new BigDecimal(firstValue.getI());
+        BigDecimal oMax = new BigDecimal(firstValue.getO());
+        BigDecimal nMax = new BigDecimal(firstValue.getN());
+        BigDecimal fiftyMax = new BigDecimal(firstValue.getFifty());
+        // 最小值
+        BigDecimal pMin = new BigDecimal(firstValue.getP());
+        BigDecimal iMin = new BigDecimal(firstValue.getI());
+        BigDecimal oMin = new BigDecimal(firstValue.getO());
+        BigDecimal nMin = new BigDecimal(firstValue.getN());
+        BigDecimal fiftyMin = new BigDecimal(firstValue.getFifty());
+        // 平均值
+        BigDecimal pAvg = new BigDecimal(BigInteger.ZERO);
+        BigDecimal iAvg = new BigDecimal(BigInteger.ZERO);
+        BigDecimal oAvg = new BigDecimal(BigInteger.ZERO);
+        BigDecimal nAvg = new BigDecimal(BigInteger.ZERO);
+        BigDecimal fiftyAvg = new BigDecimal(BigInteger.ZERO);
+        // 总和
+        BigDecimal pSum = new BigDecimal(BigInteger.ZERO);
+        BigDecimal iSum = new BigDecimal(BigInteger.ZERO);
+        BigDecimal oSum = new BigDecimal(BigInteger.ZERO);
+        BigDecimal nSum = new BigDecimal(BigInteger.ZERO);
+        BigDecimal fiftySum = new BigDecimal(BigInteger.ZERO);
+        for(Map.Entry entry : dataMap.entrySet()) {
+            String mapKey = (String) entry.getKey();
+            TMonthlyQualityReportS0501 mapValue = (TMonthlyQualityReportS0501) entry.getValue();
+            BigDecimal p = new BigDecimal(mapValue.getP());
+            BigDecimal i = new BigDecimal(mapValue.getI());
+            BigDecimal o = new BigDecimal(mapValue.getO());
+            BigDecimal n = new BigDecimal(mapValue.getN());
+            BigDecimal fifty = new BigDecimal(mapValue.getFifty());
+            if (p.compareTo(pMax) > 0) { pMax = p; }
+            if (i.compareTo(iMax) > 0) { iMax = i; }
+            if (o.compareTo(oMax) > 0) { oMax = o; }
+            if (n.compareTo(nMax) > 0) { nMax = n; }
+            if (fifty.compareTo(fiftyMax) > 0) { fiftyMax = fifty; }
+            if (p.compareTo(pMin) < 0) { pMin = p; }
+            if (i.compareTo(iMin) < 0) { iMin = i; }
+            if (o.compareTo(oMin) < 0) { oMin = o; }
+            if (n.compareTo(nMin) < 0) { nMin = n; }
+            if (fifty.compareTo(fiftyMin) < 0) { fiftyMin = fifty; }
+            pSum = pSum.add(p);
+            iSum = iSum.add(i);
+            oSum = oSum.add(o);
+            nSum = nSum.add(n);
+            fiftySum = fiftySum.add(fifty);
+        }
+        BigDecimal count = new BigDecimal(dataMap.size());
+        pAvg = pSum.divide(count, 2, RoundingMode.HALF_UP);
+        iAvg = iSum.divide(count, 2, RoundingMode.HALF_UP);
+        oAvg = oSum.divide(count, 2, RoundingMode.HALF_UP);
+        nAvg = nSum.divide(count, 2, RoundingMode.HALF_UP);
+        fiftyAvg = fiftySum.divide(count, 2, RoundingMode.HALF_UP);
+        StringBuffer description = new StringBuffer();
+        description.append("正构烷烃(max)="+ pMax.toString() + "\t");
+        description.append("异构烷烃(max)="+ iMax.toString() + "\t");
+        description.append("芳烃(max)="+ oMax.toString() + "\t");
+        description.append("烷烃(max)="+ nMax.toString() + "\t");
+        description.append("50%BP(max)="+ fiftyMax.toString() + "\t\n");
+        description.append("正构烷烃(min)="+ pMin.toString() + "\t");
+        description.append("异构烷烃(min)="+ iMin.toString() + "\t");
+        description.append("芳烃(min)="+ oMin.toString() + "\t");
+        description.append("烷烃(min)="+ nMin.toString() + "\t");
+        description.append("50%BP(min)="+ fiftyMin.toString() + "\t\n");
+        description.append("正构烷烃(avg)="+ pAvg.toString() + "\t");
+        description.append("异构烷烃(avg)="+ iAvg.toString() + "\t");
+        description.append("芳烃(avg)="+ oAvg.toString() + "\t");
+        description.append("烷烃(avg)="+ nAvg.toString() + "\t");
+        description.append("50%BP(avg)="+ fiftyAvg.toString() + "\t");
+        QualityAnalysisVO vo = new QualityAnalysisVO();
+        vo.setDataMap(dataMap);
+        vo.setDescription(description.toString());
+        return AjaxResult.success(vo);
     }
 
     /**

+ 35 - 0
master/src/main/java/com/ruoyi/project/production/controller/vo/QualityAnalysisVO.java

@@ -0,0 +1,35 @@
+package com.ruoyi.project.production.controller.vo;
+
+import com.ruoyi.project.production.domain.TMonthlyQualityReportS0501;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * 裂解炉进料原料质量近一年油品变化曲线VO
+ *
+ * @author Wang Zi Wen
+ * @email wangggziwen@163.com
+ * @date 2023/12/06 10:13:08
+ */
+public class QualityAnalysisVO {
+    private Map<String, TMonthlyQualityReportS0501> dataMap;
+
+    private String description;
+
+    public Map<String, TMonthlyQualityReportS0501> getDataMap() {
+        return dataMap;
+    }
+
+    public void setDataMap(Map<String, TMonthlyQualityReportS0501> dataMap) {
+        this.dataMap = dataMap;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 7 - 4
ui/src/views/production/quality/index.vue

@@ -2223,6 +2223,7 @@
         </el-form-item>
       </el-form>
       <div id="chart" :style="{width:width,height:height}"></div>
+      <div style="white-space: pre-wrap; margin: 10px auto; text-align: center;">{{analysisDescription}}</div>
       <table id="tableC2" v-if="showC2Table">
         <tr>
           <td colspan="5" class="td-transparent">BYC performance of C2 reactor</td>
@@ -2410,6 +2411,7 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      analysisDescription: null,
       c3ReactorTableData: {},
       c2ReactorTableData: {},
       showC3Table: false,
@@ -3466,10 +3468,11 @@ export default {
         case "1":
           this.disposeChart();
           listS0501Month(this.analysisQueryParams).then(response => {
-            let data = response.data;
+            let data = response.data.dataMap;
+            this.analysisDescription = response.data.description;
             let pArray = [];
             let iArray = [];
-            let aArray = [];
+            let oArray = [];
             let nArray = [];
             let fiftyArray = [];
             let sampleDateArray = [];
@@ -3477,7 +3480,7 @@ export default {
               sampleDateArray.push(key);
               pArray.push(data[key].p);
               iArray.push(data[key].i);
-              aArray.push(data[key].a);
+              oArray.push(data[key].o);
               nArray.push(data[key].n);
               fiftyArray.push(data[key].fifty);
             }
@@ -3535,7 +3538,7 @@ export default {
                 {
                   name: '芳烃',
                   type: 'line',
-                  data: aArray
+                  data: oArray
                 },
                 {
                   name: '烷烃',

+ 4 - 4
ui/src/views/production/quality/report.vue

@@ -225,10 +225,10 @@ export default {
       this.analysisQueryParams.endDate = this.sampleDate[1];
       // 裂解炉进料原料质量近一年油品变化曲线
       listS0501Month(this.analysisQueryParams).then(response => {
-        let data = response.data;
+        let data = response.data.dataMap;
         let pArray = [];
         let iArray = [];
-        let aArray = [];
+        let oArray = [];
         let nArray = [];
         let fiftyArray = [];
         let sampleDateArray = [];
@@ -236,7 +236,7 @@ export default {
           sampleDateArray.push(key);
           pArray.push(data[key].p);
           iArray.push(data[key].i);
-          aArray.push(data[key].a);
+          oArray.push(data[key].o);
           nArray.push(data[key].n);
           fiftyArray.push(data[key].fifty);
         }
@@ -294,7 +294,7 @@ export default {
             {
               name: '芳烃',
               type: 'line',
-              data: aArray
+              data: oArray
             },
             {
               name: '烷烃',