| | |
| | | productionOrderRoutingOperationMapper.insert(targetOperation); |
| | | |
| | | ProductionOperationTask task = new ProductionOperationTask(); |
| | | task.setTechnologyRoutingOperationId(targetOperation.getId()); |
| | | task.setProductionOrderRoutingOperationId(targetOperation.getId()); |
| | | task.setProductionOrderId(productionOrder.getId()); |
| | | task.setPlanQuantity(defaultDecimal(productionOrder.getQuantity())); |
| | | task.setCompleteQuantity(BigDecimal.ZERO); |
| | |
| | | if (productionPlans.size() != planIds.size()) { |
| | | throw new ServiceException("部分生产计划不存在"); |
| | | } |
| | | Map<Long, ProductionPlan> planMap = productionPlans.stream() |
| | | .collect(Collectors.toMap(ProductionPlan::getId, item -> item, (left, right) -> left)); |
| | | ProductionPlan mainPlan = planMap.get(planIds.get(0)); |
| | | if (mainPlan == null) { |
| | | throw new ServiceException("主生产计划不存在"); |
| | | } |
| | | Set<Long> productModelIds = productionPlans.stream() |
| | | .map(ProductionPlan::getProductModelId) |
| | | .collect(Collectors.toSet()); |
| | |
| | | if (productionPlans.stream().anyMatch(item -> item.getStatus() != null && item.getStatus() == 2)) { |
| | | throw new ServiceException("所选生产计划已下发"); |
| | | } |
| | | ProductionPlan firstPlan = productionPlans.get(0); |
| | | ProductionPlan firstPlan = mainPlan; |
| | | if (productionOrder.getProductModelId() == null) { |
| | | productionOrder.setProductModelId(firstPlan.getProductModelId()); |
| | | } else if (!Objects.equals(productionOrder.getProductModelId(), firstPlan.getProductModelId())) { |
| | |
| | | } |
| | | } |
| | | |
| | | List<ProductionOrderPickVo> result = new ArrayList<>(bomStructureList.size()); |
| | | Map<String, ProductionOrderPickVo> mergedPickMap = new LinkedHashMap<>(); |
| | | for (ProductionBomStructureVo structure : bomStructureList) { |
| | | if (structure == null || structure.getProductModelId() == null) { |
| | | continue; |
| | | } |
| | | Long productModelId = structure.getProductModelId(); |
| | | ProductionOrderPickVo vo = new ProductionOrderPickVo(); |
| | | String mergeKey = String.valueOf(structure.getTechnologyOperationId()) + "#" + productModelId; |
| | | ProductionOrderPickVo vo = mergedPickMap.get(mergeKey); |
| | | if (vo == null) { |
| | | vo = new ProductionOrderPickVo(); |
| | | vo.setProductModelId(productModelId); |
| | | vo.setOperationName(structure.getOperationName()); |
| | | vo.setTechnologyOperationId(structure.getTechnologyOperationId()); |
| | | vo.setProductName(structure.getProductName()); |
| | | vo.setModel(structure.getModel()); |
| | | vo.setDemandedQuantity(defaultDecimal(structure.getDemandedQuantity())); |
| | | vo.setDemandedQuantity(BigDecimal.ZERO); |
| | | vo.setUnit(structure.getUnit()); |
| | | List<String> batchNoList = stockBatchNoMap.get(productModelId) == null |
| | | ? Collections.emptyList() |
| | |
| | | vo.setBatchNoList(batchNoList); |
| | | vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO)); |
| | | vo.setBom(true); |
| | | result.add(vo); |
| | | mergedPickMap.put(mergeKey, vo); |
| | | } |
| | | return result; |
| | | vo.setDemandedQuantity(defaultDecimal(vo.getDemandedQuantity()).add(defaultDecimal(structure.getDemandedQuantity()))); |
| | | } |
| | | return new ArrayList<>(mergedPickMap.values()); |
| | | } |
| | | } |