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 01cf81395..415ed3bd2 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 @@ -229,6 +229,14 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl reservationZeroPackageEntities = distributionReservationZeroPackageService.list(Wrappers.query().lambda() + .in(DistributionReservationZeroPackageEntity::getReservationId, reservationIds) + .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) + ); + + + Map> packageMap; if (Func.isNotEmpty(distributionParcelListEntities)){ packageMap = distributionParcelListEntities.stream().collect(Collectors.groupingBy(DistributionParcelListVO::getReservationId)); @@ -241,6 +249,12 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl> zeroPackageMap ; + if (Func.isNotEmpty(reservationZeroPackageEntities)){ + zeroPackageMap = reservationZeroPackageEntities.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getReservationId)); + }else { + zeroPackageMap = null; + } distributionSignforVOS.forEach(d -> { if (d.getDeliveryType().equals(DistributionTypeConstant.shipie.getValue())) { @@ -259,20 +273,57 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl distributionParcelListVOS = packageMap.get(d.getReservationId()); - List listDetailEntityList = inventoryMap.get(d.getReservationId()); - if (Func.isNotEmpty(listDetailEntityList) ) { - zhuangchejianshu += listDetailEntityList.stream().filter(f -> f.getStockLockingStatus().equals(InventoryLoadingStatusConstant.yizhuangche.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); + if (Func.isNotEmpty(packageMap)){ + List distributionParcelListVOS = packageMap.get(d.getReservationId()); + if (Func.isNotEmpty(distributionParcelListVOS)) { + weizhuangchejianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + zhuangchejianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + weiqianshoujianshu += distributionParcelListVOS.stream().filter(f -> !f.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + qianshoujianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + } + } + if (Func.isNotEmpty(zeroPackageMap)){ + List zeroPackageEntities = zeroPackageMap.get(d.getReservationId()); + if (Func.isNotEmpty(zeroPackageEntities)) { + List zeroPackageIds = zeroPackageEntities.stream().map(DistributionReservationZeroPackageEntity::getParcelListId).collect(Collectors.toList()); + //查询这些单子的装车信息 + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() + .eq(DistributionLoadscanEntity::getReservationId, d.getReservationId()) + .in(DistributionLoadscanEntity::getPackageId, zeroPackageIds) + .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) + ); + //此预约单的零担计划总数 + int sum = zeroPackageEntities.stream().mapToInt(DistributionReservationZeroPackageEntity::getQuantity).sum(); + if (loadscanEntityList.isEmpty()){ + //统计装车 + int loadingNum = loadscanEntityList.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum(); + //统计签收 + int signforNUm = loadscanEntityList.stream().filter(f -> LoadScanSigningStatusConstant.yiqianshou.getValue().equals(f.getSignforState())).mapToInt(DistributionLoadscanEntity::getReceivedQuantity).sum(); + + //计算未装车 + weizhuangchejianshu += (sum - loadingNum); + zhuangchejianshu += loadingNum; + //计算未签收 + weiqianshoujianshu += (sum - signforNUm); + qianshoujianshu += signforNUm; + + } + } + } + if (Func.isNotEmpty(inventoryMap)){ + List listDetailEntityList = inventoryMap.get(d.getReservationId()); + if (Func.isNotEmpty(listDetailEntityList) ) { + zhuangchejianshu += listDetailEntityList.stream().filter(f -> f.getStockLockingStatus().equals(InventoryLoadingStatusConstant.yizhuangche.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); // weizhuangchejianshu += list.stream().filter(f -> f.getStockLockingStatus().equals(InventoryLoadingStatusConstant.weizhuangche.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); - qianshoujianshu += listDetailEntityList.stream().filter(f -> f.getStockSignfoStatus().equals(InventorySigningStatusConstant.yiqianshou.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); + qianshoujianshu += listDetailEntityList.stream().filter(f -> f.getStockSignfoStatus().equals(InventorySigningStatusConstant.yiqianshou.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); // weiqianshoujianshu += list.stream().filter(f -> f.getStockSignfoStatus().equals(InventorySigningStatusConstant.weiqianshou.getValue())).mapToInt(DisStockListDetailEntity::getNum).sum(); + } } - if (Func.isNotEmpty(distributionParcelListVOS)) { - weizhuangchejianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); - zhuangchejianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); - weiqianshoujianshu += distributionParcelListVOS.stream().filter(f -> !f.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); - qianshoujianshu += distributionParcelListVOS.stream().filter(f -> f.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); - } + + + + + //该客户的异常装车件数 Integer abnormalLoading = distributionLoadscanMapper.selectAbnormalLoadingByReservationId(d.getReservationId()); //该客户的异常签收件数