|
@@ -1,10 +1,11 @@
|
|
package com.ruoyi.project.production.controller;
|
|
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.security.access.prepost.PreAuthorize;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
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.controller.BaseController;
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
-import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 质量月报S0501Controller
|
|
* 质量月报S0501Controller
|
|
@@ -50,6 +50,7 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
|
|
int endYear = endDate.getYear() + 1900;
|
|
int endYear = endDate.getYear() + 1900;
|
|
int startMonth = startDate.getMonth() + 1;
|
|
int startMonth = startDate.getMonth() + 1;
|
|
int endMonth = endDate.getMonth() + 1;
|
|
int endMonth = endDate.getMonth() + 1;
|
|
|
|
+ // 趋势图数据
|
|
Map<String, TMonthlyQualityReportS0501> dataMap = new HashMap<>();
|
|
Map<String, TMonthlyQualityReportS0501> dataMap = new HashMap<>();
|
|
do {
|
|
do {
|
|
TMonthlyQualityReportS0501 reportS0501 = new TMonthlyQualityReportS0501();
|
|
TMonthlyQualityReportS0501 reportS0501 = new TMonthlyQualityReportS0501();
|
|
@@ -66,7 +67,84 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
|
|
startMonth++;
|
|
startMonth++;
|
|
}
|
|
}
|
|
} while (startYear != endYear || startMonth != endMonth + 1);
|
|
} 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);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|