From f88884da6e87b1fb3757451f1c5fb4d8c75a1441 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 04 六月 2026 11:52:29 +0800
Subject: [PATCH] refactor(production): 优化BOM结构需求数量计算逻辑
---
src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java | 8 ++------
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java | 5 ++---
2 files changed, 4 insertions(+), 9 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 0513bdc..c459154 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -217,22 +217,18 @@
return;
}
List<ProductionBomStructure> updateList = new ArrayList<>();
- BigDecimal lastProcessDemandedQuantity = orderQuantity;
for (ProductionBomStructure structure : structureList) {
if (structure == null || structure.getId() == null) {
continue;
}
- BigDecimal demandedQuantity = lastProcessDemandedQuantity.multiply(defaultDecimal(structure.getUnitQuantity()));
-// if (compareDecimal(structure.getDemandedQuantity(), demandedQuantity) == 0) {
-// continue;
-// }
+ // 鐩存帴浣跨敤璁㈠崟鏁伴噺 脳 褰撳墠BOM鐨勫崟浣嶄骇鍑猴紝涓嶅啀閫愬眰绱Н
+ BigDecimal demandedQuantity = orderQuantity.multiply(defaultDecimal(structure.getUnitQuantity()));
ProductionBomStructure update = new ProductionBomStructure();
update.setId(structure.getId());
update.setDemandedQuantity(demandedQuantity);
updateList.add(update);
structure.setDemandedQuantity(demandedQuantity);
- lastProcessDemandedQuantity = demandedQuantity;
}
if (!updateList.isEmpty()) {
this.updateBatchById(updateList);
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 ecdb37c..d125a42 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -437,7 +437,6 @@
productionOrderBomMapper.insert(orderBom);
Map<Long, Long> idMap = new HashMap<>();
- BigDecimal lastProcessDemandedQuantity = orderQuantity;
for (TechnologyBomStructure source : structureList) {
// 瀛愯妭鐐� parentId 闇�瑕佹槧灏勬垚鏂板揩鐓ц妭鐐� id锛屾墠鑳戒繚鐣欏師濮� BOM 灞傜骇銆�
ProductionBomStructure target = new ProductionBomStructure();
@@ -447,11 +446,11 @@
target.setProductModelId(source.getProductModelId());
target.setTechnologyOperationId(source.getOperationId());
target.setUnitQuantity(source.getUnitQuantity());
- target.setDemandedQuantity(lastProcessDemandedQuantity.multiply(source.getUnitQuantity()));
+ // 鐩存帴浣跨敤璁㈠崟鏁伴噺 脳 褰撳墠BOM鐨勫崟浣嶄骇鍑猴紝涓嶅啀閫愬眰绱Н
+ target.setDemandedQuantity(orderQuantity.multiply(source.getUnitQuantity()));
target.setUnit(source.getUnit());
productionBomStructureMapper.insert(target);
idMap.put(source.getId(), target.getId());
- lastProcessDemandedQuantity = target.getDemandedQuantity();
}
return orderBom;
}
--
Gitblit v1.9.3