|
@@ -48,8 +48,7 @@ import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingUpLo
|
|
|
import org.jeecg.modules.billet.storageBill.entity.*;
|
|
|
import org.jeecg.modules.billet.storageBill.mapper.StorageBillMapper;
|
|
|
import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
|
|
|
-import org.jeecg.modules.billet.storageBill.vo.OnDutySizeVo;
|
|
|
-import org.jeecg.modules.billet.storageBill.vo.SizeSummary;
|
|
|
+import org.jeecg.modules.billet.storageBill.vo.*;
|
|
|
import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
|
|
|
import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -3252,4 +3251,657 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
return onDutyStatistics;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OnDutyStorageBillVo queryOnDutyAllStorageBillInfoBoard(String ccmNo) {
|
|
|
+ OnDutyStorageBillVo onDutyStorageBillStatistics = new OnDutyStorageBillVo();
|
|
|
+
|
|
|
+ String shiftGroup = "";
|
|
|
+ String shift = "";
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift;
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ shift = getShiftInfo(ccmNo, "class:shift:%s");
|
|
|
+ // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .isNull(BilletHotsendChangeShift::getChangeShiftTime)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> billQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ billQueryWrapper.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .gt(StorageBill::getAmountTotal, 0);
|
|
|
+
|
|
|
+ //时间范围从 createTime 到当前时间
|
|
|
+ billQueryWrapper.between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(billQueryWrapper);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
+ int allCarNum = storageBillList.size();
|
|
|
+ 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)) {
|
|
|
+ List<DestinationStatisticsDetails> currentList1 = rollClubTwoDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubTwoDetails::getSize))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubTwoDetails> group = entry.getValue();
|
|
|
+ // 统计 blankOutput 总和
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(RollClubTwoDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
+ // 统计数量
|
|
|
+ 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());
|
|
|
+ statisticsDetailsList1.addAll(currentList1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ List<DestinationStatisticsDetails> currentList2 = rollClubThreeDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubThreeDetails::getSize))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubThreeDetails> group = entry.getValue();
|
|
|
+ // 统计 blankOutput 总和
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(RollClubThreeDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
+ // 统计数量
|
|
|
+ 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());
|
|
|
+ statisticsDetailsList2.addAll(currentList2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ List<DestinationStatisticsDetails> currentList3 = rollOutShippDetailsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollOutShippDetails::getSize))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollOutShippDetails> group = entry.getValue();
|
|
|
+ // 统计 blankOutput 总和
|
|
|
+ Double totalBlankOutput = group.stream()
|
|
|
+ .mapToDouble(RollOutShippDetails::getBlankOutput)
|
|
|
+ .sum();
|
|
|
+ // 统计数量
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ // 遍历mergedList获取nums总和
|
|
|
+ int finalAmountTotal = mergedList.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
|
|
|
+
|
|
|
+
|
|
|
+ int hotSendSum = 0;
|
|
|
+ int hotChargeSum = 0;
|
|
|
+ int stackingSum = 0;
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、创建时间 查询垛位起剁明细表
|
|
|
+ LambdaQueryWrapper<StackingUpLog> stackingUpLogQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ stackingUpLogQueryWrapper.eq(StackingUpLog::getCcmNo, ccmNo);
|
|
|
+
|
|
|
+ stackingUpLogQueryWrapper.between(StackingUpLog::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<StackingUpLog> stackingUpLogList = stackingUpLogService.list(stackingUpLogQueryWrapper);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(stackingUpLogList)) {
|
|
|
+ // 收集所有的 billetNo
|
|
|
+ Set<String> allBilletNos = new HashSet<>();
|
|
|
+ for (StackingUpLog stackingUpLog : stackingUpLogList) {
|
|
|
+ if (oConvertUtils.isNotEmpty(stackingUpLog.getBilletNo())) {
|
|
|
+ String[] billetNoArray = stackingUpLog.getBilletNo().split(",");
|
|
|
+ allBilletNos.addAll(Arrays.asList(billetNoArray));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 一次性查询所有相关的 BilletBasicInfo
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> basicInfoQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ basicInfoQueryWrapper.in(BilletBasicInfo::getBilletNo, allBilletNos);
|
|
|
+ List<BilletBasicInfo> billetBasicInfos = billetBasicInfoService.list(basicInfoQueryWrapper);
|
|
|
+
|
|
|
+ // 将 BilletBasicInfo 列表转换为以 billetNo 为键的映射
|
|
|
+ Map<String, BilletBasicInfo> billetBasicInfoMap = billetBasicInfos.stream()
|
|
|
+ .collect(Collectors.toMap(BilletBasicInfo::getBilletNo, Function.identity()));
|
|
|
+
|
|
|
+ for (StackingUpLog stackingUpLog : stackingUpLogList) {
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ if (oConvertUtils.isNotEmpty(stackingUpLog.getBilletNo())) {
|
|
|
+ List<String> billetNoList = Arrays.asList(stackingUpLog.getBilletNo().split(","));
|
|
|
+ double stackingTotalBlankOutput = 0;
|
|
|
+ for (String billetNo : billetNoList) {
|
|
|
+ BilletBasicInfo info = billetBasicInfoMap.get(billetNo);
|
|
|
+ if (info != null) {
|
|
|
+ stackingTotalBlankOutput += info.getBilletWeight();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailStatistics.setBlankOutput(stackingTotalBlankOutput);
|
|
|
+ detailStatistics.setAmountTotal(billetNoList.size());
|
|
|
+ }
|
|
|
+ detailStatistics.setSize(stackingUpLog.getSize());
|
|
|
+ }
|
|
|
+
|
|
|
+ stackingSum = stackingSum + stackingUpLogList.size() * 4;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、时间范围。查询棒一明细表
|
|
|
+ LambdaQueryWrapper<RollClubOneDetails> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ // 添加通用的查询条件
|
|
|
+ queryWrapper1.eq(RollClubOneDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollClubOneDetails::getShift, shift)
|
|
|
+ .eq(RollClubOneDetails::getShiftGroup, shiftGroup);
|
|
|
+
|
|
|
+
|
|
|
+ queryWrapper1.between(RollClubOneDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(queryWrapper1);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubOneDetailsList)){
|
|
|
+ // 棒一热送总数
|
|
|
+ hotSendSum = rollClubOneDetailsList.size();
|
|
|
+
|
|
|
+ rollClubOneDetailsList.forEach(x ->{
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ detailStatistics.setAmountTotal(1);
|
|
|
+ detailStatistics.setBlankOutput(x.getBlankOutput());
|
|
|
+ detailStatistics.setSize(x.getSize());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、时间范围。查询棒二明细表
|
|
|
+ LambdaQueryWrapper<RollClubTwoDetails> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(RollClubTwoDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollClubTwoDetails::getShift, shift)
|
|
|
+ .eq(RollClubTwoDetails::getShiftGroup, shiftGroup);
|
|
|
+
|
|
|
+ queryWrapper2.between(RollClubTwoDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
|
|
|
+ // 棒二热装总支数 获取堆垛编号为空的条数,即为热装
|
|
|
+ int count = (int) rollClubTwoDetailsList.stream().filter(details -> details.getStackAddr() == null).count();
|
|
|
+ hotChargeSum = hotChargeSum + count;
|
|
|
+
|
|
|
+ rollClubTwoDetailsList.forEach(x ->{
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ if(oConvertUtils.isEmpty(x.getStackAddr())){
|
|
|
+ detailStatistics.setAmountTotal(1);
|
|
|
+ detailStatistics.setBlankOutput(x.getBlankOutput());
|
|
|
+ detailStatistics.setSize(x.getSize());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、时间范围。查询棒三明细表
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollClubThreeDetails::getShift, shift)
|
|
|
+ .eq(RollClubThreeDetails::getShiftGroup, shiftGroup);
|
|
|
+ queryWrapper3.between(RollClubThreeDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
|
|
|
+ // 棒三热装总支数
|
|
|
+ int count = (int) rollClubThreeDetailsList.stream().filter(details -> details.getStackAddr() == null).count();
|
|
|
+ hotChargeSum = hotChargeSum + count;
|
|
|
+
|
|
|
+ rollClubThreeDetailsList.forEach(x ->{
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ if(oConvertUtils.isEmpty(x.getStackAddr())){
|
|
|
+ detailStatistics.setAmountTotal(1);
|
|
|
+ detailStatistics.setBlankOutput(x.getBlankOutput());
|
|
|
+ detailStatistics.setSize(x.getSize());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、时间范围。查询高线明细表
|
|
|
+ LambdaQueryWrapper<RollHeightDetails> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper4.eq(RollHeightDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollHeightDetails::getShift, shift)
|
|
|
+ .eq(RollHeightDetails::getShiftGroup, shiftGroup);
|
|
|
+
|
|
|
+ queryWrapper4.between(RollHeightDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<RollHeightDetails> rollHeightDetailsList = rollHeightDetailsService.list(queryWrapper4);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
|
|
|
+ // 高线总支数 高线属于热送
|
|
|
+ int hotSendHeightSum = rollHeightDetailsList.stream()
|
|
|
+ .mapToInt(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty() ? 4 : 1).sum();
|
|
|
+ hotSendSum = hotSendSum + hotSendHeightSum;
|
|
|
+
|
|
|
+ rollHeightDetailsList.forEach(x ->{
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ if(x.getStackAddr() == null){
|
|
|
+ detailStatistics.setAmountTotal(1);
|
|
|
+ }else {
|
|
|
+ detailStatistics.setAmountTotal(4);
|
|
|
+ }
|
|
|
+ detailStatistics.setBlankOutput(x.getBlankOutput());
|
|
|
+ detailStatistics.setSize(x.getSize());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别、时间范围。查询上若明细表
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper5 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper5.eq(RollOutShippDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollOutShippDetails::getShift, shift)
|
|
|
+ .eq(RollOutShippDetails::getShiftGroup, shiftGroup);
|
|
|
+
|
|
|
+ queryWrapper5.between(RollOutShippDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper5);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
|
|
|
+ // 上若热装总支数
|
|
|
+ int count = (int) rollOutShippDetailsList.stream().filter(details -> details.getStackAddr() == null).count();
|
|
|
+ hotChargeSum = hotChargeSum + count;
|
|
|
+
|
|
|
+ rollOutShippDetailsList.forEach(x ->{
|
|
|
+ DetailStatistics detailStatistics = new DetailStatistics();
|
|
|
+ if(oConvertUtils.isEmpty(x.getStackAddr())){
|
|
|
+ detailStatistics.setAmountTotal(1);
|
|
|
+ detailStatistics.setBlankOutput(x.getBlankOutput());
|
|
|
+ detailStatistics.setSize(x.getSize());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ onDutyStorageBillStatistics.setHotChargeSum(hotChargeSum);
|
|
|
+ onDutyStorageBillStatistics.setHotSendSum(hotSendSum);
|
|
|
+ onDutyStorageBillStatistics.setStackingSum(stackingSum);
|
|
|
+ onDutyStorageBillStatistics.setTotalNumber(hotChargeSum + hotSendSum);
|
|
|
+
|
|
|
+
|
|
|
+ onDutyStorageBillStatistics.setAllCarNum(allCarNum);
|
|
|
+ onDutyStorageBillStatistics.setCounts(finalAmountTotal);
|
|
|
+ onDutyStorageBillStatistics.setShift(shift);
|
|
|
+ onDutyStorageBillStatistics.setShiftGroup(shiftGroup);
|
|
|
+ return onDutyStorageBillStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OnDutyStorageBill queryOnDutyShipmentBoard(String ccmNo) {
|
|
|
+
|
|
|
+ OnDutyStorageBill onDutyStorageBill = new OnDutyStorageBill();
|
|
|
+
|
|
|
+ String shiftGroup = "";
|
|
|
+ String shift = "";
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift;
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ 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 = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班正在装运信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyStorageBill;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .eq(StorageBill::getShift, shift)
|
|
|
+ .eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, Arrays.asList("辊道", "堆垛辊道"))
|
|
|
+ .orderByDesc(StorageBill::getCreateTime);
|
|
|
+
|
|
|
+ // 时间范围从 createTime 到当前时间
|
|
|
+ queryWrapper2.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();
|
|
|
+
|
|
|
+ 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 OnDutyHotChargeVo queryOnDutyHotCharge(String ccmNo) {
|
|
|
+ OnDutyHotChargeVo onDutyHotChargeVo = new OnDutyHotChargeVo();
|
|
|
+
|
|
|
+ String shiftGroup = "";
|
|
|
+ String shift = "";
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift;
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ shift = getShiftInfo(ccmNo, "class:shift:%s");
|
|
|
+ // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .isNull(BilletHotsendChangeShift::getChangeShiftTime)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyHotChargeVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .gt(StorageBill::getAmountTotal, 0);
|
|
|
+
|
|
|
+ //时间范围从 createTime 到当前时间
|
|
|
+ queryWrapper2.between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
|
|
|
+ return onDutyHotChargeVo;
|
|
|
+ }
|
|
|
+ List<RollClubTwoDetails> rollClubTwoList = new ArrayList<>();
|
|
|
+ List<RollClubThreeDetails> rollClubThreeList = new ArrayList<>();
|
|
|
+ List<RollOutShippDetails> rollOutShippList = 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())
|
|
|
+ .and(qw -> qw.isNull(RollClubTwoDetails::getStackAddr)
|
|
|
+ .or()
|
|
|
+ .eq(RollClubTwoDetails::getStackAddr, "")); // 处理为空字符串的情况;
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollClubTwoList.addAll(rollClubTwoDetailsList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("棒三".equals(storageBill.getDestination())) {
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollClubThreeDetails::getStorageBillId, storageBill.getId())
|
|
|
+ .and(qw -> qw.isNull(RollClubThreeDetails::getStackAddr)
|
|
|
+ .or()
|
|
|
+ .eq(RollClubThreeDetails::getStackAddr, "")); // 处理为空字符串的情况;;
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollClubThreeList.addAll(rollClubThreeDetailsList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("上若".equals(storageBill.getDestination())) {
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollOutShippDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollOutShippDetails::getStorageBillId, storageBill.getId())
|
|
|
+ .and(qw -> qw.isNull(RollOutShippDetails::getStackAddr)
|
|
|
+ .or()
|
|
|
+ .eq(RollOutShippDetails::getStackAddr, ""));;
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollOutShippList.addAll(rollOutShippDetailsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int storageBillCount1 = Math.toIntExact(
|
|
|
+ rollClubTwoList.stream()
|
|
|
+ .map(RollClubTwoDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ int storageBillCount2 = Math.toIntExact(
|
|
|
+ rollClubThreeList.stream()
|
|
|
+ .map(RollClubThreeDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ int storageBillCount3 = Math.toIntExact(
|
|
|
+ rollOutShippList.stream()
|
|
|
+ .map(RollOutShippDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ onDutyHotChargeVo.setRollClubTwoNum(rollClubTwoList.size());
|
|
|
+ onDutyHotChargeVo.setRollClubTwoTrainNum(storageBillCount1);
|
|
|
+ onDutyHotChargeVo.setRollClubThreeNum(rollClubThreeList.size());
|
|
|
+ onDutyHotChargeVo.setRollClubThreeTrainNum(storageBillCount2);
|
|
|
+ onDutyHotChargeVo.setRollOutShippNum(rollOutShippList.size());
|
|
|
+ onDutyHotChargeVo.setRollOutShippTrainNum(storageBillCount3);
|
|
|
+
|
|
|
+ return onDutyHotChargeVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OnDutyColdChargeVo queryOnDutyColdCharge(String ccmNo) {
|
|
|
+ OnDutyColdChargeVo onDutyColdChargeVo = new OnDutyColdChargeVo();
|
|
|
+
|
|
|
+ String shiftGroup = "";
|
|
|
+ String shift = "";
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShift;
|
|
|
+
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
+ shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
+ shift = getShiftInfo(ccmNo, "class:shift:%s");
|
|
|
+ // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
|
|
|
+ LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
|
|
|
+ .eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
|
|
|
+ .isNull(BilletHotsendChangeShift::getChangeShiftTime)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
+ if (billetHotsendChangeShift == null){
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
+ return onDutyColdChargeVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .gt(StorageBill::getAmountTotal, 0);
|
|
|
+
|
|
|
+ //时间范围从 createTime 到当前时间
|
|
|
+ queryWrapper2.between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
+
|
|
|
+ List<StorageBill> storageBillList = baseMapper.selectList(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsEmpty(storageBillList)){
|
|
|
+ log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
|
|
|
+ return onDutyColdChargeVo;
|
|
|
+ }
|
|
|
+ List<RollClubTwoDetails> rollClubTwoList = new ArrayList<>();
|
|
|
+ List<RollClubThreeDetails> rollClubThreeList = new ArrayList<>();
|
|
|
+ List<RollOutShippDetails> rollOutShippList = 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())
|
|
|
+ .isNotNull(RollClubTwoDetails::getStackAddr) // stackAddr 不能为 NULL
|
|
|
+ .ne(RollClubTwoDetails::getStackAddr, ""); // stackAddr 不能是空字符串
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollClubTwoList.addAll(rollClubTwoDetailsList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("棒三".equals(storageBill.getDestination())) {
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollClubThreeDetails::getStorageBillId, storageBill.getId())
|
|
|
+ .isNotNull(RollClubThreeDetails::getStackAddr) // stackAddr 不能为 NULL
|
|
|
+ .ne(RollClubThreeDetails::getStackAddr, ""); // stackAddr 不能是空字符串
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollClubThreeList.addAll(rollClubThreeDetailsList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("上若".equals(storageBill.getDestination())) {
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(RollOutShippDetails::getCcmNo, ccmNo)
|
|
|
+ .eq(RollOutShippDetails::getStorageBillId, storageBill.getId())
|
|
|
+ .isNotNull(RollOutShippDetails::getStackAddr) // stackAddr 不能为 NULL
|
|
|
+ .ne(RollOutShippDetails::getStackAddr, ""); // stackAddr 不能是空字符串
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper3);
|
|
|
+
|
|
|
+ rollOutShippList.addAll(rollOutShippDetailsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int storageBillCount1 = Math.toIntExact(
|
|
|
+ rollClubTwoList.stream()
|
|
|
+ .map(RollClubTwoDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ int storageBillCount2 = Math.toIntExact(
|
|
|
+ rollClubThreeList.stream()
|
|
|
+ .map(RollClubThreeDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ int storageBillCount3 = Math.toIntExact(
|
|
|
+ rollOutShippList.stream()
|
|
|
+ .map(RollOutShippDetails::getStorageBillId)
|
|
|
+ .distinct()
|
|
|
+ .count()
|
|
|
+ );
|
|
|
+
|
|
|
+ onDutyColdChargeVo.setRollClubTwoNum(rollClubTwoList.size());
|
|
|
+ onDutyColdChargeVo.setRollClubTwoTrainNum(storageBillCount1);
|
|
|
+ onDutyColdChargeVo.setRollClubThreeNum(rollClubThreeList.size());
|
|
|
+ onDutyColdChargeVo.setRollClubThreeTrainNum(storageBillCount2);
|
|
|
+ onDutyColdChargeVo.setRollOutShippNum(rollOutShippList.size());
|
|
|
+ onDutyColdChargeVo.setRollOutShippTrainNum(storageBillCount3);
|
|
|
+
|
|
|
+ return onDutyColdChargeVo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|