From 3066a8f5c1f475997bfe23857ba4bae9395900c4 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 13 八月 2026 10:19:24 +0800
Subject: [PATCH] fix: 领料功能修改,移除订单领料,添加工序领料功能,支持按工序查询物料与已领料记录

---
 src/main/java/com/ruoyi/production/util/TaskPlanQuantityUtil.java |  119 +++--------------------------------------------------------
 1 files changed, 6 insertions(+), 113 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/util/TaskPlanQuantityUtil.java b/src/main/java/com/ruoyi/production/util/TaskPlanQuantityUtil.java
index e82d7e4..80f0b14 100644
--- a/src/main/java/com/ruoyi/production/util/TaskPlanQuantityUtil.java
+++ b/src/main/java/com/ruoyi/production/util/TaskPlanQuantityUtil.java
@@ -1,130 +1,23 @@
 package com.ruoyi.production.util;
 
-import com.ruoyi.production.pojo.ProductionBomStructure;
 import com.ruoyi.production.pojo.ProductionOrder;
-import com.ruoyi.production.pojo.ProductionOrderRoutingOperation;
-import com.ruoyi.technology.pojo.TechnologyRoutingOperation;
 import lombok.experimental.UtilityClass;
 
 import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
 
 /**
- * 宸ュ崟璁″垝鏁伴噺璁$畻宸ュ叿绫�
+ * 宸ュ崟璁″垝鏁伴噺璁$畻宸ュ叿绫汇��
+ * 鎵佸钩 BOM 鍙淮鎶も�滅墿鏂欒鏍� + 娑堣�楀伐搴忊�濓紝涓嶉厤缃换浣曟暟閲忥紝
+ * 鍥犳宸ュ簭宸ュ崟鐨勮鍒掓暟閲忕粺涓�鍙栫敓浜ц鍗曠殑涓嬪崟鏁伴噺銆�
  */
 @UtilityClass
 public class TaskPlanQuantityUtil {
 
     /**
-     * 璁$畻宸ュ崟璁″垝鏁伴噺锛堜娇鐢� TechnologyRoutingOperation锛�
+     * 鎸夌敓浜ц鍗曟暟閲忚В鏋愬伐鍗曡鍒掓暟閲忋��
      */
-    public BigDecimal resolveTaskPlanQuantity(TechnologyRoutingOperation sourceOperation,
-                                              Map<String, BigDecimal> operationDemandedQuantityMap,
-                                              ProductionOrder productionOrder,
-                                              Long rootProductModelId) {
-        if (sourceOperation == null || operationDemandedQuantityMap == null || operationDemandedQuantityMap.isEmpty()) {
-            return defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity());
-        }
-        Long outputProductModelId = sourceOperation.getProductModelId() != null
-                ? sourceOperation.getProductModelId()
-                : rootProductModelId;
-        String key = buildOperationDemandedQuantityKey(sourceOperation.getTechnologyOperationId(), outputProductModelId);
-        BigDecimal planQuantity = operationDemandedQuantityMap.get(key);
-        return planQuantity != null ? planQuantity : defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity());
-    }
-
-    /**
-     * 璁$畻宸ュ崟璁″垝鏁伴噺锛堜娇鐢� ProductionOrderRoutingOperation锛�
-     */
-    public BigDecimal resolveTaskPlanQuantity(ProductionOrderRoutingOperation routingOperation,
-                                              Map<String, BigDecimal> demandedQuantityMap,
-                                              BigDecimal orderQuantity,
-                                              Long rootProductModelId) {
-        if (routingOperation == null || demandedQuantityMap == null || demandedQuantityMap.isEmpty()) {
-            return orderQuantity;
-        }
-        Long outputProductModelId = routingOperation.getProductModelId() != null
-                ? routingOperation.getProductModelId()
-                : rootProductModelId;
-        String key = buildOperationDemandedQuantityKey(routingOperation.getTechnologyOperationId(), outputProductModelId);
-        BigDecimal planQuantity = demandedQuantityMap.get(key);
-        return planQuantity != null ? planQuantity : orderQuantity;
-    }
-
-    /**
-     * 鏋勫缓宸ュ簭闇�姹傞噺鏄犲皠琛�
-     */
-    public Map<String, BigDecimal> buildOperationDemandedQuantityMap(List<ProductionBomStructure> bomStructures, Long rootProductModelId) {
-        if (bomStructures == null || bomStructures.isEmpty()) {
-            return Collections.emptyMap();
-        }
-        Map<Long, ProductionBomStructure> structureById = new HashMap<>();
-        for (ProductionBomStructure item : bomStructures) {
-            if (item != null && item.getId() != null) {
-                structureById.put(item.getId(), item);
-            }
-        }
-        Map<String, BigDecimal> demandedQuantityMap = new HashMap<>();
-        Set<String> mergedOutputNodeKeySet = new HashSet<>();
-        for (ProductionBomStructure bomStructure : bomStructures) {
-            if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) {
-                continue;
-            }
-            ProductionBomStructure outputNode = resolveOperationOutputNode(bomStructure, structureById);
-            Long outputProductModelId = resolveOutputProductModelId(outputNode, rootProductModelId);
-            if (outputProductModelId == null) {
-                continue;
-            }
-            String mergedOutputNodeKey = buildOperationOutputNodeKey(bomStructure.getTechnologyOperationId(),
-                    outputNode == null ? null : outputNode.getId(), outputProductModelId);
-            if (!mergedOutputNodeKeySet.add(mergedOutputNodeKey)) {
-                continue;
-            }
-            BigDecimal demandedQuantity = defaultDecimal(outputNode == null ? null : outputNode.getDemandedQuantity());
-            String key = buildOperationDemandedQuantityKey(bomStructure.getTechnologyOperationId(), outputProductModelId);
-            demandedQuantityMap.merge(key, demandedQuantity, BigDecimal::add);
-        }
-        return demandedQuantityMap;
-    }
-
-    /**
-     * 鏋勫缓宸ュ簭闇�姹傞噺key
-     */
-    public String buildOperationDemandedQuantityKey(Long operationId, Long outputProductModelId) {
-        return String.valueOf(operationId) + "#" + String.valueOf(outputProductModelId);
-    }
-
-    /**
-     * 鏋勫缓杈撳嚭鑺傜偣key
-     */
-    public String buildOperationOutputNodeKey(Long operationId, Long outputNodeId, Long outputProductModelId) {
-        return String.valueOf(operationId) + "#" + String.valueOf(outputNodeId) + "#" + String.valueOf(outputProductModelId);
-    }
-
-    /**
-     * 瑙f瀽宸ュ簭杈撳嚭鑺傜偣
-     */
-    public ProductionBomStructure resolveOperationOutputNode(ProductionBomStructure bomStructure,
-                                                             Map<Long, ProductionBomStructure> structureById) {
-        if (bomStructure == null) {
-            return null;
-        }
-        if (bomStructure.getParentId() == null) {
-            return bomStructure;
-        }
-        ProductionBomStructure parent = structureById.get(bomStructure.getParentId());
-        return parent != null ? parent : bomStructure;
-    }
-
-    /**
-     * 瑙f瀽杈撳嚭浜у搧瑙勬牸ID
-     */
-    public Long resolveOutputProductModelId(ProductionBomStructure outputNode, Long rootProductModelId) {
-        if (outputNode == null) {
-            return rootProductModelId;
-        }
-        return outputNode.getProductModelId() != null ? outputNode.getProductModelId() : rootProductModelId;
+    public BigDecimal resolveTaskPlanQuantity(ProductionOrder productionOrder) {
+        return defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity());
     }
 
     /**

--
Gitblit v1.9.3