Browse Source

打开定时任务

tags/v1.1.0
wanghaoran 2 years ago
parent
commit
a67eac469f
1 changed files with 4 additions and 6 deletions
  1. +4
    -6
      tuoheng-admin/src/main/java/com/tuoheng/admin/task/ScheduledTask.java

+ 4
- 6
tuoheng-admin/src/main/java/com/tuoheng/admin/task/ScheduledTask.java View File

private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");




/* @Scheduled(fixedRate = 3000)
@Scheduled(fixedRate = 1000)
public void scheduledTask() { public void scheduledTask() {


log.info("执行定时执行飞行任务:" + LocalDateTime.now()); log.info("执行定时执行飞行任务:" + LocalDateTime.now());




List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>() List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) .eq(ThMission::getMark, MarkTypeEnum.VALID.getCode())
.ge(ThMission::getExecutionStartTime, dateformat.format(new Date())) .ge(ThMission::getExecutionStartTime, dateformat.format(new Date()))
.ge(ThMission::getExecutionStatus, 1) .ge(ThMission::getExecutionStatus, 1)
.eq(ThMission::getStatus, TaskStatusEnum.WAIT.getCode())); .eq(ThMission::getStatus, TaskStatusEnum.WAIT.getCode()));


log.info("一秒钟一次");
log.info("执行定时执行飞行任务,一秒钟一次");


for (ThMission thMission : thMissions) { for (ThMission thMission : thMissions) {
JsonResult jsonResult = inspectionService.executeTask(String.valueOf(thMission.getId()));
JsonResult jsonResult = inspectionService.executeTask(String.valueOf(thMission.getId()), null);
thMission.setExecutionStatus(2); thMission.setExecutionStatus(2);
if(jsonResult.getCode()!=0 && ObjectUtil.isEmpty(jsonResult.getData())){ if(jsonResult.getCode()!=0 && ObjectUtil.isEmpty(jsonResult.getData())){
thMission.setStatus(TaskStatusEnum.FAIL.getCode()); thMission.setStatus(TaskStatusEnum.FAIL.getCode());
} }
missionMapper.updateById(thMission); missionMapper.updateById(thMission);
} }
}*/
}
} }

Loading…
Cancel
Save