12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package com.malk.yibaoju.schedule;
- import com.malk.yibaoju.service.YBJService;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.scheduling.annotation.EnableScheduling;
- import org.springframework.scheduling.annotation.Scheduled;
- /**
- * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
- */
- @Slf4j
- @Configuration
- @EnableScheduling
- @ConditionalOnProperty(name = {"spel.scheduling"})
- public class ScheduleTask {
- @Autowired
- private YBJService ybjService;
- /**
- * 每月25日0点5分执行定时任务
- */
- @Scheduled(cron = "0 30 0 25 * ?")
- public void syncDingTalkFailedList() {
- try {
- ybjService.syncCreatePlan();
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- /**
- * 每天凌晨1-4点更新计划护理的任务状态
- */
- @Scheduled(cron = " 0 5 0 * * ? ")
- public void syncDingTalkStatus() {
- try {
- ybjService.syncUpdatePlanStatus();
- } catch (Exception e) {
- // 记录错误信息
- e.printStackTrace();
- }
- }
- }
|