diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java index cf33908b4..884c71bb2 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java @@ -57,6 +57,15 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl idArray = Arrays.asList(ids.split(",")); QueryWrapper wrapper = new QueryWrapper(); @@ -66,6 +75,7 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl list = baseMapper.selectList(wrapper); List data = new ArrayList<>(); + List carNumberList = new ArrayList<>(); for (BusinessPreOrderEntity distributionBusinessPreOrderEntity : list) { if (distributionBusinessPreOrderEntity.getInWarehouse() == 1) { @@ -76,10 +86,19 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl1){ + throw new ServiceException("不能同时操作多个车次"); } BusinessSanDTO businessSanDTO = new BusinessSanDTO(); businessSanDTO.setOrderPackageCode(sb.toString()); + businessSanDTO.setInWarehouseException(0); + businessSanDTO.setDistrCarNumber(carNumberList.get(0)); R r = inOrderWarehourse(businessSanDTO); if (r.isSuccess()) { // 更新成功 @@ -281,7 +300,8 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl selectDistributionDeliveryInfowrapPage(Map reservationPackageDTO,IPage page); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryInfoServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryInfoServiceImpl.java index 7a799b6e2..21970c548 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryInfoServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryInfoServiceImpl.java @@ -98,73 +98,122 @@ public class DistributionDeliveryInfoServiceImpl extends BaseServiceImpl selectDistributionDeliveryInfowrapPage(Map reservationPackageDTO, IPage page) { - if (Func.isEmpty(reservationPackageDTO.get("reservationId"))) { + // 参数非空校验 + if (reservationPackageDTO == null || page == null) { + throw new IllegalArgumentException("ReservationPackageDTO and page cannot be null"); + } + + // reservationId的数据类型转换安全性校验 + String reservationIdStr = (String) reservationPackageDTO.get("reservationId"); + if (Func.isEmpty(reservationIdStr)) { return null; } + long reservationId; + try { + reservationId = Long.parseLong(reservationIdStr); + } catch (NumberFormatException e) { + log.error("Invalid reservationId format: {}", reservationIdStr, e); + throw new IllegalArgumentException("Invalid reservationId format"); + } + // 逻辑保持不变,优化了数据类型转换的安全性检查 if (Func.isNotEmpty(reservationPackageDTO.get("orderPackageStatus"))) { String orderPackageStatus = (String) reservationPackageDTO.get("orderPackageStatus"); - if (Func.isNotBlank(orderPackageStatus)) { - if (!"70".equals(orderPackageStatus)) { - reservationPackageDTO.put("unSigning", "70"); - reservationPackageDTO.remove("orderPackageStatus"); - } + if (Func.isNotBlank(orderPackageStatus) && !"70".equals(orderPackageStatus)) { + reservationPackageDTO.put("unSigning", "70"); + reservationPackageDTO.remove("orderPackageStatus"); } } + List parcelListEntityList = baseMapper.selectDistributionDeliverywrapInfoPage(page, reservationPackageDTO); + + Set ids = new HashSet<>(); + Set orderPackageCodes = new HashSet<>(); + + for (DistributionParcelListEntity distributionParcelListEntity : parcelListEntityList) { + ids.add(distributionParcelListEntity.getId()); + orderPackageCodes.add(distributionParcelListEntity.getOrderPackageCode()); + } + List parcelListVOS = DistributionParcelListWrapper.build().listVO(parcelListEntityList); - parcelListVOS.forEach(p -> { - //查询扫描表, - DistributionLoadscanEntity loadscanEntity = distributionLoadscanService.getOne(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getPackageId, p.getId()) - .eq(DistributionLoadscanEntity::getReservationId, Long.parseLong((String) reservationPackageDTO.get("reservationId"))) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, p.getOrderPackageCode()) - ); - if (Func.isNotEmpty(loadscanEntity)) { - try { - p.setLoadingTime(loadscanEntity.getScanTime()); - switch (loadscanEntity.getScanStatus()) { - case "1": - p.setScanStatus(LoadingStatusConstant.quxiao.getName()); - break; - case "2": - p.setScanStatus(LoadingStatusConstant.saomiao.getName()); - break; - case "3": - p.setScanStatus(LoadingStatusConstant.queren.getName()); - break; - case "4": - p.setScanStatus(LoadingStatusConstant.yijianzhuangche.getName()); - break; - case "5": - p.setScanStatus(LoadingStatusConstant.buluzhuangche.getName()); - break; - default: - log.info("selectDistributionDeliveryInfowrapPage >>>loadscanEntity.getScanStatus() 不满足匹配条件 {}",loadscanEntity.getScanStatus()); - break; - } - if (Func.isNotEmpty(loadscanEntity.getSigningTime())) { - p.setSigningTime(loadscanEntity.getSigningTime()); - } - if (Func.isNotEmpty(loadscanEntity.getScanUser())) { - p.setScanUser(loadscanEntity.getScanUser()); - } - if (Func.isNotEmpty(loadscanEntity.getDriverName())) { - p.setDriverName(loadscanEntity.getDriverName()); - } - if (Func.isNotEmpty(loadscanEntity.getSigningUser())) { - p.setSigningUser(loadscanEntity.getSigningUser()); - } - } catch (Exception e) { - log.error(">>> 系统异常",e); - throw new CustomerException("系统异常,请联系管理员"); - } - } - }); + + // 保持不变,优化性能需要注意的是ids和orderPackageCodes的处理 + List loadscanEntitys = distributionLoadscanService.list(Wrappers.query().lambda() + .in(DistributionLoadscanEntity::getPackageId, ids) + .eq(DistributionLoadscanEntity::getReservationId, reservationId) + .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) + .in(DistributionLoadscanEntity::getOrderPackageCode, orderPackageCodes) + ); + + // 对加载的VO列表进行处理的逻辑抽取到一个独立的方法 + processParcelListVOS(parcelListVOS, loadscanEntitys, reservationIdStr); + return page.setRecords(parcelListVOS); } + private void processParcelListVOS(List parcelListVOS, List loadscanEntitys, String reservationIdStr) { + parcelListVOS.forEach(p -> { + DistributionLoadscanEntity loadscanEntity = getLoadscanEntity(loadscanEntitys, p); + if (Func.isNotEmpty(loadscanEntity)) { + try { + updateParcelStatus(p, loadscanEntity); + } catch (Exception e) { + log.error("Processing parcel failed for reservationId: {}, Error: {}", reservationIdStr, e.getMessage(), e); + throw new CustomerException("Processing parcel failed. Please contact administrator"); + } + } + }); +} + + private void updateParcelStatus(DistributionParcelListVO parcel, DistributionLoadscanEntity loadscanEntity) { + parcel.setLoadingTime(loadscanEntity.getScanTime()); + switch (loadscanEntity.getScanStatus()) { + case "1": + parcel.setScanStatus(LoadingStatusConstant.quxiao.getName()); + break; + case "2": + parcel.setScanStatus(LoadingStatusConstant.saomiao.getName()); + break; + case "3": + parcel.setScanStatus(LoadingStatusConstant.queren.getName()); + break; + case "4": + parcel.setScanStatus(LoadingStatusConstant.yijianzhuangche.getName()); + break; + case "5": + parcel.setScanStatus(LoadingStatusConstant.buluzhuangche.getName()); + break; + default: + log.info("loadscanEntity.getScanStatus() does not meet matching conditions: {}", loadscanEntity.getScanStatus()); + break; + } + if (Func.isNotEmpty(loadscanEntity.getSigningTime())) { + parcel.setSigningTime(loadscanEntity.getSigningTime()); + } + if (Func.isNotEmpty(loadscanEntity.getScanUser())) { + parcel.setScanUser(loadscanEntity.getScanUser()); + } + if (Func.isNotEmpty(loadscanEntity.getDriverName())) { + parcel.setDriverName(loadscanEntity.getDriverName()); + } + if (Func.isNotEmpty(loadscanEntity.getSigningUser())) { + parcel.setSigningUser(loadscanEntity.getSigningUser()); + } +} + + + + + private DistributionLoadscanEntity getLoadscanEntity(List loadscanEntitys, DistributionParcelListVO p) { + for (DistributionLoadscanEntity loadscanEntity : loadscanEntitys) { + if(loadscanEntity.getPackageId().equals(p.getId())&& loadscanEntity.getOrderPackageCode().equals(p.getOrderPackageCode())){ + return loadscanEntity; + } + } + return null; + + } + @Override public IPage selectDistributionDeliveryInfopackdetail(IPage page, DistributionDeliveryInfoDTO distributionDeliveryInfoDTO) { List distributionDeliveryInfoVOS = baseMapper.selectDistributionDeliverypackdetailPage(page, distributionDeliveryInfoDTO); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index f1082c71a..4f95819d7 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -2687,9 +2687,14 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl>>> 签收推送报错",e); + } @@ -2963,6 +2968,19 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl>>> 签收推送报错",e); + } + } else { //一个客户下出现重复包条码 log.error("############出现重复包条码:{}", collect);