diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 84e76c86c..d2f7b589d 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -10356,38 +10356,170 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl carsLoadScanEntities = new ArrayList<>(); + carsLoadScanEntities.add(trunklineCarsLoadScan); + //把carsLoadScanEntities中所有元素的scanCode放入一个Set集合 + Set scanCodeSet = carsLoadScanEntities.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toSet()); + + log.info("###############adnormalHasStock: 当前同步的数据 {}",scanCodeSet); + + List scanCodeList = new ArrayList<>(scanCodeSet); + + List allAdvanceDetailList = new ArrayList<>(); + + int packageBatchSize = 500; + List> orderPackageCodeGroups = new ArrayList<>(); + + for (int i = 0; i < scanCodeList.size(); i += packageBatchSize) { + int endIndex = Math.min(i + packageBatchSize, scanCodeList.size()); + orderPackageCodeGroups.add(scanCodeList.subList(i, endIndex)); + } + + orderPackageCodeGroups.forEach(orderPackageCodeGroup -> { + List advanceDetailEntityList = trunklineAdvanceDetailService.findListByOrderPackageCodeList(orderPackageCodeGroup); + allAdvanceDetailList.addAll(advanceDetailEntityList); + }); + + //把allAdvanceDetailList转化成orderPackageCode为key的Map + Map advanceDetailMap = allAdvanceDetailList.stream().collect(Collectors.toMap(TrunklineAdvanceDetailEntity::getOrderPackageCode, Function.identity())); + + List updateScanList = new ArrayList<>(); + List incomingAdvanceDetailList = new ArrayList<>(); + List udateAdvanceDetailList = new ArrayList<>(); + Set orderPackageCodeSet = new HashSet<>(); + + carsLoadScanEntities.forEach(carsLoadScanEntity -> { + String orderPackageCode = carsLoadScanEntity.getScanCode(); + TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = advanceDetailMap.get(orderPackageCode); + if(!Objects.isNull(trunklineAdvanceDetailEntity)){ + orderPackageCodeSet.add(orderPackageCode); + TrunklineCarsLoadScanEntity updateScanEntity = new TrunklineCarsLoadScanEntity(); + updateScanEntity.setId(carsLoadScanEntity.getId()); + + String packageStatus = trunklineAdvanceDetailEntity.getPackageStatus(); + if(packageStatus.equals("0")){ + updateScanEntity.setFromWarehouseId(trunklineAdvanceDetailEntity.getWarehouseId()); + incomingAdvanceDetailList.add(trunklineAdvanceDetailEntity); }else{ - Integer unbingTray = 0; - if(StringUtil.isNotBlank(trayCode)){ - unbingTray = 1; - } - unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null); + updateScanEntity.setFromWarehouseId(trunklineAdvanceDetailEntity.getNowWarehouseId()); + udateAdvanceDetailList.add(trunklineAdvanceDetailEntity); } + updateScanEntity.setOrderCode(trunklineAdvanceDetailEntity.getOrderCode()); + updateScanEntity.setWaybillId(trunklineAdvanceDetailEntity.getWaybillId()); + updateScanEntity.setWaybillNo(trunklineAdvanceDetailEntity.getWaybillNo()); + updateScanEntity.setIsData(1); + updateScanList.add(updateScanEntity); } - }else{ - Integer unbingTray = 0; - if(StringUtil.isNotBlank(trayCode)){ - unbingTray = 1; + }); + + if(CollUtil.isNotEmpty(incomingAdvanceDetailList)){ + + for (TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity : incomingAdvanceDetailList) { + InComingDTO inComingDTO = new InComingDTO(); + inComingDTO.setOrderPackageCode(trunklineAdvanceDetailEntity.getOrderPackageCode()); + inComingDTO.setIncomingType(IncomingTypeEnum.SYNC_INCOMING.getCode()); + inComingDTO.setWarehouseId(warehouseId); + R r = inComingService.incomingPackage(inComingDTO); + if(r.getCode() != 200){ + throw new CustomerException(405,"入库失败"); + } } - //零担 - unloadZeroNoXz(loadId,waybillNo,num,warehouseId,unbingTray,trayCode,orderCode,"异常列表入库"); + } + + if(CollUtil.isNotEmpty(udateAdvanceDetailList)){ + List updateParceList = new ArrayList<>(); + udateAdvanceDetailList.forEach(trunklineAdvanceDetailEntity -> { + String orderPackageCode = trunklineAdvanceDetailEntity.getOrderPackageCode(); + List list = distributionParcelListClient.findListByOrderPackageCodeAndStatus(orderPackageCode,"20"); + //把list通过warehouseId进行分组 + + if(CollUtil.isNotEmpty(list)){ + list.forEach(distributionParcelListEntity -> { + DistributionParcelListEntity updateEntity = new DistributionParcelListEntity(); + updateEntity.setId(distributionParcelListEntity.getId()); + updateEntity.setOrderPackageStatus("60"); + updateEntity.setOrderCode(distributionParcelListEntity.getOrderCode()); + updateEntity.setWarehouseId(distributionParcelListEntity.getWarehouseId()); + updateParceList.add(updateEntity); + }); + } + + }); + distributionParcelListClient.updateList(updateParceList); + + advanceService.saveOrderAndPackages(udateAdvanceDetailList, warehouseId); + + List updateNowWarehouseList = new ArrayList<>(); + udateAdvanceDetailList.forEach(trunklineAdvanceDetailEntity -> { + TrunklineAdvanceDetailEntity updateEntity = new TrunklineAdvanceDetailEntity(); + updateEntity.setId(trunklineAdvanceDetailEntity.getId()); + updateEntity.setNowWarehouseId(warehouseId); + updateEntity.setNowWarehouseName(warehouseName); + updateNowWarehouseList.add(updateEntity); + }); + + trunklineAdvanceDetailService.updateBatchById(updateNowWarehouseList); + } + + trunklineCarsLoadScanService.updateBatchById(updateScanList); + int i= 0; + + //完结所有包件异常列表 + if(CollUtil.isNotEmpty(orderPackageCodeSet)){ + i = orderPackageCodeSet.size(); + DealWithAbnormalVO dealWithAbnormalVO = new DealWithAbnormalVO(); + dealWithAbnormalVO.setOrderPackageCodes(new ArrayList<>(orderPackageCodeSet)); + dealWithAbnormalVO.setCarsNo(loadCode); + dealWithAbnormalVO.setWarehouseName(warehouseName); + dealWithAbnormalVO.setNickName(AuthUtil.getNickName()); + dealWithAbnormalVO.setRemark("数据同步系统自动处理("+warehouseName+" "+loadCode+" "+AuthUtil.getNickName()+")"); + abnormalRecordClient.dealwithOrderPackageCodes(dealWithAbnormalVO); } + + + +// if(type==1){ +// //包件 +// DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(scanCode, warehouseId); +// if(Objects.isNull(parcelListEntity)){ +// log.info("#########adnormalHasStock: 包件信息不存在"); +// Integer unbingTray = 0; +// if(StringUtil.isNotBlank(trayCode)){ +// unbingTray = 1; +// } +// unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null); +// }else{ +// String orderPackageStatus = parcelListEntity.getOrderPackageStatus(); +// if("20".equals(orderPackageStatus)){ +// log.warn("#########adnormalHasStock: 包件已入库 scanCode={} warehouseId={}",scanCode,warehouseId); +// return R.success("包件已入库"); +// }else{ +// Integer unbingTray = 0; +// if(StringUtil.isNotBlank(trayCode)){ +// unbingTray = 1; +// } +// unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null); +// } +// } +// }else{ +// Integer unbingTray = 0; +// if(StringUtil.isNotBlank(trayCode)){ +// unbingTray = 1; +// } +// //零担 +// unloadZeroNoXz(loadId,waybillNo,num,warehouseId,unbingTray,trayCode,orderCode,"异常列表入库"); +// +// } return R.success("入库成功"); } @@ -12631,6 +12763,9 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl