From 32bf2bed7dc2a14afeb50b72723570eaf295e316 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 28 五月 2026 09:53:35 +0800
Subject: [PATCH] feat(purchase): 新增采购草稿简易新增功能并完善生产订单库存数量显示

---
 src/main/java/com/ruoyi/production/service/impl/ProductionOrderPickServiceImpl.java |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderPickServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderPickServiceImpl.java
index 554b95e..3d9a515 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderPickServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderPickServiceImpl.java
@@ -189,6 +189,7 @@
             return Collections.emptyList();
         }
         List<ProductionOrderPickVo> detailList = baseMapper.listPickedDetailByOrderId(productionOrderId);
+        fillStockQuantity(detailList);
         fillBatchNoList(detailList);
         fillSelectableBatchNoList(detailList);
         return detailList;
@@ -1121,6 +1122,34 @@
         }
     }
 
+    private void fillStockQuantity(List<ProductionOrderPickVo> detailList) {
+        if (detailList == null || detailList.isEmpty()) {
+            return;
+        }
+        Set<Long> productModelIdSet = detailList.stream()
+                .map(ProductionOrderPickVo::getProductModelId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        if (productModelIdSet.isEmpty()) {
+            return;
+        }
+        List<StockInventory> stockList = stockInventoryMapper.selectList(
+                Wrappers.<StockInventory>lambdaQuery()
+                        .in(StockInventory::getProductModelId, productModelIdSet));
+        Map<Long, BigDecimal> stockQuantityMap = new HashMap<>();
+        for (StockInventory stockInventory : stockList) {
+            if (stockInventory == null || stockInventory.getProductModelId() == null) {
+                continue;
+            }
+            stockQuantityMap.merge(stockInventory.getProductModelId(),
+                    defaultDecimal(stockInventory.getQualitity()),
+                    BigDecimal::add);
+        }
+        for (ProductionOrderPickVo detail : detailList) {
+            detail.setStockQuantity(stockQuantityMap.getOrDefault(detail.getProductModelId(), BigDecimal.ZERO));
+        }
+    }
+
     private String buildBatchNoGroupKey(ProductionOrderPickVo detail) {
         // 鏋勫缓鎵规鑱氬悎鍒嗙粍閿��
         return detail.getProductionOrderId() + "|"

--
Gitblit v1.9.3