|
@@ -577,6 +577,63 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
generateYeweiReport(date, "ck_", "0100120_hy", SysConfigEnum.PRODUCE_YEWEI_LXL_HY.name());// 硫酰氯
|
|
|
generateYeweiReport(date, "ck_", "0100160_hy", SysConfigEnum.PRODUCE_YEWEI_YJ_HY.name());// 液碱
|
|
|
generateYeweiReport(date, "ck_", "0100086_hy", SysConfigEnum.PRODUCE_YEWEI_YS_HY.name());// 盐酸
|
|
|
+
|
|
|
+ // 重新更新:当日耗用=当日库存+当日入库-前一天库存
|
|
|
+ generateHyAgain(date, "ck_", "0100087_hy", SysConfigEnum.PRODUCE_YEWEI_903_HY.name());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新计算耗用:当日耗用=当日库存+当日入库-前一天库存
|
|
|
+ * @param date
|
|
|
+ * @param prefix
|
|
|
+ * @param no
|
|
|
+ * @param name
|
|
|
+ */
|
|
|
+ private void generateHyAgain(LocalDate date, String prefix, String no, String name) {
|
|
|
+ ProduceData produceData = produceDataService.selectByNo(prefix + no);
|
|
|
+
|
|
|
+ // 找到当日耗用
|
|
|
+ Weekend<ProduceReport> weekend = new Weekend<>(ProduceReport.class);
|
|
|
+ WeekendCriteria<ProduceReport, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(ProduceReport::getDataId, produceData.getId())
|
|
|
+ .andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
+ .andEqualTo(ProduceReport::getMonth, date.getMonthValue()).andEqualTo(ProduceReport::getDate, date);
|
|
|
+ ProduceReport report = mapper.selectOneByExample(weekend);
|
|
|
+
|
|
|
+ // 找到当日库存
|
|
|
+ Weekend<ProduceReport> weekend2 = new Weekend<>(ProduceReport.class);
|
|
|
+ WeekendCriteria<ProduceReport, Object> weekendCriteria2= weekend2.weekendCriteria();
|
|
|
+ weekendCriteria2.andEqualTo(ProduceReport::getNo, "hy_" + no.replace("_hy", "_stock"))
|
|
|
+ .andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
+ .andEqualTo(ProduceReport::getMonth, date.getMonthValue())
|
|
|
+ .andEqualTo(ProduceReport::getDay, date.getDayOfMonth())
|
|
|
+ .andEqualTo(ProduceReport::getDate, date);
|
|
|
+ ProduceReport reportStock = mapper.selectOneByExample(weekend2);
|
|
|
+
|
|
|
+ // 找到前一天库存
|
|
|
+ LocalDate preDate = date.plusDays(-1);
|
|
|
+ Weekend<ProduceReport> weekend3 = new Weekend<>(ProduceReport.class);
|
|
|
+ WeekendCriteria<ProduceReport, Object> weekendCriteria3= weekend3.weekendCriteria();
|
|
|
+ weekendCriteria3.andEqualTo(ProduceReport::getNo, "hy_" + no.replace("_hy", "_stock"))
|
|
|
+ .andEqualTo(ProduceReport::getYear, preDate.getYear())
|
|
|
+ .andEqualTo(ProduceReport::getMonth, preDate.getMonthValue())
|
|
|
+ .andEqualTo(ProduceReport::getDay, preDate.getDayOfMonth())
|
|
|
+ .andEqualTo(ProduceReport::getDate, preDate);
|
|
|
+ ProduceReport reportStockPre = mapper.selectOneByExample(weekend3);
|
|
|
+
|
|
|
+ // 找到当日入库
|
|
|
+ Weekend<ProduceReport> weekend4 = new Weekend<>(ProduceReport.class);
|
|
|
+ WeekendCriteria<ProduceReport, Object> weekendCriteria4= weekend4.weekendCriteria();
|
|
|
+ weekendCriteria4.andEqualTo(ProduceReport::getNo, "ck_" + no.replace("_hy", ""))
|
|
|
+ .andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
+ .andEqualTo(ProduceReport::getMonth, date.getMonthValue())
|
|
|
+ .andEqualTo(ProduceReport::getDay, date.getDayOfMonth())
|
|
|
+ .andEqualTo(ProduceReport::getDate, date);
|
|
|
+ ProduceReport inStock = mapper.selectOneByExample(weekend4);
|
|
|
+
|
|
|
+ // 更新
|
|
|
+ report.setValue(new BigDecimal(reportStock.getValue()).add(new BigDecimal(inStock.getValue())).subtract(new BigDecimal(reportStockPre.getValue())).toString());
|
|
|
+ this.modModelByPrimaryKey(report);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -742,7 +799,8 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
.andEqualTo(ProduceReport::getDay, date.getDayOfMonth())
|
|
|
.andEqualTo(ProduceReport::getDate, date);
|
|
|
ProduceReport cs077Month = mapper.selectOneByExample(weekend977Month);
|
|
|
-
|
|
|
+ log.info("month: " + month.getValue());
|
|
|
+ log.info("cs077Month: " + cs077Month.getValue());
|
|
|
if(StringUtils.isBlank(cs077Month.getValue()) || new BigDecimal(cs077Month.getValue()).compareTo(new BigDecimal(0))==0){
|
|
|
danhaoMonth.setValue("0");
|
|
|
}else{
|