From e80eae3bcd9f1ee0eecd4072f943f2519762f164 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 20 十月 2026 15:18:21 +0800
Subject: [PATCH] feat: 工序添加是否领料,用于后续生产订单领料
---
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java | 76 ++++++++++++++++++++++++++++++++-----
1 files changed, 65 insertions(+), 11 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 defce97..43a89a6 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -371,6 +371,9 @@
productionOrderBomMapper.insert(orderBom);
Map<Long, Long> idMap = new HashMap<>();
+ Map<Long, Boolean> operationPickMap = loadOperationPickMap(structureList.stream()
+ .map(TechnologyBomStructure::getOperationId)
+ .collect(Collectors.toList()));
for (TechnologyBomStructure source : structureList) {
// 瀛愯妭鐐� parentId 闇�瑕佹槧灏勬垚鏂板揩鐓ц妭鐐� id锛屾墠鑳戒繚鐣欏師濮� BOM 灞傜骇銆�
ProductionBomStructure target = new ProductionBomStructure();
@@ -379,6 +382,7 @@
target.setParentId(source.getParentId() == null ? null : idMap.get(source.getParentId()));
target.setProductModelId(source.getProductModelId());
target.setTechnologyOperationId(source.getOperationId());
+ target.setIsPick(operationPickMap.getOrDefault(source.getOperationId(), Boolean.FALSE));
target.setUnitQuantity(source.getUnitQuantity());
target.setDemandedQuantity(defaultDecimal(orderQuantity)
.multiply(defaultDecimal(source.getUnitQuantity())));
@@ -387,6 +391,26 @@
idMap.put(source.getId(), target.getId());
}
return orderBom;
+ }
+
+ /**
+ * 鎵归噺璇诲彇宸ュ簭鐨勨�滄槸鍚﹂鏂欌�濇爣璁帮紝閬垮厤BOM蹇収閫愯鏌ヨ宸ュ簭琛ㄣ��
+ */
+ private Map<Long, Boolean> loadOperationPickMap(List<Long> technologyOperationIds) {
+ if (technologyOperationIds == null || technologyOperationIds.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ Set<Long> operationIdSet = technologyOperationIds.stream()
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+ if (operationIdSet.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ return technologyOperationMapper.selectBatchIds(operationIdSet).stream()
+ .filter(item -> item != null && item.getId() != null)
+ .collect(Collectors.toMap(TechnologyOperation::getId,
+ item -> Boolean.TRUE.equals(item.getIsPick()),
+ (left, right) -> left));
}
private void clearProductionSnapshot(Long productionOrderId) {
@@ -1076,32 +1100,62 @@
}
}
- // 鏀堕泦璁㈠崟鎴愬搧瑙勬牸ID锛氬寘鍚敓浜ц鍗曟垚鍝佽鏍间笌BOM鏍硅妭鐐硅鏍硷紝鐢ㄤ簬鎺掗櫎鈥滆嚜宸扁�濊繖涓�鐗╂枡
+ // production_bom_structure.is_pick 鏄敓浜ц鍒掍笅鍙戞椂鐨勫伐搴忛鏂欐爣璁板揩鐓э紱
+ // 棰嗘枡鍙拌处璇诲彇鏃朵互宸ュ簭涓绘暟鎹殑鏈�鏂版爣璁颁负鍑嗭紝淇濊瘉宸ュ簭涓婄殑鈥滄槸鍚﹂鏂欌�濊皟鏁村悗鏃犻渶閲嶆柊涓嬪彂鍗冲彲鐢熸晥锛�
+ // 宸ュ簭宸茶鍒犻櫎鏃朵繚鐣欏揩鐓у�硷紝閬垮厤鍘嗗彶璁㈠崟鐨勯鏂欒寖鍥翠涪澶便��
+ Map<Long, Boolean> operationPickMap = loadOperationPickMap(bomStructureList.stream()
+ .filter(Objects::nonNull)
+ .map(ProductionBomStructureVo::getTechnologyOperationId)
+ .collect(Collectors.toList()));
+ for (ProductionBomStructureVo structure : bomStructureList) {
+ if (structure == null || structure.getTechnologyOperationId() == null) {
+ continue;
+ }
+ Boolean latestPick = operationPickMap.get(structure.getTechnologyOperationId());
+ if (latestPick != null) {
+ structure.setIsPick(latestPick);
+ }
+ }
+
+ // 鏀堕泦璁㈠崟鎴愬搧瑙勬牸ID锛氱敓浜ц鍗曟垚鍝佽鏍� + 璁㈠崟BOM蹇収鐨勬牴鑺傜偣瑙勬牸锛岀敤浜庢帓闄も�滆嚜宸扁�濊繖涓�鐗╂枡銆�
+ // 娉ㄦ剰锛欱OM缁撴瀯閲岄鏂欑墿鏂欐湰韬篃鍙兘鏄� parent_id 涓虹┖鐨勭嫭绔嬭妭鐐癸紝杩欓噷涓嶈兘鍐嶆妸鎵�鏈夋牴鑺傜偣閮藉綋鎴愭垚鍝佹帓闄わ紝
+ // 鍚﹀垯鈥滈鏂欌�濆伐搴忎笅鐨勭墿鏂欎細琚暣浣撹繃婊ゆ帀銆�
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);
+ if (orderBom.getProductModelId() != null) {
+ finishedProductModelIds.add(orderBom.getProductModelId());
+ }
// 鏀堕泦鎵�鏈夎寮曠敤涓虹埗绾х殑鑺傜偣ID锛欱OM浠庢渶鍚庝竴閬撳伐搴忓線閲岄厤缃墠涓�閬撳伐搴忥紝
- // 涓棿鑺傜偣鏄笂涓�閬撳伐搴忕殑浜у嚭锛堣嚜鍒讹級锛屽彧鏈夋瘡鏉″垎鏀渶閲屽眰鐨勫彾瀛愯妭鐐规墠鏄湡姝i渶瑕侀鐢ㄧ殑鐗╂枡銆�
+ // 涓棿鑺傜偣鏄笂涓�閬撳伐搴忕殑浜у嚭锛堣嚜鍒讹級锛屾棫鍙e緞鍙湁姣忔潯鍒嗘敮鏈�閲屽眰鐨勫彾瀛愯妭鐐规墠鏄湡姝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()))
+ // 棰嗘枡鑼冨洿浠ュ伐搴忕殑鈥滄槸鍚﹂鏂欌�濇爣璁颁负鍑嗭細鍙湁鏍囪浜嗛鏂欑殑宸ュ簭锛屽叾娑堣�楃殑鐗╂枡鎵嶈繘鍏ラ鏂欏彴璐︺��
+ // 娉ㄦ剰锛氶鏂欑墿鏂欏湪BOM缁撴瀯涓彲鑳芥槸鐙珛鑺傜偣锛坧arent_id 涓虹┖锛夛紝鎵�浠ヨ繖閲屼笉闄愬埗灞傜骇锛屽彧鐪嬪伐搴忔爣璁帮紱
+ // 鍙帓闄や笌璁㈠崟鎴愬搧鍚岃鏍肩殑鐗╂枡锛堟垚鍝佹湰韬棤闇�棰嗘枡锛夈��
+ List<ProductionBomStructureVo> markedPickStructureList = bomStructureList.stream()
+ .filter(s -> s != null && Boolean.TRUE.equals(s.getIsPick()))
.filter(s -> s.getProductModelId() == null || !finishedProductModelIds.contains(s.getProductModelId()))
.collect(Collectors.toList());
+ // 瀹為檯棰嗘枡椤癸細浼樺厛浣跨敤宸ュ簭棰嗘枡鏍囪锛�
+ // 鍏煎鍘嗗彶鏁版嵁锛氬綋璇ヨ鍗旴OM缁撴瀯閲屾病鏈変换浣曞伐搴忔爣璁伴鏂欐椂锛屽洖閫�涓哄師鏉ョ殑鈥滃彾瀛愯妭鐐归鏂欌�濊鍒欙紝
+ // 閬垮厤灏氭湭鍚敤鈥滄槸鍚﹂鏂欌�濇爣璁扮殑瀹㈡埛鎵撳紑棰嗘枡鍙拌处鏃舵暟鎹獊鐒朵负绌恒��
+ List<ProductionBomStructureVo> childStructureList = markedPickStructureList;
+ if (childStructureList.isEmpty()) {
+ 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());
+ }
+
// 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
List<Long> productModelIds = childStructureList.stream()
.map(ProductionBomStructureVo::getProductModelId)
--
Gitblit v1.9.3