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