package com.sf.dangbao.core.TimeTask;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author pxz
* @date 2019/4/28
* @description :
*/
@Configuration
public class QuartzJobConfig {
@Value("${send.corn}")
private String sendTaskJobCorn;
@Value("${send.tomorrow}")
private String tomorrowJobCorn;
@Bean
public JobDetail distributeTaskJob() {
return JobBuilder.newJob(DistributeTaskJob.class).withIdentity("distributeTaskJob").storeDurably().build();
}
@Bean
public JobDetail tomorrowTaskJob(){
return JobBuilder.newJob(TomorrowTaskJob.class).withIdentity("tomorrowTaskJob").storeDurably().build();
}
@Bean
public Trigger storeCheckJobTrigger() {
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(sendTaskJobCorn);
return TriggerBuilder.newTrigger().forJob(distributeTaskJob()).withIdentity("storeCheckJobTrigger")
.withSchedule(scheduleBuilder).build();
}
@Bean
public Trigger tomorrowJobTrigger() {
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(tomorrowJobCorn);
return TriggerBuilder.newTrigger().forJob(tomorrowTaskJob()).withIdentity("tomorrowJobTrigger")
.withSchedule(scheduleBuilder).build();
}
}