From 07d6e47c51a0ac489d6a8da76f893675d7d2a75f Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 21 八月 2026 16:10:50 +0800
Subject: [PATCH] fix: 需求总量耗料计算修改
---
src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java | 5 ++---
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java | 29 ++++++-----------------------
2 files changed, 8 insertions(+), 26 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..c1e665c 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -217,13 +217,13 @@
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()));
+ BigDecimal demandedQuantity = defaultDecimal(orderQuantity)
+ .multiply(defaultDecimal(structure.getUnitQuantity()));
// if (compareDecimal(structure.getDemandedQuantity(), demandedQuantity) == 0) {
// continue;
// }
@@ -232,7 +232,6 @@
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 caff402..e3b547d 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -442,7 +442,6 @@
productionOrderBomMapper.insert(orderBom);
Map<Long, Long> idMap = new HashMap<>();
- BigDecimal lastProcessDemandedQuantity = orderQuantity;
for (TechnologyBomStructure source : structureList) {
// 瀛愯妭鐐� parentId 闇�瑕佹槧灏勬垚鏂板揩鐓ц妭鐐� id锛屾墠鑳戒繚鐣欏師濮� BOM 灞傜骇銆�
ProductionBomStructure target = new ProductionBomStructure();
@@ -452,11 +451,11 @@
target.setProductModelId(source.getProductModelId());
target.setTechnologyOperationId(source.getOperationId());
target.setUnitQuantity(source.getUnitQuantity());
- target.setDemandedQuantity(lastProcessDemandedQuantity.multiply(source.getUnitQuantity()));
+ target.setDemandedQuantity(defaultDecimal(orderQuantity)
+ .multiply(defaultDecimal(source.getUnitQuantity())));
target.setUnit(source.getUnit());
productionBomStructureMapper.insert(target);
idMap.put(source.getId(), target.getId());
- lastProcessDemandedQuantity = target.getDemandedQuantity();
}
return orderBom;
}
@@ -1074,7 +1073,7 @@
return Collections.emptyList();
}
- // 鏌ヨ瀹屾暣鐨凚OM缁撴瀯锛堝寘鎷牴鑺傜偣锛夛紝鐢ㄤ簬璁$畻灞傜骇闇�姹傛暟閲�
+ // 鏌ヨ瀹屾暣鐨凚OM缁撴瀯锛堝寘鎷牴鑺傜偣锛夛紝姣忎釜鑺傜偣鐙珛璁$畻闇�姹傛暟閲�
List<ProductionBomStructureVo> bomStructureList = productionBomStructureMapper.listByBomId(orderBom.getId());
if (bomStructureList == null || bomStructureList.isEmpty()) {
return Collections.emptyList();
@@ -1084,26 +1083,10 @@
ProductionOrder productionOrder = productionOrderMapper.selectById(productionOrderId);
BigDecimal orderQuantity = productionOrder != null ? defaultDecimal(productionOrder.getQuantity()) : BigDecimal.ZERO;
- // 鏋勫缓鏍戝舰缁撴瀯骞惰绠楀眰绾ч渶姹傛暟閲�
- Map<Long, ProductionBomStructureVo> structureByIdMap = bomStructureList.stream()
- .filter(s -> s != null && s.getId() != null)
- .collect(Collectors.toMap(ProductionBomStructureVo::getId, s -> s));
-
- // 鎸夊眰绾ц绠楅渶姹傛暟閲忥細瀛愮骇闇�姹傛暟閲� = 鐖剁骇闇�姹傛暟閲� 脳 瀛愮骇鍗曚綅浜у嚭鎵�闇�鏁伴噺
for (ProductionBomStructureVo structure : bomStructureList) {
- if (structure == null) continue;
-
- if (structure.getParentId() == null || structure.getParentId() == 0) {
- // 鏍硅妭鐐癸細闇�姹傛暟閲� = 璁㈠崟鏁伴噺
- structure.setDemandedQuantity(orderQuantity);
- } else {
- // 瀛愯妭鐐癸細闇�姹傛暟閲� = 鐖剁骇闇�姹傛暟閲� 脳 瀛愮骇鍗曚綅浜у嚭鎵�闇�鏁伴噺
- ProductionBomStructureVo parent = structureByIdMap.get(structure.getParentId());
- if (parent != null) {
- BigDecimal parentDemandedQty = defaultDecimal(parent.getDemandedQuantity());
- BigDecimal unitQuantity = defaultDecimal(structure.getUnitQuantity());
- structure.setDemandedQuantity(parentDemandedQty.multiply(unitQuantity));
- }
+ if (structure != null) {
+ structure.setDemandedQuantity(orderQuantity
+ .multiply(defaultDecimal(structure.getUnitQuantity())));
}
}
--
Gitblit v1.9.3