|
@@ -156,22 +156,28 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
@RequiresPermissions("billetHotsendChangeShift:billet_hotsend_change_shift:add")
|
|
|
@PostMapping(value = "/add")
|
|
|
public Result<String> add(@RequestBody BilletHotsendChangeShift billetHotsendChangeShiftVo) {
|
|
|
+ // 通过铸机号查询最新的一条记录
|
|
|
LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
|
|
|
- queryWrapperCS.between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
|
|
|
- List<BilletHotsendChangeShift> billetHotsendChangeShiftList = billetHotsendChangeShiftService.list(queryWrapperCS);
|
|
|
-
|
|
|
- String nextShift = String.join(",", billetHotsendChangeShiftVo.getShift(), billetHotsendChangeShiftVo.getShiftGroup());
|
|
|
- if (oConvertUtils.listIsNotEmpty(billetHotsendChangeShiftList)) {
|
|
|
- boolean exists = billetHotsendChangeShiftList.stream().map(x -> String.join(",", x.getShift(), x.getShiftGroup())).anyMatch(s -> s.equals(nextShift));
|
|
|
- if (exists){
|
|
|
- return Result.error("当天不能重复交班");
|
|
|
- }
|
|
|
- }
|
|
|
- JSONObject jsonObject = billetHotsendChangeShiftService.billetHotsendChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
- if (jsonObject.containsKey("fail")){
|
|
|
- return Result.OK((String) jsonObject.get("fail"));
|
|
|
+ queryWrapperCS.eq(BilletHotsendChangeShift::getCcmNo, billetHotsendChangeShiftVo.getCcmNo())
|
|
|
+ .isNotNull(BilletHotsendChangeShift::getChangeShiftTime)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapperCS, false);
|
|
|
+ if (billetHotsendChangeShift.getShift().equals(billetHotsendChangeShiftVo.getShift()) && billetHotsendChangeShift.getShiftGroup().equals(billetHotsendChangeShiftVo.getShiftGroup())){
|
|
|
+ return Result.error("该班别已交班,请勿重复交班!");
|
|
|
}
|
|
|
- return Result.OK((String) jsonObject.get("success"));
|
|
|
+
|
|
|
+// // B端手动交班下发mqtt
|
|
|
+// if ("5".equals(billetHotsendChangeShiftVo.getCcmNo())){
|
|
|
+// billetHotsendChangeShiftService.fiveChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
+// }else if ("6".equals(billetHotsendChangeShiftVo.getCcmNo())){
|
|
|
+// billetHotsendChangeShiftService.sixChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
+// }
|
|
|
+// JSONObject jsonObject = billetHotsendChangeShiftService.billetHotsendChangeShiftHandle(billetHotsendChangeShiftVo);
|
|
|
+// if (jsonObject.containsKey("fail")){
|
|
|
+// return Result.OK((String) jsonObject.get("fail"));
|
|
|
+// }
|
|
|
+ return Result.OK("交班成功!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -306,21 +312,21 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
|
|
|
|
|
|
// 每天 08:00:00 执行的定时任务
|
|
|
- @Scheduled(cron = "0 0 8 * * ?")
|
|
|
+// @Scheduled(cron = "0 0 8 * * ?")
|
|
|
public void executeDayShiftTask() {
|
|
|
log.info("自动化定时交班——白班:08:00:00开始执行!");
|
|
|
performShiftChange("白班");
|
|
|
}
|
|
|
|
|
|
// 每天 16:00:00 执行的定时任务
|
|
|
- @Scheduled(cron = "0 0 16 * * ?")
|
|
|
+// @Scheduled(cron = "0 0 16 * * ?")
|
|
|
public void executeMiddleShiftTask() {
|
|
|
log.info("自动定时交班——中班:16:00:00开始执行!");
|
|
|
performShiftChange("中班");
|
|
|
}
|
|
|
|
|
|
// 每天 00:00:00 执行的定时任务
|
|
|
- @Scheduled(cron = "0 0 0 * * ?")
|
|
|
+// @Scheduled(cron = "0 0 0 * * ?")
|
|
|
public void executeNeightShiftTask() {
|
|
|
log.info("自动化定时交班——白班:00:00:00开始执行!");
|
|
|
performShiftChange("夜班");
|
|
@@ -770,7 +776,8 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
log.info("{}{}", "5号机查询班次实绩吊运明细、轧钢棒二、轧钢棒三、轧钢上若维护到交班信息失败,交班记录为空!", new Date());
|
|
|
return;
|
|
|
}
|
|
|
- commonShift1(billetHotsendChangeShift);
|
|
|
+// commonShift1(billetHotsendChangeShift);
|
|
|
+ commonShiftBas(billetHotsendChangeShift);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -796,10 +803,204 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
log.info("{}{}", "6号机查询班次实绩吊运明细、轧钢棒二、轧钢棒三、轧钢上若维护到交班信息失败,交班记录为空!", new Date());
|
|
|
return;
|
|
|
}
|
|
|
- commonShift1(billetHotsendChangeShift);
|
|
|
+// commonShift1(billetHotsendChangeShift);
|
|
|
+ commonShiftBas(billetHotsendChangeShift);
|
|
|
|
|
|
}
|
|
|
+ private void commonShiftBas(BilletHotsendChangeShift billetHotsendChangeShift) {
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList3 = new ArrayList<>();
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、交班的创建时间,交班时间,查询所有目的地是棒二的钢坯基础信息
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(BilletBasicInfo::getCcmNo, billetHotsendChangeShift.getCcmNo())
|
|
|
+ .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
|
|
|
+ .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
|
|
|
+ .between(BilletBasicInfo::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper1);
|
|
|
+ if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
|
|
|
+ log.info("{}{}", "钢坯基础信息为空,班次实绩同步!", JSON.toJSON(billetHotsendChangeShift));
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ List<BilletBasicInfo> rollClubTwoList = billetBasicInfoList.stream()
|
|
|
+ .filter(info -> "roll_club_two".equals(info.getBelongTable()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<BilletBasicInfo> rollClubThreeList = billetBasicInfoList.stream()
|
|
|
+ .filter(info -> "roll_club_three".equals(info.getBelongTable()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<BilletBasicInfo> rollOutShippList = billetBasicInfoList.stream()
|
|
|
+ .filter(info -> "roll_out_shipp".equals(info.getBelongTable()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoList)){
|
|
|
+ List<DestinationStatisticsDetails> currentList1 = rollClubTwoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BilletBasicInfo::getLength))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = String.valueOf(entry.getKey());
|
|
|
+ List<BilletBasicInfo> group = entry.getValue();
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(BilletBasicInfo::getBilletWeight)
|
|
|
+ .sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ totalBlankOutput = bd.doubleValue();
|
|
|
+ int totalNums = group.size();
|
|
|
+ String ccmNos = group.isEmpty() ? null : String.valueOf(group.get(0).getCcmNo());
|
|
|
+ return new DestinationStatisticsDetails(size, totalNums, totalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ statisticsDetailsList1.addAll(currentList1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeList)){
|
|
|
+ List<DestinationStatisticsDetails> currentList2 = rollClubThreeList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BilletBasicInfo::getLength))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = String.valueOf(entry.getKey());
|
|
|
+ List<BilletBasicInfo> group = entry.getValue();
|
|
|
+ // 统计 blankOutput 总和
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(BilletBasicInfo::getBilletWeight)
|
|
|
+ .sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ totalBlankOutput = bd.doubleValue();
|
|
|
+ int totalNums = group.size();
|
|
|
+ String ccmNos = group.isEmpty() ? null : String.valueOf(group.get(0).getCcmNo());
|
|
|
+ return new DestinationStatisticsDetails(size, totalNums, totalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ statisticsDetailsList2.addAll(currentList2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippList)){
|
|
|
+ List<DestinationStatisticsDetails> currentList3 = rollOutShippList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BilletBasicInfo::getLength))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = String.valueOf(entry.getKey());
|
|
|
+ List<BilletBasicInfo> group = entry.getValue();
|
|
|
+ // 统计 blankOutput 总和
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(BilletBasicInfo::getBilletWeight)
|
|
|
+ .sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ totalBlankOutput = bd.doubleValue();
|
|
|
+ int totalNums = group.size();
|
|
|
+ String ccmNos = group.isEmpty() ? null : String.valueOf(group.get(0).getCcmNo());
|
|
|
+ return new DestinationStatisticsDetails(size, totalNums, totalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ statisticsDetailsList3.addAll(currentList3);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并三个列表并根据 size 分组统计
|
|
|
+ List<DestinationStatisticsDetails> mergedList = Stream.concat(
|
|
|
+ Stream.concat(statisticsDetailsList1.stream(), statisticsDetailsList2.stream()),
|
|
|
+ statisticsDetailsList3.stream()
|
|
|
+ ).collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<DestinationStatisticsDetails> group = entry.getValue();
|
|
|
+ int totalNums = group.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
|
|
|
+ double totalBlankOutput = group.stream().mapToDouble(DestinationStatisticsDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double finalBlankOutput = bd.doubleValue();
|
|
|
+ String ccmNoForGroup = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
+ return new DestinationStatisticsDetails(size, totalNums, finalBlankOutput, ccmNoForGroup);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ // 班次装运统计 车次总数、总重、总支数 查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(StorageBill::getCcmNo, billetHotsendChangeShift.getCcmNo())
|
|
|
+ .eq(StorageBill::getShift, billetHotsendChangeShift.getShift())
|
|
|
+ .eq(StorageBill::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
|
|
|
+ .isNotNull(StorageBill::getDestination)
|
|
|
+ .ne(StorageBill::getTypeConfigId, "1024")
|
|
|
+ .between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
+ List<StorageBill> storageBillList = storageBillService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询班次实绩吊运明细、轧钢棒二、轧钢棒三、轧钢上若,装运信息为空!", billetHotsendChangeShift.getCcmNo());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 过滤 storageBillList 中总支数为0的记录,计算出总条数
|
|
|
+ int allCarNum = (int) storageBillList.stream()
|
|
|
+ .filter(storageBill -> storageBill.getAmountTotal() != 0)
|
|
|
+ .count();
|
|
|
+ // 装运总车次
|
|
|
+ billetHotsendChangeShift.setAllCarNum(allCarNum);
|
|
|
+
|
|
|
+ int finalAmountTotal = mergedList.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
|
|
|
+ billetHotsendChangeShift.setCounts(finalAmountTotal);
|
|
|
+
|
|
|
+ double finalBlankOutputs = mergedList.stream().mapToDouble(DestinationStatisticsDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(finalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ billetHotsendChangeShift.setBlankOutputs(bd.doubleValue());
|
|
|
+
|
|
|
+ // 轧钢棒二明细
|
|
|
+ // 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
|
|
|
+ Map<String, DestinationStatisticsDetails> result1 = statisticsDetailsList1.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ DestinationStatisticsDetails::getSize,
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.reducing((first, second) -> {
|
|
|
+ DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
|
|
|
+ combined.setSize(first.getSize());
|
|
|
+ combined.setNums(first.getNums() + second.getNums());
|
|
|
+ combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
|
|
|
+ combined.setCcmNo(first.getCcmNo());
|
|
|
+ return combined;
|
|
|
+ }),
|
|
|
+ Optional::get
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsGroup1List = new ArrayList<>(result1.values());
|
|
|
+ billetHotsendChangeShift.setRollClubTwoDetails(JSON.toJSONString(statisticsDetailsGroup1List));
|
|
|
+
|
|
|
+ // 轧钢棒三明细
|
|
|
+ // 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
|
|
|
+ Map<String, DestinationStatisticsDetails> result2 = statisticsDetailsList2.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ DestinationStatisticsDetails::getSize,
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.reducing((first, second) -> {
|
|
|
+ DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
|
|
|
+ combined.setSize(first.getSize());
|
|
|
+ combined.setNums(first.getNums() + second.getNums());
|
|
|
+ combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
|
|
|
+ combined.setCcmNo(first.getCcmNo());
|
|
|
+ return combined;
|
|
|
+ }),
|
|
|
+ Optional::get
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsGroup2List = new ArrayList<>(result2.values());
|
|
|
+ billetHotsendChangeShift.setRollClubThreeDetails(JSON.toJSONString(statisticsDetailsGroup2List));
|
|
|
+
|
|
|
+ // 轧钢上若明细
|
|
|
+ // 按照 size 分组,计算 nums 和 blankOutput 的总和,取每组第一条记录的 ccmNo
|
|
|
+ Map<String, DestinationStatisticsDetails> result3 = statisticsDetailsList3.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ DestinationStatisticsDetails::getSize,
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.reducing((first, second) -> {
|
|
|
+ DestinationStatisticsDetails combined = new DestinationStatisticsDetails();
|
|
|
+ combined.setSize(first.getSize());
|
|
|
+ combined.setNums(first.getNums() + second.getNums());
|
|
|
+ combined.setBlankOutput(roundToFourDecimals(first.getBlankOutput() + second.getBlankOutput()));
|
|
|
+ combined.setCcmNo(first.getCcmNo());
|
|
|
+ return combined;
|
|
|
+ }),
|
|
|
+ Optional::get
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsGroup3List = new ArrayList<>(result3.values());
|
|
|
+ billetHotsendChangeShift.setRollClubShipDetails(JSON.toJSONString(statisticsDetailsGroup3List));
|
|
|
+ billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
|
|
|
+ }
|
|
|
/**
|
|
|
* 5.6号机
|
|
|
* 统计班次吊运明细、轧钢棒二、轧钢棒三、轧钢上若维护到交班信息 公共方法
|
|
@@ -1046,7 +1247,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
.between(RollClubOneDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(queryWrapperDetails);
|
|
|
if (oConvertUtils.listIsEmpty(rollClubOneDetailsList)){
|
|
|
- log.info("{}{}", "5号机查询班次实绩轧钢棒一,装运单为空!", new Date());
|
|
|
+ log.info("{}{}", "5号机查询班次实绩轧钢棒一明细为空!", new Date());
|
|
|
return;
|
|
|
}
|
|
|
// 根据size属性进行分组,并统计每组的总数和总重 直接在流操作中完成分组、求和并保留 4 位小数
|
|
@@ -1113,7 +1314,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
|
|
|
.between(RollHeightDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
List<RollHeightDetails> rollHeightDetailsList = rollHeightDetailsService.list(queryWrapperDetails6);
|
|
|
if (oConvertUtils.listIsEmpty(rollHeightDetailsList)){
|
|
|
- log.info("{}{}", "6号机查询班次实绩轧钢高线,明细为空!", new Date());
|
|
|
+ log.info("{}{}", "6号机查询班次实绩轧钢高线明细为空!", new Date());
|
|
|
return;
|
|
|
}
|
|
|
|