MJYScheduleTask.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package com.malk.minjiaoyuan.schedule;
  2. import com.malk.minjiaoyuan.service.MJYService;
  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 MJYScheduleTask {
  17. @Autowired
  18. private MJYService mjyService;
  19. /**
  20. * 定时同步后更新为已同步 [0...5分钟/次]
  21. */
  22. @Scheduled(cron = "0 0/5 * * * ?")
  23. public void Time_Period_1() {
  24. try {
  25. log.info("###### [MJY]同步教师档案开始 [已邀请] ######");
  26. mjyService.syncTeacherStatus();
  27. } catch (Exception e) {
  28. log.error(e.getMessage(), e); // 记录错误日志
  29. }
  30. log.info("###### [MJY]同步教师档案结束 [已邀请] ######");
  31. }
  32. }