package com.gk.hotwork.doublePrevention.scheduls;
|
|
import com.gk.hotwork.doublePrevention.entity.PreventDangerCheckTask;
|
import com.gk.hotwork.doublePrevention.entity.PreventDangerCheckWork;
|
import com.gk.hotwork.doublePrevention.service.baseService.PreventDangerCheckTaskService;
|
import com.gk.hotwork.doublePrevention.service.baseService.PreventDangerCheckWorkService;
|
import org.apache.commons.lang3.ObjectUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
import java.util.Date;
|
import java.util.List;
|
|
@Component
|
public class PreventSearchWorkStatusSchedule {
|
|
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(PreventSearchWorkStatusSchedule.class);
|
|
@Autowired
|
private PreventDangerCheckTaskService preventDangerCheckTaskService;
|
@Autowired
|
private PreventDangerCheckWorkService preventDangerCheckWorkService;
|
|
@Scheduled(cron = "0 0/20 * * * ?")
|
//@PostConstruct
|
public void searchTask(){
|
logger.info("【】重置任务状态开始执行....");
|
Date date = new Date();
|
Date startTime = null;
|
Date endTime = null;
|
|
startTime = date;
|
endTime = new Date(date.getTime() + 60 * 60 * 1000L);
|
//检查后面30分钟内的所有work,看是否有未关闭,且未生成任务的,如果
|
//检索所有即将到时间的任务 ,nextExecTime
|
List<PreventDangerCheckWork> checkWorkList = preventDangerCheckWorkService.listExecCheckWork(startTime, endTime);
|
|
for (PreventDangerCheckWork checkWork : checkWorkList) {
|
PreventDangerCheckTask task = preventDangerCheckTaskService.getTaskByCheckWorkIdAndStartTime(checkWork.getId(), checkWork.getNextCheckTime());
|
if (ObjectUtils.isEmpty(task)){
|
preventDangerCheckWorkService.resetCheckWorkStatus(checkWork.getId());
|
}
|
}
|
logger.info("【】重置任务状态执行结束");
|
|
}
|
|
}
|