RZScheduleTask.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.malk.rongzhi.schedule;
  2. import com.malk.rongzhi.service.RZService;
  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 RZScheduleTask {
  17. @Autowired
  18. private RZService rzService;
  19. private void syncAttendance2EKB() {
  20. try {
  21. log.info("###### [RZ]同步考勤数据至易快报 ######");
  22. rzService.uploadTravelData();
  23. } catch (Exception e) {
  24. log.error(e.getMessage(), e); // 记录错误日志
  25. }
  26. log.info("###### [RZ]同步考勤数据至易快报 ######");
  27. }
  28. /**
  29. * 同步考勤数据☞易快报, [0...5分钟/次]
  30. */
  31. @Scheduled(cron = "0 0/5 22-23 * * ?")
  32. public void Time_Period_1() {
  33. syncAttendance2EKB();
  34. }
  35. /**
  36. * 同步考勤数据☞易快报, [0...5分钟/次]
  37. */
  38. @Scheduled(cron = "0 0/5 0-6 * * ?")
  39. public void Time_Period_2() {
  40. syncAttendance2EKB();
  41. }
  42. /**
  43. * 同步考勤数据☞易快报, [0...5分钟/次]
  44. */
  45. @Scheduled(cron = "0 0,5,10,15,20,25,30 7 * * ? ")
  46. public void Time_Period_3() {
  47. syncAttendance2EKB();
  48. }
  49. }