diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index b8092f416..87316a13a 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -3988,7 +3988,24 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl parcelListEntities = trunklineCarsLoadScanService.findParceListByCarsLoadScanIds(carsLoadScanIds); //把parcelListEntities转成orderPackageCode为键值的map Map parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, e -> e)); - List stockArticleEntities = trunklineCarsLoadScanService.findOrderListByCarsLoadScanIds(carsLoadScanIds); + + //把loadScanEntityList中所有元素的fromWarehouseId进行分组 + Map> fromWarehouseIdMap = loadScanEntityList.stream().filter(e -> Objects.nonNull(e.getFromWarehouseId())).collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getFromWarehouseId)); + + List stockArticleEntities = new ArrayList<>(); + + fromWarehouseIdMap.keySet().forEach(fromWarehouseId -> { + List list = fromWarehouseIdMap.get(fromWarehouseId); + //把list中所有的orderCode放入一个Set集合 + Set orderCodeSet = list.stream().map(TrunklineCarsLoadScanEntity::getOrderCode).collect(Collectors.toSet()); + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderCodeSet(orderCodeSet); + findParamterDTO.setWarehouseId(fromWarehouseId); + List stockArticleEntityList = distributionStockArticleClient.findListByOrderCodesAndWarehouseId(findParamterDTO); + stockArticleEntities.addAll(stockArticleEntityList); + + }); + //把stockArticleEntities转成orderCode为键值的map Map stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, e -> e)); // List waybillEntities = trunklineCarsLoadScanService.findWaybillListByCarsLoadScanIds(carsLoadScanIds);