ProjectChangeSyncTimer.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.malk.timer;
  2. import com.malk.service.workhours.WorkHoursCalcService;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.scheduling.annotation.EnableScheduling;
  7. import org.springframework.scheduling.annotation.Scheduled;
  8. /**
  9. * 项目变更审批增量同步定时器
  10. * <p>
  11. * 每天 3 次错峰扫描项目变更审批表单最近 7 天 gmtModified 的实例,
  12. * 对涉及员工的应报工时按「变更生效日之后」重算 Manager (仅外部员工受影响; 内部员工 Manager 走钉钉主管不受本任务影响)。
  13. * <p>
  14. * cron 时点故意错开 WorkHoursCalcTimer 的 07:00/12:15/18:30, 避免宜搭 QPS 突发叠加。
  15. */
  16. @Slf4j
  17. @Configuration
  18. @EnableScheduling
  19. public class ProjectChangeSyncTimer {
  20. @Autowired
  21. private WorkHoursCalcService workHoursCalcService;
  22. // 每天 06:45 / 12:45 / 18:45 三次错峰
  23. @Scheduled(cron = "0 45 6 * * ?")
  24. @Scheduled(cron = "0 45 12 * * ?")
  25. @Scheduled(cron = "0 45 18 * * ?")
  26. public void syncProjectChanges() {
  27. log.info("开始执行项目变更审批增量同步任务");
  28. try {
  29. workHoursCalcService.syncProjectChanges(7);
  30. log.info("项目变更审批增量同步任务执行完成");
  31. } catch (Exception e) {
  32. log.error("项目变更审批增量同步任务执行失败", e);
  33. }
  34. }
  35. }