20230922-ljl-fixBug
ljl 1 year ago
parent cebcab0be4
commit bc24100d2a

@ -582,18 +582,19 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
shopIds.add(String.valueOf(shopId)); shopIds.add(String.valueOf(shopId));
List<String> purchaseOrderIds = purchaseOrders.stream().map(x -> x.getPurchaseOrderId().toString()).collect(Collectors.toList()); List<String> purchaseOrderIds = purchaseOrders.stream().map(x -> x.getPurchaseOrderId().toString()).collect(Collectors.toList());
List<PurchaseOrderItem> allItems = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, status); List<PurchaseOrderItem> allItems = getPurchaseOrderItemsMapByPurchaseOrderIds(shopIds, purchaseOrderIds, status);
Map<Integer, List<PurchaseOrderItem>> purchaseOrderIdAndItemMap = new HashMap<>(); Map<Long, List<PurchaseOrderItem>> purchaseOrderIdAndItemMap = new HashMap<>();
for (PurchaseOrderItem item: allItems) { for (PurchaseOrderItem item: allItems) {
List<PurchaseOrderItem> subItems; List<PurchaseOrderItem> subItems = new ArrayList<>();
if (purchaseOrderIdAndItemMap.containsKey(item.getPurchaseOrderId())) { Long purchaseOrderId = Long.valueOf(item.getPurchaseOrderId());
subItems = purchaseOrderIdAndItemMap.get(item.getPurchaseOrderId()); if (purchaseOrderIdAndItemMap.containsKey(purchaseOrderId)) {
} else { subItems = purchaseOrderIdAndItemMap.get(purchaseOrderId);
subItems = new ArrayList<>();
} }
subItems.add(item); subItems.add(item);
purchaseOrderIdAndItemMap.put(item.getPurchaseOrderId(), subItems); purchaseOrderIdAndItemMap.put(purchaseOrderId, subItems);
} }
for (PurchaseOrder purchaseOrder : purchaseOrders) { for (PurchaseOrder purchaseOrder : purchaseOrders) {
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId();
purchaseOrder.setItems(purchaseOrderIdAndItemMap.get(purchaseOrderId));
} }
} }
return purchaseOrders; return purchaseOrders;

Loading…
Cancel
Save