|  |  | 
 |  |  |         if(assemblyDao.exists(plan.name,plan.id)){ | 
 |  |  |             throw new RuntimeException("计划名称不能重复"); | 
 |  |  |         } | 
 |  |  |         PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); | 
 |  |  |         if(process == null || !process.proId.equals(plan.proId)){ | 
 |  |  |             throw new RuntimeException("产品与生产流程不匹配"); | 
 |  |  |         } | 
 |  |  |         extractedCheck(plan); | 
 |  |  |         PrBatchNumber batch = new PrBatchNumber(); | 
 |  |  |         batch.batchNumber = getNextCode(); | 
 |  |  |         batch.proId = plan.proId; | 
 |  |  | 
 |  |  |         if(assemblyDao.exists(plan.name,plan.id)){ | 
 |  |  |             throw new RuntimeException("计划名称不能重复"); | 
 |  |  |         } | 
 |  |  |         PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); | 
 |  |  |         if(process == null || !process.proId.equals(plan.proId)){ | 
 |  |  |             throw new RuntimeException("产品与生产流程不匹配"); | 
 |  |  |         } | 
 |  |  |         PrAssemblyPlan origPlan = assemblyDao.selectByPrimaryKey(plan.id); | 
 |  |  |         PrBatchNumber batch = batchDao.selectByPrimaryKey(origPlan.batchId); | 
 |  |  |         //如果有投入,产品和流程不能变更 | 
 |  |  | 
 |  |  |                 throw new RuntimeException("计划已投入,产品与生产流程不能变更"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //Fancy add 2024/07/09   如果状态为执行 ,则结束日期必须大于等于当前日期 | 
 |  |  |         if(plan.status == PlanStatusEnum.NORMAL.getCode()){ | 
 |  |  |             String endDateStr = plan.getEndDate(); | 
 |  |  |             LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE); | 
 |  |  |             LocalDate nextDay = endDate.plusDays(1); | 
 |  |  |             LocalDate today = LocalDate.now(); // 获取当前日期 | 
 |  |  |             if (nextDay.isBefore(today)) { | 
 |  |  |                 throw new RuntimeException("执行状态结束日期必须大于等于当前日期"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         extractedCheck(plan); | 
 |  |  |         //产品改变则更新全部已生成设备号 | 
 |  |  |         if(origPlan.proId != plan.proId){ | 
 |  |  |             batch.proId = plan.proId; | 
 |  |  | 
 |  |  |         return assemblyDao.updateByPrimaryKeySelective(plan); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void extractedCheck(PrAssemblyPlan plan) { | 
 |  |  |         PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId); | 
 |  |  |         if(process == null || !process.proId.equals(plan.proId)){ | 
 |  |  |             throw new RuntimeException("产品与生产流程不匹配"); | 
 |  |  |         } | 
 |  |  |         //开始日期要小于结束日期 | 
 |  |  |         if(plan.startDate.compareTo(plan.endDate) > 0){ | 
 |  |  |             throw new RuntimeException("开始日期不能大于结束日期"); | 
 |  |  |         } | 
 |  |  |         //Fancy add 2024/07/09   如果状态为执行 ,则结束日期必须大于等于当前日期 | 
 |  |  |         if(plan.status == PlanStatusEnum.NORMAL.getCode()){ | 
 |  |  |             String endDateStr = plan.getEndDate(); | 
 |  |  |             LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE); | 
 |  |  |             LocalDate nextDay = endDate.plusDays(1); | 
 |  |  |             LocalDate today = LocalDate.now(); // 获取当前日期 | 
 |  |  |             if (nextDay.isBefore(today)) { | 
 |  |  |                 throw new RuntimeException("执行状态结束日期必须大于等于当前日期,请修改结束日期"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Transactional | 
 |  |  |     public int addDevice(Long planId,int num){ | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Transactional | 
 |  |  |     public int updateStatus(PrAssemblyPlan plan) { | 
 |  |  |         if(plan.status == PlanStatusEnum.NORMAL.getCode()){ | 
 |  |  |             PrAssemblyPlan assemblyPlan = assemblyDao.selectByPrimaryKey(plan.id); | 
 |  |  |             assemblyPlan.status = plan.status; | 
 |  |  |             extractedCheck(assemblyPlan); | 
 |  |  |         } | 
 |  |  |         PrAssemblyPlan param = new PrAssemblyPlan(); | 
 |  |  |         param.id =plan.id; | 
 |  |  |         param.status = plan.status; |