|
@@ -2,10 +2,12 @@ package com.ruoyi.project.production.service.impl;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import com.graphbuilder.math.func.AvgFunction;
|
|
import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
|
|
import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
|
|
import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
|
|
import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
|
|
import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
|
|
import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
|
|
@@ -100,7 +102,121 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 计算total的值:1~12月之和
|
|
|
|
|
|
+ * 计算平均值
|
|
|
|
+ *
|
|
|
|
+ * @param monthlyProductionReportVOs 前端月报数据集合
|
|
|
|
+ */
|
|
|
|
+ private void calcAvg(List<MonthlyProductionReportVO> monthlyProductionReportVOs) {
|
|
|
|
+ for (int i = 0; i < monthlyProductionReportVOs.size(); i++) {
|
|
|
|
+ MonthlyProductionReportVO monthlyProductionReportVO = monthlyProductionReportVOs.get(i);
|
|
|
|
+ BigDecimal total = null;
|
|
|
|
+ BigDecimal avg = null;
|
|
|
|
+ int count = 0;
|
|
|
|
+ String janStr = monthlyProductionReportVO.getJan();
|
|
|
|
+ String febStr = monthlyProductionReportVO.getFeb();
|
|
|
|
+ String marStr = monthlyProductionReportVO.getMar();
|
|
|
|
+ String aprStr = monthlyProductionReportVO.getApr();
|
|
|
|
+ String mayStr = monthlyProductionReportVO.getMay();
|
|
|
|
+ String junStr = monthlyProductionReportVO.getJun();
|
|
|
|
+ String julStr = monthlyProductionReportVO.getJul();
|
|
|
|
+ String augStr = monthlyProductionReportVO.getAug();
|
|
|
|
+ String sepStr = monthlyProductionReportVO.getSep();
|
|
|
|
+ String octStr = monthlyProductionReportVO.getOct();
|
|
|
|
+ String novStr = monthlyProductionReportVO.getNov();
|
|
|
|
+ String decStr = monthlyProductionReportVO.getDec();
|
|
|
|
+ BigDecimal jan = null;
|
|
|
|
+ BigDecimal feb = null;
|
|
|
|
+ BigDecimal mar = null;
|
|
|
|
+ BigDecimal apr = null;
|
|
|
|
+ BigDecimal may = null;
|
|
|
|
+ BigDecimal jun = null;
|
|
|
|
+ BigDecimal jul = null;
|
|
|
|
+ BigDecimal aug = null;
|
|
|
|
+ BigDecimal sep = null;
|
|
|
|
+ BigDecimal oct = null;
|
|
|
|
+ BigDecimal nov = null;
|
|
|
|
+ BigDecimal dec = null;
|
|
|
|
+ if (janStr == null) {
|
|
|
|
+ jan = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ jan = new BigDecimal(janStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (febStr == null) {
|
|
|
|
+ feb = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ feb = new BigDecimal(febStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (marStr == null) {
|
|
|
|
+ mar = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ mar = new BigDecimal(marStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (aprStr == null) {
|
|
|
|
+ apr = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ apr = new BigDecimal(aprStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (mayStr == null) {
|
|
|
|
+ may = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ may = new BigDecimal(mayStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (junStr == null) {
|
|
|
|
+ jun = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ jun = new BigDecimal(junStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (julStr == null) {
|
|
|
|
+ jul = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ jul = new BigDecimal(julStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (augStr == null) {
|
|
|
|
+ aug = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ aug = new BigDecimal(augStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (sepStr == null) {
|
|
|
|
+ sep = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ sep = new BigDecimal(sepStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (octStr == null) {
|
|
|
|
+ oct = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ oct = new BigDecimal(octStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (novStr == null) {
|
|
|
|
+ nov = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ nov = new BigDecimal(novStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ if (decStr == null) {
|
|
|
|
+ dec = new BigDecimal("0");
|
|
|
|
+ } else {
|
|
|
|
+ dec = new BigDecimal(decStr);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ total = jan.add(feb).add(mar).add(apr).add(may).add(jun)
|
|
|
|
+ .add(jul).add(aug).add(sep).add(oct).add(nov).add(dec);
|
|
|
|
+ avg = total.divide(new BigDecimal(count), 2, RoundingMode.HALF_UP);
|
|
|
|
+ monthlyProductionReportVO.setAvg(avg.toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 计算总和
|
|
*
|
|
*
|
|
* @param monthlyProductionReportVOs 前端月报数据集合
|
|
* @param monthlyProductionReportVOs 前端月报数据集合
|
|
*/
|
|
*/
|
|
@@ -671,7 +787,7 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.calcTotal(monthlyProductionReportVOs);
|
|
|
|
|
|
+ this.calcAvg(monthlyProductionReportVOs);
|
|
return monthlyProductionReportVOs;
|
|
return monthlyProductionReportVOs;
|
|
}
|
|
}
|
|
|
|
|