| | |
| | | throw new ServiceException("生产订单不存在"); |
| | | } |
| | | |
| | | // 获取订单BOM |
| | | ProductionOrderBom orderBom = productionOrderBomMapper.selectOne( |
| | | Wrappers.<ProductionOrderBom>lambdaQuery() |
| | | .eq(ProductionOrderBom::getProductionOrderId, productionOrder.getId())); |
| | | |
| | | // 确定根产品规格ID |
| | | Long rootProductModelId = orderBom != null && orderBom.getProductModelId() != null |
| | | ? orderBom.getProductModelId() |
| | | : productionOrder.getProductModelId(); |
| | | |
| | | // 获取BOM结构列表 |
| | | List<ProductionBomStructure> orderBomStructureList = orderBom == null || orderBom.getId() == null |
| | | ? Collections.emptyList() |
| | | : productionBomStructureMapper.selectList( |
| | | Wrappers.<ProductionBomStructure>lambdaQuery() |
| | | .eq(ProductionBomStructure::getProductionOrderBomId, orderBom.getId()) |
| | | .orderByAsc(ProductionBomStructure::getId)); |
| | | |
| | | // 构建工序需求量映射 |
| | | Map<String, BigDecimal> operationDemandedQuantityMap = |
| | | TaskPlanQuantityUtil.buildOperationDemandedQuantityMap(orderBomStructureList, rootProductModelId); |
| | | |
| | | // 获取工艺路线工序(用于计算计划数量) |
| | | TechnologyRoutingOperation sourceOperation = technologyRoutingOperationMapper.selectById( |
| | | updatedOperation.getTechnologyRoutingOperationId()); |
| | | // 将原来的私有方法替换为调用工具类 |
| | | BigDecimal planQuantity = TaskPlanQuantityUtil.resolveTaskPlanQuantity( |
| | | sourceOperation, |
| | | operationDemandedQuantityMap, |
| | | productionOrder, |
| | | rootProductModelId); |
| | | task.setPlanQuantity(planQuantity); |
| | | // 扁平BOM不配置数量,工单计划数量统一取订单数量 |
| | | task.setPlanQuantity(TaskPlanQuantityUtil.resolveTaskPlanQuantity(productionOrder)); |
| | | task.setCompleteQuantity(BigDecimal.ZERO); |
| | | task.setWorkOrderNo(generateNextTaskNo()); |
| | | task.setStatus(2); |