|
@@ -1202,15 +1202,228 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject queryOnDutyStorageBillInfoHandle(String ccmNo) {
|
|
|
- JSONObject result = new JSONObject();
|
|
|
+ public OnDutyStorageBill queryOnDutyStorageBillInfoHandle(String ccmNo) {
|
|
|
+ OnDutyStorageBill onDutyStorageBill = new OnDutyStorageBill();
|
|
|
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ String shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ String shift = getShiftInfo(ccmNo, "class:shift:%s");
|
|
|
+ // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyStorageBill;
|
|
|
+ }
|
|
|
+ // 根据铸机号、班组、班别、licensePlate不等于”辊道“或者”堆垛辊道“,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .eq(StorageBill::getShift, shift)
|
|
|
+ .eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, "辊道", "堆垛辊道")
|
|
|
+ .gt(StorageBill::getAmountTotal, 0)
|
|
|
+ .isNull(StorageBill::getOutTime)
|
|
|
+ .between(StorageBill::getCreateTime,billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
|
|
|
+ return onDutyStorageBill;
|
|
|
+ }
|
|
|
+ List<OnDutyStorageBillInfo> onDutyStorageBillInfos = new ArrayList<>();
|
|
|
+ for (StorageBill storageBill : storageBillList) {
|
|
|
+ OnDutyStorageBillInfo onDutyStorageBillInfo = new OnDutyStorageBillInfo();
|
|
|
+ BeanUtils.copyProperties(storageBill, onDutyStorageBillInfo);
|
|
|
+ if ("棒二".equals(storageBill.getDestination())){
|
|
|
+ // 根据装运单ID查询棒二明细表,并计算出坯量
|
|
|
+ LambdaQueryWrapper<RollClubTwoDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubTwoDetails::getCcmNo, ccmNo).eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)) {
|
|
|
+ // 统计 blankOutput 总和并保留 4 位小数
|
|
|
+ double totalBlankOutput = rollClubTwoDetailsList.stream()
|
|
|
+ .mapToDouble(RollClubTwoDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
|
|
|
+ BigDecimal bd = new BigDecimal(totalBlankOutput);
|
|
|
+ bd = bd.setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double blankOutputSum = bd.doubleValue();
|
|
|
+ onDutyStorageBillInfo.setBlankOutput(blankOutputSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("棒三".equals(storageBill.getDestination())){
|
|
|
+ // 根据装运单ID查询棒二明细表,并计算出坯量
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo).eq(RollClubThreeDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)) {
|
|
|
+ // 统计 blankOutput 总和并保留 4 位小数
|
|
|
+ double totalBlankOutput = rollClubThreeDetailsList.stream()
|
|
|
+ .mapToDouble(RollClubThreeDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
|
|
|
+ BigDecimal bd = new BigDecimal(totalBlankOutput);
|
|
|
+ bd = bd.setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double blankOutputSum = bd.doubleValue();
|
|
|
+ onDutyStorageBillInfo.setBlankOutput(blankOutputSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("上若".equals(storageBill.getDestination())){
|
|
|
+ // 根据装运单ID查询棒二明细表,并计算出坯量
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollOutShippDetails::getCcmNo, ccmNo).eq(RollOutShippDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)) {
|
|
|
+ // 统计 blankOutput 总和并保留 4 位小数
|
|
|
+ double totalBlankOutput = rollOutShippDetailsList.stream()
|
|
|
+ .mapToDouble(RollOutShippDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
|
|
|
- return result;
|
|
|
+ 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);
|
|
|
+ return onDutyStorageBill;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public OnDutyStorageBillStatistics queryOnDutyAllStorageBillInfoHandle(String ccmNo) {
|
|
|
+ OnDutyStorageBillStatistics onDutyStorageBillStatistics = new OnDutyStorageBillStatistics();
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ String shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ String shift = getShiftInfo(ccmNo, "class:shift:%s");
|
|
|
+ // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
+ // 根据铸机号、班组、班别、licensePlate不等于”辊道“或者”堆垛辊道“,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .eq(StorageBill::getShift, shift)
|
|
|
+ .eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, "辊道", "堆垛辊道")
|
|
|
+ .gt(StorageBill::getAmountTotal, 0)
|
|
|
+ .between(StorageBill::getCreateTime,billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList3 = new ArrayList<>();
|
|
|
+ for (StorageBill storageBill : storageBillList) {
|
|
|
+
|
|
|
+ if ("棒二".equals(storageBill.getDestination())){
|
|
|
+ LambdaQueryWrapper<RollClubTwoDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubTwoDetails::getCcmNo, ccmNo).eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
|
|
|
+ statisticsDetailsList1 = rollClubTwoDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubTwoDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubTwoDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollClubTwoDetails::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());
|
|
|
+ int totalNums = statisticsDetailsList1.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+ onDutyStorageBillStatistics.setCounts(totalNums);
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ onDutyStorageBillStatistics.setBlankOutputs(bd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("棒三".equals(storageBill.getDestination())){
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo).eq(RollClubThreeDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
|
|
|
+ statisticsDetailsList2 = rollClubThreeDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubThreeDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubThreeDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollClubThreeDetails::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());
|
|
|
+ int totalNums = statisticsDetailsList2.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+ onDutyStorageBillStatistics.setCounts(totalNums);
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ onDutyStorageBillStatistics.setBlankOutputs(bd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("上若".equals(storageBill.getDestination())){
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollOutShippDetails::getCcmNo, ccmNo).eq(RollOutShippDetails::getStorageBillId, storageBill.getId());
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
|
|
|
+ statisticsDetailsList3 = rollOutShippDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollOutShippDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollOutShippDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollOutShippDetails::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());
|
|
|
+ int totalNums = statisticsDetailsList3.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+ onDutyStorageBillStatistics.setCounts(totalNums);
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ onDutyStorageBillStatistics.setBlankOutputs(bd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|