|
@@ -153,55 +153,32 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
model.setMonth(date.getMonthValue());
|
|
|
model.setDay(date.getDayOfMonth());
|
|
|
super.modModelByDTO(model);
|
|
|
- /*LocalDate date = model.getDate();
|
|
|
- model.setYear(date.getYear());
|
|
|
- model.setMonth(date.getMonthValue());
|
|
|
- model.setDay(date.getDayOfMonth());
|
|
|
- ProduceData produceData = produceDataService.getModelById(model.getDataId());
|
|
|
+
|
|
|
+ // 查找月累计产量
|
|
|
+ ProduceData monthData = produceDataService.selectByNo(model.getNo().replace("yjh", "month"));
|
|
|
Weekend<ProduceReport> weekend = new Weekend<>(ProduceReport.class);
|
|
|
WeekendCriteria<ProduceReport, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
- weekendCriteria.andEqualTo(ProduceReport::getDataId, produceData.getId())
|
|
|
+ weekendCriteria.andEqualTo(ProduceReport::getDataId, monthData.getId())
|
|
|
.andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
- .andEqualTo(ProduceReport::getMonth, date.getMonthValue());
|
|
|
- mapper.deleteByExample(weekend);*/
|
|
|
-
|
|
|
- // 新增这一个月的月计划数据
|
|
|
- /*List<ProduceReport> reportList = new ArrayList<>();
|
|
|
- ProduceData wcl = produceDataService.selectByNo(model.getNo() + "_yjh");
|
|
|
- for (int i = 1; i <= date.lengthOfMonth(); i++) {
|
|
|
- ProduceReport report = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
- report.setYear(date.getYear());
|
|
|
- report.setMonth(date.getMonthValue());
|
|
|
- report.setDay(i);
|
|
|
- report.setValue(model.getValue());
|
|
|
- report.setDataId(produceData.getId());
|
|
|
- LocalDate localDate = LocalDate.of(date.getYear(), date.getMonthValue(), i);
|
|
|
- report.setDate(localDate);
|
|
|
- reportList.add(report);
|
|
|
-
|
|
|
- // 月累计产量
|
|
|
- Weekend<ProduceReport> weekend2 = new Weekend<>(ProduceReport.class);
|
|
|
- WeekendCriteria<ProduceReport, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
- weekendCriteria2.andEqualTo(ProduceReport::getDataId, produceData.getId())
|
|
|
- .andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
- .andEqualTo(ProduceReport::getMonth, date.getMonthValue()).andEqualTo(ProduceReport::getDay, i);
|
|
|
- ProduceReport monthReport = mapper.selectOneByExample(weekend2);
|
|
|
- if (monthReport == null) {
|
|
|
- monthReport = BeanConverterUtil.copyObjectProperties(wcl, ProduceReport.class);
|
|
|
- monthReport.setYear(date.getYear());
|
|
|
- monthReport.setMonth(date.getMonthValue());
|
|
|
- monthReport.setDay(i);
|
|
|
- monthReport.setDataId(wcl.getId());
|
|
|
- monthReport.setDate(localDate);
|
|
|
- monthReport.setValue("0");
|
|
|
- reportList.add(monthReport);
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- // 重新计算这一个月的数据和完成率
|
|
|
- /*if (!CollectionUtils.isEmpty(reportList)) {
|
|
|
- mapper.insertListforComplex(reportList);
|
|
|
- }*/
|
|
|
+ .andEqualTo(ProduceReport::getMonth, date.getMonthValue())
|
|
|
+ .andEqualTo(ProduceReport::getDay, date.getDayOfMonth());
|
|
|
+ ProduceReport monthReport = mapper.selectOneByExample(weekend);
|
|
|
+
|
|
|
+ // 重新计算完成率
|
|
|
+ ProduceData wclData = produceDataService.selectByNo(model.getNo() + "_wcl");
|
|
|
+ Weekend<ProduceReport> weekend2 = new Weekend<>(ProduceReport.class);
|
|
|
+ WeekendCriteria<ProduceReport, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
+ weekendCriteria2.andEqualTo(ProduceReport::getDataId, wclData.getId())
|
|
|
+ .andEqualTo(ProduceReport::getYear, date.getYear())
|
|
|
+ .andEqualTo(ProduceReport::getMonth, date.getMonthValue())
|
|
|
+ .andEqualTo(ProduceReport::getDay, date.getDayOfMonth());
|
|
|
+ ProduceReport wclReport = mapper.selectOneByExample(weekend2);
|
|
|
+ if (StringUtils.isBlank(model.getValue()) || new BigDecimal("0").compareTo(new BigDecimal(model.getValue())) >= 0) {
|
|
|
+ wclReport.setValue("100");
|
|
|
+ } else {
|
|
|
+ wclReport.setValue(new BigDecimal(monthReport.getValue()).multiply(new BigDecimal(100)).divide(new BigDecimal(model.getValue()), 2, RoundingMode.HALF_UP).toString());
|
|
|
+ }
|
|
|
+ mapper.updateByPrimaryKey(wclReport);
|
|
|
} else if (model.getNo().equals("xiaoshou_lhn")
|
|
|
|| model.getNo().equals("xiaoshou_0300083")
|
|
|
|| model.getNo().equals("dl_电_hy")
|
|
@@ -783,7 +760,6 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 生成某一天的生产量
|
|
|
* 生产报表每日统计:每天凌晨1点统计
|