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 | 23 ++++++++++++++++++++++-
1 files changed, 22 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 0ec5ca8..caff402 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -1107,9 +1107,30 @@
}
}
- // 杩囨护鍑洪潪鏍硅妭鐐癸紙瀹為檯棰嗘枡椤癸級
+ // 鏀堕泦璁㈠崟鎴愬搧瑙勬牸ID锛氬寘鍚敓浜ц鍗曟垚鍝佽鏍间笌BOM鏍硅妭鐐硅鏍硷紝鐢ㄤ簬鎺掗櫎鈥滆嚜宸扁�濊繖涓�鐗╂枡
+ Set<Long> finishedProductModelIds = new HashSet<>();
+ if (productionOrder != null && productionOrder.getProductModelId() != null) {
+ finishedProductModelIds.add(productionOrder.getProductModelId());
+ }
+ bomStructureList.stream()
+ .filter(s -> s != null && (s.getParentId() == null || s.getParentId() == 0))
+ .map(ProductionBomStructureVo::getProductModelId)
+ .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