From 354ce8fa93b6b53b711c9b7245c3bc81ab384888 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 21 七月 2026 16:42:53 +0800
Subject: [PATCH] feat: 优化领料只领取叶子节点的料

---
 src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
index 8c710cf..caff402 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -1118,9 +1118,18 @@
                 .filter(Objects::nonNull)
                 .forEach(finishedProductModelIds::add);
 
-        // 杩囨护鍑洪潪鏍硅妭鐐癸紙瀹為檯棰嗘枡椤癸級锛屽苟鎺掗櫎涓庤鍗曟垚鍝佸悓瑙勬牸鐨勭墿鏂欙紙鑷埗鎴愬搧鏃犻渶棰嗘枡锛�
+        // 鏀堕泦鎵�鏈夎寮曠敤涓虹埗绾х殑鑺傜偣ID锛欱OM浠庢渶鍚庝竴閬撳伐搴忓線閲岄厤缃墠涓�閬撳伐搴忥紝
+        // 涓棿鑺傜偣鏄笂涓�閬撳伐搴忕殑浜у嚭锛堣嚜鍒讹級锛屽彧鏈夋瘡鏉″垎鏀渶閲屽眰鐨勫彾瀛愯妭鐐规墠鏄湡姝i渶瑕侀鐢ㄧ殑鐗╂枡銆�
+        Set<Long> parentNodeIds = bomStructureList.stream()
+                .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
+                .map(ProductionBomStructureVo::getParentId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+
+        // 杩囨护鍑哄彾瀛愯妭鐐癸紙瀹為檯棰嗘枡椤癸級锛氶潪鏍硅妭鐐广�侀潪涓棿鑺傜偣锛屽苟鎺掗櫎涓庤鍗曟垚鍝佸悓瑙勬牸鐨勭墿鏂欙紙鑷埗鎴愬搧鏃犻渶棰嗘枡锛�
         List<ProductionBomStructureVo> childStructureList = bomStructureList.stream()
                 .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
+                .filter(s -> s.getId() == null || !parentNodeIds.contains(s.getId()))
                 .filter(s -> s.getProductModelId() == null || !finishedProductModelIds.contains(s.getProductModelId()))
                 .collect(Collectors.toList());
 

--
Gitblit v1.9.3