| | |
| | | // 查询主生产计划 |
| | | List<ProductionPlanDto> plans = productionPlanMapper.selectWithMaterialByIds(productionPlanDto.getIds()); |
| | | |
| | | if (plans == null || plans.isEmpty()) { |
| | | throw new ServiceException("下发失败,生产计划不存在"); |
| | | } |
| | | |
| | | // 校验是否存在不同的产品名称 |
| | | String firstProductName = plans.get(0).getProductName(); |
| | | if (plans.stream().anyMatch(p -> p.getProductName() == null || !p.getProductName().equals(firstProductName))) { |
| | |
| | | productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode()); |
| | | productOrder.setStrength(productionPlanDto.getStrength()); |
| | | productOrder.setProductMaterialSkuId(productionPlanDto.getProductMaterialSkuId()); |
| | | productOrder.setProductMaterialSkuId(plans.get(0).getProductMaterialSkuId()); |
| | | |
| | | Long orderId = productOrderService.insertProductOrder(productOrder); |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean update(ProductionPlanDto productionPlanDto) { |
| | | if (productionPlanDto == null) { |
| | | throw new ServiceException("编辑失败,数据不能为空"); |
| | | } |
| | | ProductionPlan productionPlan = getById(productionPlanDto.getId()); |
| | | if (productionPlan == null) { |
| | | throw new ServiceException("编辑失败,主生产计划不存在"); |
| | | } |
| | | |
| | | // 已下发状态,不能编辑 |
| | | if (productionPlanDto.getStatus() != 0) { |
| | | throw new BaseException("已下发或部分下发状态,不能编辑"); |
| | | if (productionPlan.getStatus() != 0) { |
| | | throw new BaseException("编辑失败,该生产计划已下发或部分下发状态,禁止编辑"); |
| | | } |
| | | // 查询是否有关联订单 |
| | | boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null); |