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/ProductionOrderServiceImpl.java | 29 ++++++-----------------------
1 files changed, 6 insertions(+), 23 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 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