U8ScheduleTask.java 992 B

1234567891011121314151617181920212223242526272829303132333435
  1. package com.malk.shangfeng.schedule;
  2. import com.malk.shangfeng.service.SFService;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  6. import org.springframework.context.annotation.Configuration;
  7. import org.springframework.scheduling.annotation.EnableScheduling;
  8. import org.springframework.scheduling.annotation.Scheduled;
  9. /**
  10. * @EnableScheduling 开启定时任务 [配置参考McScheduleTask]
  11. */
  12. @Slf4j
  13. @Configuration
  14. @EnableScheduling
  15. @ConditionalOnProperty(name = {"spel.scheduling"})
  16. public class U8ScheduleTask {
  17. @Autowired
  18. private SFService sfService;
  19. /**
  20. * 每天凌晨4点同步
  21. */
  22. @Scheduled(cron = "0 0 2 * * ? ")
  23. public void syncDingTalkFailedList() {
  24. try {
  25. sfService.syncU8Project();
  26. } catch (Exception e) {
  27. // 记录错误信息
  28. e.printStackTrace();
  29. }
  30. }
  31. }