| | |
| | | import com.dy.pmsGlobal.pojoBa.BaUser; |
| | | import com.dy.pmsGlobal.pojoPr.*; |
| | | import com.dy.pmsGlobal.util.UserUtil; |
| | | import com.dy.pmsProduct.taskPlan.PlanStatusEnum; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | if (orderDao.exists(p.name, p.id)) { |
| | | throw new RuntimeException("订单名称不能重复"); |
| | | } |
| | | p.setDeleted(false); |
| | | extractedCheck(p); |
| | | p.deleted = false; |
| | | BaUser loginUser = userUtil.getUser(UserTokenContext.get()); |
| | | if (loginUser != null) { |
| | | p.creator = loginUser.id; |
| | |
| | | if (orderDao.exists(p.name, p.id)) { |
| | | throw new RuntimeException("订单名称不能重复"); |
| | | } |
| | | extractedCheck(p); |
| | | int count = orderDao.updateByPrimaryKeySelective(p); |
| | | if (count > 0) { |
| | | saveOrderItems(p); |
| | |
| | | } |
| | | /** |
| | | * 只更新状态,不更新其他字段 |
| | | * @param plan |
| | | * @param order |
| | | * 更新状态 如果有在执行中的任务,不让暂停 |
| | | * @return |
| | | */ |
| | | /* @Transactional |
| | | public int updateStatus(PrOrder plan) { |
| | | if(plan.status == PlanStatusEnum.NORMAL.getCode()){ |
| | | PrAssemblyPlan assemblyPlan = assemblyDao.selectByPrimaryKey(plan.id); |
| | | assemblyPlan.status = plan.status; |
| | | extractedCheck(assemblyPlan); |
| | | @Transactional |
| | | public int updateStatus(PrOrder order) { |
| | | if(order.status == OrderStatusEnum.NORMAL.getCode()){ |
| | | PrOrder prOrder = orderDao.selectByPrimaryKey(order.id); |
| | | prOrder.status = order.status; |
| | | extractedCheck(prOrder); |
| | | } |
| | | PrAssemblyPlan param = new PrAssemblyPlan(); |
| | | param.id =plan.id; |
| | | param.status = plan.status; |
| | | return assemblyDao.updateByPrimaryKeySelective(param); |
| | | PrOrder param = new PrOrder(); |
| | | param.id =order.id; |
| | | param.status = order.status; |
| | | return orderDao.updateByPrimaryKeySelective(param); |
| | | } |
| | | 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); |
| | | //如果交期小于当前时间,不允许设置为正常 |
| | | private void extractedCheck(PrOrder order) { |
| | | if(order.status == OrderStatusEnum.NORMAL.getCode()){ |
| | | String deliveryDateStr = order.getDeliveryDate(); |
| | | LocalDate endDate = LocalDate.parse(deliveryDateStr, DateTimeFormatter.ISO_LOCAL_DATE); |
| | | LocalDate nextDay = endDate.plusDays(1); |
| | | LocalDate today = LocalDate.now(); // 获取当前日期 |
| | | if (nextDay.isBefore(today)) { |
| | | throw new RuntimeException("执行状态结束日期必须大于等于当前日期,请修改结束日期"); |
| | | throw new RuntimeException("交付日期必须大于等于当前日期,请修改交付日期"); |
| | | } |
| | | } |
| | | }*/ |
| | | //如果有在生产的任务不能设置为暂停 或 结束 |
| | | /* |
| | | PrProductionProcess process = processDao.selectByPrimaryKey(order.processId); |
| | | if(process == null || !process.proId.equals(order.proId)){ |
| | | throw new RuntimeException("产品与生产流程不匹配"); |
| | | } |
| | | //开始日期要小于结束日期 |
| | | if(order.startDate.compareTo(order.endDate) > 0){ |
| | | throw new RuntimeException("开始日期不能大于结束日期"); |
| | | }*/ |
| | | } |
| | | } |