From 4af1779c445da07151f7f87bf8a856bbdc16cf15 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期六, 16 五月 2026 16:53:51 +0800
Subject: [PATCH] fix(生产工单与BOM): 修复多级BOM需求量计算错误及参数传递问题

---
 src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
index 6a30baf..a9f76fd 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -216,11 +216,13 @@
             return;
         }
         List<ProductionBomStructure> updateList = new ArrayList<>();
+        BigDecimal lastProcessDemandedQuantity = orderQuantity;
         for (ProductionBomStructure structure : structureList) {
             if (structure == null || structure.getId() == null) {
                 continue;
             }
-            BigDecimal demandedQuantity = defaultDecimal(structure.getUnitQuantity()).multiply(orderQuantity);
+
+            BigDecimal demandedQuantity = lastProcessDemandedQuantity.multiply(defaultDecimal(structure.getUnitQuantity()));
             if (compareDecimal(structure.getDemandedQuantity(), demandedQuantity) == 0) {
                 continue;
             }
@@ -229,6 +231,7 @@
             update.setDemandedQuantity(demandedQuantity);
             updateList.add(update);
             structure.setDemandedQuantity(demandedQuantity);
+            lastProcessDemandedQuantity = demandedQuantity;
         }
         if (!updateList.isEmpty()) {
             this.updateBatchById(updateList);
@@ -307,7 +310,7 @@
             if (matchedOperation == null) {
                 matchedOperation = insertRoutingOperationSnapshot(orderRouting.getId(), productionOrderId, desiredOperation);
             } else {
-                updateRoutingOperationSnapshotIfNecessary(matchedOperation, orderRouting.getId(), productionOrderId, desiredOperation);
+                updateRoutingOperationSnapshotIfNecessary(desiredOperation, orderRouting.getId(), productionOrderId, matchedOperation);
             }
             finalOperationList.add(matchedOperation);
         }

--
Gitblit v1.9.3