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); 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; }