情景:对比某个事项,短时间内没处理的信息,会发送邮件短信进行通知处理
适用场景:
1.专门的定时任务,例如拉大表
2.专门的业务没处理及时,要执行定时发送邮件
实现逻辑是一致的
例如:、
1.启动类加载定时注解
@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
//开启定时
@EnableScheduling
public class TimerbatchManageApplication {
public static void main(String[] args) {
SpringApplication.run(TimerbatchManageApplication.class, args);
}
}
2.配置文件配置相关时间,什么时候执行
schedules: “0 10 9 ? * *”
3.逻辑执行:
其中,发送给谁,组装逻辑参数,在业务模块,实现即可,fegin调用
/**
* @Auther: jdl
* @Date: 2019/11/19
* @Description: 派工24小时未处理,发送请求;
*/
@Configuration
@PropertySource(value="classpath:application.yml")
public class DemoJob {
private static final Logger log = LoggerFactory.getLogger(DemoJob.class);
@Autowired
private CaseManageFeignClient caseManageFeignClient;
@Autowired
private BaseManageFeignClient baseManageFeignClient;
// 每5秒执行一次*/5 * * * * ? 0 0 12 * * ?
// @Scheduled(cron = "${cron}")
@Scheduled(cron = "${schedules}")
public void work() {
long start = System.currentTimeMillis();
log.info("\r\n***************开始执行定时任务*****************");
//调用案件派工接口,获取所有>=24小时的案件,以及相应的领导数据;
List<String> caseList = new ArrayList<String>();
//String distributeTimeBatch = caseManageFeignClient.timerBatchList(JSON.toJSONString(caseList));
String agreeTimeBatch = baseManageFeignClient.timerBatchList(JSON.toJSONString(caseList));
log.info("协议定时任务耗时:" + (System.currentTimeMillis() - start));
log.info("\r\n***************定时任务结束*****************\n\n\n");
}
希望能够帮助到你们