|
|
|
|
package com.ann.job;
|
|
|
|
|
|
|
|
|
|
import com.ann.entity.filing.MessageSubordinate;
|
|
|
|
|
import com.ann.service.MessageSubordinateService;
|
|
|
|
|
import com.ann.service.impl.QueueService;
|
|
|
|
|
import com.ann.utils.QuartzUtils;
|
|
|
|
|
import org.quartz.Job;
|
|
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
|
|
import org.quartz.JobExecutionException;
|
|
|
|
|
import org.quartz.Scheduler;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 取从属表未解析的数据
|
|
|
|
|
*
|
|
|
|
|
* @Author: LeiJiaXin
|
|
|
|
|
* @Date: 2019/8/16 10:11
|
|
|
|
|
*/
|
|
|
|
|
public class ScheduledJob implements Job {
|
|
|
|
|
|
|
|
|
|
static final Logger logger = LoggerFactory.getLogger(ScheduledJob.class);
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
Scheduler scheduler;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
MessageSubordinateService messageSubordinateService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
QueueService queueService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute(JobExecutionContext context) {
|
|
|
|
|
try {
|
|
|
|
|
//System.out.println("动态的定时任务1执行时间:" + LocalTime.now());
|
|
|
|
|
QuartzUtils.pauseScheduleJob(scheduler, "group1", "job5");
|
|
|
|
|
List<MessageSubordinate> all = messageSubordinateService.findAllByStatus(0);
|
|
|
|
|
queueService.doSomething(all);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果报错-- 捕捉异常 继续执行
|
|
|
|
|
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
|
|
|
|
|
}
|
|
|
|
|
QuartzUtils.resumeScheduleJob(scheduler, "group1", "job5");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|