|
@@ -279,10 +279,10 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
processRollHeightDetails(rollHeightDetails);
|
|
|
result.setRollHeightDetails(rollHeightDetails);
|
|
|
|
|
|
- List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(new LambdaQueryWrapper<RollDeputyCrossDetails>().in(RollDeputyCrossDetails::getStorageBillId, idList));
|
|
|
- processRollDeputyCrossDetails(rollDeputyCrossDetailsList);
|
|
|
- result.setRollDeputyCrossDetailsList(rollDeputyCrossDetailsList);
|
|
|
-
|
|
|
+// List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(new LambdaQueryWrapper<RollDeputyCrossDetails>().in(RollDeputyCrossDetails::getStorageBillId, idList));
|
|
|
+// processRollDeputyCrossDetails(rollDeputyCrossDetailsList);
|
|
|
+// result.setRollDeputyCrossDetailsList(rollDeputyCrossDetailsList);
|
|
|
+//
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -804,7 +804,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList3 = new ArrayList<>();
|
|
|
- List<DestinationStatisticsDetails> statisticsDetailsList4 = new ArrayList<>();
|
|
|
// 统计总数
|
|
|
int totalNumsAll = 0;
|
|
|
BigDecimal totalBlankOutputsAll = BigDecimal.ZERO;
|
|
@@ -967,62 +966,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
}
|
|
|
|
|
|
|
|
|
- LambdaQueryWrapper<RollDeputyCrossDetails> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper4.eq(RollDeputyCrossDetails::getCcmNo, ccmNo);
|
|
|
- queryWrapper4.eq(RollDeputyCrossDetails::getShiftGroup, shiftGroup);
|
|
|
- queryWrapper4.eq(RollDeputyCrossDetails::getShift, shift);
|
|
|
- // 添加大于 billetHotsendChangeShiftList 的 createTime 条件
|
|
|
- if (billetHotsendChangeShift != null && billetHotsendChangeShift.getCreateTime() != null) {
|
|
|
- if (oConvertUtils.isEmpty(changeShiftId)) {
|
|
|
- // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
|
|
|
- queryWrapper4.between(RollDeputyCrossDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
- } else {
|
|
|
- // 当 changeShiftId 不为空时,时间范围从 createTime 到 updateTime
|
|
|
- queryWrapper4.between(RollDeputyCrossDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
- }
|
|
|
- }
|
|
|
- List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(queryWrapper4);
|
|
|
- if (oConvertUtils.listIsNotEmpty(rollDeputyCrossDetailsList)) {
|
|
|
- statisticsDetailsList4 = rollDeputyCrossDetailsList.stream()
|
|
|
- // 过滤掉 stackAddr 不为空的记录
|
|
|
- .filter(detail -> detail.getStackAddr() == null || detail.getStackAddr().isEmpty())
|
|
|
- .collect(Collectors.groupingBy(RollDeputyCrossDetails::getSize, Collectors.toList()))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> {
|
|
|
- String size = entry.getKey();
|
|
|
- List<RollDeputyCrossDetails> group = entry.getValue();
|
|
|
- // 统计总支数,过滤后 stackAddr 均为空,直接按 1 计算
|
|
|
- int nums = group.size();
|
|
|
-
|
|
|
- Double totalBlankOutput = group.stream().mapToDouble(RollDeputyCrossDetails::getBlankOutput).sum();
|
|
|
- BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
- double finalBlankOutput = bd.doubleValue();
|
|
|
-
|
|
|
- String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
- return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- // 计算总数时,同样过滤 stackAddr 不为空的记录
|
|
|
- int totalNums = statisticsDetailsList4.stream()
|
|
|
- .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
- .sum();
|
|
|
-
|
|
|
- double totalBlankOutputs = rollDeputyCrossDetailsList.stream()
|
|
|
- .filter(detail -> detail.getStackAddr() == null || detail.getStackAddr().isEmpty()) // 过滤
|
|
|
- .mapToDouble(RollDeputyCrossDetails::getBlankOutput)
|
|
|
- .sum();
|
|
|
-
|
|
|
- BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
- totalNumsAll += totalNums;
|
|
|
- totalBlankOutputsAll = totalBlankOutputsAll.add(bd);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 合并四个列表并根据 size 分组统计
|
|
|
- List<DestinationStatisticsDetails> mergedList = Stream.of(
|
|
|
- statisticsDetailsList1, statisticsDetailsList2, statisticsDetailsList3, statisticsDetailsList4 // 添加第四个列表
|
|
|
- )
|
|
|
- .flatMap(Collection::stream) // 将所有列表合并成一个流
|
|
|
+ // 合并两个列表并根据 size 分组统计
|
|
|
+ List<DestinationStatisticsDetails> mergedList = Stream.concat(statisticsDetailsList1.stream(), statisticsDetailsList2.stream())
|
|
|
.collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
|
|
|
.entrySet().stream()
|
|
|
.map(entry -> {
|
|
@@ -1034,8 +979,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
double finalBlankOutput = bd.doubleValue();
|
|
|
String ccmNoForGroup = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
return new DestinationStatisticsDetails(size, totalNums, finalBlankOutput, ccmNoForGroup);
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
log.info("{}{}", "钢坯热装单班统计查询结果:", JSON.toJSON(mergedList));
|
|
|
onDutyStatistics.setCounts(totalNumsAll);
|
|
@@ -1764,23 +1708,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
onDutyStorageBillInfo.setBlankOutput(blankOutputSum);
|
|
|
}
|
|
|
}
|
|
|
- if ("付跨".equals(storageBill.getDestination())){
|
|
|
- // 根据装运单ID查询付跨明细表,并计算出坯量
|
|
|
- LambdaQueryWrapper<RollDeputyCrossDetails> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper4.eq(RollDeputyCrossDetails::getCcmNo, ccmNo).eq(RollDeputyCrossDetails::getStorageBillId, storageBill.getId());
|
|
|
- List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(queryWrapper4);
|
|
|
- if (oConvertUtils.listIsNotEmpty(rollDeputyCrossDetailsList)) {
|
|
|
- // 统计 blankOutput 总和并保留 4 位小数
|
|
|
- double totalBlankOutput = rollDeputyCrossDetailsList.stream()
|
|
|
- .mapToDouble(RollDeputyCrossDetails::getBlankOutput)
|
|
|
- .sum();
|
|
|
-
|
|
|
- BigDecimal bd = new BigDecimal(totalBlankOutput);
|
|
|
- bd = bd.setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
- double blankOutputSum = bd.doubleValue();
|
|
|
- onDutyStorageBillInfo.setBlankOutput(blankOutputSum);
|
|
|
- }
|
|
|
- }
|
|
|
onDutyStorageBillInfos.add(onDutyStorageBillInfo);
|
|
|
}
|
|
|
onDutyStorageBill.setOnDutyStorageBillInfos(onDutyStorageBillInfos);
|
|
@@ -1843,7 +1770,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
|
|
|
List<DestinationStatisticsDetails> statisticsDetailsList3 = new ArrayList<>();
|
|
|
- List<DestinationStatisticsDetails> statisticsDetailsList4 = new ArrayList<>();
|
|
|
|
|
|
for (StorageBill storageBill : storageBillList) {
|
|
|
if ("棒二".equals(storageBill.getDestination())) {
|
|
@@ -1929,41 +1855,12 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
statisticsDetailsList3.addAll(currentList3);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if ("付跨".equals(storageBill.getDestination())) {
|
|
|
- LambdaQueryWrapper<RollDeputyCrossDetails> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper4.eq(RollDeputyCrossDetails::getCcmNo, ccmNo).eq(RollDeputyCrossDetails::getStorageBillId, storageBill.getId());
|
|
|
- List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(queryWrapper4);
|
|
|
- if (oConvertUtils.listIsNotEmpty(rollDeputyCrossDetailsList)) {
|
|
|
- List<DestinationStatisticsDetails> currentList4 = rollDeputyCrossDetailsList.stream()
|
|
|
- .collect(Collectors.groupingBy(RollDeputyCrossDetails::getSize))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> {
|
|
|
- String size = entry.getKey();
|
|
|
- List<RollDeputyCrossDetails> group = entry.getValue();
|
|
|
- // 统计 blankOutput 总和
|
|
|
- Double totalBlankOutput = group.stream()
|
|
|
- .mapToDouble(RollDeputyCrossDetails::getBlankOutput)
|
|
|
- .sum();
|
|
|
- BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
- totalBlankOutput = bd.doubleValue();
|
|
|
- // 统计数量
|
|
|
- Integer totalNums = group.stream()
|
|
|
- .mapToInt(detail -> detail.getStackAddr() != null ? 4 : 1).sum();
|
|
|
- // 取第一个元素的 ccmNo 作为该分组的 ccmNo
|
|
|
- String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
- return new DestinationStatisticsDetails(size, totalNums, totalBlankOutput, ccmNos);
|
|
|
- }).collect(Collectors.toList());
|
|
|
- statisticsDetailsList4.addAll(currentList4);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- // 合并四个列表并根据 size 分组统计
|
|
|
+ // 合并三个列表并根据 size 分组统计
|
|
|
List<DestinationStatisticsDetails> mergedList = Stream.concat(
|
|
|
- Stream.concat(Stream.concat(statisticsDetailsList1.stream(), statisticsDetailsList2.stream()),
|
|
|
- statisticsDetailsList3.stream()),
|
|
|
- statisticsDetailsList4.stream()
|
|
|
+ Stream.concat(statisticsDetailsList1.stream(), statisticsDetailsList2.stream()),
|
|
|
+ statisticsDetailsList3.stream()
|
|
|
).collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
|
|
|
.entrySet().stream()
|
|
|
.map(entry -> {
|
|
@@ -2549,47 +2446,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
|
|
|
summaryList.addAll(result5);
|
|
|
|
|
|
- // 根据铸机号、班组、班别、交班的创建时间,查询付跨符合条件的信息
|
|
|
- LambdaQueryWrapper<RollDeputyCrossDetails> queryWrapper6 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper6.eq(RollDeputyCrossDetails::getCcmNo, ccmNo)
|
|
|
- .eq(RollDeputyCrossDetails::getShift, shift)
|
|
|
- .eq(RollDeputyCrossDetails::getShiftGroup, shiftGroup);
|
|
|
- if (oConvertUtils.isEmpty(changeShiftId)) {
|
|
|
- // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
|
|
|
- queryWrapper6.between(RollDeputyCrossDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
- } else {
|
|
|
- // 当 changeShiftId 不为空时,时间范围从 createTime 到 updateTime
|
|
|
- queryWrapper6.between(RollDeputyCrossDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
|
|
|
- }
|
|
|
- List<RollDeputyCrossDetails> list6 = rollDeputyCrossDetailsService.list(queryWrapper6);
|
|
|
-
|
|
|
- // 根据 size 分组,并统计总支数和总 BlankOutput
|
|
|
- List<SizeSummary> result6 = list6.stream()
|
|
|
- .collect(Collectors.groupingBy(RollDeputyCrossDetails::getSize))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> {
|
|
|
- String size = entry.getKey();
|
|
|
- List<RollDeputyCrossDetails> group = entry.getValue();
|
|
|
-
|
|
|
- // 统计总支数,如果 stackAddr 不为空,则乘以 4
|
|
|
- int totalNums = group.stream()
|
|
|
- .mapToInt(detail -> (detail.getStackAddr() != null && !detail.getStackAddr().isEmpty()) ? 4 : 1)
|
|
|
- .sum();
|
|
|
-
|
|
|
- // 累加 BlankOutput (转换为 BigDecimal)
|
|
|
- BigDecimal totalBlankOutput = group.stream()
|
|
|
- .map(RollDeputyCrossDetails::getBlankOutput)
|
|
|
- .filter(Objects::nonNull) // 过滤 null 值
|
|
|
- .map(BigDecimal::valueOf) // Double 转 BigDecimal
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- // 返回处理后的分组结果
|
|
|
- return new SizeSummary(size, totalNums, totalBlankOutput);
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- summaryList.addAll(result6);
|
|
|
-
|
|
|
-
|
|
|
// 对 summaryList 进行二次分组,聚合数据
|
|
|
List<OnDutySizeVo> onDutySizeVoList = summaryList.stream()
|
|
|
.collect(Collectors.groupingBy(SizeSummary::getSize))
|
|
@@ -3072,6 +2928,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
billetHotsend.setRollclubthreeNum(oConvertUtils.isNotEmpty(idExistBh.getRollclubthreeNum()) ? idExistBh.getRollclubthreeNum() + groupRollClubCommonList.size() * 4 : groupRollClubCommonList.size() * 4 );
|
|
|
}else if ("roll_out_shipp".equals(billetHotsendTypeConfig.getBelongTable())){
|
|
|
billetHotsend.setRolloutshippNum(oConvertUtils.isNotEmpty(idExistBh.getRolloutshippNum()) ? idExistBh.getRolloutshippNum() + groupRollClubCommonList.size() * 4 : groupRollClubCommonList.size() * 4 );
|
|
|
+ }else if ("roll_deputy_cross".equals(billetHotsendTypeConfig.getBelongTable())){
|
|
|
+ billetHotsend.setRollDeputyCrossNum(oConvertUtils.isNotEmpty(idExistBh.getRollDeputyCrossNum()) ? idExistBh.getRollDeputyCrossNum() + groupRollClubCommonList.size() * 4 : groupRollClubCommonList.size() * 4 );
|
|
|
}
|
|
|
billetHotsendBaseMapper.updateById(billetHotsend);
|
|
|
}
|
|
@@ -7701,63 +7559,6 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void processRollDeputyCrossDetails(List<RollDeputyCrossDetails> rollDeputyCrossDetailsList) {
|
|
|
- if (CollectionUtils.isEmpty(rollDeputyCrossDetailsList)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 1. 统一收集所有 billetNo,避免多次查询
|
|
|
- Set<String> allBilletNos = rollDeputyCrossDetailsList.stream()
|
|
|
- .map(RollDeputyCrossDetails::getBilletNo)
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .flatMap(billetNo -> Arrays.stream(billetNo.split(",")))
|
|
|
- .map(String::trim)
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- // 2. 一次性查询 BilletBasicInfo,避免重复查询数据库
|
|
|
- Map<String, String> billetToAssemblyMap = new HashMap<>();
|
|
|
- if (CollectionUtils.isNotEmpty(allBilletNos)) {
|
|
|
- List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(
|
|
|
- new LambdaQueryWrapper<BilletBasicInfo>().in(BilletBasicInfo::getBilletNo, allBilletNos));
|
|
|
-
|
|
|
- // 构建 billetNo -> assemblyNumber 映射
|
|
|
- billetToAssemblyMap = billetBasicInfoList.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- BilletBasicInfo::getBilletNo,
|
|
|
- BilletBasicInfo::getAssemblyNumber,
|
|
|
- (existing, replacement) -> existing // 遇到重复 billetNo,保留第一个
|
|
|
- ));
|
|
|
- }
|
|
|
- // 3. 遍历 details 并更新 assemblyNumber
|
|
|
- for (RollDeputyCrossDetails details : rollDeputyCrossDetailsList) {
|
|
|
- // 解析 billetNo
|
|
|
- Set<String> billetNoSet = Optional.ofNullable(details.getBilletNo())
|
|
|
- .map(billetNo -> Arrays.stream(billetNo.split(","))
|
|
|
- .map(String::trim)
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .collect(Collectors.toSet()))
|
|
|
- .orElse(Collections.emptySet());
|
|
|
-
|
|
|
- if (billetNoSet.isEmpty()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 先加入 details 现有的 assemblyNumber
|
|
|
- Set<String> assemblySet = new HashSet<>();
|
|
|
- String existingAssembly = details.getAssemblyNumber();
|
|
|
- if (StringUtils.isNotBlank(existingAssembly)) {
|
|
|
- Collections.addAll(assemblySet, existingAssembly.split(","));
|
|
|
- }
|
|
|
- // 直接从 Map 获取 assemblyNumber,避免重复查询数据库
|
|
|
- billetNoSet.stream()
|
|
|
- .map(billetToAssemblyMap::get)
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
- .forEach(assemblySet::add);
|
|
|
- // 更新 assemblyNumber
|
|
|
- details.setAssemblyNumber(String.join(",", assemblySet));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
public void processRollHeightDetails(List<RollHeightDetails> rollHeightDetailsList) {
|
|
|
if (CollectionUtils.isEmpty(rollHeightDetailsList)) {
|