|
@@ -1457,7 +1457,114 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
|
|
|
*/
|
|
|
@Override
|
|
|
public List<MonthlyProductionReportVO> selectChemicalConsumeByYear(Long year) {
|
|
|
- return null;
|
|
|
+ // 当前日期
|
|
|
+ Date currentDate = new Date();
|
|
|
+ // 当前年份
|
|
|
+ Long currentYear = Long.parseLong(currentDate.getYear() + 1900 + "");
|
|
|
+ // 当前月份
|
|
|
+ Long currentMonth = Long.parseLong(currentDate.getMonth() + 1 + "");
|
|
|
+ // 从数据库中查出的当前year的月报数据集合,每个元素对应当前year某个月的数据
|
|
|
+ List<TMonthlyProductionReport> tMonthlyProductionReports = tMonthlyProductionReportMapper.selectChemicalConsumeByYear(year);
|
|
|
+ // 前端月报数据集合,每个元素对应当前某个指标的title、unit、1~12月的数据以及年度汇总数据
|
|
|
+ List<MonthlyProductionReportVO> monthlyProductionReportVOs = new ArrayList<>();
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_pt3000","PT-3000","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_naoh","NAOH","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_pt4000","PT-4000","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_ec3392a","EC3392A","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_2w906","2W906","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_ec1489a","EC1489A","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_ec1486a","EC1486A","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_20y3483","20Y3483","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_8q202","8Q202","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_20y97a","20Y97A","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_ec3269a","EC3269A","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_20y25","20Y25","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_20y77","20Y77","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_510ws","510WS","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_n130","N130","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_h2so4","H2SO4","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_naoh2","NaOH","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_ch3oh","CH3OH","TO"));
|
|
|
+ monthlyProductionReportVOs.add(new MonthlyProductionReportVO("chemical_consume_pt30002","PT-3000","TO"));
|
|
|
+ // 遍历从数据库中查出的月报数据集合,结果为0~12条数据不等
|
|
|
+ for (int i = 0; i < tMonthlyProductionReports.size(); i++) {
|
|
|
+ TMonthlyProductionReport tMonthlyProductionReport = tMonthlyProductionReports.get(i);
|
|
|
+ String chemicalConsumePt3000 = tMonthlyProductionReport.getChemicalConsumePt3000();
|
|
|
+ String chemicalConsumeNaoh = tMonthlyProductionReport.getChemicalConsumeNaoh();
|
|
|
+ String chemicalConsumePt4000 = tMonthlyProductionReport.getChemicalConsumePt4000();
|
|
|
+ String chemicalConsumeEc3392a = tMonthlyProductionReport.getChemicalConsumeEc3392a();
|
|
|
+ String chemicalConsume2w906 = tMonthlyProductionReport.getChemicalConsume2w906();
|
|
|
+ String chemicalConsumeEc1489a = tMonthlyProductionReport.getChemicalConsumeEc1489a();
|
|
|
+ String chemicalConsumeEc1486a = tMonthlyProductionReport.getChemicalConsumeEc1486a();
|
|
|
+ String chemicalConsume20y3483 = tMonthlyProductionReport.getChemicalConsume20y3483();
|
|
|
+ String chemicalConsume8q202 = tMonthlyProductionReport.getChemicalConsume8q202();
|
|
|
+ String chemicalConsume20y97a = tMonthlyProductionReport.getChemicalConsume20y97a();
|
|
|
+ String chemicalConsumeEc3269a = tMonthlyProductionReport.getChemicalConsumeEc3269a();
|
|
|
+ String chemicalConsume20y25 = tMonthlyProductionReport.getChemicalConsume20y25();
|
|
|
+ String chemicalConsume20y77 = tMonthlyProductionReport.getChemicalConsume20y77();
|
|
|
+ String chemicalConsume510ws = tMonthlyProductionReport.getChemicalConsume510ws();
|
|
|
+ String chemicalConsumeN130 = tMonthlyProductionReport.getChemicalConsumeN130();
|
|
|
+ String chemicalConsumeH2so4 = tMonthlyProductionReport.getChemicalConsumeH2so4();
|
|
|
+ String chemicalConsumeNaoh2 = tMonthlyProductionReport.getChemicalConsumeNaoh2();
|
|
|
+ String chemicalConsumeCh3oh = tMonthlyProductionReport.getChemicalConsumeCh3oh();
|
|
|
+ String chemicalConsumePt30002 = tMonthlyProductionReport.getChemicalConsumePt30002();
|
|
|
+ Long reportMonth = tMonthlyProductionReport.getReportMonth(); // 当前元素的所属月份
|
|
|
+ Long reportYear = tMonthlyProductionReport.getReportYear(); // 当前元素的所属年份
|
|
|
+ // 前端数据集合的class
|
|
|
+ Class clazz = null;
|
|
|
+ // 当前元素调用的set方法
|
|
|
+ Method method = null;
|
|
|
+ try {
|
|
|
+ clazz = Class.forName("com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO");
|
|
|
+ method = this.getSetMethod(reportMonth, clazz);
|
|
|
+ // 按照当前元素的所属月份调取相应set方法
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(0), chemicalConsumePt3000);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(1), chemicalConsumeNaoh);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(2), chemicalConsumePt4000);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(3), chemicalConsumeEc3392a);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(4), chemicalConsume2w906);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(5), chemicalConsumeEc1489a);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(6), chemicalConsumeEc1486a);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(7), chemicalConsume20y3483);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(8), chemicalConsume8q202);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(9), chemicalConsume20y97a);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(10), chemicalConsumeEc3269a);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(11), chemicalConsume20y25);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(12), chemicalConsume20y77);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(13), chemicalConsume510ws);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(14), chemicalConsumeN130);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(15), chemicalConsumeH2so4);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(16), chemicalConsumeNaoh2);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(17), chemicalConsumeCh3oh);
|
|
|
+ method.invoke(monthlyProductionReportVOs.get(18), chemicalConsumePt30002);
|
|
|
+ // 当前年份=所属年份,当前月份=所属月份
|
|
|
+ if (currentMonth.equals(reportMonth) && currentYear.equals(reportYear)) {
|
|
|
+ monthlyProductionReportVOs.get(0).setCurrently(chemicalConsumePt3000);
|
|
|
+ monthlyProductionReportVOs.get(1).setCurrently(chemicalConsumeNaoh);
|
|
|
+ monthlyProductionReportVOs.get(2).setCurrently(chemicalConsumePt4000);
|
|
|
+ monthlyProductionReportVOs.get(3).setCurrently(chemicalConsumeEc3392a);
|
|
|
+ monthlyProductionReportVOs.get(4).setCurrently(chemicalConsume2w906);
|
|
|
+ monthlyProductionReportVOs.get(5).setCurrently(chemicalConsumeEc1489a);
|
|
|
+ monthlyProductionReportVOs.get(6).setCurrently(chemicalConsumeEc1486a);
|
|
|
+ monthlyProductionReportVOs.get(7).setCurrently(chemicalConsume20y3483);
|
|
|
+ monthlyProductionReportVOs.get(8).setCurrently(chemicalConsume8q202);
|
|
|
+ monthlyProductionReportVOs.get(9).setCurrently(chemicalConsume20y97a);
|
|
|
+ monthlyProductionReportVOs.get(10).setCurrently(chemicalConsumeEc3269a);
|
|
|
+ monthlyProductionReportVOs.get(11).setCurrently(chemicalConsume20y25);
|
|
|
+ monthlyProductionReportVOs.get(12).setCurrently(chemicalConsume20y77);
|
|
|
+ monthlyProductionReportVOs.get(13).setCurrently(chemicalConsume510ws);
|
|
|
+ monthlyProductionReportVOs.get(14).setCurrently(chemicalConsumeN130);
|
|
|
+ monthlyProductionReportVOs.get(15).setCurrently(chemicalConsumeH2so4);
|
|
|
+ monthlyProductionReportVOs.get(16).setCurrently(chemicalConsumeNaoh2);
|
|
|
+ monthlyProductionReportVOs.get(17).setCurrently(chemicalConsumeCh3oh);
|
|
|
+ monthlyProductionReportVOs.get(18).setCurrently(chemicalConsumePt30002);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.calcTotal(monthlyProductionReportVOs);
|
|
|
+ return monthlyProductionReportVOs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1931,4 +2038,123 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
|
|
|
}
|
|
|
return affectedRows;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改Chemical Consume
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateChemicalConsume(MonthlyUpdateVO monthlyUpdateVO) {
|
|
|
+ // 受影响行数
|
|
|
+ int affectedRows = 0;
|
|
|
+ List<MonthlyProductionReportVO> tableData = monthlyUpdateVO.getTableData();
|
|
|
+ long year = monthlyUpdateVO.getYear();
|
|
|
+ Class clazz = null;
|
|
|
+ try {
|
|
|
+ clazz = Class.forName("com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO");
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ for (MonthlyProductionReportVO tableDatum : tableData) {
|
|
|
+ for (int i = 0; i < 12; i++) {
|
|
|
+ TMonthlyProductionReport report = new TMonthlyProductionReport();
|
|
|
+ report.setReportMonth((long)(i + 1));
|
|
|
+ report.setReportYear(year);
|
|
|
+ Method getMethod = null;
|
|
|
+ String monthValue = null;
|
|
|
+ try {
|
|
|
+ if (i == 0) { getMethod = clazz.getDeclaredMethod("getJan"); }
|
|
|
+ if (i == 1) { getMethod = clazz.getDeclaredMethod("getFeb"); }
|
|
|
+ if (i == 2) { getMethod = clazz.getDeclaredMethod("getMar"); }
|
|
|
+ if (i == 3) { getMethod = clazz.getDeclaredMethod("getApr"); }
|
|
|
+ if (i == 4) { getMethod = clazz.getDeclaredMethod("getMay"); }
|
|
|
+ if (i == 5) { getMethod = clazz.getDeclaredMethod("getJun"); }
|
|
|
+ if (i == 6) { getMethod = clazz.getDeclaredMethod("getJul"); }
|
|
|
+ if (i == 7) { getMethod = clazz.getDeclaredMethod("getAug"); }
|
|
|
+ if (i == 8) { getMethod = clazz.getDeclaredMethod("getSep"); }
|
|
|
+ if (i == 9) { getMethod = clazz.getDeclaredMethod("getOct"); }
|
|
|
+ if (i == 10) { getMethod = clazz.getDeclaredMethod("getNov"); }
|
|
|
+ if (i == 11) { getMethod = clazz.getDeclaredMethod("getDec"); }
|
|
|
+ monthValue = (String) getMethod.invoke(tableDatum);
|
|
|
+ } catch (NoSuchMethodException e1){
|
|
|
+ e1.printStackTrace();
|
|
|
+ } catch (IllegalAccessException e2) {
|
|
|
+ e2.printStackTrace();
|
|
|
+ } catch (InvocationTargetException e3) {
|
|
|
+ e3.printStackTrace();
|
|
|
+ }
|
|
|
+ if (monthValue == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ("chemical_consume_pt3000".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumePt3000(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_naoh".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeNaoh(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_pt4000".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumePt4000(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_ec3392a".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeEc3392a(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_2w906".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume2w906(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_ec1489a".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeEc1489a(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_ec1486a".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeEc1486a(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_20y3483".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume20y3483(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_8q202".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume8q202(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_20y97a".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume20y97a(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_ec3269a".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeEc3269a(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_20y25".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume20y25(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_20y77".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume20y77(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_510ws".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsume510ws(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_n130".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeN130(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_h2so4".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeH2so4(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_naoh2".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeNaoh2(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_ch3oh".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumeCh3oh(monthValue);
|
|
|
+ }
|
|
|
+ if ("chemical_consume_pt30002".equals(tableDatum.getDictLabel())) {
|
|
|
+ report.setChemicalConsumePt30002(monthValue);
|
|
|
+ }
|
|
|
+ // 当前报告年份
|
|
|
+ int reportYear = Integer.parseInt(report.getReportYear().toString());
|
|
|
+ // 当前报告月份
|
|
|
+ int reportMonth = Integer.parseInt(report.getReportMonth().toString());
|
|
|
+ // 查询年份=reportYear,月份=reportMonth的月报数据
|
|
|
+ int count = tMonthlyProductionReportMapper.selectTMonthlyProductionReportCountByDate(reportYear, reportMonth);
|
|
|
+ if (count == 0) { // 新增月报数据
|
|
|
+ affectedRows += tMonthlyProductionReportMapper.insertTMonthlyProductionReport(report);
|
|
|
+ } else { // 更新月报数据
|
|
|
+ affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return affectedRows;
|
|
|
+ }
|
|
|
}
|