|
@@ -319,14 +319,14 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
|
|
|
// 生产量数据
|
|
|
List<ProduceReport> sclList = new ArrayList<>();
|
|
|
- sclList.addAll(generateSCL("scl_", date, "0300027", ProduceRecordTypeEnum.CCP_RK.getValue()));// 生产量:977,产成品
|
|
|
- generateSCL("scl_", date, "0600032", ProduceRecordTypeEnum.BCP_RK.getValue());// 生产量:902,半成品
|
|
|
+ sclList.addAll(generateSCL("scl_", date, "0300027", ProduceRecordTypeEnum.CCP_RK.getValue(), new BigDecimal(0.3)));// 生产量:977,产成品
|
|
|
+ generateSCL("scl_", date, "0600032", ProduceRecordTypeEnum.BCP_RK.getValue(), new BigDecimal(1));// 生产量:902,半成品
|
|
|
|
|
|
// 销售出货量
|
|
|
- generateSCL("xiaoshou_", date, "0300027", ProduceRecordTypeEnum.XS_CK.getValue());// 977:0300027
|
|
|
- generateSCL("xiaoshou_", date, "0300083", ProduceRecordTypeEnum.XS_CK.getValue());// 锂渣:0300083
|
|
|
- generateSCL("xiaoshou_", date, "0300073", ProduceRecordTypeEnum.XS_CK.getValue());// 氟化钠:0300073
|
|
|
- generateSCL("xiaoshou_", date, "lhn", ProduceRecordTypeEnum.XS_CK.getValue());//氯化钠:手填,先生成0
|
|
|
+ generateSCL("xiaoshou_", date, "0300027", ProduceRecordTypeEnum.XS_CK.getValue(), new BigDecimal(0.3));// 977:0300027
|
|
|
+ generateSCL("xiaoshou_", date, "0300083", ProduceRecordTypeEnum.XS_CK.getValue(), new BigDecimal(1));// 锂渣:0300083
|
|
|
+ generateSCL("xiaoshou_", date, "0300073", ProduceRecordTypeEnum.XS_CK.getValue(), new BigDecimal(1));// 氟化钠:0300073
|
|
|
+ generateSCL("xiaoshou_", date, "lhn", ProduceRecordTypeEnum.XS_CK.getValue(), new BigDecimal(1));//氯化钠:手填,先生成0
|
|
|
|
|
|
// 库存数据
|
|
|
generateStock(date, "0300027");//977:0300027,
|
|
@@ -360,7 +360,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
generateCk(date, "0100120", sclList);// 硫酰氯(合成)
|
|
|
generateCk(date, "0100160", sclList);//液碱32%
|
|
|
generateCk(date, "0100086", sclList);//盐酸
|
|
|
- generateCk(date, "0100075", sclList);//氢氧化钠(工业级片碱),这个是手工录入,不计算
|
|
|
+ generateCk(date, "0100075", sclList);//氢氧化钠(工业级片碱),这个是从库存出库获取
|
|
|
|
|
|
// 物料:库存数据
|
|
|
generateStockXCL(date, "0600032");//GS-902
|
|
@@ -437,7 +437,6 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
public void generateDianReport(LocalDate date, List<ProduceReport> sclList) {
|
|
|
|
|
|
// 电力记录数据
|
|
|
- // 统计当天数据
|
|
|
ProduceRecord find = new ProduceRecord();
|
|
|
find.setProductNo("电");
|
|
|
find.setDate(date);
|
|
@@ -514,48 +513,49 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
ProduceReport dayScl = sclList.stream().filter(dept -> dept.getNo().endsWith("_0300027")).collect(Collectors.toList()).get(0);
|
|
|
String prefixHy = "hy_";
|
|
|
produceData = produceDataService.selectByNo(prefixHy + no);
|
|
|
- report = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
- report.setDate(date);
|
|
|
- report.setDataId(produceData.getId());
|
|
|
-
|
|
|
+ ProduceReport dayHy = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
+ dayHy.setDate(date);
|
|
|
+ dayHy.setDataId(produceData.getId());
|
|
|
+ log.info("produceRecord.getNum():" + produceRecord.getNum() + ", dayScl.getValue():" + dayScl.getValue());
|
|
|
if (dayScl == null || dayScl.getValue().compareTo("1") == 0) {
|
|
|
- dayScl.setValue("1");
|
|
|
+ dayHy.setValue("1");
|
|
|
} else {
|
|
|
if (new BigDecimal(dayScl.getValue()).compareTo(new BigDecimal("0")) == 0) {
|
|
|
- report.setValue(produceRecord.getNum().setScale(0, RoundingMode.HALF_UP).toString());
|
|
|
+ dayHy.setValue("0");
|
|
|
} else {
|
|
|
- BigDecimal hyDayValue = new BigDecimal(produceRecord.getNum().toString()).divide(new BigDecimal(dayScl.getValue()).multiply(new BigDecimal(0.3)), BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(1000)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- report.setValue(hyDayValue.toString());
|
|
|
+ BigDecimal hyDayValue = new BigDecimal(produceRecord.getNum().toString()).divide(new BigDecimal(dayScl.getValue()).multiply(new BigDecimal(1)), BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ dayHy.setValue(hyDayValue.toString());
|
|
|
+ log.info("dayHy" + dayHy);
|
|
|
}
|
|
|
}
|
|
|
- report.setYear(date.getYear());
|
|
|
- report.setMonth(date.getMonthValue());
|
|
|
- report.setDay(date.getDayOfMonth());
|
|
|
- report.setCreatedTime(LocalDateTime.now());
|
|
|
- this.saveModel(report);
|
|
|
+ dayHy.setYear(date.getYear());
|
|
|
+ dayHy.setMonth(date.getMonthValue());
|
|
|
+ dayHy.setDay(date.getDayOfMonth());
|
|
|
+ dayHy.setCreatedTime(LocalDateTime.now());
|
|
|
+ this.saveModel(dayHy);
|
|
|
|
|
|
// 当月单耗
|
|
|
ProduceReport monthScl = sclList.stream().filter(dept -> dept.getNo().endsWith("_0300027_month")).collect(Collectors.toList()).get(0);
|
|
|
produceData = produceDataService.selectByNo(prefixHy + no + "_month");
|
|
|
- report = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
- report.setDate(date);
|
|
|
- report.setDataId(produceData.getId());
|
|
|
+ ProduceReport monthHy = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
+ monthHy.setDate(date);
|
|
|
+ monthHy.setDataId(produceData.getId());
|
|
|
|
|
|
if (monthScl == null) {
|
|
|
monthScl.setValue("1");
|
|
|
} else {
|
|
|
if (new BigDecimal(monthScl.getValue()).compareTo(new BigDecimal("0")) == 0) {
|
|
|
- report.setValue(new BigDecimal(monthVO.getTotalValue()).setScale(0, RoundingMode.HALF_UP).toString());
|
|
|
+ monthHy.setValue("0");
|
|
|
} else {
|
|
|
- BigDecimal hyDayValue = new BigDecimal(monthVO.getTotalValue()).divide(new BigDecimal(monthScl.getValue()).multiply(new BigDecimal(0.3)), BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(1000)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- report.setValue(hyDayValue.toString());
|
|
|
+ BigDecimal hyDayValue = new BigDecimal(monthVO.getTotalValue()).divide(new BigDecimal(monthScl.getValue()).multiply(new BigDecimal(1)), BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(1000)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
+ monthHy.setValue(hyDayValue.toString());
|
|
|
}
|
|
|
}
|
|
|
- report.setYear(date.getYear());
|
|
|
- report.setMonth(date.getMonthValue());
|
|
|
- report.setDay(date.getDayOfMonth());
|
|
|
- report.setCreatedTime(LocalDateTime.now());
|
|
|
- this.saveModel(report);
|
|
|
+ monthHy.setYear(date.getYear());
|
|
|
+ monthHy.setMonth(date.getMonthValue());
|
|
|
+ monthHy.setDay(date.getDayOfMonth());
|
|
|
+ monthHy.setCreatedTime(LocalDateTime.now());
|
|
|
+ this.saveModel(monthHy);
|
|
|
|
|
|
|
|
|
// 库存0:hy_电_stock、可用天数0:hy_电_avg
|
|
@@ -613,7 +613,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
generateYeweiReport(date, "ck_", "0100160_hy", SysConfigEnum.PRODUCE_YEWEI_YJ_HY.name());// 液碱
|
|
|
generateYeweiReport(date, "ck_", "0100086_hy", SysConfigEnum.PRODUCE_YEWEI_YS_HY.name());// 盐酸
|
|
|
|
|
|
- // 单独计算904:月均单耗 = 本月耗用/CS-977月累计产量*0.3
|
|
|
+ // 单独计算904:月均单耗 = 本月耗用/CS-977月累计产量
|
|
|
generate904Report(date, "ck_", "0100074_hy");// 904
|
|
|
|
|
|
// 重新更新:24当日耗用=23当日库存+24当日入库-24库存
|
|
@@ -651,7 +651,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 计算904,单独计算904:月均单耗 = 本月耗用/CS-977月累计产量*0.3
|
|
|
+ * 计算904,单独计算904:月均单耗 = 本月耗用/CS-977月累计产量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param prefix
|
|
@@ -693,7 +693,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
if ((StringUtils.isBlank(report1.getValue())) || (new BigDecimal(report1.getValue()).compareTo(new BigDecimal(0.0)) == 0)) {
|
|
|
report3.setValue("0");
|
|
|
} else {
|
|
|
- report3.setValue(new BigDecimal(report2.getValue()).divide(new BigDecimal(report1.getValue()).multiply(new BigDecimal(0.3)), RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
+ report3.setValue(new BigDecimal(report2.getValue()).divide(new BigDecimal(report1.getValue()).multiply(new BigDecimal(1)), RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
}
|
|
|
this.modModelByPrimaryKey(report3);
|
|
|
}
|
|
@@ -765,7 +765,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
|
|
|
// 默认977
|
|
|
String sclNo = "scl_0300027";
|
|
|
- BigDecimal rate = new BigDecimal(0.3);
|
|
|
+ BigDecimal rate = new BigDecimal(1);
|
|
|
if (no.equals("0100010_hy") || no.equals("0100065_hy") || no.equals("0100120_hy") || no.equals("0100160_hy") || no.equals("0100086_hy")) {
|
|
|
sclNo = "scl_0600032";// 902
|
|
|
rate = new BigDecimal(1);
|
|
@@ -977,7 +977,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
|
|
|
// 默认977
|
|
|
String sclNo = "scl_0300027";
|
|
|
- BigDecimal rate = new BigDecimal(0.3);
|
|
|
+ BigDecimal rate = new BigDecimal(1);
|
|
|
if (no.equals("0100010_hy") || no.equals("0100065_hy") || no.equals("0100120_hy") || no.equals("0100160_hy") || no.equals("0100086_hy")) {
|
|
|
sclNo = "scl_0600032";// 902
|
|
|
rate = new BigDecimal(1);
|
|
@@ -1174,7 +1174,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
/**
|
|
|
* 手填的数据,先生成0
|
|
|
* <p>
|
|
|
- * 1:动力单耗的计算逻辑:动力使用量/当日产量*0.3
|
|
|
+ * 1:动力单耗的计算逻辑:动力使用量/当日产量
|
|
|
* 当日产量是977的产量
|
|
|
* <p>
|
|
|
* 当日单耗
|
|
@@ -1209,12 +1209,13 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
* @param date 日期
|
|
|
* @param no 编号
|
|
|
* @param type 类型
|
|
|
+ * @param type 折算比例
|
|
|
* <p>
|
|
|
* 1: 生产量:
|
|
|
* CS-977 0300027
|
|
|
* 902 0600032
|
|
|
*/
|
|
|
- public List<ProduceReport> generateSCL(String prefix, LocalDate date, String no, Integer type) {
|
|
|
+ public List<ProduceReport> generateSCL(String prefix, LocalDate date, String no, Integer type, BigDecimal rate) {
|
|
|
List<ProduceReport> resultList = new ArrayList<>();
|
|
|
// 统计当天数据
|
|
|
ProduceRecordDTO dto = new ProduceRecordDTO();
|
|
@@ -1234,7 +1235,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
ProduceReport report = BeanConverterUtil.copyObjectProperties(produceData, ProduceReport.class);
|
|
|
report.setDate(date);
|
|
|
report.setDataId(produceData.getId());
|
|
|
- report.setValue(new BigDecimal(total.toString()).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ report.setValue(new BigDecimal(total.toString()).multiply(rate).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
report.setYear(date.getYear());
|
|
|
report.setMonth(date.getMonthValue());
|
|
|
report.setDay(date.getDayOfMonth());
|
|
@@ -1486,7 +1487,7 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
if (new BigDecimal("0").compareTo(new BigDecimal(dayScl.getValue())) == 0) {
|
|
|
dayHy.setValue("0");
|
|
|
} else {
|
|
|
- BigDecimal hyDayValue = total.divide(new BigDecimal(dayScl.getValue()).multiply(new BigDecimal(0.3)), 2).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal hyDayValue = total.divide(new BigDecimal(dayScl.getValue()).multiply(new BigDecimal(1)), 2).setScale(2, RoundingMode.HALF_UP);
|
|
|
dayHy.setValue(hyDayValue.toString());
|
|
|
}
|
|
|
dayHy.setYear(date.getYear());
|
|
@@ -1501,10 +1502,10 @@ public class ProduceReportServiceImpl extends BaseServiceImpl<ProduceReportMappe
|
|
|
ProduceReport monthHy = BeanConverterUtil.copyObjectProperties(hyMonth, ProduceReport.class);
|
|
|
monthHy.setDate(date);
|
|
|
monthHy.setDataId(hyMonth.getId());
|
|
|
- if (new BigDecimal("0").compareTo(monthVO.getTotalValue()) == 0 || new BigDecimal(monthScl.getValue()).compareTo(new BigDecimal(0)) <= 0) {
|
|
|
+ if (new BigDecimal("0").compareTo(new BigDecimal(monthReport.getValue())) == 0 || new BigDecimal(monthScl.getValue()).compareTo(new BigDecimal(0)) <= 0) {
|
|
|
monthHy.setValue("0");
|
|
|
} else {
|
|
|
- BigDecimal hyMonthValue = (monthVO.getTotalValue().divide(new BigDecimal(monthScl.getValue()).multiply(new BigDecimal(0.3)), RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal hyMonthValue = (new BigDecimal(monthReport.getValue()).divide(new BigDecimal(monthScl.getValue()).multiply(new BigDecimal(1)), RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP);
|
|
|
monthHy.setValue(hyMonthValue.toString());
|
|
|
}
|
|
|
monthHy.setYear(date.getYear());
|