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