| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.dy.common.schedulerTask.TaskJob; |
| | | import com.dy.common.springUtil.SpringContextUtil; |
| | | import com.dy.common.util.SysUtil; |
| | | import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper; |
| | | import com.dy.pmsGlobal.daoPr.PrDeviceMapper; |
| | | import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | public class AssemblyPlanTask extends TaskJob { |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void execute(JobExecutionContext ctx) { |
| | | log.info("开始执行 组装计划任务定时检查"); |
| | | PrAssemblyPlanMapper assemblyDao = SpringContextUtil.getBean(PrAssemblyPlanMapper.class); |
| | | PrDeviceMapper deviceDao = SpringContextUtil.getBean(PrDeviceMapper.class); |
| | | Map<String,Object> planParams = new HashMap<>(); |
| | | planParams.put("status",PlanStatusEnum.NORMAL.getCode()); |
| | | List<PrAssemblyPlan> list = assemblyDao.selectSome(planParams); |
| | | for (PrAssemblyPlan plan : list) { |
| | | HashMap<String, Object> deviceParams = new HashMap<>(); |
| | | deviceParams.put("batchId", plan.getBatchId()); |
| | | deviceParams.put("status", DeviceStatus.COMPLETED.getCode()); |
| | | Long count = deviceDao.selectSomeCount(deviceParams); |
| | | if(count>plan.number && DateUtil.between(DateUtil.parse(plan.endDate), DateUtil.date(), DateUnit.DAY)>3){ |
| | | plan.setStatus(PlanStatusEnum.END.getCode()); |
| | | assemblyDao.updateByPrimaryKeySelective(plan); |
| | | try{ |
| | | PrAssemblyPlanMapper assemblyDao = SpringContextUtil.getBean(PrAssemblyPlanMapper.class); |
| | | PrDeviceMapper deviceDao = SpringContextUtil.getBean(PrDeviceMapper.class); |
| | | Map<String,Object> planParams = new HashMap<>(); |
| | | planParams.put("status",PlanStatusEnum.NORMAL.getCode()); |
| | | List<PrAssemblyPlan> list = assemblyDao.selectSome(planParams); |
| | | for (PrAssemblyPlan plan : list) { |
| | | HashMap<String, Object> deviceParams = new HashMap<>(); |
| | | deviceParams.put("batchId", plan.getBatchId()); |
| | | deviceParams.put("status", DeviceStatus.COMPLETED.getCode()); |
| | | Long count = deviceDao.selectSomeCount(deviceParams); |
| | | if(count>plan.number && DateUtil.between(DateUtil.parse(plan.endDate), DateUtil.date(), DateUnit.DAY)>3){ |
| | | plan.setStatus(PlanStatusEnum.END.getCode()); |
| | | assemblyDao.updateByPrimaryKeySelective(plan); |
| | | } |
| | | } |
| | | if(assemblyDao!=null){ |
| | | throw new RuntimeException(""); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("组装计划任务定时检查异常",e); |
| | | try{ |
| | | SysUtil.InfoVo vo = SysUtil.info() ; |
| | | System.out.println(vo.toString()); |
| | | }catch (Exception e1){} |
| | | } |
| | | log.info("完成 组装计划任务定时检查"); |
| | | } |