From 9f052ad68599a13c63b07dc225464cdc11f28e48 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期二, 02 六月 2026 11:23:05 +0800
Subject: [PATCH] fix: 若产品结构投入与产出品都是自己,且比例为1,这种情况不需要领料

---
 src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java |   50 ++++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 22 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 9543cad..5c103b8 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -1066,8 +1066,19 @@
         }
 
         // 杩囨护鍑洪潪鏍硅妭鐐癸紙瀹為檯棰嗘枡椤癸級
+        // 鎺掗櫎鎶曞叆鍝佷笌浜у嚭鍝佺浉鍚屼笖姣斾緥涓�1鐨勬儏鍐碉紙鑷韩鍔犲伐锛屼笉闇�瑕侀鏂欙級
         List<ProductionBomStructureVo> childStructureList = bomStructureList.stream()
                 .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
+                .filter(s -> {
+                    ProductionBomStructureVo parent = structureByIdMap.get(s.getParentId());
+                    if (parent == null) {
+                        return true;
+                    }
+                    // 鎶曞叆鍝佷笌浜у嚭鍝佺浉鍚屼笖姣斾緥涓�1鏃讹紝涓嶉渶瑕侀鏂�
+                    boolean sameProduct = Objects.equals(s.getProductModelId(), parent.getProductModelId());
+                    boolean unitRatio = BigDecimal.ONE.compareTo(defaultDecimal(s.getUnitQuantity())) == 0;
+                    return !(sameProduct && unitRatio);
+                })
                 .collect(Collectors.toList());
 
         // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
@@ -1095,34 +1106,29 @@
             }
         }
 
-        Map<String, ProductionOrderPickVo> mergedPickMap = new LinkedHashMap<>();
+        List<ProductionOrderPickVo> pickList = new ArrayList<>();
         for (ProductionBomStructureVo structure : childStructureList) {
             if (structure == null || structure.getProductModelId() == null) {
                 continue;
             }
             Long productModelId = structure.getProductModelId();
-            String mergeKey = String.valueOf(structure.getTechnologyOperationId()) + "#" + productModelId;
-            ProductionOrderPickVo vo = mergedPickMap.get(mergeKey);
-            if (vo == null) {
-                vo = new ProductionOrderPickVo();
-                vo.setProductModelId(productModelId);
-                vo.setOperationName(structure.getOperationName());
-                vo.setTechnologyOperationId(structure.getTechnologyOperationId());
-                vo.setProductName(structure.getProductName());
-                vo.setModel(structure.getModel());
-                vo.setDemandedQuantity(BigDecimal.ZERO);
-                vo.setUnit(structure.getUnit());
-                List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
-                        ? Collections.emptyList()
-                        : new ArrayList<>(stockBatchNoMap.get(productModelId));
-                vo.setBatchNoList(batchNoList);
-                vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
-                vo.setBom(true);
-                mergedPickMap.put(mergeKey, vo);
-            }
-            vo.setDemandedQuantity(defaultDecimal(vo.getDemandedQuantity()).add(defaultDecimal(structure.getDemandedQuantity())));
+            ProductionOrderPickVo vo = new ProductionOrderPickVo();
+            vo.setProductModelId(productModelId);
+            vo.setOperationName(structure.getOperationName());
+            vo.setTechnologyOperationId(structure.getTechnologyOperationId());
+            vo.setProductName(structure.getProductName());
+            vo.setModel(structure.getModel());
+            vo.setDemandedQuantity(defaultDecimal(structure.getDemandedQuantity()));
+            vo.setUnit(structure.getUnit());
+            List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
+                    ? Collections.emptyList()
+                    : new ArrayList<>(stockBatchNoMap.get(productModelId));
+            vo.setBatchNoList(batchNoList);
+            vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
+            vo.setBom(true);
+            pickList.add(vo);
         }
-        return new ArrayList<>(mergedPickMap.values());
+        return pickList;
     }
 
     @Override

--
Gitblit v1.9.3