diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionDeliveryListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionDeliveryListClient.java index 82b66a7e5..64d375214 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionDeliveryListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionDeliveryListClient.java @@ -69,13 +69,35 @@ public interface IDistributionDeliveryListClient { * @param deliveryId * @param reservationId * @param orderPackageId - * @param conditions 1-订制品 2-库存 + * @param conditions * @return */ @GetMapping(TOP+"/retentionDeliveryReservationPackage") boolean retentionDeliveryReservationPackage(@RequestParam("deliveryId")Long deliveryId,@RequestParam("reservationId") Long reservationId,@RequestParam("orderPackageId") Long orderPackageId,@RequestParam("conditions") Integer conditions); + /** + * 配送任务滞留库存品 + * @param deliveryId + * @param reservationId + * @param orderPackageId + * + */ + @GetMapping(TOP+"/retentionDeliveryReservationInventory") + boolean retentionDeliveryReservationInventory(@RequestParam("deliveryId")Long deliveryId,@RequestParam("reservationId") Long reservationId,@RequestParam("orderPackageId") Long orderPackageId); + + /** + * 滞留取消零担包件 + * @param deliveryId + * @param reservationId + * @param orderPackageId + * @param retentionQuantity + * @return + */ + @GetMapping(TOP+"/retentionDeliveryReservationZeroPackage") + boolean retentionDeliveryReservationZeroPackage(@RequestParam("deliveryId")Long deliveryId,@RequestParam("reservationId") Long reservationId,@RequestParam("orderPackageId") Long orderPackageId, @RequestParam("retentionQuantity")Integer retentionQuantity, @RequestParam("orderId")Long orderId); + + // /** // * 根据配送任务ID查询配送司机信息 // * @param distributionRetentionScanVo diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionDeliveryListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionDeliveryListClient.java index ef5fe932c..3a97fc1b3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionDeliveryListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionDeliveryListClient.java @@ -65,9 +65,16 @@ public class DistributionDeliveryListClient implements IDistributionDeliveryList return distributionDeliveryListService.retentionDeliveryReservationPackage(deliveryId,reservationId,orderPackageId,conditions); } -// @Override -// public void retentionCancelDeliveryPack(DistributionRetentionScanVo distributionRetentionScanVo) { -// distributionDeliveryListService.retentionCancelDeliveryPack(distributionRetentionScanVo); -// } + @Override + public boolean retentionDeliveryReservationInventory(Long deliveryId, Long reservationId, Long orderPackageId) { + return distributionDeliveryListService.retentionDeliveryReservationInventory(deliveryId,reservationId,orderPackageId); + + } + + @Override + public boolean retentionDeliveryReservationZeroPackage(Long deliveryId, Long reservationId, Long orderPackageId, Integer retentionQuantity,Long orderId) { + return distributionDeliveryListService.retentionDeliveryReservationZeroPackage(deliveryId,reservationId,orderPackageId,retentionQuantity,orderId); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java index d710fa0ff..f9f9cfc46 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java @@ -429,6 +429,12 @@ public interface DistributionDeliveryListMapper extends BaseMapper selectRetentionZeroPackage(@Param("deliveryId")Long deliveryId, @Param("orderCode")String barcode); /** diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.xml index 69cbe885b..c41573b4b 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.xml @@ -1607,6 +1607,8 @@ WHERE ldrs.stock_article_id = #{orderId} AND lddl.id=#{deliveryListId} and ldrs.stock_article_status in ('1','3') AND ldrzp.zero_package_status IN ( '1', '3' ) + + @@ -1139,5 +1151,39 @@ LEFT JOIN logpm_distribution_delivery_list AS lddl ON lds.delivery_id = lddl.id AND lddl.is_deleted = 0 WHERE lds.reservation_id =#{reservationId} AND lds.is_deleted = 0 + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSigndetailMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSigndetailMapper.xml index b41fe0044..f15b56997 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSigndetailMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSigndetailMapper.xml @@ -142,7 +142,7 @@ JOIN logpm_distribution_stock_article ldsa ON ldrs.stock_article_id = ldsa.id join logpm_distribution_reservation_package ldrp on ldr.id = ldrp.reservation_id - lds.is_deleted = 0 + lds.is_deleted = 0 and ldr.is_deleted = 0 and ldr.service_number like concat('%',#{param.serviceNumber},'%') diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.java index 0addf16c9..e796b9823 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionSignforMapper.java @@ -266,4 +266,22 @@ public interface DistributionSignforMapper extends BaseMapper UPDATE logpm_distribution_signfor lds set lds.receivedin_quantity = ( lds.receivedin_quantity + #{packageNub} ) WHERE lds.is_deleted =0 and lds.reservation_id = #{reservationId} and lds.delivery_id =#{deliveryId} + + UPDATE logpm_distribution_signfor lds set lds.loaded_number = ( lds.loaded_number - #{nub} ) WHERE lds.is_deleted =0 and lds.reservation_id = #{reservationId} and loaded_number !=0 and lds.delivery_id = #{deliveryId} + + + UPDATE logpm_distribution_signfor lds set lds.loadedin_number = ( lds.loadedin_number - #{nub} ) WHERE lds.is_deleted =0 and lds.reservation_id = #{reservationId} and loadedin_number !=0 and lds.delivery_id = #{deliveryId} + DELETE FROM logpm_distribution_signfor @@ -326,7 +332,7 @@ JOIN logpm_distribution_delivery_list lddl ON lddl.id = lds.delivery_id JOIN logpm_distribution_reservation ldr ON ldr.id = lds.reservation_id - lds.is_deleted = 0 + lds.is_deleted = 0 and ldr.is_deleted = 0 and ldr.mall_name like concat('%',#{param.mallName},'%') @@ -445,7 +451,7 @@ JOIN logpm_distribution_delivery_list lddl ON lddl.id = lds.delivery_id JOIN logpm_distribution_reservation ldr ON ldr.id = lds.reservation_id - lds.is_deleted = 0 and lds.driver_signing ='1' + lds.is_deleted = 0 and lds.driver_signing ='1' and ldr.is_deleted = 0 and ldr.mall_name like concat('%',#{param.mallName},'%') @@ -491,7 +497,7 @@ JOIN logpm_distribution_delivery_list lddl ON lddl.id = lds.delivery_id JOIN logpm_distribution_reservation ldr ON ldr.id = lds.reservation_id - lds.is_deleted = 0 and lds.signing_status ='1' + lds.is_deleted = 0 and lds.signing_status ='1' and ldr.is_deleted = 0 and ldr.mall_name like concat('%',#{param.mallName},'%') diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java index 810ede52a..815e494a8 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionAsyncService.java @@ -235,4 +235,19 @@ public interface IDistributionAsyncService { * @param deliveryId */ void checkSignStatus(Long packageId, Long reservationId, Long deliveryId); + + /** + * 维护滞留之后预约和包件的数量状态 + * @param reservationId + * @param deliveryId + */ + void checkRetentionReservationAndDeliveryInfo(Long reservationId, Long deliveryId); + + /** + * 取消滞留库存品包件信息并维护预约单数量信息 + * @param reservationId + * @param deliveryId + * @param orderPackageId + */ + void checkRetentionInventoryReservationAndDeliveryInfo(Long reservationId, Long deliveryId, Long orderPackageId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java index de4d7c393..b5f01bd33 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java @@ -334,6 +334,25 @@ public interface IDistributionDeliveryListService extends BaseService distributionParcelListEntities = distributionParcelListMapper.selectList(Wrappers.query().lambda() .eq(DistributionParcelListEntity::getStockArticleId, id) ); int sum = distributionParcelListEntities.stream().filter(i -> i.getOrderPackageStockupStatus().equals(OrderPackageStockupStatusConstant.daibeihuo.getValue())).collect(Collectors.toList()).stream().mapToInt(DistributionParcelListEntity::getQuantity).sum(); - if(sum == 0 && byId.getStockupStatus().equals(OrderStockupStatusConstant.bufenbeihuo.getValue())){ + if (sum == 0 && byId.getStockupStatus().equals(OrderStockupStatusConstant.bufenbeihuo.getValue())) { byId.setStockupStatus(OrderStockupStatusConstant.yibeihu.getValue()); boolean b = distributionStockArticleService.updateById(byId); - log.debug("###执行结果={}",b); + log.debug("###执行结果={}", b); } } } /** * 修改包件预约状态 + * * @param ids 订单ID */ @Async @Override public void updateParcelListReservation(List ids) { log.debug("####修改包件预约状态"); - ids.stream().forEach( i ->{ + ids.stream().forEach(i -> { DistributionParcelListEntity distributionParcelListEntity = new DistributionParcelListEntity(); distributionParcelListEntity.setId(i); distributionParcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); int i1 = distributionParcelListMapper.updateById(distributionParcelListEntity); - log.debug("####修改包件预约数量===={}",i1); + log.debug("####修改包件预约数量===={}", i1); }); } @@ -359,7 +362,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { @Async @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED, rollbackFor = Exception.class) - public void changeMarketDeliveryListStatus(String barcode, Long deliveryId,Long reservationId) { + public void changeMarketDeliveryListStatus(String barcode, Long deliveryId, Long reservationId) { //查询库存品 DisStockListDetailEntity loadingInventoryDetail = distributionDeliveryListMapper.getLoadingInventoryDetail(barcode, deliveryId); @@ -399,7 +402,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { log.error("####库存品记录错误+{" + reservationStockarticleEntityList + "}"); return; } - checkReservationAndDeliveryLoadingStatus(deliveryId,reservationId); + checkReservationAndDeliveryLoadingStatus(deliveryId, reservationId); } @Async @@ -515,12 +518,12 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { if (inventorySigningFlag && reservationSigningFlag) { r.setSigningStatus(ReservationSigningStatusConstant.yiqianshou.getValue()); } else { - inventorySigningFlag = distributionReservationStocklistEntities.stream().allMatch(i -> !i.getSigningStatus().equals(ReservationInventorySigningStatusConstant.yiqianshou.getValue())); - reservationSigningFlag = parcelListEntities.stream().allMatch(p -> !p.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())); - if (inventorySigningFlag && reservationSigningFlag){ + inventorySigningFlag = distributionReservationStocklistEntities.stream().allMatch(i -> !i.getSigningStatus().equals(ReservationInventorySigningStatusConstant.yiqianshou.getValue())); + reservationSigningFlag = parcelListEntities.stream().allMatch(p -> !p.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())); + if (inventorySigningFlag && reservationSigningFlag) { r.setSigningStatus(ReservationSigningStatusConstant.daiqianshou.getValue()); - }else { + } else { r.setSigningStatus(ReservationSigningStatusConstant.bufenqianshou.getValue()); } } @@ -562,24 +565,24 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //查询一个配送任务下的所有客户 List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(deliveryId); boolean loadingStatusFlag = reservationEntityList.stream().allMatch(r -> r.getLoadingStatus().equals(ReservationLoadingStatusConstant.yizhuangche.getValue())); - if (loadingStatusFlag){ + if (loadingStatusFlag) { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.yizhuangche.getValue()); - }else { + } else { loadingStatusFlag = reservationEntityList.stream().allMatch(r -> r.getLoadingStatus().equals(ReservationLoadingStatusConstant.daizhuangche.getValue())); - if (loadingStatusFlag){ + if (loadingStatusFlag) { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.weizhuangche.getValue()); - }else { + } else { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.bunfenzhuangche.getValue()); } } boolean signingStatusFlag = reservationEntityList.stream().allMatch(r -> r.getSigningStatus().equals(ReservationSigningStatusConstant.yiqianshou.getValue())); - if (signingStatusFlag){ + if (signingStatusFlag) { deliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.yiwancheng.getValue()); - }else { + } else { loadingStatusFlag = reservationEntityList.stream().allMatch(r -> r.getLoadingStatus().equals(ReservationSigningStatusConstant.daiqianshou.getValue())); - if (loadingStatusFlag){ + if (loadingStatusFlag) { deliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.daipeisong.getValue()); - }else { + } else { deliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.peisongzhong.getValue()); } } @@ -589,14 +592,15 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { /** * 判断包件是否该下架 + * * @param stockupDTO */ @Async @Override public void stockupSelfOffShelf(StockupDTO stockupDTO) throws InterruptedException { BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); - if(Objects.isNull(myCurrentWarehouse)){ - throw new CustomerException(403,"仓库信息不能为空"); + if (Objects.isNull(myCurrentWarehouse)) { + throw new CustomerException(403, "仓库信息不能为空"); } //判断类型 @@ -613,7 +617,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //有 List collectY = distributionStockupSelfVO.stream().filter(o -> ObjectUtils.isNotNull(o.getAllocationId())).collect(Collectors.toList()); collectY.stream().collect(Collectors.groupingBy(DistributionStockupSelfVO::getAllocationId)) - .forEach( (k,v) -> { + .forEach((k, v) -> { List list = new ArrayList<>(); AtomicInteger a = new AtomicInteger(); AtomicInteger b = new AtomicInteger(); @@ -629,11 +633,11 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { if (a.get() == b.get()) { //下架 list.forEach(i -> { - warehouseUpdownTypeClient.downPackage(i,myCurrentWarehouse.getId()); + warehouseUpdownTypeClient.downPackage(i, myCurrentWarehouse.getId()); }); } - } ); + }); //没有 /*List collectW = distributionStockupSelfVO.stream().filter(o -> ObjectUtils.isNull(o.getAllocationId())).collect(Collectors.toList()); @@ -660,21 +664,21 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { @Override @Transactional - public void checkLoadingByPackage(DistributionParcelListEntity parcelListEntity, Long deliveryId,Long reservationId) { - if (Func.isEmpty(parcelListEntity)){ - log.error("############包件信息异常:{}",parcelListEntity); + public void checkLoadingByPackage(DistributionParcelListEntity parcelListEntity, Long deliveryId, Long reservationId) { + if (Func.isEmpty(parcelListEntity)) { + log.error("############包件信息异常:{}", parcelListEntity); throw new RuntimeException("包件信息异常"); } //维护包件所属订单是否均已完成装车,如果均已完成装车则订单进行装车状态的修改 - if (parcelListEntity.getConditions() != 2){ + if (parcelListEntity.getConditions() != 2) { DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); //查询出该订单的装车件数 Integer orderLoadingNum = distributionLoadscanMapper.selectOrderLoadingNum(stockArticleEntity.getId()); - if (Func.isNotEmpty(orderLoadingNum) && orderLoadingNum > 0){ + if (Func.isNotEmpty(orderLoadingNum) && orderLoadingNum > 0) { //存在装车数量,需要对装车数量进行判定 - if (orderLoadingNum == stockArticleEntity.getTotalNumber()){ + if (orderLoadingNum == stockArticleEntity.getTotalNumber()) { stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); - }else { + } else { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); } distributionStockArticleService.updateById(stockArticleEntity); @@ -689,34 +693,34 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //判断客户是否完成装车 DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(reservationId); int reservationPackageTotal = distributionReservationEntity.getReservationNum() + distributionReservationEntity.getReservationStockListNum(); - if (reservationPackageTotal!=0){ - DistributionLoadingNumDTO reservationLoadingNum = distributionReservationMapper.selectReservationLoadingNum(distributionReservationEntity.getId()); - if (Func.isNotEmpty(reservationLoadingNum)){ - int reservationLoadingQuantity = reservationLoadingNum.getPackageLoadingQuantity()+reservationLoadingNum.getInventoryLoadingQuantity(); - if (reservationLoadingQuantity == reservationPackageTotal){ + if (reservationPackageTotal != 0) { + DistributionLoadingNumDTO reservationLoadingNum = distributionReservationMapper.selectReservationLoadingNum(distributionReservationEntity.getId()); + if (Func.isNotEmpty(reservationLoadingNum)) { + int reservationLoadingQuantity = reservationLoadingNum.getPackageLoadingQuantity() + reservationLoadingNum.getInventoryLoadingQuantity(); + if (reservationLoadingQuantity == reservationPackageTotal) { distributionReservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.yizhuangche.getValue()); - }else { + } else { distributionReservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.bufenzhuangche.getValue()); } distributionReservationMapper.updateById(distributionReservationEntity); } - }else { + } else { log.error("##########查询客户配送数量为0"); } DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(deliveryId); int deliveryPackageTotal = distributionDeliveryListEntity.getDeliveryNumber(); - if (deliveryPackageTotal!=0){ + if (deliveryPackageTotal != 0) { DistributionLoadingNumDTO deliveryLoadingNum = distributionDeliveryListMapper.selectDeliveryLoadingNum(distributionDeliveryListEntity.getId()); - if (Func.isNotEmpty(deliveryLoadingNum)){ - int deliveryLoadingQuantity = deliveryLoadingNum.getPackageLoadingQuantity()+deliveryLoadingNum.getInventoryLoadingQuantity(); - if (deliveryPackageTotal == deliveryLoadingQuantity){ + if (Func.isNotEmpty(deliveryLoadingNum)) { + int deliveryLoadingQuantity = deliveryLoadingNum.getPackageLoadingQuantity() + deliveryLoadingNum.getInventoryLoadingQuantity(); + if (deliveryPackageTotal == deliveryLoadingQuantity) { distributionDeliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.yizhuangche.getValue()); - }else { + } else { distributionDeliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.bunfenzhuangche.getValue()); } distributionDeliveryListMapper.updateById(distributionDeliveryListEntity); } - }else { + } else { log.error("##########查询客户配送数量为0"); } } @@ -798,62 +802,61 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { // } - // } @Override public void checkLoadingByDelivery(Long deliveryId) { DistributionDeliveryListEntity deliveryListEntity = distributionDeliveryListMapper.selectById(deliveryId); - if (Func.isNotEmpty(deliveryListEntity)){ + if (Func.isNotEmpty(deliveryListEntity)) { List deliveryParcelListEntities = distributionDeliveryListMapper.selectPackageListByDeliveryListId(deliveryId); - boolean deliveryLoadingFlag = deliveryParcelListEntities.stream().allMatch(p->p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - if (deliveryLoadingFlag){ + boolean deliveryLoadingFlag = deliveryParcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); + if (deliveryLoadingFlag) { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.yizhuangche.getValue()); - }else { - deliveryLoadingFlag = deliveryParcelListEntities.stream().allMatch(p->p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())); - if (deliveryLoadingFlag){ + } else { + deliveryLoadingFlag = deliveryParcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())); + if (deliveryLoadingFlag) { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.weizhuangche.getValue()); - }else { + } else { deliveryListEntity.setDeliveryListLoadingStatus(DeliveryLoadingStatusConstant.bunfenzhuangche.getValue()); } } distributionDeliveryListMapper.updateById(deliveryListEntity); } List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(deliveryId); - if (Func.isNotEmpty(reservationEntityList) && reservationEntityList.size()>0){ + if (Func.isNotEmpty(reservationEntityList) && reservationEntityList.size() > 0) { for (DistributionReservationEntity reservationEntity : reservationEntityList) { List parcelListEntities = distributionReservationMapper.selectPackageListByReservationId(reservationEntity.getId()); Map> order = parcelListEntities.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getStockArticleId)); - order.forEach((k,v)->{ + order.forEach((k, v) -> { DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(k); List stockArticlePackageList = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, k)); - if (stockArticlePackageList.size() == v.size()){ + if (stockArticlePackageList.size() == v.size()) { boolean orderLoadingFlag = v.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - if (orderLoadingFlag){ + if (orderLoadingFlag) { stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); - }else { + } else { orderLoadingFlag = v.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())); - if (!orderLoadingFlag){ + if (!orderLoadingFlag) { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); } } - }else { + } else { boolean orderbufenLoadingFlag = v.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - if (orderbufenLoadingFlag){ + if (orderbufenLoadingFlag) { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); } } distributionStockArticleService.updateById(stockArticleEntity); }); boolean reservationLoadingFlag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - if (reservationLoadingFlag){ + if (reservationLoadingFlag) { reservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.yizhuangche.getValue()); - }else { - reservationLoadingFlag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())); - if (reservationLoadingFlag){ + } else { + reservationLoadingFlag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())); + if (reservationLoadingFlag) { reservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.daizhuangche.getValue()); - }else { + } else { reservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.bufenzhuangche.getValue()); } } @@ -868,13 +871,13 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(packageId); parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); distributionParcelListService.updateById(parcelListEntity); - if (Func.isNotEmpty(parcelListEntity)){ + if (Func.isNotEmpty(parcelListEntity)) { DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); Integer orderLoadingNum = distributionLoadscanMapper.selectOrderLoadingNum(stockArticleEntity.getId()); - if (Func.isNotEmpty(orderLoadingNum) && orderLoadingNum > 0){ - if (stockArticleEntity.getTotalNumber() ==orderLoadingNum ){ + if (Func.isNotEmpty(orderLoadingNum) && orderLoadingNum > 0) { + if (stockArticleEntity.getTotalNumber() == orderLoadingNum) { stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); - }else { + } else { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); } distributionStockArticleService.updateById(stockArticleEntity); @@ -888,13 +891,13 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { .eq(DistributionParcelListEntity::getStockArticleId, parcelListEntity.getStockArticleId())); DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); boolean flag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageReservationStatus().equals(OrderPackageReservationStatusConstant.yiyueyue.getValue())); - if (flag){ + if (flag) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); - }else { - flag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageReservationStatus().equals(OrderPackageReservationStatusConstant.daiyuyue.getValue())); - if (flag){ + } else { + flag = parcelListEntities.stream().allMatch(p -> p.getOrderPackageReservationStatus().equals(OrderPackageReservationStatusConstant.daiyuyue.getValue())); + if (flag) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); - }else { + } else { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); } @@ -912,40 +915,39 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } catch (InterruptedException e) { throw new RuntimeException(e); } - log.debug("修改备货数据》》》",stockupDTO); + log.debug("修改备货数据》》》", stockupDTO); QueryWrapper queryWrapper = new QueryWrapper(); - if(ObjectUtils.isNotNull(stockupDTO.getStockArticleId())){ - queryWrapper.eq("stock_article_id",stockupDTO.getStockArticleId()); + if (ObjectUtils.isNotNull(stockupDTO.getStockArticleId())) { + queryWrapper.eq("stock_article_id", stockupDTO.getStockArticleId()); } - if(stockupDTO.getStockArticleIdList() != null && !stockupDTO.getStockArticleIdList().equals(null)){ - queryWrapper.in("stock_article_id",stockupDTO.getStockArticleIdList()); + if (stockupDTO.getStockArticleIdList() != null && !stockupDTO.getStockArticleIdList().equals(null)) { + queryWrapper.in("stock_article_id", stockupDTO.getStockArticleIdList()); } - queryWrapper.eq("reservation_id",stockupDTO.getReservationId()); + queryWrapper.eq("reservation_id", stockupDTO.getReservationId()); List list = reservationZeroPackageService.list(queryWrapper); AtomicBoolean pian = new AtomicBoolean(true); DistributionStockupEntity stockupEntity = new DistributionStockupEntity(); list.stream().forEach(i -> { - if(!i.getQuantity().equals(i.getRealityQuantity())){ + if (!i.getQuantity().equals(i.getRealityQuantity())) { //不同 不能修改为完成 pian.set(false); } }); - if(pian.get()){ + if (pian.get()) { AtomicReference s = new AtomicReference<>(false); - if(stockupDTO.getTypeService().equals("3")){ + if (stockupDTO.getTypeService().equals("3")) { //自提 //查询有没有不是零担的订单 List distributionStockPackageVOS = distrilbutionBillStockService.listPackageSelf(stockupDTO.getReservationId()); - if(!distributionStockPackageVOS.isEmpty()){ + if (!distributionStockPackageVOS.isEmpty()) { - distributionStockPackageVOS.forEach( i ->{ - if(getDoneStockUp(i.getStockArticleId(), i.getParcelListId(), stockupDTO.getReservationId(), stockupDTO.getTypeService())){ + distributionStockPackageVOS.forEach(i -> { + if (getDoneStockUp(i.getStockArticleId(), i.getParcelListId(), stockupDTO.getReservationId(), stockupDTO.getTypeService())) { //没有扫 s.set(true); } }); - }else{ - + } else { //查询有没有库存品 @@ -953,50 +955,50 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { .eq(DistributionDeliveryDetailsEntity::getBillLadingId, stockupDTO.getReservationId()) .in(DistributionDeliveryDetailsEntity::getInventoryStatus, "1", "3") ); - if(!distributionDeliveryDetailsEntities.isEmpty()){ + if (!distributionDeliveryDetailsEntities.isEmpty()) { int sum = distributionDeliveryDetailsEntities.stream().mapToInt(DistributionDeliveryDetailsEntity::getQuantity).sum(); //全部的库存数量 - distributionDeliveryDetailsEntities.forEach(d ->{ - if(!getDoneStockUpStock(d.getStockListId(),stockupDTO.getReservationId(),stockupDTO.getTypeService(),stockupDTO.getStockupId(),sum )){ + distributionDeliveryDetailsEntities.forEach(d -> { + if (!getDoneStockUpStock(d.getStockListId(), stockupDTO.getReservationId(), stockupDTO.getTypeService(), stockupDTO.getStockupId(), sum)) { s.set(true); } }); } - if(s.get()){ + if (s.get()) { stockupEntity.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); - }else{ + } else { stockupEntity.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); stockupEntity.setFixTime(new Date()); } } - }else{ + } else { //商,市 //查询数据 List distributionStockupInfoEntities = distributionStockupInfoMapper.selectList(Wrappers.query().lambda() .eq(DistributionStockupInfoEntity::getStockupId, stockupDTO.getStockupId()) ); - distributionStockupInfoEntities.forEach(v ->{ + distributionStockupInfoEntities.forEach(v -> { //查询包件数据 List packageEntities = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() .eq(DistributionReservationPackageEntity::getReservationId, v.getReservationId()) .eq(DistributionReservationPackageEntity::getPacketBarStatus, '1') ); - packageEntities.forEach( i ->{ - if(getDoneStockUp(i.getStockArticleId(), i.getParceListId(), v.getReservationId(), stockupDTO.getTypeService())){ + packageEntities.forEach(i -> { + if (getDoneStockUp(i.getStockArticleId(), i.getParceListId(), v.getReservationId(), stockupDTO.getTypeService())) { //没有扫 s.set(true); } }); }); - if(!s.get()){ + if (!s.get()) { //查询有没有库存品 List distributionReservationStocklistEntities = distributionReservationStocklistMapper.selectList(Wrappers.query().lambda() .eq(DistributionReservationStocklistEntity::getReservationId, stockupDTO.getReservationId()) .in(DistributionReservationStocklistEntity::getStockListStatus, "1", "3") ); - if(!distributionReservationStocklistEntities.isEmpty()){ + if (!distributionReservationStocklistEntities.isEmpty()) { int sum = distributionReservationStocklistEntities.stream().mapToInt(DistributionReservationStocklistEntity::getRealityNum).sum(); //全部的库存数量 - distributionReservationStocklistEntities.forEach(d ->{ - if(!getDoneStockUpStock(d.getStocklistId(),stockupDTO.getReservationId(),stockupDTO.getTypeService(),stockupDTO.getStockupId(),sum )){ + distributionReservationStocklistEntities.forEach(d -> { + if (!getDoneStockUpStock(d.getStocklistId(), stockupDTO.getReservationId(), stockupDTO.getTypeService(), stockupDTO.getStockupId(), sum)) { s.set(true); } }); @@ -1005,14 +1007,14 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { stockupEntity.setFixTime(new Date()); } } - if(s.get()){ + if (s.get()) { stockupEntity.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); - }else{ + } else { stockupEntity.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); stockupEntity.setFixTime(new Date()); } - }else{ + } else { stockupEntity.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); } stockupEntity.setId(stockupDTO.getStockupId()); @@ -1025,10 +1027,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(parcelNumberEntity.getParcelListId()); //计算该品类的使用数量,这里数量被使用就一定会进行预约 int a = parcelNumber.getDeliveryQuantity() + parcelNumber.getOutboundQuantity(); - if (a == 0){ + if (a == 0) { parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); - }else { - if (a == parcelNumberEntity.getHandQuantity()){ + } else { + if (a == parcelNumberEntity.getHandQuantity()) { parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.yiyueyue.getValue()); } } @@ -1036,17 +1038,17 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); List parcelListEntityList = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, stockArticleEntity.getId())); boolean flag = parcelListEntityList.stream().allMatch(p -> Func.equals(p.getOrderPackageReservationStatus(), OrderPackageReservationStatusConstant.yiyueyue.getValue())); - if (flag){ + if (flag) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); - }else { + } else { List parcelNumberEntityList = distributionParcelNumberService.list(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getStockArticleId, stockArticleEntity.getId())); AtomicInteger atomicInteger = new AtomicInteger(); - parcelNumberEntityList.forEach(p->{ + parcelNumberEntityList.forEach(p -> { atomicInteger.getAndAdd(p.getDeliveryQuantity() + p.getOutboundQuantity()); }); - if (stockArticleEntity.getHandQuantity()> atomicInteger.get()){ + if (stockArticleEntity.getHandQuantity() > atomicInteger.get()) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); - }else if (stockArticleEntity.getHandQuantity() == atomicInteger.get()){ + } else if (stockArticleEntity.getHandQuantity() == atomicInteger.get()) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); } } @@ -1055,67 +1057,67 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { @Override @Transactional - public void checkZeroStockArticleLoadingStatus(DistributionParcelNumberEntity parcelNumberEntity,Long deliveryId,Long reservationId) { - if (Func.isEmpty(parcelNumberEntity)){ - log.error("#################parcelNumberEntity参数错误:{}",parcelNumberEntity); + public void checkZeroStockArticleLoadingStatus(DistributionParcelNumberEntity parcelNumberEntity, Long deliveryId, Long reservationId) { + if (Func.isEmpty(parcelNumberEntity)) { + log.error("#################parcelNumberEntity参数错误:{}", parcelNumberEntity); return; } DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelNumberEntity.getStockArticleId()); - if (Func.equals(stockArticleEntity.getIsZero(),IsOrNoConstant.no.getValue())){ - log.error("#################查询订单异常,订单ID为:{}",parcelNumberEntity.getStockArticleId()); + if (Func.equals(stockArticleEntity.getIsZero(), IsOrNoConstant.no.getValue())) { + log.error("#################查询订单异常,订单ID为:{}", parcelNumberEntity.getStockArticleId()); return; } List parcelNumberEntities = distributionParcelNumberService.list(Wrappers.query().lambda() .eq(DistributionParcelNumberEntity::getStockArticleId, stockArticleEntity.getId())); - if (Func.isEmpty(parcelNumberEntities)){ - log.error("#################查询零担订单包件品类异常,订单ID为:{}",stockArticleEntity.getId()); + if (Func.isEmpty(parcelNumberEntities)) { + log.error("#################查询零担订单包件品类异常,订单ID为:{}", stockArticleEntity.getId()); return; } - parcelNumberEntities.forEach(p->{ + parcelNumberEntities.forEach(p -> { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(p.getParcelListId()); - if (p.getOutboundQuantity() == p.getQuantity()){ + if (p.getOutboundQuantity() == p.getQuantity()) { parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); - }else { + } else { parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.weizhuancghe.getValue()); } distributionParcelListService.updateById(parcelListEntity); }); List parcelListEntityList = distributionParcelListService.list(Wrappers.query().lambda() .eq(DistributionParcelListEntity::getStockArticleId, stockArticleEntity.getId())); - if (Func.isEmpty(parcelListEntityList)){ - log.error("#################查询零担订单包件异常,订单ID为:{}",stockArticleEntity.getId()); + if (Func.isEmpty(parcelListEntityList)) { + log.error("#################查询零担订单包件异常,订单ID为:{}", stockArticleEntity.getId()); return; } int outboundQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getOutboundQuantity).sum(); - if (outboundQuantity > 0 && outboundQuantity < stockArticleEntity.getTotalNumber()){ + if (outboundQuantity > 0 && outboundQuantity < stockArticleEntity.getTotalNumber()) { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); stockArticleEntity.setDeliveryQuantity(stockArticleEntity.getDeliveryQuantity() + outboundQuantity); } - if (stockArticleEntity.getTotalNumber() == outboundQuantity){ + if (stockArticleEntity.getTotalNumber() == outboundQuantity) { stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); stockArticleEntity.setDeliveryQuantity(stockArticleEntity.getDeliveryQuantity() + outboundQuantity); } distributionStockArticleService.updateById(stockArticleEntity); //维护预约客户和配送任务装车状态 - checkReservationAndDeliveryLoadingStatus(deliveryId,reservationId); + checkReservationAndDeliveryLoadingStatus(deliveryId, reservationId); } @Override public void checkSignStatus(Long packageId, Long reservationId, Long deliveryId) { - if (Func.isNotEmpty(packageId)){ + if (Func.isNotEmpty(packageId)) { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(packageId); //维护包件所属订单签收状态 DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); //维护该订单的签收状态 - if (Func.isNotEmpty(stockArticleEntity)){ + if (Func.isNotEmpty(stockArticleEntity)) { Integer totalNumber = stockArticleEntity.getTotalNumber(); Integer orderSignNum = distributionLoadscanMapper.selectOrderSignNum(stockArticleEntity.getId()); Integer orderLoadingNum = distributionLoadscanMapper.selectOrderLoadingNum(stockArticleEntity.getId()); - if (Func.isNotEmpty(orderSignNum) && orderSignNum>0){ - if (totalNumber ==orderSignNum){ + if (Func.isNotEmpty(orderSignNum) && orderSignNum > 0) { + if (totalNumber == orderSignNum) { stockArticleEntity.setOrderStatus(OrderStatusConstant.qianshou.getValue()); - }else { + } else { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue()); } } @@ -1124,27 +1126,150 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { } - checkReservationAndDeliveryLoadingStatus(deliveryId,reservationId); + checkReservationAndDeliveryLoadingStatus(deliveryId, reservationId); checkReservationAndDeliverySigningStatus(reservationId, deliveryId); //注意:这里对于异常装车的包件也需要进行统计 } + @Override + public void checkRetentionReservationAndDeliveryInfo(Long reservationId, Long deliveryId) { + DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(reservationId); + if (Func.isNotEmpty(distributionReservationEntity)) { + //重新统计预约单包件数量 + List distributionReservationStockarticleEntities = distributionReservationMapper.selectStockArticleByReservationId(reservationId); + if (Func.isNotEmpty(distributionReservationStockarticleEntities)) { + for (DistributionReservationStockarticleEntity distributionReservationStockarticleEntity : distributionReservationStockarticleEntities) { + if (distributionReservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())) { + List distributionParcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(reservationId, distributionReservationStockarticleEntity.getStockArticleId()); + if (Func.isNotEmpty(distributionParcelListEntities)) { + if (distributionParcelListEntities.size() != distributionReservationStockarticleEntity.getReservationNum()) { + distributionReservationStockarticleEntity.setReservationNum(distributionParcelListEntities.size()); + distributionReservationStockarticleMapper.updateById(distributionReservationStockarticleEntity); + } + } else { + distributionReservationStockarticleEntity.setReservationNum(0); + distributionReservationStockarticleEntity.setStockArticleStatus(ReservationOrderStatusConstant.quxiao.getValue()); + distributionReservationStockarticleMapper.updateById(distributionReservationStockarticleEntity); + } + } else if (distributionReservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.yes.getValue())) { + //零担需要判断是否已经进行了全部的滞留操作 + List distributionParcelNumberVOS = distributionReservationMapper.selectReservationZeroOrderDetail(distributionReservationStockarticleEntity.getStockArticleId(), distributionReservationStockarticleEntity.getReservationId()); + if (Func.isNotEmpty(distributionParcelNumberVOS)) { + int sum = distributionParcelNumberVOS.stream().mapToInt(DistributionParcelNumberVO::getReservationNum).sum(); + if (distributionReservationStockarticleEntity.getReservationNum() != sum) { + distributionReservationStockarticleEntity.setReservationNum(sum); + if (sum == 0) { + distributionReservationStockarticleEntity.setStockArticleStatus(ReservationOrderStatusConstant.quxiao.getValue()); + } + distributionReservationStockarticleMapper.updateById(distributionReservationStockarticleEntity); + } + } + } + } + } + //维护预约的预约数量 + maintenanceReservationPackageNum(reservationId); + maintenanceDeliveryPackageNum(deliveryId); + } + } + + @Override + public void checkRetentionInventoryReservationAndDeliveryInfo(Long reservationId, Long deliveryId, Long orderPackageId) { + DisStockListDetailEntity disStockListDetail = disStockListDetailService.getById(orderPackageId); + if (Func.isNotEmpty(disStockListDetail)){ + DistributionReservationStocklistEntity reservationStocklistEntity = distributionReservationMapper.selectInventoryInfoByReservationIdAndInventoryId(reservationId,disStockListDetail.getStockListId()); + if (Func.isNotEmpty(reservationStocklistEntity)){ + //查询该类型的库存品是否进行了全部滞留 + List list = disStockListDetailService.list(Wrappers.query().lambda() + .eq(DisStockListDetailEntity::getReservationId, reservationStocklistEntity.getReservationId()) + .eq(DisStockListDetailEntity::getStockListId, reservationStocklistEntity.getStocklistId()) + .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) + ); + reservationStocklistEntity.setReservationNum(0); + if (Func.isNotEmpty(list)){ + int sum = list.stream().mapToInt(DisStockListDetailEntity::getNum).sum(); + reservationStocklistEntity.setReservationNum(sum); + } + if (reservationStocklistEntity.getReservationNum()==0){ + reservationStocklistEntity.setStockListStatus(ReservationOrderStatusConstant.quxiao.getValue()); + } + distributionReservationStocklistMapper.updateById(reservationStocklistEntity); + } + + } + //维护预约的预约数量 + maintenanceReservationPackageNum(reservationId); + maintenanceDeliveryPackageNum(deliveryId); + } + + /** + * 维护配送数量和状态 + * @param deliveryId + */ + @Transactional + private void maintenanceDeliveryPackageNum(Long deliveryId) { + DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(deliveryId); + if (Func.isNotEmpty(distributionDeliveryListEntity)){ + List distributionReservationEntities = distributionDeliveryListMapper.selectReservationByDeliveryListId(distributionDeliveryListEntity.getId()); + if (Func.isNotEmpty(distributionReservationEntities)){ + int sum = distributionReservationEntities.stream().mapToInt(DistributionReservationEntity::getReservationNum).sum() + distributionReservationEntities.stream().mapToInt(DistributionReservationEntity::getReservationStockListNum).sum(); + distributionDeliveryListEntity.setDeliveryNumber(sum); + }else { + distributionDeliveryListEntity.setDeliveryNumber(0); + } + distributionDeliveryListMapper.updateById(distributionDeliveryListEntity); + if (distributionDeliveryListEntity.getDeliveryNumber() == 0){ + distributionDeliveryListMapper.deleteById(distributionDeliveryListEntity); + } + } + } + + /** + * 维护预约数量和状态 + * @param reservationId + */ + @Transactional + private void maintenanceReservationPackageNum(Long reservationId) { + DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(reservationId); + if (Func.isNotEmpty(distributionReservationEntity)){ + List distributionReservationStockarticleEntities = distributionReservationMapper.selectStockArticleByReservationId(distributionReservationEntity.getId()); + if (Func.isNotEmpty(distributionReservationStockarticleEntities)){ + int sum = distributionReservationStockarticleEntities.stream().mapToInt(DistributionReservationStockarticleEntity::getReservationNum).sum(); + distributionReservationEntity.setReservationNum(sum); + }else { + distributionReservationEntity.setReservationNum(0); + } + List distributionReservationStocklistEntities = distributionReservationMapper.selectStockListByReservationId(distributionReservationEntity.getId()); + if (Func.isNotEmpty(distributionReservationStocklistEntities)){ + //统计库存品数 + int sum = distributionReservationStocklistEntities.stream().mapToInt(DistributionReservationStocklistEntity::getReservationNum).sum(); + distributionReservationEntity.setReservationStockListNum(sum); + }else { + distributionReservationEntity.setReservationStockListNum(0); + } + distributionReservationMapper.updateById(distributionReservationEntity); + if (distributionReservationEntity.getReservationNum() ==0 && distributionReservationEntity.getReservationStockListNum() == 0){ + distributionReservationMapper.deleteById(distributionReservationEntity); + } + } +} + @Transactional private void checkReservationAndDeliverySigningStatus(Long reservationId, Long deliveryId) { //维护客户签收状态 DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(reservationId); - if (Func.isNotEmpty(distributionReservationEntity)){ + if (Func.isNotEmpty(distributionReservationEntity)) { int reservationTotal = distributionReservationEntity.getReservationNum() + distributionReservationEntity.getReservationStockListNum(); //查询该客户的签收数量 - DistributionLoadingNumDTO reservationSigningNum= distributionReservationMapper.selectReservationSigningNum(distributionReservationEntity.getId()); - if (Func.isNotEmpty(reservationSigningNum)){ + DistributionLoadingNumDTO reservationSigningNum = distributionReservationMapper.selectReservationSigningNum(distributionReservationEntity.getId()); + if (Func.isNotEmpty(reservationSigningNum)) { int reservationSigningQuantity = reservationSigningNum.getPackageSigningQuantity() + reservationSigningNum.getInventorySigningQuantity(); - if (reservationSigningQuantity>0){ - if (reservationTotal ==reservationSigningQuantity){ + if (reservationSigningQuantity > 0) { + if (reservationTotal == reservationSigningQuantity) { distributionReservationEntity.setSigningStatus(ReservationSigningStatusConstant.yiqianshou.getValue()); - }else { + } else { distributionReservationEntity.setSigningStatus(ReservationSigningStatusConstant.bufenqianshou.getValue()); } distributionReservationMapper.updateById(distributionReservationEntity); @@ -1155,15 +1280,15 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //维护配送任务签收状态 DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(deliveryId); - if (Func.isNotEmpty(distributionDeliveryListEntity)){ + if (Func.isNotEmpty(distributionDeliveryListEntity)) { Integer deliverySigningTotal = distributionDeliveryListEntity.getDeliveryNumber(); - DistributionLoadingNumDTO deliverySigningNum= distributionDeliveryListMapper.selectDeliverySigningNum(distributionReservationEntity.getId()); - if (Func.isNotEmpty(deliverySigningNum)){ + DistributionLoadingNumDTO deliverySigningNum = distributionDeliveryListMapper.selectDeliverySigningNum(distributionReservationEntity.getId()); + if (Func.isNotEmpty(deliverySigningNum)) { int deliverySigningQuantity = deliverySigningNum.getPackageSigningQuantity() + deliverySigningNum.getInventorySigningQuantity(); - if (deliverySigningQuantity>0){ - if (deliverySigningTotal ==deliverySigningQuantity){ + if (deliverySigningQuantity > 0) { + if (deliverySigningTotal == deliverySigningQuantity) { distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.yiwancheng.getValue()); - }else { + } else { distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.peisongzhong.getValue()); } distributionDeliveryListMapper.updateById(distributionDeliveryListEntity); @@ -1198,10 +1323,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { .eq(DistributionReservationZeroPackageEntity::getIsDeleted, 0) .in(DistributionReservationZeroPackageEntity::getZeroPackageStatus, "1", "3") ); - if(!list3.isEmpty()){ + if (!list3.isEmpty()) { //零担数据 int sum = list3.stream().mapToInt(DistributionReservationZeroPackageEntity::getQuantity).sum(); - pack.set(pack.get()+sum); + pack.set(pack.get() + sum); } boolean apj = false; @@ -1225,7 +1350,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //查询包件数量 List distributionStockPackageVOS = distrilbutionBillStockService.listPackageSelf(billLadingId); int size = distributionStockPackageVOS.size(); //包件数量 - pack.set(pack.get()+size); + pack.set(pack.get() + size); //查询签收数量 List list2 = distributionBillLadingScanMapper.selectList(Wrappers.query().lambda() .eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) @@ -1417,10 +1542,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { public void changeOrderReservationStatus(DistributionStockArticleDTO stockArticleDTO) { Long id = stockArticleDTO.getId(); DistributionStockArticleEntity stockArticleEntity = Func.copy(stockArticleDTO, DistributionStockArticleEntity.class); - if (stockArticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())){ + if (stockArticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())) { List parcelListEntityList = distributionParcelListService.getBaseMapper().selectList(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, id)); boolean flag = parcelListEntityList.stream().allMatch(p -> p.getOrderPackageReservationStatus().equals(OrderPackageReservationStatusConstant.yiyueyue.getValue())); - if (flag && stockArticleEntity.getTotalNumber()==parcelListEntityList.size()) { + if (flag && stockArticleEntity.getTotalNumber() == parcelListEntityList.size()) { assert stockArticleEntity != null; stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); } else { @@ -1433,19 +1558,19 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); } } - }else { + } else { //检测零担订单是否完成预约 List parcelNumberEntities = distributionParcelNumberService.list(Wrappers.query().lambda() .eq(DistributionParcelNumberEntity::getStockArticleId, stockArticleDTO.getId())); AtomicInteger unavailableNum = new AtomicInteger(); - parcelNumberEntities.forEach(p->{ + parcelNumberEntities.forEach(p -> { unavailableNum.getAndAdd(p.getOutboundQuantity() + p.getDeliveryQuantity()); }); - if (unavailableNum.get() == stockArticleDTO.getHandQuantity()){ + if (unavailableNum.get() == stockArticleDTO.getHandQuantity()) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.yiyueyue.getValue()); - }else if (unavailableNum.get() < stockArticleDTO.getHandQuantity()){ + } else if (unavailableNum.get() < stockArticleDTO.getHandQuantity()) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.bufenyuyue.getValue()); - }else if (unavailableNum.get() == 0){ + } else if (unavailableNum.get() == 0) { stockArticleEntity.setReservationStatus(OrderReservationStatusConstant.daiyuyue.getValue()); } } @@ -1505,18 +1630,18 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { */ @Override @Transactional(rollbackFor = Exception.class) - public void stockupUpdateState(StockupDTO stockupDTO,int num) { + public void stockupUpdateState(StockupDTO stockupDTO, int num) { BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); - if(stockupDTO.getScanType().equals(1)){ + if (stockupDTO.getScanType().equals(1)) { //包件 //查询包件备货状态 List distributionParcelListEntities = distributionParcelListMapper.selectList(Wrappers.query().lambda() .eq(DistributionParcelListEntity::getOrderPackageCode, stockupDTO.getPacketBarCode()) - .eq(ObjectUtils.isNotNull(myCurrentWarehouse),DistributionParcelListEntity::getWarehouseId,myCurrentWarehouse.getId() ) + .eq(ObjectUtils.isNotNull(myCurrentWarehouse), DistributionParcelListEntity::getWarehouseId, myCurrentWarehouse.getId()) ); //修改 - if(!distributionParcelListEntities.isEmpty()){ + if (!distributionParcelListEntities.isEmpty()) { DistributionParcelListEntity distributionParcelListEntity = new DistributionParcelListEntity(); distributionParcelListEntity.setId(distributionParcelListEntities.get(0).getId()); distributionParcelListEntity.setOrderPackageStockupStatus(OrderPackageStockupStatusConstant.yibeihu.getValue()); @@ -1545,7 +1670,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { .eq(DistributionStockEntity::getReservationId, i.getReservationId()) .eq(DistributionStockEntity::getStockupId, stockupDTO.getStockupId()) ); - if(!list.isEmpty()){ + if (!list.isEmpty()) { int size = list.stream().mapToInt(DistributionStockEntity::getStockQuantity).sum(); nuy.set(nuy.get() + size); } @@ -1559,7 +1684,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { nu.set(nu.get() + sum); } //修改预约备货状态 - if(nuy.get() >= nu.get()){ + if (nuy.get() >= nu.get()) { DistributionReservationEntity reservationEntity = new DistributionReservationEntity(); reservationEntity.setId(i.getReservationId()); reservationEntity.setStockupStatus(ReservationStockupStatusConstant.yibeihuo.getValue()); @@ -1631,7 +1756,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { * @param stockupDTO */ @Override - public void stockupSelfUpdateState(StockupDTO stockupDTO,int num) { + public void stockupSelfUpdateState(StockupDTO stockupDTO, int num) { //查询全部订单数据 List distrilbutionBillStockEntities = distrilbutionBillStockMapper.selectList(Wrappers.query().lambda() @@ -1647,7 +1772,7 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { // AtomicReference z = new AtomicReference<>(false); // AtomicReference zeroNum = new AtomicReference<>(0); //零担已备货的数量 AtomicReference zeroYuNum = new AtomicReference<>(0); //零担预约的数量 - if(!listZero.isEmpty()){ + if (!listZero.isEmpty()) { int sum = listZero.stream().mapToInt(DistributionReservationZeroPackageEntity::getQuantity).sum(); zeroYuNum.set(sum); //有 @@ -1672,9 +1797,9 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //查询订单的非零担数据 List distributionStockPackageVOS = distrilbutionBillStockService.listPackageSelf(stockupDTO.getReservationId()); //计算全部预约件数 - if(!distributionStockPackageVOS.isEmpty()){ + if (!distributionStockPackageVOS.isEmpty()) { nu.set(distributionStockPackageVOS.size() + zeroYuNum.get()); - }else{ + } else { nu.set(zeroYuNum.get()); } // distrilbutionBillStockEntities.forEach(i -> { @@ -1727,11 +1852,11 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { //修改 } } else { - if(i == 0){ + if (i == 0) { //修改备货状态 distributionStockup.setId(stockupDTO.getStockupId()); distributionStockup.setStockupStatus(StockupStatusConstant.yibeihuo.getValue()); - }else{ + } else { //修改备货状态 distributionStockup.setId(stockupDTO.getStockupId()); distributionStockup.setStockupStatus(StockupStatusConstant.beihuozhong.getValue()); @@ -1748,27 +1873,28 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { /** * 查询是否有没有备货的数据 + * * @param stockArticleId * @param parcelListId * @param reservationId * @param typeService * @return */ - public Boolean getDoneStockUp(Long stockArticleId,Long parcelListId,Long reservationId,String typeService){ + public Boolean getDoneStockUp(Long stockArticleId, Long parcelListId, Long reservationId, String typeService) { QueryWrapper queryWrapper1 = new QueryWrapper<>(); - queryWrapper1.eq("stock_article",stockArticleId); - queryWrapper1.eq("parcel_list_id",parcelListId); + queryWrapper1.eq("stock_article", stockArticleId); + queryWrapper1.eq("parcel_list_id", parcelListId); - if(typeService.equals("3")){ - queryWrapper1.eq("bill_lading_id",reservationId); - }else{ - queryWrapper1.eq("reservation_id",reservationId); + if (typeService.equals("3")) { + queryWrapper1.eq("bill_lading_id", reservationId); + } else { + queryWrapper1.eq("reservation_id", reservationId); } DistributionStockEntity stockEntity = distributionStockService.selectOne(queryWrapper1); - if(ObjectUtils.isNull(stockEntity)){ + if (ObjectUtils.isNull(stockEntity)) { //没有扫 return true; - }else{ + } else { return false; } @@ -1776,26 +1902,27 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { /** * 查询是否有没有备货的库存品数据 + * * @param stockListId * @param reservationId * @param typeService * @return */ - public Boolean getDoneStockUpStock(Long stockListId,Long reservationId,String typeService,Long stockupId,Integer num ){ + public Boolean getDoneStockUpStock(Long stockListId, Long reservationId, String typeService, Long stockupId, Integer num) { QueryWrapper queryWrapper1 = new QueryWrapper<>(); - queryWrapper1.eq("stock_list_id",stockListId); - queryWrapper1.eq("stockup_id",stockupId); - queryWrapper1.eq("type","2"); + queryWrapper1.eq("stock_list_id", stockListId); + queryWrapper1.eq("stockup_id", stockupId); + queryWrapper1.eq("type", "2"); - if(typeService.equals("3")){ - queryWrapper1.eq("bill_lading_id",reservationId); - }else{ - queryWrapper1.eq("reservation_id",reservationId); + if (typeService.equals("3")) { + queryWrapper1.eq("bill_lading_id", reservationId); + } else { + queryWrapper1.eq("reservation_id", reservationId); } List stockEntityList = distributionStockService.selectList(queryWrapper1); - if(!stockEntityList.isEmpty() && stockEntityList.size() >= num){ + if (!stockEntityList.isEmpty() && stockEntityList.size() >= num) { return true; //已完成 - } else{ + } else { return false; //未完成 } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index 90bd2feff..b50ae1eed 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -173,9 +173,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); - List collect = myWatchWarehouse.stream() - .map(BasicdataWarehouseEntity::getId) - .collect(Collectors.toList()); + List collect = myWatchWarehouse.stream().map(BasicdataWarehouseEntity::getId).collect(Collectors.toList()); distributionDeliveryList.setWarehouseIdList(collect); List distributionDeliveryListEntities = baseMapper.selectDistributionDeliveryListPage(page, distributionDeliveryList); return page.setRecords(distributionDeliveryListEntities); @@ -186,17 +184,17 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl exportDistributionDeliveryList(Map distributionDeliveryList) { Object o = distributionDeliveryList.get("ids"); - if(ObjectUtils.isNotNull(o)){ + if (ObjectUtils.isNotNull(o)) { distributionDeliveryList.remove("ids"); } BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); - if(ObjectUtils.isNull(myCurrentWarehouse)){ + if (ObjectUtils.isNull(myCurrentWarehouse)) { throw new ServiceException("没有仓库信息!"); } QueryWrapper queryWrapper = Condition.getQueryWrapper(distributionDeliveryList, DistributionDeliveryListEntity.class); - queryWrapper.eq("warehouse_id",myCurrentWarehouse.getId()); - if(ObjectUtils.isNotNull(o)){ - queryWrapper.in("id",String.valueOf(o).split(",")); + queryWrapper.eq("warehouse_id", myCurrentWarehouse.getId()); + if (ObjectUtils.isNotNull(o)) { + queryWrapper.in("id", String.valueOf(o).split(",")); } queryWrapper.lambda().eq(DistributionDeliveryListEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED); List list = new ArrayList<>(); @@ -204,23 +202,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl { // distributionDeliveryList.setTypeName(DictCache.getValue(DictEnum.YES_NO, DistributionDeliveryList.getType())); DistributionDeliveryListExcel deliveryListExcel = new DistributionDeliveryListExcel(); - BeanUtils.copyProperties(dis,deliveryListExcel); + BeanUtils.copyProperties(dis, deliveryListExcel); String value = DictBizCache.getValue(DictBizConstant.DISTRIBUTION_TYPE, dis.getType()); deliveryListExcel.setType(value); String valuek = DictBizCache.getValue(DictBizConstant.DISTRIBUTION_DELIVERY_KiIND, dis.getKind()); deliveryListExcel.setKind(valuek); String valueks = DictBizCache.getValue(DictBizConstant.DISTRIBUTION_DELIVERY_STATUS, dis.getDeliveryStatus()); deliveryListExcel.setState(valueks); - deliveryListExcel.setInventoryNub(ObjectUtils.isNotNull(dis.getInventoryNub() ) ? dis.getInventoryNub() : 0 ); + deliveryListExcel.setInventoryNub(ObjectUtils.isNotNull(dis.getInventoryNub()) ? dis.getInventoryNub() : 0); //查询配送数据 - if(dis.getKind().equals("1")){ + if (dis.getKind().equals("1")) { //z自 List list1 = distributionDeliverySelfService.list(Wrappers.query().lambda().eq(DistributionDeliverySelfEntity::getDeliveryId, dis.getId())); String collect = list1.stream().map(DistributionDeliverySelfEntity::getDriverName).collect(Collectors.joining(",")); String colle = list1.stream().map(DistributionDeliverySelfEntity::getVehicleNub).collect(Collectors.joining(",")); deliveryListExcel.setDriver(collect); deliveryListExcel.setVehicle(colle); - }else{ + } else { //三 List list1 = distributionDeliveryTripartiteService.list(Wrappers.query().lambda().eq(DistributionDeliveryTripartiteEntity::getDeliveryId, dis.getId())); String collect = list1.stream().map(DistributionDeliveryTripartiteEntity::getDriverName).collect(Collectors.joining(",")); @@ -228,7 +226,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionDeliverySelfEntity::getDeliveryId, distributionDeliveryListVO.getId()) - .eq(DistributionDeliverySelfEntity::getIsMaster, 2)); + DistributionDeliverySelfEntity deliverySelfServiceOne = distributionDeliverySelfService.getOne(Wrappers.query().lambda().eq(DistributionDeliverySelfEntity::getDeliveryId, distributionDeliveryListVO.getId()).eq(DistributionDeliverySelfEntity::getIsMaster, 2)); distributionDeliveryListVO.setDriverName(deliverySelfServiceOne.getDriverName()); distributionDeliveryListVO.setDriverPhone(deliverySelfServiceOne.getDriverPhone()); distributionDeliveryListVO.setVehicleName(deliverySelfServiceOne.getVehicleNub()); @@ -460,9 +456,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl DistributionPackadeliEntitys = new ArrayList<>(); - List distributionLoadscanEntities = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionDeliveryList.getId()) - .ne(DistributionLoadscanEntity::getScanStatus, 1)); + List distributionLoadscanEntities = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionDeliveryList.getId()).ne(DistributionLoadscanEntity::getScanStatus, 1)); distributionLoadscanEntities.forEach(e -> { DistributionPackadeliEntity distributionPackadeliEntity = new DistributionPackadeliEntity(); @@ -470,10 +464,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliveryListEntity::getId, distributionDeliveryList.getId()) - .set(DistributionDeliveryListEntity::getDeliveryStatus, DeliveryStatusConstant.peisongzhong.getValue()) - ); + return this.update(new UpdateWrapper().lambda().eq(DistributionDeliveryListEntity::getId, distributionDeliveryList.getId()).set(DistributionDeliveryListEntity::getDeliveryStatus, DeliveryStatusConstant.peisongzhong.getValue())); } @@ -513,10 +504,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl parcelListEntityList = distributionParcelListEntities.stream().filter(p -> Func.equals(p.getOrderPackageCode(), distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); if (parcelListEntityList.size() == 1) { //在配送任务中存在该包件的计划 - List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(distributionLoadscanEntitiesflag) && distributionLoadscanEntitiesflag.size() == 1) { return Resp.scanSuccess("重复扫码", "重复扫码"); } @@ -573,11 +561,10 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); + DistributionParcelListEntity parcelListEntity = distributionParcelListService.getOne(Wrappers.query().lambda().eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); boolean shangpeiFlag = reservationEntityList.stream().allMatch(r -> r.getDeliveryType().equals(DistributionTypeConstant.shipie.getValue())); if (Func.isEmpty(parcelListEntity)) { @@ -585,11 +572,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationEntities = reservationEntityList.stream().filter(r -> Func.isNotEmpty(r.getConsignee()) - && r.getConsignee().equals(stockArticleEntity.getCustomerName()) - && r.getDeliveryAddress().equals(stockArticleEntity.getCustomerAddress()) - && r.getDeliveryPhone().equals(stockArticleEntity.getCustomerTelephone()) - && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); + List reservationEntities = reservationEntityList.stream().filter(r -> Func.isNotEmpty(r.getConsignee()) && r.getConsignee().equals(stockArticleEntity.getCustomerName()) && r.getDeliveryAddress().equals(stockArticleEntity.getCustomerAddress()) && r.getDeliveryPhone().equals(stockArticleEntity.getCustomerTelephone()) && r.getMallName().equals(stockArticleEntity.getMallName())).collect(Collectors.toList()); //查看是否存在满足条件的预约单 if (reservationEntities.size() == 1) { return R.fail(5000, "异常装车"); @@ -614,7 +597,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl voGoodsLsit = trayTypeDataVO.getGoodsLsit(); @@ -623,51 +606,48 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl trayGoodIds = voGoodsLsit.stream().filter(v -> v.getAssociationType().equals("3")).map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); List parcelListEntities = distributionParcelListService.listByIds(trayGoodIds); - if (trayGoodIds.size() != parcelListEntities.size()){ + if (trayGoodIds.size() != parcelListEntities.size()) { return Resp.scanFail("托盘存在其他货物", "托盘存在其他货物"); } //判断该货物都属于同一客户才能进行装车 List parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); boolean isBelongToReservation = parcelListEntities.stream().allMatch(tp -> parcelListEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()).contains(tp.getId())); - log.info("#########!!!!!!!!!!!!!!!!!--------- 111111111 isBelongToReservation={}",isBelongToReservation); + log.info("#########!!!!!!!!!!!!!!!!!--------- 111111111 isBelongToReservation={}", isBelongToReservation); if (isBelongToReservation) { log.info("#########!!!!!!!!!!!!!!!!!--------- 222222222"); - List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .ne(DistributionLoadscanEntity::getScanStatus, 1) - .eq(DistributionLoadscanEntity::getTrayNo, distrilbutionloadingscanDTO.getBarcode())); + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscanEntity::getScanStatus, 1).eq(DistributionLoadscanEntity::getTrayNo, distrilbutionloadingscanDTO.getBarcode())); boolean trayLoadingStatus = parcelListEntities.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - log.info("#########!!!!!!!!!!!!!!!!!--------- 333333333 trayLoadingStatus={} loadscanEntityList={}",trayLoadingStatus,loadscanEntityList); + log.info("#########!!!!!!!!!!!!!!!!!--------- 333333333 trayLoadingStatus={} loadscanEntityList={}", trayLoadingStatus, loadscanEntityList); if (Func.isNotEmpty(loadscanEntityList) && loadscanEntityList.size() > 0 && trayLoadingStatus) { return Resp.scanFail("重复扫描", "重复扫描"); } - log.info("#########!!!!!!!!!!!!!!!!!--------- 444444444 parcelListEntities={}",parcelListEntities); + log.info("#########!!!!!!!!!!!!!!!!!--------- 444444444 parcelListEntities={}", parcelListEntities); if (Func.isEmpty(parcelListEntities) || parcelListEntities.size() <= 0) { return Resp.scanFail("操作失败", "该托盘上无货物信息"); } - log.info("#########!!!!!!!!!!!!!!!!!--------- 55555555555 distrilbutionloadingscanDTO={}",distrilbutionloadingscanDTO); + log.info("#########!!!!!!!!!!!!!!!!!--------- 55555555555 distrilbutionloadingscanDTO={}", distrilbutionloadingscanDTO); if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { //存在客户 这里就是针对客户进行的整托装车 // List parcelListEntityList = distributionReservationMapper.selectPackageListByReservationId(distrilbutionloadingscanDTO.getReservationId()); Map parcelListEntityMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getId, Function.identity(), (k1, k2) -> k2)); boolean reservationFlag = parcelListEntities.stream().allMatch(p -> Func.isNotEmpty(parcelListEntityMap.get(p.getId()))); - log.info("#########!!!!!!!!!!!!!!!!!--------- 6666666666 reservationFlag={}",reservationFlag); + log.info("#########!!!!!!!!!!!!!!!!!--------- 6666666666 reservationFlag={}", reservationFlag); if (reservationFlag) { try { - warehouseUpdownTypeClient.downTray(distrilbutionloadingscanDTO.getBarcode(),myCurrentWarehouse.getId()); - }catch (Exception e){ - log.error("#################货物下架错误:{}",distrilbutionloadingscanDTO.getBarcode()); + warehouseUpdownTypeClient.downTray(distrilbutionloadingscanDTO.getBarcode(), myCurrentWarehouse.getId()); + } catch (Exception e) { + log.error("#################货物下架错误:{}", distrilbutionloadingscanDTO.getBarcode()); // return Resp.scanFail("装车失败", "装车失败"); } List reservationLoadscanEntities = new ArrayList<>(); for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { - log.info("#########!!!!!!!!!!!!!!!!!--------- 88888888888 parcelListEntities={}",parcelListEntities); + log.info("#########!!!!!!!!!!!!!!!!!--------- 88888888888 parcelListEntities={}", parcelListEntities); if (parcelListEntity.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.weizhuancghe.getValue())) { parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); parcelListEntity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue()); distributionParcelListService.updateById(parcelListEntity); DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); - log.info("#########!!!!!!!!!!!!!!!!!--------- 77777777777 distributionDeliverySelfEntity={}",distributionDeliverySelfEntity); + log.info("#########!!!!!!!!!!!!!!!!!--------- 77777777777 distributionDeliverySelfEntity={}", distributionDeliverySelfEntity); if (Func.isNotEmpty(distributionDeliverySelfEntity.getDeliveryId())) { loadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); } @@ -706,7 +686,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl trayGoodIds = voGoodsLsit.stream().filter(v -> v.getAssociationType().equals("3")).map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); - //此时经过过滤后的包件ID和托盘上的所有包件ID数量一致,视为该托盘上的均为包件 + //此时经过过滤后的包件ID和托盘上的所有包件ID数量一致,视为该托盘上的均为包件 // if (voGoodsLsit.size() == trayGoodIds.size()) { // List parcelListEntities = distributionParcelListService.listByIds(trayGoodIds); //// if (trayLoadingStatus){ @@ -886,12 +866,8 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); - List distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); AtomicInteger loadingNum = new AtomicInteger(); AtomicInteger abnormalLoadingNum = new AtomicInteger(); if (Func.isNotEmpty(distributionLoadscanEntitiesflag)) { @@ -1353,10 +1329,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .set(DistributionLoadscanEntity::getScanStatus, 3) - ); + boolean update = distributionLoadscanService.update(new UpdateWrapper().lambda().eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).set(DistributionLoadscanEntity::getScanStatus, 3)); return R.success("成功"); } @@ -1394,14 +1367,9 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliverySelfEntity::getIsMaster, ServiceConstant.IS_MASTER_YES) - .eq(DistributionDeliverySelfEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - ); + distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectOne(new QueryWrapper().lambda().eq(DistributionDeliverySelfEntity::getIsMaster, ServiceConstant.IS_MASTER_YES).eq(DistributionDeliverySelfEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); } else { - DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper().lambda() - .eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - ); + DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper().lambda().eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity); } } else { @@ -1417,19 +1385,16 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationStockarticleEntityList = distributionReservationStockarticleService.list(Wrappers.query().lambda() - .eq(DistributionReservationStockarticleEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId())); + List reservationStockarticleEntityList = distributionReservationStockarticleService.list(Wrappers.query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId())); if (Func.isEmpty(reservationStockarticleEntityList)) { log.error("####################reservationStockarticleEntityList维护数据异常,reservationID:{}", distrilbutionloadingscanDTO.getReservationId()); } - List stockListDetailEntityList = disStockListDetailService.list(Wrappers.query().lambda() - .eq(DisStockListDetailEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationInventoryStatusConstant.quxiao.getValue())); + List stockListDetailEntityList = disStockListDetailService.list(Wrappers.query().lambda().eq(DisStockListDetailEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).ne(DisStockListDetailEntity::getStockPackageStatus, ReservationInventoryStatusConstant.quxiao.getValue())); boolean inventoryLoadingFlag = stockListDetailEntityList.stream().allMatch(i -> i.getStockPackageStatus().equals(InventoryLoadingStatusConstant.yizhuangche.getValue())); boolean inventoryStockUpFlag = stockListDetailEntityList.stream().anyMatch(l -> Func.isEmpty(l.getStockPackageCode())); if (inventoryStockUpFlag) { log.error("##################库存品未备货"); - return Resp.scanFail("操作失败","存在库存品未备货"); + return Resp.scanFail("操作失败", "存在库存品未备货"); // return R.fail("该客户存在库存品暂未备货 一键装车失败!!!"); } Map> allStockArticle = reservationStockarticleEntityList.stream().filter(f -> Func.isNotEmpty(f.getIsZero())).collect(Collectors.groupingBy(DistributionReservationStockarticleEntity::getIsZero)); @@ -1439,96 +1404,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl { - List parcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(distrilbutionloadingscanDTO.getReservationId(), reservationStockarticleEntity.getStockArticleId()); - for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { - DistributionLoadscanEntity packageLoadingScan = distributionLoadscanService.getOne(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()) - .eq(DistributionLoadscanEntity::getPackageId, parcelListEntity.getId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); - if (Func.isEmpty(packageLoadingScan)){ - DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); - BladeUser user = AuthUtil.getUser(); -// loadscanEntity.setScanUser(user.getUserName()); - loadscanEntity.setScanUser(user.getNickName()); - loadscanEntity.setDriverName(finalDistributionDeliverySelfEntity.getDriverName()); - loadscanEntity.setVehicleName(finalDistributionDeliverySelfEntity.getVehicleNub()); - loadscanEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); - loadscanEntity.setOneClick(2); - loadscanEntity.setScanUser(user.getUserName()); - loadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId()); - loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); - loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); - loadscanEntity.setLoadedNub(parcelListEntity.getQuantity()); - loadscanEntity.setScanTime(new Date()); - if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverPhone())) { - loadscanEntity.setDriverPhone(finalDistributionDeliverySelfEntity.getDriverPhone()); - } - if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getVehicleId())) { - loadscanEntity.setVehicleId(finalDistributionDeliverySelfEntity.getVehicleId()); - } - if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverId())) { - loadscanEntity.setDriverId(finalDistributionDeliverySelfEntity.getDriverId()); - } - if (Func.isNotEmpty(finalDistributionDeliverySelfEntity.getId())) { - loadscanEntity.setLoadingId(finalDistributionDeliverySelfEntity.getId().toString()); - } - if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverId())) { - loadscanEntity.setDriverId(finalDistributionDeliverySelfEntity.getDriverId()); - } - if (Func.isNotEmpty(parcelListEntity.getOrderPackageCode())) { - loadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode()); - } - if (Func.isNotEmpty(parcelListEntity.getId())) { - loadscanEntity.setPackageId(parcelListEntity.getId()); - } - if (Func.isNotEmpty(parcelListEntity.getId())) { - loadscanEntity.setPackageId(parcelListEntity.getId()); - } - if (Func.isNotEmpty(parcelListEntity.getStockArticleId())) { - loadscanEntity.setOrderId(parcelListEntity.getStockArticleId()); - } - if (Func.isNotEmpty(distrilbutionloadingscanDTO.getDeliveryId())) { - loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); - } -// parcelListEntity.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue()); -// distributionParcelListService.updateById(parcelListEntity); - distributionLoadscanService.save(loadscanEntity); - Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); - - Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); - warehouseUpdownTypeClient.downPackageOrDelTray(parcelListEntity.getOrderPackageCode(), myCurrentWarehouse.getId()); - distributionAsyncService.checkOrderLoadingStatus(parcelListEntity.getId()); - } - //异步修改包件状态 -// distributionAsyncService.changeMarketDeliveryListStatus(loadscanEntity.getOrderPackageCode(), loadscanEntity.getDeliveryId()); - } -// }); - break; - case "1": - //零担订单 -// v.forEach(zord -> { - List parcelNumberVOS = distributionReservationMapper.selectReservationZeroOrderDetail(reservationStockarticleEntity.getStockArticleId(), distrilbutionloadingscanDTO.getReservationId()); - for (DistributionParcelNumberVO parcelNumberVO : parcelNumberVOS) { - //这里需要查询是否已经存在有装车数据,如果有那么这里应该进行修改 - DistributionLoadscanEntity loadscanServiceOne = distributionLoadscanService.getOne(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()) - .eq(DistributionLoadscanEntity::getPackageId, parcelNumberVO.getParcelListId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List parcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(distrilbutionloadingscanDTO.getReservationId(), reservationStockarticleEntity.getStockArticleId()); + for (DistributionParcelListEntity parcelListEntity : parcelListEntities) { + DistributionLoadscanEntity packageLoadingScan = distributionLoadscanService.getOne(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()).eq(DistributionLoadscanEntity::getPackageId, parcelListEntity.getId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isEmpty(packageLoadingScan)) { DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); - DistributionParcelNumberEntity parcelNumberEntity = Func.copy(parcelNumberVO, DistributionParcelNumberEntity.class); - if (Func.isNotEmpty(loadscanServiceOne)) { - loadscanEntity = loadscanServiceOne; - } BladeUser user = AuthUtil.getUser(); -// loadscanEntity.setScanUser(user.getUserName()); +// loadscanEntity.setScanUser(user.getUserName()); loadscanEntity.setScanUser(user.getNickName()); loadscanEntity.setDriverName(finalDistributionDeliverySelfEntity.getDriverName()); loadscanEntity.setVehicleName(finalDistributionDeliverySelfEntity.getVehicleNub()); loadscanEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); loadscanEntity.setOneClick(2); loadscanEntity.setScanUser(user.getUserName()); + loadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId()); + loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); + loadscanEntity.setPackageNub(parcelListEntity.getQuantity()); + loadscanEntity.setLoadedNub(parcelListEntity.getQuantity()); loadscanEntity.setScanTime(new Date()); if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverPhone())) { loadscanEntity.setDriverPhone(finalDistributionDeliverySelfEntity.getDriverPhone()); @@ -1545,92 +1437,157 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl { + List parcelNumberVOS = distributionReservationMapper.selectReservationZeroOrderDetail(reservationStockarticleEntity.getStockArticleId(), distrilbutionloadingscanDTO.getReservationId()); + for (DistributionParcelNumberVO parcelNumberVO : parcelNumberVOS) { + //这里需要查询是否已经存在有装车数据,如果有那么这里应该进行修改 + DistributionLoadscanEntity loadscanServiceOne = distributionLoadscanService.getOne(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()).eq(DistributionLoadscanEntity::getPackageId, parcelNumberVO.getParcelListId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + DistributionLoadscanEntity loadscanEntity = new DistributionLoadscanEntity(); + DistributionParcelNumberEntity parcelNumberEntity = Func.copy(parcelNumberVO, DistributionParcelNumberEntity.class); + if (Func.isNotEmpty(loadscanServiceOne)) { + loadscanEntity = loadscanServiceOne; + } + BladeUser user = AuthUtil.getUser(); +// loadscanEntity.setScanUser(user.getUserName()); + loadscanEntity.setScanUser(user.getNickName()); + loadscanEntity.setDriverName(finalDistributionDeliverySelfEntity.getDriverName()); + loadscanEntity.setVehicleName(finalDistributionDeliverySelfEntity.getVehicleNub()); + loadscanEntity.setScanStatus(LoadingStatusConstant.yijianzhuangche.getValue()); + loadscanEntity.setOneClick(2); + loadscanEntity.setScanUser(user.getUserName()); + loadscanEntity.setScanTime(new Date()); + if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverPhone())) { + loadscanEntity.setDriverPhone(finalDistributionDeliverySelfEntity.getDriverPhone()); + } + if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getVehicleId())) { + loadscanEntity.setVehicleId(finalDistributionDeliverySelfEntity.getVehicleId()); + } + if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverId())) { + loadscanEntity.setDriverId(finalDistributionDeliverySelfEntity.getDriverId()); + } + if (Func.isNotEmpty(finalDistributionDeliverySelfEntity.getId())) { + loadscanEntity.setLoadingId(finalDistributionDeliverySelfEntity.getId().toString()); + } + if (StringUtils.isNotBlank(finalDistributionDeliverySelfEntity.getDriverId())) { + loadscanEntity.setDriverId(finalDistributionDeliverySelfEntity.getDriverId()); + } + if (Func.isNotEmpty(distrilbutionloadingscanDTO.getReservationId())) { + loadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId()); + } + if (Func.isNotEmpty(distrilbutionloadingscanDTO.getDeliveryId())) { + loadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(parcelNumberVO.getStockArticleId())) { - loadscanEntity.setOrderId(parcelNumberVO.getStockArticleId()); - } + if (Func.isNotEmpty(parcelNumberVO.getParcelListId())) { + loadscanEntity.setPackageId(parcelNumberVO.getParcelListId()); + } - if (Func.isEmpty(loadscanServiceOne)) { - if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { - loadscanEntity.setPackageNub(parcelNumberVO.getReservationNum()); - } - if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { - loadscanEntity.setLoadedNub(parcelNumberVO.getReservationNum()); - } - loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); - distributionLoadscanService.save(loadscanEntity); - //更新装车数量 - Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); + if (Func.isNotEmpty(parcelNumberVO.getStockArticleId())) { + loadscanEntity.setOrderId(parcelNumberVO.getStockArticleId()); + } + + if (Func.isEmpty(loadscanServiceOne)) { + if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { + loadscanEntity.setPackageNub(parcelNumberVO.getReservationNum()); + } + if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { + loadscanEntity.setLoadedNub(parcelNumberVO.getReservationNum()); + } + loadscanEntity.setTrainNumber(distributionDeliveryListEntity.getTrainNumber()); + distributionLoadscanService.save(loadscanEntity); + //更新装车数量 + Integer j = distributionSignforMapper.updateloadByReservationId(loadscanEntity.getDeliveryId(), loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); + BigDecimal handQuantity = new BigDecimal(parcelNumberVO.getHandQuantity()); + BigDecimal reservationNum = new BigDecimal(parcelNumberVO.getReservationNum()); + BigDecimal outboundQuantity = new BigDecimal(parcelNumberVO.getOutboundQuantity()); + BigDecimal deliveryQuantity = new BigDecimal(parcelNumberVO.getDeliveryQuantity()); + int handNum = handQuantity.subtract(reservationNum).intValue(); + parcelNumberEntity.setHandQuantity(handNum); + int outboundNum = outboundQuantity.add(reservationNum).intValue(); + parcelNumberEntity.setOutboundQuantity(outboundNum); + parcelNumberEntity.setDeliveryQuantity(deliveryQuantity.subtract(reservationNum).intValue()); + distributionParcelNumberService.updateById(parcelNumberEntity); + //维护零担订单在库 以及维护状态 + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelNumberVO.getStockArticleId()); + stockArticleEntity.setHandQuantity(stockArticleEntity.getHandQuantity() + loadscanEntity.getPackageNub() - parcelNumberVO.getReservationNum()); + distributionStockArticleService.updateById(stockArticleEntity); + } else { + //装车数量比计划数量少,这里才会进行一键装车数据修改 + if (loadscanServiceOne.getPackageNub() <= parcelNumberVO.getReservationNum()) { + //这里就需要维护零担品类的出库数量 +// Integer packageNub = loadscanEntity.getPackageNub(); + BigDecimal packageLoadingNub = new BigDecimal(loadscanServiceOne.getPackageNub()); BigDecimal handQuantity = new BigDecimal(parcelNumberVO.getHandQuantity()); BigDecimal reservationNum = new BigDecimal(parcelNumberVO.getReservationNum()); BigDecimal outboundQuantity = new BigDecimal(parcelNumberVO.getOutboundQuantity()); BigDecimal deliveryQuantity = new BigDecimal(parcelNumberVO.getDeliveryQuantity()); - int handNum = handQuantity.subtract(reservationNum).intValue(); + int handNum = handQuantity.add(packageLoadingNub).subtract(reservationNum).intValue(); + int deliveryNum = deliveryQuantity.add(packageLoadingNub).subtract(reservationNum).intValue(); + int outboundNum = outboundQuantity.subtract(packageLoadingNub).add(reservationNum).intValue(); parcelNumberEntity.setHandQuantity(handNum); - int outboundNum = outboundQuantity.add(reservationNum).intValue(); + parcelNumberEntity.setDeliveryQuantity(deliveryNum); parcelNumberEntity.setOutboundQuantity(outboundNum); - parcelNumberEntity.setDeliveryQuantity(deliveryQuantity.subtract(reservationNum).intValue()); + if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { + loadscanServiceOne.setPackageNub(parcelNumberVO.getReservationNum()); + } + if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { + loadscanServiceOne.setLoadedNub(parcelNumberVO.getReservationNum()); + } + distributionLoadscanService.updateById(loadscanServiceOne); distributionParcelNumberService.updateById(parcelNumberEntity); //维护零担订单在库 以及维护状态 DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelNumberVO.getStockArticleId()); - stockArticleEntity.setHandQuantity(stockArticleEntity.getHandQuantity() + loadscanEntity.getPackageNub() - parcelNumberVO.getReservationNum()); + stockArticleEntity.setHandQuantity(stockArticleEntity.getHandQuantity() - parcelNumberVO.getReservationNum()); distributionStockArticleService.updateById(stockArticleEntity); - } else { - //装车数量比计划数量少,这里才会进行一键装车数据修改 - if (loadscanServiceOne.getPackageNub() <= parcelNumberVO.getReservationNum()) { - //这里就需要维护零担品类的出库数量 -// Integer packageNub = loadscanEntity.getPackageNub(); - BigDecimal packageLoadingNub = new BigDecimal(loadscanServiceOne.getPackageNub()); - BigDecimal handQuantity = new BigDecimal(parcelNumberVO.getHandQuantity()); - BigDecimal reservationNum = new BigDecimal(parcelNumberVO.getReservationNum()); - BigDecimal outboundQuantity = new BigDecimal(parcelNumberVO.getOutboundQuantity()); - BigDecimal deliveryQuantity = new BigDecimal(parcelNumberVO.getDeliveryQuantity()); - int handNum = handQuantity.add(packageLoadingNub).subtract(reservationNum).intValue(); - int deliveryNum = deliveryQuantity.add(packageLoadingNub).subtract(reservationNum).intValue(); - int outboundNum = outboundQuantity.subtract(packageLoadingNub).add(reservationNum).intValue(); - parcelNumberEntity.setHandQuantity(handNum); - parcelNumberEntity.setDeliveryQuantity(deliveryNum); - parcelNumberEntity.setOutboundQuantity(outboundNum); - if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { - loadscanServiceOne.setPackageNub(parcelNumberVO.getReservationNum()); - } - if (Func.isNotEmpty(parcelNumberVO.getQuantity())) { - loadscanServiceOne.setLoadedNub(parcelNumberVO.getReservationNum()); - } - distributionLoadscanService.updateById(loadscanServiceOne); - distributionParcelNumberService.updateById(parcelNumberEntity); - //维护零担订单在库 以及维护状态 - DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelNumberVO.getStockArticleId()); - stockArticleEntity.setHandQuantity(stockArticleEntity.getHandQuantity() - parcelNumberVO.getReservationNum()); - distributionStockArticleService.updateById(stockArticleEntity); - Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); - //维护签收表装车数量 - DistributionSignforEntity signforEntity = distributionSignforService.getOne(Wrappers.query().lambda().eq(DistributionSignforEntity::getDeliveryId, loadscanServiceOne.getDeliveryId()).eq(DistributionSignforEntity::getReservationId, loadscanServiceOne.getReservationId())); - if (Func.isEmpty(signforEntity)) { - log.error("##################签收查询失败,预约ID:{}", loadscanServiceOne.getReservationId()); - throw new RuntimeException("服务器正忙..."); - } - BigDecimal loadedNumber = new BigDecimal(signforEntity.getLoadedNumber()); - signforEntity.setLoadedNumber(loadedNumber.subtract(packageLoadingNub).add(reservationNum).intValue()); - distributionSignforService.updateById(signforEntity); - //异步修改包件状态 + Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId()); + //维护签收表装车数量 + DistributionSignforEntity signforEntity = distributionSignforService.getOne(Wrappers.query().lambda().eq(DistributionSignforEntity::getDeliveryId, loadscanServiceOne.getDeliveryId()).eq(DistributionSignforEntity::getReservationId, loadscanServiceOne.getReservationId())); + if (Func.isEmpty(signforEntity)) { + log.error("##################签收查询失败,预约ID:{}", loadscanServiceOne.getReservationId()); + throw new RuntimeException("服务器正忙..."); + } + BigDecimal loadedNumber = new BigDecimal(signforEntity.getLoadedNumber()); + signforEntity.setLoadedNumber(loadedNumber.subtract(packageLoadingNub).add(reservationNum).intValue()); + distributionSignforService.updateById(signforEntity); + //异步修改包件状态 // distributionAsyncService.checkZeroStockArticleLoadingStatus(parcelNumberEntity); // JsonObject jsonObject = new JsonObject(); // jsonObject.addProperty(""); // warehouseUpdownTypeClient.downZeroOrder() - } } } } + } // }); break; @@ -1711,7 +1668,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .set(DistributionLoadscanEntity::getScanStatus, 3) - ); + boolean update = distributionLoadscanService.update(new UpdateWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).set(DistributionLoadscanEntity::getScanStatus, 3)); //异步确认包条扫描信息 // distributionAsyncService.makeSureByPackage(distrilbutionloadingscanDTO); //库存品确认装车 - distributionLoadscaninvnService.update(new UpdateWrapper().lambda() - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .set(DistributionLoadscaninvnEntity::getScanStatus, 3) - ); + distributionLoadscaninvnService.update(new UpdateWrapper().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).set(DistributionLoadscaninvnEntity::getScanStatus, 3)); return R.status(update); } @@ -1994,19 +1945,11 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .eq(DistributionLoadscanEntity::getScanStatus, 1) - ); + List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).eq(DistributionLoadscanEntity::getScanStatus, 1)); if (!distributionLoadscanEntitiesflag.isEmpty()) { return R.fail(3002, "重复取消"); } - List distributionLoadscanEntitiesflag2 = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscaninvnEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()) - .eq(DistributionLoadscaninvnEntity::getScanStatus, 1) - ); + List distributionLoadscanEntitiesflag2 = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscaninvnEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()).eq(DistributionLoadscaninvnEntity::getScanStatus, 1)); if (!distributionLoadscanEntitiesflag2.isEmpty()) { return R.fail(3002, "重复取消"); } @@ -2039,9 +1982,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionReservationStockarticleEntity::getStockArticleId, distrilbutionloadingscanDTO.getBarcode())); + DistributionReservationStockarticleEntity distributionReservationStockarticleEntity = distributionReservationStockarticleMapper.selectOne(new QueryWrapper().lambda().eq(DistributionReservationStockarticleEntity::getStockArticleId, distrilbutionloadingscanDTO.getBarcode())); if (distributionReservationStockarticleEntity.getIsHaveData() == 1) { //查询订单是否属于该配送任务 List distributionLoadscanEntities = baseMapper.selectOrderpallet(distrilbutionloadingscanDTO.getBarcode(), distrilbutionloadingscanDTO.getDeliveryId()); @@ -2105,10 +2046,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(Wrappers.query().lambda() - .eq(DistributionLoadscaninvnEntity::getOrderPackageCode, barcode) - .ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); + List distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(Wrappers.query().lambda().eq(DistributionLoadscaninvnEntity::getOrderPackageCode, barcode).ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()).eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); int size = distributionLoadscaninvnEntities.size(); if (size == 1) { //这里就是存在有该库存品的扫描 @@ -2116,9 +2054,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl list = disStockListDetailService.list(Wrappers.query().lambda() - .eq(DisStockListDetailEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .ne(DisStockListDetailEntity::getStockPackageStatus, ReservationInventoryStatusConstant.quxiao.getValue())); + List list = disStockListDetailService.list(Wrappers.query().lambda().eq(DisStockListDetailEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).ne(DisStockListDetailEntity::getStockPackageStatus, ReservationInventoryStatusConstant.quxiao.getValue())); List detailEntities = list.stream().filter(l -> Func.isNotEmpty(l.getStockPackageCode())).collect(Collectors.toList()); if (detailEntities.size() <= 0) { return Resp.scanFail("此码无效", "此码无效"); @@ -2135,7 +2071,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda().eq(DistributionStockListEntity::getId, distributionLoadscaninvnEntity.getInventoryId())); BigDecimal quantityStock = new BigDecimal(distributionStockListEntity.getQuantityStock()); @@ -2154,6 +2090,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscanEntities = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .ne(DistributionLoadscanEntity::getScanStatus, 1) - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode()) - ); + List distributionLoadscanEntities = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().ne(DistributionLoadscanEntity::getScanStatus, 1).eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); if (null == distributionLoadscanEntities || distributionLoadscanEntities.isEmpty()) { return R.fail(3005, "该货物未装车"); } @@ -2343,7 +2276,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionAppDeliveryListVOS = new ArrayList<>(); boolean delivery = false; - String value1 = DictBizCache.getValue("role_class", "delivery_driver_new"); + String value1 = DictBizCache.getValue("role_class", "delivery_driver_new"); if (roleId.contains(value1)) delivery = true; @@ -2391,23 +2324,17 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) - .eq(DistributionLoadscanEntity::getSignforState, 2) - ).intValue(); + Integer lad = distributionLoadscanMapper.selectCount(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()).eq(DistributionLoadscanEntity::getSignforState, 2)).intValue(); //查询库存品签收件数 - Integer nad = distributionLoadscaninvnMapper.selectCount(new QueryWrapper().lambda() - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) - .eq(DistributionLoadscaninvnEntity::getSignforState, 2) - ).intValue(); + Integer nad = distributionLoadscaninvnMapper.selectCount(new QueryWrapper().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionAppDeliveryListVO.getId()).eq(DistributionLoadscaninvnEntity::getSignforState, 2)).intValue(); //维护计划数 List reservationEntityList = baseMapper.selectReservationByDeliveryListId(distributionAppDeliveryListVO.getId()); - if (Func.isNotEmpty(reservationEntityList)){ + if (Func.isNotEmpty(reservationEntityList)) { int packageNum = reservationEntityList.stream().mapToInt(DistributionReservationEntity::getReservationNum).sum(); int invertoryNum = reservationEntityList.stream().mapToInt(DistributionReservationEntity::getReservationStockListNum).sum(); distributionAppDeliveryListVO.setDeliveryNumber(packageNum + invertoryNum); - }else { + } else { return null; } distributionAppDeliveryListVO.setSignNub(lad + nad); @@ -2419,18 +2346,13 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl deliveryStockArticleInfo = baseMapper.getDeliveryStockArticleInfo(distributionAppDeliveryListVO.getId()); // deliveryStockArticleInfo.forEach(); List distributionReservationEntities = baseMapper.selectReservationByDeliveryListId(distributionAppDeliveryListVO.getId()); - distributionReservationEntities.forEach(r->{ + distributionReservationEntities.forEach(r -> { List reservationStockarticleEntityList = distributionReservationMapper.selectStockArticleByReservationId(r.getId()); - reservationStockarticleEntityList.forEach(rs->{ - List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) - .eq(DistributionLoadscanEntity::getOrderId, rs.getStockArticleId()) - .eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - ); - if (Func.isNotEmpty(loadscanEntityList)){ + reservationStockarticleEntityList.forEach(rs -> { + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListVO.getId()).eq(DistributionLoadscanEntity::getOrderId, rs.getStockArticleId()).eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(loadscanEntityList)) { int loadSum = loadscanEntityList.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum(); - if (rs.getReservationNum() == loadSum){ + if (rs.getReservationNum() == loadSum) { ordCount.getAndIncrement(); } } @@ -2445,9 +2367,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionSignforEntityList = distributionSignforMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionSignforEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) - ); + List distributionSignforEntityList = distributionSignforMapper.selectList(new QueryWrapper().lambda().eq(DistributionSignforEntity::getDeliveryId, distributionAppDeliveryListVO.getId())); //提取id List reList = distributionSignforEntityList.stream().map(DistributionSignforEntity::getId).collect(Collectors.toList()); distributionAppDeliveryListVO.setType_name(dictBizClient.getValue("distribution_type", distributionAppDeliveryListVO.getType()).getData()); @@ -2460,21 +2380,17 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliverySelfEntity::getDeliveryId, distributionAppDeliveryListVO.getId()) - ).intValue(); + aLong = distributionDeliverySelfMapper.selectCount(new QueryWrapper().lambda().eq(DistributionDeliverySelfEntity::getDeliveryId, distributionAppDeliveryListVO.getId())).intValue(); } else { - aLong2 = distributionDeliveryTripartiteMapper.selectCount(new QueryWrapper().lambda() - .eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distributionAppDeliveryListVO.getId())).intValue(); + aLong2 = distributionDeliveryTripartiteMapper.selectCount(new QueryWrapper().lambda().eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distributionAppDeliveryListVO.getId())).intValue(); } if (aLong == 0 && aLong2 == 0) { distributionAppDeliveryListVO.setVehicleStatus_name("未配车"); } //查询是否备货 distributionAppDeliveryListVO.setIsstock("备货未完成"); - List stockEntityList = distributionStockMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionStockEntity::getReservationId, distributionAppDeliveryListVO.getReservationId())); - if (Func.isNotEmpty(stockEntityList)){ + List stockEntityList = distributionStockMapper.selectList(new QueryWrapper().lambda().eq(DistributionStockEntity::getReservationId, distributionAppDeliveryListVO.getReservationId())); + if (Func.isNotEmpty(stockEntityList)) { Integer deliveryNumber = distributionAppDeliveryListVO.getDeliveryNumber(); //配送件数 int sum = stockEntityList.stream().mapToInt(DistributionStockEntity::getStockQuantity).sum(); if (sum == deliveryNumber) { @@ -2510,10 +2426,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl customList = distributionDeliveryInfoMapper.selectAppcustomList(detail.getId()); for (DistributionAppReservationVO distributionAppReservationVO : customList) { //查询备货是否完成 - Integer aLong = distributionStockMapper.selectCount(new QueryWrapper().lambda() - .eq(DistributionStockEntity::getReservationId, distributionAppReservationVO.getId()) - .eq(DistributionStockEntity::getType, 1) - ).intValue(); + Integer aLong = distributionStockMapper.selectCount(new QueryWrapper().lambda().eq(DistributionStockEntity::getReservationId, distributionAppReservationVO.getId()).eq(DistributionStockEntity::getType, 1)).intValue(); distributionAppReservationVO.setIsstock("是"); distributionAppReservationVO.setIsload("是"); if (aLong < distributionAppReservationVO.getReservationNum()) { @@ -2539,10 +2452,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationPackageEntityList = distributionReservationPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getReservationId, rs.getReservationId()) - .eq(DistributionReservationPackageEntity::getStockArticleId, stockArticleEntity.getId()) - .ne(DistributionReservationPackageEntity::getPacketBarStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationPackageEntityList = distributionReservationPackageService.list(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getReservationId, rs.getReservationId()).eq(DistributionReservationPackageEntity::getStockArticleId, stockArticleEntity.getId()).ne(DistributionReservationPackageEntity::getPacketBarStatus, ReservationPackageStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(reservationPackageEntityList)) { ArrayList distributionParcelListVOS = new ArrayList<>(); reservationPackageEntityList.forEach(rp -> { @@ -2656,57 +2566,45 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl loadscanEntityList = new ArrayList<>(); List trayList = new ArrayList<>(); for (DistributionReservationStockarticleEntity reservationStockarticleEntity : reservationStockarticleEntityList) { - if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())){ + if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())) { //查询订制品备货数量 - List packageListStockUpScan = distributionStockMapper.selectList(Wrappers.query().lambda() - .eq(DistributionStockEntity::getType, 1) - .eq(DistributionStockEntity::getParcelListId, reservationStockarticleEntity.getStockArticleId()) - .eq(DistributionStockEntity::getReservationId, reservationStockarticleEntity.getReservationId())); - if (Func.isNotEmpty(packageListStockUpScan)){ + List packageListStockUpScan = distributionStockMapper.selectList(Wrappers.query().lambda().eq(DistributionStockEntity::getType, 1).eq(DistributionStockEntity::getParcelListId, reservationStockarticleEntity.getStockArticleId()).eq(DistributionStockEntity::getReservationId, reservationStockarticleEntity.getReservationId())); + if (Func.isNotEmpty(packageListStockUpScan)) { distributionStockEntities.addAll(packageListStockUpScan); } //统计托盘数 //查询所有包件 List parcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(reservationStockarticleEntity.getReservationId(), reservationStockarticleEntity.getStockArticleId()); - parcelListEntities.forEach(p->{ + parcelListEntities.forEach(p -> { WarehouseTrayGoodsEntity warehouseTrayGoodsEntity = new WarehouseTrayGoodsEntity(); warehouseTrayGoodsEntity.setAssociationId(p.getId()); warehouseTrayGoodsEntity.setAssociationValue(p.getOrderPackageCode()); warehouseTrayGoodsEntity.setAssociationType("3"); List trayGoodsClientTrayList = warehouseTrayGoodsClient.getTrayList(warehouseTrayGoodsEntity); - if (Func.isNotEmpty(trayGoodsClientTrayList)){ + if (Func.isNotEmpty(trayGoodsClientTrayList)) { trayList.addAll(trayGoodsClientTrayList); } }); //查询订制品装车数量 - List packageListLoadingScan = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()) - .eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); - if (Func.isNotEmpty(packageListLoadingScan)){ + List packageListLoadingScan = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()).eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(packageListLoadingScan)) { loadscanEntityList.addAll(packageListLoadingScan); } - }else if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.yes.getValue())){ + } else if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.yes.getValue())) { //查询零担备货数量 - List zeroPackageListStockUpScan = distributionStockMapper.selectList(Wrappers.query().lambda() - .eq(DistributionStockEntity::getType, 2) - .eq(DistributionStockEntity::getParcelListId, reservationStockarticleEntity.getStockArticleId()) - .eq(DistributionStockEntity::getReservationId, reservationStockarticleEntity.getReservationId())); - if (Func.isNotEmpty(zeroPackageListStockUpScan)){ + List zeroPackageListStockUpScan = distributionStockMapper.selectList(Wrappers.query().lambda().eq(DistributionStockEntity::getType, 2).eq(DistributionStockEntity::getParcelListId, reservationStockarticleEntity.getStockArticleId()).eq(DistributionStockEntity::getReservationId, reservationStockarticleEntity.getReservationId())); + if (Func.isNotEmpty(zeroPackageListStockUpScan)) { distributionStockEntities.addAll(zeroPackageListStockUpScan); } //查询零担装车数量 - List zeroPackageListLoadingScan = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()) - .eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); - if (Func.isNotEmpty(zeroPackageListLoadingScan)){ + List zeroPackageListLoadingScan = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()).eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(zeroPackageListLoadingScan)) { loadscanEntityList.addAll(zeroPackageListLoadingScan); } } } distributionAppReservationVO.setTrayNum(0); - if (Func.isNotEmpty(trayList)){ + if (Func.isNotEmpty(trayList)) { // Long count = trayList.stream().map(WarehouseTrayGoodsEntity::getTrayId).count(); Long aaa = trayList.stream().map(WarehouseTrayGoodsEntity::getTrayId).distinct().count(); distributionAppReservationVO.setTrayNum(aaa.intValue()); @@ -2714,25 +2612,21 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl stockListDetailEntityList = distributionReservationMapper.selectInventoryListByReservation(distributionAppReservationVO.getId()); // boolean inventoryStockupStatus = stockListDetailEntityList.stream().allMatch(i -> Func.isNotEmpty(i.getStockPackageCode())); //备货数和计划数一致时完成备货 - if (distributionStockEntities.size()+stockListDetailEntityList.stream().filter(s->Func.isNotEmpty(s.getStockPackageCode())).count() == distributionAppReservationVO.getReservationNum()){ + if (distributionStockEntities.size() + stockListDetailEntityList.stream().filter(s -> Func.isNotEmpty(s.getStockPackageCode())).count() == distributionAppReservationVO.getReservationNum()) { distributionAppReservationVO.setIsstock("是"); - }else { + } else { distributionAppReservationVO.setIsstock("否"); } Integer packageListScanNum = loadscanEntityList.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum(); Long inventoryListScanNum = stockListDetailEntityList.stream().filter(i -> Func.isNotEmpty(i.getStockPackageCode()) && i.getStockLockingStatus().equals(InventoryLoadingStatusConstant.yizhuangche.getValue())).count(); distributionAppReservationVO.setLoadingNub(packageListScanNum + inventoryListScanNum.intValue()); - if (packageListScanNum + inventoryListScanNum ==distributionAppReservationVO.getReservationNum() ) { + if (packageListScanNum + inventoryListScanNum == distributionAppReservationVO.getReservationNum()) { distributionAppReservationVO.setIsload("是"); } else { distributionAppReservationVO.setIsload("否"); } - - - - // List parcelListEntities = distributionReservationMapper.selectPackageListByReservationId(distributionAppReservationVO.getId()); // // boolean stockArticleStockupStatus = parcelListEntities.stream().allMatch(s -> Func.isNotEmpty(s.getOrderPackageStockupStatus()) && s.getOrderPackageStockupStatus().equals(OrderPackageStockupStatusConstant.yibeihu.getValue())); @@ -2770,15 +2664,15 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl selectDistributionAppDeliverywrapIn(DistributionAppDeliveryListDTO distributionAppDeliveryListDTO) { List detailEntities = baseMapper.selectInventoryListByDeliveryListId(distributionAppDeliveryListDTO.getId()); - if (Func.isEmpty(detailEntities)){ + if (Func.isEmpty(detailEntities)) { return null; } List stockListIds = detailEntities.stream().map(DisStockListDetailEntity::getStockListId).distinct().collect(Collectors.toList()); List distributionStockListEntities = distributionStockListService.listByIds(stockListIds); Map stockListMap = distributionStockListEntities.stream().collect(Collectors.toMap(DistributionStockListEntity::getId, Function.identity(), (k1, k2) -> k2)); List disStockListDetailVOS = DistributionDisStockListWrapper.build().listVO(detailEntities); - disStockListDetailVOS.stream().forEach(sd->{ - if (Func.isNotEmpty(stockListMap.get(sd.getStockListId()))){ + disStockListDetailVOS.stream().forEach(sd -> { + if (Func.isNotEmpty(stockListMap.get(sd.getStockListId()))) { DistributionStockListEntity distributionStockListEntity = stockListMap.get(sd.getStockListId()); sd.setMarketName(distributionStockListEntity.getMarketName()); sd.setDescriptionGoods(distributionStockListEntity.getDescriptionGoods()); @@ -2965,13 +2859,10 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId()) - .ne(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.yizhuangche.getValue()) - .ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()) - .notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); - if (Func.isEmpty(distributionParcelListEntities)){ + List distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId()).ne(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.yizhuangche.getValue()).ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()).notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); + if (Func.isEmpty(distributionParcelListEntities)) { - throw new RuntimeException(s.getOrderCode()+"无可用数量"); + throw new RuntimeException(s.getOrderCode() + "无可用数量"); } distributionParcelListEntities.forEach(dp -> { if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { @@ -3059,7 +2950,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationStockarticleEntityList = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId()) - .ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); + List reservationStockarticleEntityList = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId()).ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); Map> oldOrder = reservationStockarticleEntityList.stream().collect(Collectors.groupingBy(DistributionReservationStockarticleEntity::getStockArticleId)); v.forEach(s -> { orderTotal.getAndIncrement(); @@ -3187,10 +3076,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId()) - .ne(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.yizhuangche.getValue()) - .ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()) - .notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); + List distributionParcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, s.getId()).ne(DistributionParcelListEntity::getOrderPackageLoadingStatus, OrderPackageLoadingStatusConstant.yizhuangche.getValue()).ne(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.yiyueyue.getValue()).notIn(DistributionParcelListEntity::getOrderPackageStatus, new String[]{OrderPackageStatusConstant.yichuku.getValue(), OrderPackageStatusConstant.yiqianshou.getValue()})); distributionParcelListEntities.forEach(dp -> { if (!dp.getOrderPackageStatus().equals(OrderPackageStatusConstant.yiqianshou.getValue())) { if (!Func.equals(dp.getOrderPackageFreezeStatus(), OrderPackageFreezeStatusConstant.yidongjie.getValue()) && !Func.equals(dp.getOrderPackageReservationStatus(), OrderPackageReservationStatusConstant.yiyueyue.getValue())) { @@ -3282,11 +3168,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl packageListInfo = s.getPackageListInfo(); log.info("reservationEntity.getId()>>>>>>>>{}", reservationEntity.getId()); log.info("s.getId()>>>>>>>>{}", s.getId()); - List list = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionReservationPackageEntity::getStockArticleId, s.getId()) - .ne(DistributionReservationPackageEntity::getPacketBarStatus, "2") - ); + List list = distributionReservationPackageMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()).eq(DistributionReservationPackageEntity::getStockArticleId, s.getId()).ne(DistributionReservationPackageEntity::getPacketBarStatus, "2")); // List distributionReservationPackageEntities = distributionReservationPackageMapper.selectList(new QueryWrapper().lambda() // .eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()) // .eq(DistributionReservationPackageEntity::getStockArticleId, s.getId()) @@ -3336,10 +3218,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationZeroPackageEntity::getReservationId, reservationStockarticleEntity.getReservationId()) - .eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()) - .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda().eq(DistributionReservationZeroPackageEntity::getReservationId, reservationStockarticleEntity.getReservationId()).eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()).ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(reservationZeroPackageEntityList)) { Map> oldZeroPackageList = reservationZeroPackageEntityList.stream().collect(Collectors.groupingBy(DistributionReservationZeroPackageEntity::getParcelListId)); List parcelNumberVOS = s.getParcelNumberVOS(); @@ -3351,9 +3230,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionParcelNumberEntity::getStockArticleId, distributionReservationZeroPackageEntity.getStockArticleId()) - .eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getStockArticleId, distributionReservationZeroPackageEntity.getStockArticleId()).eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId())); BigDecimal dongjieNum = new BigDecimal(parcelNumberEntity.getDeliveryQuantity().toString()); BigDecimal yuanlaiNum = new BigDecimal(distributionReservationZeroPackageEntity.getQuantity().toString()); BigDecimal xiugaiNum = new BigDecimal(pn.getReservationNum().toString()); @@ -3367,9 +3244,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionParcelNumberEntity::getStockArticleId, pn.getStockArticleId()) - .eq(DistributionParcelNumberEntity::getParcelListId, pn.getParcelListId())); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getStockArticleId, pn.getStockArticleId()).eq(DistributionParcelNumberEntity::getParcelListId, pn.getParcelListId())); DistributionReservationZeroPackageEntity reservationZeroPackageEntity = new DistributionReservationZeroPackageEntity(); reservationZeroPackageEntity.setZeroPackageStatus(ReservationPackageStatusConstant.xinzeng.getValue()); reservationZeroPackageEntity.setQuantity(pn.getReservationNum()); @@ -3394,9 +3269,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionParcelNumberEntity::getStockArticleId, reservationZeroPackageEntity.getStockArticleId()) - .eq(DistributionParcelNumberEntity::getParcelListId, reservationZeroPackageEntity.getParcelListId())); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getStockArticleId, reservationZeroPackageEntity.getStockArticleId()).eq(DistributionParcelNumberEntity::getParcelListId, reservationZeroPackageEntity.getParcelListId())); BigDecimal dongjieNum = new BigDecimal(parcelNumberEntity.getDeliveryQuantity().toString()); BigDecimal yuanlaiNum = new BigDecimal(distributionReservationZeroPackageEntity.getQuantity().toString()); parcelNumberEntity.setDeliveryQuantity(dongjieNum.subtract(yuanlaiNum).intValue()); @@ -3425,9 +3298,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl { DistributionReservationStockarticleEntity reservationStockarticleEntity = n.get(0); if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())) { - List reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionReservationPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId())); + List reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()).eq(DistributionReservationPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId())); reservationPackageEntityList.forEach(p -> { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(p.getParceListId()); parcelListEntity.setOrderPackageReservationStatus(OrderPackageReservationStatusConstant.daiyuyue.getValue()); @@ -3440,15 +3311,11 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationZeroPackageEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()) - .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda().eq(DistributionReservationZeroPackageEntity::getReservationId, reservationEntity.getId()).eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()).ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); reservationZeroPackageEntityList.forEach(rzp -> { rzp.setZeroPackageStatus(ReservationPackageStatusConstant.quxiao.getValue()); distributionReservationZeroPackageService.updateById(rzp); - DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() - .eq(DistributionParcelNumberEntity::getParcelListId, rzp.getParcelListId())); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getParcelListId, rzp.getParcelListId())); if (Func.isNotEmpty(parcelNumberEntity)) { // parcelNumberEntity.setHandQuantity(parcelNumberEntity.getHandQuantity() + rzp.getQuantity()); parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - rzp.getQuantity()); @@ -3484,17 +3351,13 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl entities = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda() - .ne(DistributionReservationStockarticleEntity::getStockArticleStatus, "2") - .eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId())); + List entities = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda().ne(DistributionReservationStockarticleEntity::getStockArticleStatus, "2").eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId())); entities.forEach(e -> { if (e.getIsZero().equals(IsOrNoConstant.no.getValue())) { e.setStockArticleStatus(ReservationOrderStatusConstant.quxiao.getValue()); distributionReservationStockarticleService.updateById(e); //这个订单的包件预约进行取消 - List packageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getStockArticleId, e.getStockArticleId()) - .ne(DistributionReservationPackageEntity::getPacketBarStatus, "2")); + List packageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getStockArticleId, e.getStockArticleId()).ne(DistributionReservationPackageEntity::getPacketBarStatus, "2")); packageEntityList.forEach(p -> { p.setPacketBarStatus(ReservationPackageStatusConstant.quxiao.getValue()); distributionReservationPackageService.updateById(p); @@ -3510,15 +3373,11 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationZeroPackageEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionReservationZeroPackageEntity::getStockArticleId, e.getStockArticleId()) - .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda().eq(DistributionReservationZeroPackageEntity::getReservationId, reservationEntity.getId()).eq(DistributionReservationZeroPackageEntity::getStockArticleId, e.getStockArticleId()).ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); reservationZeroPackageEntityList.forEach(rzp -> { rzp.setZeroPackageStatus(ReservationPackageStatusConstant.quxiao.getValue()); distributionReservationZeroPackageService.updateById(rzp); - DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda() - .eq(DistributionParcelNumberEntity::getParcelListId, rzp.getParcelListId())); + DistributionParcelNumberEntity parcelNumberEntity = distributionParcelNumberService.getOne(Wrappers.query().lambda().eq(DistributionParcelNumberEntity::getParcelListId, rzp.getParcelListId())); if (Func.isNotEmpty(parcelNumberEntity)) { // parcelNumberEntity.setHandQuantity(parcelNumberEntity.getHandQuantity() + rzp.getQuantity()); parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - rzp.getQuantity()); @@ -3949,7 +3808,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl appParcelListVOS = new ArrayList<>(); List reservationStockarticleEntityList = baseMapper.selectReservationStockByDeliveryId(distributionAppDeliveryListDTO.getId()); List reservationEntityList = baseMapper.selectReservationByDeliveryListId(distributionAppDeliveryListDTO.getId()); - if (Func.isEmpty(reservationEntityList)){ - log.error("###################查询配送预约信息异常,deliveryID:{}",distributionAppDeliveryListDTO.getId()); + if (Func.isEmpty(reservationEntityList)) { + log.error("###################查询配送预约信息异常,deliveryID:{}", distributionAppDeliveryListDTO.getId()); return null; } - if (Func.isEmpty(reservationStockarticleEntityList)){ + if (Func.isEmpty(reservationStockarticleEntityList)) { return null; } //计划客户数 @@ -3992,20 +3851,16 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl{ - if (rs.getIsZero().equals(IsOrNoConstant.no.getValue())){ + reservationStockarticleEntityList.forEach(rs -> { + if (rs.getIsZero().equals(IsOrNoConstant.no.getValue())) { List parcelListEntityList = distributionReservationMapper.selectPackageByReservationAndStockArticle(rs.getReservationId(), rs.getStockArticleId()); - List packageLoadingList = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListDTO.getId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - .eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()) - .in(DistributionLoadscanEntity::getPackageId, parcelListEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()))); - if (Func.isNotEmpty(packageLoadingList)){ + List packageLoadingList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListDTO.getId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()).eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()).in(DistributionLoadscanEntity::getPackageId, parcelListEntityList.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()))); + if (Func.isNotEmpty(packageLoadingList)) { signNubSr.getAndAdd(packageLoadingList.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum()); } boolean packageFlag = parcelListEntityList.stream().allMatch(p -> p.getOrderPackageLoadingStatus().equals(OrderPackageLoadingStatusConstant.yizhuangche.getValue())); - if (packageFlag){ + if (packageFlag) { //完成订单累加 loadOrdNub.getAndIncrement(); } @@ -4013,27 +3868,23 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl parcelNumberVOS = distributionReservationMapper.selectReservationZeroOrderDetail(rs.getStockArticleId(), rs.getReservationId()); - List loadscanEntities = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListDTO.getId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - .eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()) - .in(DistributionLoadscanEntity::getPackageId, parcelNumberVOS.stream().map(DistributionParcelNumberVO::getParcelListId).collect(Collectors.toList()))); - if (Func.isNotEmpty(loadscanEntities)){ + List loadscanEntities = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionAppDeliveryListDTO.getId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()).eq(DistributionLoadscanEntity::getReservationId, rs.getReservationId()).in(DistributionLoadscanEntity::getPackageId, parcelNumberVOS.stream().map(DistributionParcelNumberVO::getParcelListId).collect(Collectors.toList()))); + if (Func.isNotEmpty(loadscanEntities)) { //统计装车数量 signNubSr.getAndAdd(loadscanEntities.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum()); int zeroPackageLoadingNum = loadscanEntities.stream().mapToInt(DistributionLoadscanEntity::getLoadedNub).sum(); - if (rs.getReservationNum() == zeroPackageLoadingNum){ + if (rs.getReservationNum() == zeroPackageLoadingNum) { loadOrdNub.getAndIncrement(); } } - parcelNumberVOS.forEach(p->{ + parcelNumberVOS.forEach(p -> { DistributionAppParcelListVO appParcelListVO = Func.copy(p, DistributionAppParcelListVO.class); appParcelListVOS.add(appParcelListVO); }); - }else { - log.error("############reservation_stockarticle表isZero字段维护错误,reservationId:{}",rs.getReservationId()); + } else { + log.error("############reservation_stockarticle表isZero字段维护错误,reservationId:{}", rs.getReservationId()); } }); @@ -4269,9 +4120,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl loadscanEntities = distributionLoadscanMapper.selectList(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distributionDeliveryInfoDTO.getDeliveryId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List loadscanEntities = distributionLoadscanMapper.selectList(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distributionDeliveryInfoDTO.getDeliveryId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); Map loadingDataMap = null; if (Func.isNotEmpty(loadscanEntities)) { loadingDataMap = loadscanEntities.stream().collect(Collectors.toMap(DistributionLoadscanEntity::getPackageId, Function.identity(), (k1, k2) -> k2)); @@ -4285,7 +4134,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl queryWrapper = Condition.getQueryWrapper(params, DistributionStockArticleEntity.class); queryWrapper.ne("reservation_status", "30"); - LambdaQueryWrapper lambdaQueryWrapper = Wrappers.query().lambda() - .eq(DistributionStockArticleEntity::getGenre, genre) - .ne(DistributionStockArticleEntity::getReservationStatus, "30") - .eq(DistributionStockArticleEntity::getTypeService, typeService) - .notIn(DistributionStockArticleEntity::getId, list); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.query().lambda().eq(DistributionStockArticleEntity::getGenre, genre).ne(DistributionStockArticleEntity::getReservationStatus, "30").eq(DistributionStockArticleEntity::getTypeService, typeService).notIn(DistributionStockArticleEntity::getId, list); if (Func.isNotEmpty(mallName)) { lambdaQueryWrapper.like(DistributionStockArticleEntity::getMallName, mallName); } @@ -4493,15 +4338,9 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliverySelfEntity::getId, loadingId) - .set(DistributionDeliverySelfEntity::getDepartureTime, format) - ); + b = distributionDeliverySelfService.update(new UpdateWrapper().lambda().eq(DistributionDeliverySelfEntity::getId, loadingId).set(DistributionDeliverySelfEntity::getDepartureTime, format)); } else { - b = distributionDeliveryTripartiteService.update(new UpdateWrapper().lambda() - .eq(DistributionDeliveryTripartiteEntity::getId, loadingId) - .set(DistributionDeliveryTripartiteEntity::getDepartureTime, format) - ); + b = distributionDeliveryTripartiteService.update(new UpdateWrapper().lambda().eq(DistributionDeliveryTripartiteEntity::getId, loadingId).set(DistributionDeliveryTripartiteEntity::getDepartureTime, format)); } //修改主表状态 @@ -4561,22 +4400,15 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl { //2、将预约计划进行确认状态的回滚 // DistributionReservationEntity reservationEntity = distributionReservationMapper.selectById(s.getReservationId()); - DistributionReservationEntity reservationEntity = distributionReservationMapper.selectOne(Wrappers.query().lambda() - .eq(DistributionReservationEntity::getId, s.getReservationId()) - .ne(DistributionReservationEntity::getReservationStatus, ReservationStatusConstant.yiquexiao.getValue())); + DistributionReservationEntity reservationEntity = distributionReservationMapper.selectOne(Wrappers.query().lambda().eq(DistributionReservationEntity::getId, s.getReservationId()).ne(DistributionReservationEntity::getReservationStatus, ReservationStatusConstant.yiquexiao.getValue())); reservationEntity.setReservationStatus(ReservationStatusConstant.yiqueren.getValue()); reservationEntity.setLoadingStatus(ReservationLoadingStatusConstant.daizhuangche.getValue()); distributionReservationMapper.updateById(reservationEntity); //将该预约下的所有包件信息进行修改为初始预约状态 - List reservationStockarticleEntityList = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId()) - .ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); + List reservationStockarticleEntityList = distributionReservationStockarticleMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationStockarticleEntity::getReservationId, reservationEntity.getId()).ne(DistributionReservationStockarticleEntity::getStockArticleStatus, ReservationOrderStatusConstant.quxiao.getValue())); reservationStockarticleEntityList.forEach(o -> { if (o.getIsZero().equals(IsOrNoConstant.no.getValue())) { - List reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionReservationPackageEntity::getStockArticleId, o.getStockArticleId()) - .ne(DistributionReservationPackageEntity::getPacketBarStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getReservationId, reservationEntity.getId()).eq(DistributionReservationPackageEntity::getStockArticleId, o.getStockArticleId()).ne(DistributionReservationPackageEntity::getPacketBarStatus, ReservationPackageStatusConstant.quxiao.getValue())); reservationPackageEntityList.forEach(p -> { DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(p.getParceListId()); //TODO 这里取消应该有一个取消的任务 @@ -4614,11 +4446,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionStockListEntities = baseMapper.getInventoryByDeliveryId(page, distributionDeliveryInfoDTO.getDeliveryId()); distributionStockListEntities.forEach(rs -> { - List list = distributionLoadscaninvnService.list(Wrappers.query().lambda() - .eq(DistributionLoadscaninvnEntity::getInventoryId, rs.getStocklistId()) - .eq(DistributionLoadscaninvnEntity::getReservationId, rs.getReservationId()) - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionDeliveryInfoDTO.getDeliveryId()) - .ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List list = distributionLoadscaninvnService.list(Wrappers.query().lambda().eq(DistributionLoadscaninvnEntity::getInventoryId, rs.getStocklistId()).eq(DistributionLoadscaninvnEntity::getReservationId, rs.getReservationId()).eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionDeliveryInfoDTO.getDeliveryId()).ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); rs.setLoadedinNumber(0); if (Func.isNotEmpty(list)) { //存在装车记录 @@ -4762,9 +4590,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda() - .eq(DistributionReservationPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .like(DistributionReservationPackageEntity::getPacketBarCode, distrilbutionloadingscanDTO.getBarcode())); + List reservationPackageEntityList = distributionReservationPackageMapper.selectList(Wrappers.query().lambda().eq(DistributionReservationPackageEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).like(DistributionReservationPackageEntity::getPacketBarCode, distrilbutionloadingscanDTO.getBarcode())); if (Func.isNotEmpty(reservationPackageEntityList) && reservationPackageEntityList.size() > 0) { List longs = reservationPackageEntityList.stream().map(DistributionReservationPackageEntity::getParceListId).collect(Collectors.toList()); collect = distributionParcelListService.listByIds(longs); @@ -4842,15 +4668,13 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl a = new ArrayList<>(); customList.forEach(c -> { String trayCode = c.getTrayCode(); - List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, distributionDeliveryList.getReservationId()) - .eq(DistributionLoadscanEntity::getTrayNo, trayCode).ne(DistributionLoadscanEntity::getScanStatus, "1")); + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, distributionDeliveryList.getReservationId()).eq(DistributionLoadscanEntity::getTrayNo, trayCode).ne(DistributionLoadscanEntity::getScanStatus, "1")); c.setIsScan(1); if (Func.isNotEmpty(loadscanEntityList) && loadscanEntityList.size() > 0) { c.setIsScan(2); } TrayTypeDataVO trayTypeDataVO = warehouseTrayTypeClient.selectListByTrayCode(c.getTrayCode()); - if (Func.isNotEmpty(trayTypeDataVO)){ + if (Func.isNotEmpty(trayTypeDataVO)) { List goodsLsit = trayTypeDataVO.getGoodsLsit(); if (Func.isNotEmpty(goodsLsit)) { List longs = goodsLsit.stream().map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); @@ -4876,11 +4700,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl loadscanEntities = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); + List loadscanEntities = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()).eq(DistributionLoadscanEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); if (Func.isNotEmpty(loadscanEntities)) { //存在装车数据了 log.error("配送计划null:{}", loadscanEntities); @@ -4892,8 +4712,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl parcelListEntities = distributionParcelListService.list(Wrappers.query().lambda() - .eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); + List parcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getOrderPackageCode, distrilbutionloadingscanDTO.getBarcode())); if (Func.isNotEmpty(parcelListEntities) && parcelListEntities.size() == 1) { DistributionParcelListEntity parcelListEntity = parcelListEntities.get(0); DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(parcelListEntity.getStockArticleId()); @@ -4904,14 +4723,9 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliverySelfEntity::getIsMaster, ServiceConstant.IS_MASTER_YES) - .eq(DistributionDeliverySelfEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - ); + distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectOne(new QueryWrapper().lambda().eq(DistributionDeliverySelfEntity::getIsMaster, ServiceConstant.IS_MASTER_YES).eq(DistributionDeliverySelfEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); } else { - DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper().lambda() - .eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - ); + DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(new QueryWrapper().lambda().eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); BeanUtils.copyProperties(distributionDeliveryTripartiteEntity, distributionDeliverySelfEntity); } } else { @@ -4922,9 +4736,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl loadscanAbnormalEntityList = distributionLoadscanAbnormalService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanAbnormalEntity::getDeliveryListId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanAbnormalEntity::getPackageCode, distrilbutionloadingscanDTO.getBarcode())); + List loadscanAbnormalEntityList = distributionLoadscanAbnormalService.list(Wrappers.query().lambda().eq(DistributionLoadscanAbnormalEntity::getDeliveryListId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanAbnormalEntity::getPackageCode, distrilbutionloadingscanDTO.getBarcode())); if (Func.isNotEmpty(loadscanAbnormalEntityList) && loadscanAbnormalEntityList.size() > 1) { return Resp.scanFail("操作失败", "重复添加"); } @@ -4952,9 +4764,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda() - .eq(DistributionSignforEntity::getReservationId, reservationEntity.getId()) - .eq(DistributionSignforEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); + DistributionSignforEntity signforEntity = distributionSignforService.getOne(Wrappers.query().lambda().eq(DistributionSignforEntity::getReservationId, reservationEntity.getId()).eq(DistributionSignforEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId())); if (Func.isNotEmpty(signforEntity)) { //标识该客户存在异常装车包件,为了后续的异常装车审核 signforEntity.setIsHaveAbnormalPackage(2); @@ -5045,10 +4853,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl parcelListEntities = distributionParcelListService.list(Wrappers.query().lambda() - .eq(DistributionParcelListEntity::getStockArticleId, orderId) - .eq(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.daiyuyue.getValue()) - .notIn(DistributionParcelListEntity::getOrderPackageStatus, OrderPackageStatusConstant.yiqianshou.getValue(), OrderPackageStatusConstant.yichuku.getValue())); + List parcelListEntities = distributionParcelListService.list(Wrappers.query().lambda().eq(DistributionParcelListEntity::getStockArticleId, orderId).eq(DistributionParcelListEntity::getOrderPackageReservationStatus, OrderPackageReservationStatusConstant.daiyuyue.getValue()).notIn(DistributionParcelListEntity::getOrderPackageStatus, OrderPackageStatusConstant.yiqianshou.getValue(), OrderPackageStatusConstant.yichuku.getValue())); if (Func.isNotEmpty(reservationPackageList)) { List parcelListVOS = DistributionParcelListWrapper.build().listVO(reservationPackageList); allPackageList.addAll(DistributionParcelListWrapper.build().listVO(reservationPackageList)); @@ -5128,10 +4933,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda() - .eq(DistributionReservationZeroPackageEntity::getReservationId, reservationStockarticleEntity.getReservationId()) - .eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()) - .ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); + List reservationZeroPackageEntityList = distributionReservationZeroPackageService.list(Wrappers.query().lambda().eq(DistributionReservationZeroPackageEntity::getReservationId, reservationStockarticleEntity.getReservationId()).eq(DistributionReservationZeroPackageEntity::getStockArticleId, reservationStockarticleEntity.getStockArticleId()).ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, ReservationPackageStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(reservationZeroPackageEntityList)) { //查询零担订单品类信息 List zeroPackageIds = reservationZeroPackageEntityList.stream().map(DistributionReservationZeroPackageEntity::getParcelListId).collect(Collectors.toList()); @@ -5144,11 +4946,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl zeroPackageMap = parcelNumberEntityList.stream().collect(Collectors.toMap(DistributionParcelNumberEntity::getParcelListId, Function.identity(), (k1, k2) -> k2)); List operationZeroPackageIds = parcelListDTOS.stream().map(DistributionParcelNumberDTO::getParcelListId).collect(Collectors.toList()); //查询是否已经有装车数据了 - List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda() - .eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()) - .eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()) - .in(DistributionLoadscanEntity::getPackageId, operationZeroPackageIds) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List loadscanEntityList = distributionLoadscanService.list(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, reservationStockarticleEntity.getReservationId()).eq(DistributionLoadscanEntity::getOrderId, reservationStockarticleEntity.getStockArticleId()).in(DistributionLoadscanEntity::getPackageId, operationZeroPackageIds).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); Map> loadMap = null; if (Func.isNotEmpty(loadscanEntityList)) { loadMap = loadscanEntityList.stream().collect(Collectors.groupingBy(DistributionLoadscanEntity::getPackageId)); @@ -5191,7 +4989,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) - .ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List distributionLoadscanEntitiesflag = distributionLoadscanMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(distributionLoadscanEntitiesflag)) { //统计装车包件 @@ -5325,9 +5120,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() - .eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + List distributionLoadscaninvnEntities = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()).ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); if (Func.isNotEmpty(distributionLoadscaninvnEntities)) { //统计库存品装车数量 int inventoryLoadingNum = distributionLoadscaninvnEntities.stream().mapToInt(DistributionLoadscaninvnEntity::getLoadedNub).sum(); @@ -5345,18 +5138,18 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl retentionScanVos = new ArrayList<>(); - switch (retentionType){ + switch (retentionType) { case 1: //包件--库存品 和包件 List parcelListEntities = baseMapper.selectPackageListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); // List detailEntities = baseMapper.selectInventoryListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(parcelListEntities)){ - List packageInfo = parcelListEntities.stream().filter(p -> Func.equals(p.getOrderPackageCode(),distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); - if (packageInfo.size()>1){ - log.error("################包条码重复:{}",distrilbutionloadingscanDTO.getBarcode()); - return Resp.scanFail("操作失败","操作失败"); + if (Func.isNotEmpty(parcelListEntities)) { + List packageInfo = parcelListEntities.stream().filter(p -> Func.equals(p.getOrderPackageCode(), distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); + if (packageInfo.size() > 1) { + log.error("################包条码重复:{}", distrilbutionloadingscanDTO.getBarcode()); + return Resp.scanFail("操作失败", "操作失败"); } - if (packageInfo.size() == 1){ + if (packageInfo.size() == 1) { // DistributionRetentionScanVo distributionRetentionScanVo = new DistributionRetentionScanVo(); //此时才是满足条件的包件,能够进行滞留 //通过配送任务和包件确定预约信息 @@ -5366,26 +5159,26 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl detailEntities = baseMapper.selectInventoryListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(detailEntities)){ - List stockListDetailEntities = detailEntities.stream().filter(i -> Func.isNotEmpty(i.getStockPackageCode()) && Func.equals(i.getStockPackageCode(), distrilbutionloadingscanDTO.getDeliveryId())).collect(Collectors.toList()); - if (stockListDetailEntities.size()> 1){ - log.error("################库存品条码重复:{}",distrilbutionloadingscanDTO.getBarcode()); - return Resp.scanFail("操作失败","操作失败"); + if (Func.isNotEmpty(detailEntities)) { + List stockListDetailEntities = detailEntities.stream().filter(i -> Func.isNotEmpty(i.getStockPackageCode()) && Func.equals(i.getStockPackageCode(), distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); + if (stockListDetailEntities.size() > 1) { + log.error("################库存品条码重复:{}", distrilbutionloadingscanDTO.getBarcode()); + return Resp.scanFail("操作失败", "操作失败"); } - if (stockListDetailEntities.size() == 1){ + if (stockListDetailEntities.size() == 1) { DisStockListDetailEntity disStockListDetailEntity = stockListDetailEntities.get(0); DistributionRetentionScanVo inventoryPackage = baseMapper.selectRetentionInventoryPackage(disStockListDetailEntity.getStockPackageCode(), distrilbutionloadingscanDTO.getDeliveryId()); retentionScanVos.add(inventoryPackage); } - }else { - log.error("################查询包件和库存品为空:{}",distrilbutionloadingscanDTO.getDeliveryId()); - return Resp.scanFail("操作失败","不属于该配送任务!!!"); + } else { + log.error("################查询包件和库存品为空:{}", distrilbutionloadingscanDTO.getDeliveryId()); + return Resp.scanFail("操作失败", "不属于该配送任务!!!"); } } break; case 2: - List distributionRetentionScanVos = baseMapper.selectRetentionZeroPackage(distrilbutionloadingscanDTO.getDeliveryId(),distrilbutionloadingscanDTO.getBarcode()); - if (Func.isNotEmpty(distributionRetentionScanVos)){ + List distributionRetentionScanVos = baseMapper.selectRetentionZeroPackage(distrilbutionloadingscanDTO.getDeliveryId(), distrilbutionloadingscanDTO.getBarcode()); + if (Func.isNotEmpty(distributionRetentionScanVos)) { retentionScanVos.addAll(distributionRetentionScanVos); } // //托盘 @@ -5419,8 +5212,8 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl reservationStockarticleEntityList = baseMapper.selectReservationStockByDeliveryId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isEmpty(reservationStockarticleEntityList)){ - log.error("#############配送任务查询订单错误,deliveryId:{}",distrilbutionloadingscanDTO.getDeliveryId()); + if (Func.isEmpty(reservationStockarticleEntityList)) { + log.error("#############配送任务查询订单错误,deliveryId:{}", distrilbutionloadingscanDTO.getDeliveryId()); return null; } List orderIds = reservationStockarticleEntityList.stream().filter(rs -> Func.isNotEmpty(rs.getIsZero()) && rs.getIsZero().equals(IsOrNoConstant.yes.getValue())).map(DistributionReservationStockarticleEntity::getStockArticleId).collect(Collectors.toList()); - if (Func.isEmpty(orderIds)){ + if (Func.isEmpty(orderIds)) { log.error("####################配送任务下无零担信息:{}"); - return Resp.scanFail("查询错误","该任务无零担订单"); + return Resp.scanFail("查询错误", "该任务无零担订单"); } List parcelNumberVOS = new ArrayList<>(); - orderIds.forEach(o->{ + orderIds.forEach(o -> { List parcelNumberVOList = baseMapper.selectDeliveryZeroOrderDetail(o, distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(parcelNumberVOList)){ + if (Func.isNotEmpty(parcelNumberVOList)) { parcelNumberVOS.addAll(parcelNumberVOList); } }); - if (Func.isEmpty(parcelNumberVOS)){ - return Resp.scanFail("查询失败","该配送任务无该零担订单"); + if (Func.isEmpty(parcelNumberVOS)) { + return Resp.scanFail("查询失败", "该配送任务无该零担订单"); } return R.data(parcelNumberVOS); } @@ -5453,17 +5246,20 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl detailEntities = baseMapper.selectInventoryListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isEmpty(detailEntities)){ - log.error("######################查询配送任务零担信息错误,deliveryId:{},",distrilbutionloadingscanDTO.getDeliveryId()); + if (Func.isEmpty(detailEntities)) { + log.error("######################查询配送任务零担信息错误,deliveryId:{},", distrilbutionloadingscanDTO.getDeliveryId()); return null; } List stockListDetailEntities = detailEntities.stream().filter(d -> Func.isNotEmpty(d.getStockPackageCode())).filter(d -> d.getStockPackageCode().equals(distrilbutionloadingscanDTO.getBarcode())).collect(Collectors.toList()); List disStockListDetailVOS = DistributionDisStockListWrapper.build().listVO(stockListDetailEntities); List inventoryIds = disStockListDetailVOS.stream().map(DisStockListDetailVO::getStockListId).distinct().collect(Collectors.toList()); DistributionStockListEntity distributionStockListEntity = distributionStockListService.listByIds(inventoryIds).get(0); - disStockListDetailVOS.stream().forEach(d->{d.setMarketName(distributionStockListEntity.getMarketName());d.setCargoNumber(distributionStockListEntity.getCargoNumber());}); - if (Func.isEmpty(stockListDetailEntities)){ - return Resp.scanFail("查询失败","不属于该配送任务"); + disStockListDetailVOS.stream().forEach(d -> { + d.setMarketName(distributionStockListEntity.getMarketName()); + d.setCargoNumber(distributionStockListEntity.getCargoNumber()); + }); + if (Func.isEmpty(stockListDetailEntities)) { + return Resp.scanFail("查询失败", "不属于该配送任务"); } return R.data(stockListDetailEntities); } @@ -5489,57 +5285,52 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl goodsLsit = trayTypeDataVO.getGoodsLsit(); - if (Func.isEmpty(goodsLsit)){ - log.error("#############托盘无货物,taryCode:{}",barcode); - return Resp.scanFail("该托盘无货物","该托盘无货物"); + if (Func.isEmpty(goodsLsit)) { + log.error("#############托盘无货物,taryCode:{}", barcode); + return Resp.scanFail("该托盘无货物", "该托盘无货物"); } boolean isAll = goodsLsit.stream().allMatch(good -> good.getAssociationType().equals("3")); - if (!isAll){ + if (!isAll) { int size = goodsLsit.stream().map(WarehouseTrayGoodsEntity::getAssociationType).distinct().collect(Collectors.toList()).size(); - log.error("#############托盘存在多种货物类型,货物种类:{}",size); - return Resp.scanFail("该托盘存在多种货物","该托盘存在多种货物"); + log.error("#############托盘存在多种货物类型,货物种类:{}", size); + return Resp.scanFail("该托盘存在多种货物", "该托盘存在多种货物"); } List parcelListEntities = baseMapper.selectPackageListByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isEmpty(parcelListEntities)){ - log.error("#############配送任务不存在包件信息,配送任务ID:{}",distrilbutionloadingscanDTO.getDeliveryId()); - return Resp.scanFail("配送任务无包件信息","配送任务无包件信息"); + if (Func.isEmpty(parcelListEntities)) { + log.error("#############配送任务不存在包件信息,配送任务ID:{}", distrilbutionloadingscanDTO.getDeliveryId()); + return Resp.scanFail("配送任务无包件信息", "配送任务无包件信息"); } //查询托盘货物是否都属于该配送计划的包件 - boolean isExist = goodsLsit.stream() - .map(WarehouseTrayGoodsEntity::getAssociationId) - .collect(Collectors.toList()).stream() - .allMatch(goodId -> parcelListEntities.stream() - .map(DistributionParcelListEntity::getId) - .collect(Collectors.toList()).contains(goodId)); - - if (isExist){ + boolean isExist = goodsLsit.stream().map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()).stream().allMatch(goodId -> parcelListEntities.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()).contains(goodId)); + + if (isExist) { DistributionTrayRetentionVO distributionTrayRetentionVO = new DistributionTrayRetentionVO(); DistributionTrayRetentionVO trayRetentionVO = Func.copy(trayTypeDataVO, DistributionTrayRetentionVO.class); List retentionScanVos = new ArrayList<>(); //托盘货物都存在该配送任务的包件列表 //进行客户划分 - goodsLsit.forEach(g->{ + goodsLsit.forEach(g -> { DistributionRetentionScanVo retentionScanVo = baseMapper.selectRetentionPackage(g.getAssociationValue(), distrilbutionloadingscanDTO.getDeliveryId()); - if (Func.isNotEmpty(retentionScanVo)){ + if (Func.isNotEmpty(retentionScanVo)) { retentionScanVo.setScanType(3); retentionScanVos.add(retentionScanVo); - }else { - log.error("#############查询托盘包件信息错误,包件码为:{}",g.getAssociationValue()); + } else { + log.error("#############查询托盘包件信息错误,包件码为:{}", g.getAssociationValue()); } }); - if (Func.isNotEmpty(retentionScanVos)){ + if (Func.isNotEmpty(retentionScanVos)) { trayRetentionVO.setGoodsList(retentionScanVos); return R.data(trayRetentionVO); } - }else { - return Resp.scanFail("托盘存在包件不属于该配送任务","托盘存在包件不属于该配送任务"); + } else { + return Resp.scanFail("托盘存在包件不属于该配送任务", "托盘存在包件不属于该配送任务"); } return null; } @@ -5548,22 +5339,109 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImplquery().lambda().eq(DistributionLoadscanEntity::getDeliveryId, deliveryId).eq(DistributionLoadscanEntity::getReservationId, reservationId).eq(DistributionLoadscanEntity::getPackageId, orderPackageId).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(loadscanEntity)) { + //已经进行装车 + loadscanEntity.setScanStatus(LoadingStatusConstant.quxiao.getValue()); + distributionLoadscanService.updateById(loadscanEntity); +// 对应签收信息的装车数量要进行扣减 + int a = distributionSignforMapper.deductionLoadingPacjageNum(loadscanEntity.getReservationId(), loadscanEntity.getDeliveryId(), loadscanEntity.getLoadedNub()); + } + //进行了一条包件任务的取消,此时就应该对预约、配送任务进行数量的维护 + distributionAsyncService.checkRetentionReservationAndDeliveryInfo(reservationId, deliveryId); + return true; + } else { + //查询出多个包件信息 + log.info("######################,reservationId:{}", reservationId); + log.error("############查询预约包件信息错误:{}", orderPackageId); + return false; } - return false; } + @Override + public boolean retentionDeliveryReservationInventory(Long deliveryId, Long reservationId, Long orderPackageId) { + DistributionDeliveryListEntity deliveryListEntity = this.getById(deliveryId); + if (Func.isEmpty(deliveryListEntity)) { + log.error("###########查询配送任务异常,deliveyId:{}", deliveryId); + return false; + } +//对库存品包件进行取消配送状态标识 + int row = distributionReservationMapper.cancelReservationInventory(reservationId, orderPackageId); + if (row == 1) { + //只进行了一次修改,这里就需要进行是否装车进行判断 + DistributionLoadscaninvnEntity loadscaninvnEntity = distributionLoadscaninvnService.getOne(Wrappers.query().lambda().eq(DistributionLoadscaninvnEntity::getDeliveryId, deliveryId).eq(DistributionLoadscaninvnEntity::getReservationId, reservationId).eq(DistributionLoadscaninvnEntity::getInventoryPackageId, orderPackageId).ne(DistributionLoadscaninvnEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + if (Func.isNotEmpty(loadscaninvnEntity)) { + loadscaninvnEntity.setScanStatus(LoadingStatusConstant.quxiao.getValue()); + distributionLoadscaninvnService.updateById(loadscaninvnEntity); + //库存品装车数量扣减 + int a = distributionSignforMapper.deductionLoadingInventoryNum(loadscaninvnEntity.getReservationId(), loadscaninvnEntity.getDeliveryId(), loadscaninvnEntity.getLoadedNub()); + } + distributionAsyncService.checkRetentionInventoryReservationAndDeliveryInfo(reservationId, deliveryId, orderPackageId); + return true; + } else { + return false; + } + } + + @Override + public boolean retentionDeliveryReservationZeroPackage(Long deliveryId, Long reservationId, Long orderPackageId, Integer retentionQuantity, Long orderId) { + DistributionDeliveryListEntity deliveryListEntity = this.getById(deliveryId); + if (Func.isEmpty(deliveryListEntity)) { + log.error("###########查询配送任务异常,deliveyId:{}", deliveryId); + return false; + } + //进行零担包件数量修改 + int row = distributionReservationMapper.cancelReservationZeroPackage(reservationId, orderPackageId, retentionQuantity); + if (row == 1) { + //查询零担包件的装车详情 + DistributionLoadscanEntity zeroLoadscanEntity = distributionLoadscanService.getOne(Wrappers.query().lambda().eq(DistributionLoadscanEntity::getReservationId, reservationId).eq(DistributionLoadscanEntity::getDeliveryId, deliveryId).eq(DistributionLoadscanEntity::getPackageId, orderPackageId).ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue())); + //存在装车数据,这里需要对装车数据进行扣减或者进行整体状态的一个取消标识 + //查询滞留数量是否有效 + List distributionParcelNumberVOS = distributionReservationMapper.selectReservationZeroOrderDetail(orderId, reservationId); + if (Func.isNotEmpty(distributionParcelNumberVOS)) { + Map zeroPackageMap = distributionParcelNumberVOS.stream().collect(Collectors.toMap(DistributionParcelNumberVO::getParcelListId, Function.identity(), (k1, k2) -> k2)); + if (Func.isNotEmpty(zeroPackageMap.get(orderPackageId))) { + //存在零担的信息 + //校验零担滞留数量是否有效 + DistributionParcelNumberVO distributionParcelNumberVO = zeroPackageMap.get(orderPackageId); + if (distributionParcelNumberVO.getReservationNum() < retentionQuantity) { + //信息不合法 + log.error("##############无效的滞留零担数量:{}", retentionQuantity); + return false; + } + //进行是否装车判断 + if (Func.isNotEmpty(zeroLoadscanEntity)) { + //存在装车数据 + zeroLoadscanEntity.setLoadedNub(zeroLoadscanEntity.getLoadedNub() - retentionQuantity); + if (zeroLoadscanEntity.getLoadedNub() < retentionQuantity){ + zeroLoadscanEntity.setLoadedNub(0);; + } + + } + } else { + return false; + } + } else { + return false; + } + + } + return false; + } public Map getDriverCar(String kind, Long deliveryListEntityId) { Map map = new HashMap<>(); @@ -5765,13 +5643,13 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl m:spaclOrderList){ + for (Map m : spaclOrderList) { Integer num = (Integer) m.get("数量"); spaclNum = spaclNum + num; } @@ -5795,7 +5673,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl 0 && !spaclStockList.isEmpty()) { map.put("库存品集合", spaclStockList); Integer spaclStockNum = 0; - for (Map m:spaclStockList){ + for (Map m : spaclStockList) { Integer num = (Integer) m.get("数量"); spaclStockNum = spaclStockNum + num; } @@ -5919,7 +5797,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl selectWarehouseRetentionWaybillPage(IPage page, WarehouseWaybillDetentionVO warehouseWaybillDetentionVO) { - List warehouseRetentionRecordVOS = baseMapper.selectWarehouseWaybillRecordPage(page,warehouseWaybillDetentionVO); + List warehouseRetentionRecordVOS = baseMapper.selectWarehouseWaybillRecordPage(page, warehouseWaybillDetentionVO); return page.setRecords(warehouseRetentionRecordVOS); } @@ -105,7 +97,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl pageList = baseMapper.retentionPackageList(page,retentionDTO); + IPage pageList = baseMapper.retentionPackageList(page, retentionDTO); return WarehouseRetentionRecordWrapper.build().pageVO(pageList); } @@ -116,14 +108,14 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImplquery().lambda() .eq(WarehouseRetentionRecordEntity::getRetentionType, RetentionTypeConstant.peisongzhiliu.getValue()) .eq(WarehouseRetentionRecordEntity::getTaskId, deliveryId)); - if (Func.isEmpty(retentionRecordEntity)){ + if (Func.isEmpty(retentionRecordEntity)) { return null; } WarehouseRetentionRecordVO warehouseRetentionRecordVO = WarehouseRetentionRecordWrapper.build().entityVO(retentionRecordEntity); @@ -155,7 +147,7 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl retentionScanEntityList = warehouseRetentionScanService.list(Wrappers.query().lambda() .eq(WarehouseRetentionScanEntity::getDeliveryId, retentionRecordEntity.getTaskId()) .eq(WarehouseRetentionScanEntity::getRefId, retentionRecordEntity.getId())); - if (Func.isNotEmpty(retentionScanEntityList)){ + if (Func.isNotEmpty(retentionScanEntityList)) { warehouseRetentionRecordVO.setRetentionScanVOList(WarehouseRetentionScanWrapper.build().listVO(retentionScanEntityList)); } return warehouseRetentionRecordVO; @@ -165,13 +157,13 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl warehouseRetentionScanDTOS = warehouseRetentionRecordDTO.getWarehouseRetentionScanDTOS(); - if (Func.isEmpty(warehouseRetentionScanDTOS)){ + if (Func.isEmpty(warehouseRetentionScanDTOS)) { log.error("############用户提交空滞留列表"); - return Resp.scanFail("操作失败","无滞留包件信息"); + return Resp.scanFail("操作失败", "无滞留包件信息"); } BladeUser user = AuthUtil.getUser(); //TODO 保存车次数据还需要处理 @@ -187,7 +179,8 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl{ + AtomicBoolean saveFlah = new AtomicBoolean(false); + warehouseRetentionScanDTOS.forEach(r -> { //查询是否进行多次滞留 WarehouseRetentionScanEntity retentionScanServiceOne = warehouseRetentionScanService.getOne(Wrappers.query().lambda() .eq(WarehouseRetentionScanEntity::getConditions, r.getConditions()) @@ -199,31 +192,44 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl idArr = null; - if (null != ids && !ids.toString().equals("")){ + if (null != ids && !ids.toString().equals("")) { idArr = Arrays.asList(paramMap.get("ids").toString().split(",")); } @@ -255,13 +261,13 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl warehouseRetentionScanDTOList = warehouseRetentionScanDTOS.getWarehouseRetentionScanDTOS(); - if (Func.isEmpty(warehouseRetentionScanDTOList)){ - log.error("##########缺少滞留包件列表:{}",warehouseRetentionScanDTOList); - return Resp.scanFail("无滞留包件信息","无滞留包件信息"); + if (Func.isEmpty(warehouseRetentionScanDTOList)) { + log.error("##########缺少滞留包件列表:{}", warehouseRetentionScanDTOList); + return Resp.scanFail("无滞留包件信息", "无滞留包件信息"); } //如果滞留全部为空,这里执行删除操作 //查询出该滞留任务是否存在 @@ -269,21 +275,21 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl retentionPackageMap = retentionScanEntityList.stream().collect(Collectors.toMap(WarehouseRetentionScanEntity::getOrderPackageId, Function.identity(), (k1, k2) -> k2)); - warehouseRetentionScanDTOList.forEach(rs->{ - if (Func.isNotEmpty(retentionPackageMap.get(rs.getOrderPackageId()))){ + warehouseRetentionScanDTOList.forEach(rs -> { + if (Func.isNotEmpty(retentionPackageMap.get(rs.getOrderPackageId()))) { //查看是否是零担,如果是零担需要查看是否发生数量修改 WarehouseRetentionScanEntity warehouseRetentionScanEntity = retentionPackageMap.get(rs.getOrderPackageId()); - if (retentionPackageMap.get(rs.getOrderPackageId()).getConditions()==3){ + if (retentionPackageMap.get(rs.getOrderPackageId()).getConditions() == 3) { //零担查看是否发生数据修改 - if (warehouseRetentionScanEntity.getRetentionQuantity() != rs.getRetentionQuantity() && rs.getRetentionQuantity()>0){ + if (warehouseRetentionScanEntity.getRetentionQuantity() != rs.getRetentionQuantity() && rs.getRetentionQuantity() > 0) { warehouseRetentionScanEntity.setRetentionQuantity(rs.getRetentionQuantity()); warehouseRetentionScanService.updateById(warehouseRetentionScanEntity); } } - }else { + } else { //在原列表中查询不到,这里视为新增滞留包件 rs.setRetentionScanTime(new Date()); rs.setRetentionScanUserId(user.getUserId()); @@ -292,7 +298,21 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl