AWScheduleTask.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.malk.aiwei.schedule;
  2. import com.malk.aiwei.service.AWClint;
  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 AWScheduleTask {
  17. @Autowired
  18. private AWClint awClint;
  19. /**
  20. * 每天12.30,00.30点同步, 项目主数据
  21. */
  22. @Scheduled(cron = "0 30 0,12 * * ? ")
  23. public void sync_4() {
  24. try {
  25. awClint.syncProject(null);
  26. } catch (Exception e) {
  27. // 记录错误信息
  28. e.printStackTrace();
  29. }
  30. }
  31. /**
  32. * 每天凌晨1点同步, 预检项
  33. */
  34. @Scheduled(cron = "0 0 1 * * ? ")
  35. public void sync_1() {
  36. try {
  37. awClint.syncCheckList(0);
  38. } catch (Exception e) {
  39. // 记录错误信息
  40. e.printStackTrace();
  41. }
  42. }
  43. /**
  44. * 每天凌晨1.30点同步. 预检项
  45. */
  46. @Scheduled(cron = "0 30 1 * * ? ")
  47. public void sync_2() {
  48. try {
  49. awClint.syncCheckList(1);
  50. } catch (Exception e) {
  51. // 记录错误信息
  52. e.printStackTrace();
  53. }
  54. }
  55. /**
  56. * 每天凌晨2点同步, 预检项
  57. */
  58. @Scheduled(cron = "0 0 2 * * ? ")
  59. public void sync_3() {
  60. try {
  61. awClint.syncCheckList(2);
  62. } catch (Exception e) {
  63. // 记录错误信息
  64. e.printStackTrace();
  65. }
  66. }
  67. /**
  68. * 每天20点同步, 全量同步CRM
  69. */
  70. @Scheduled(cron = "0 0 20 * * ? ")
  71. public void sync_5() {
  72. try {
  73. awClint.syncBaseLineForCRM();
  74. } catch (Exception e) {
  75. // 记录错误信息
  76. e.printStackTrace();
  77. }
  78. }
  79. }