CalendarTask.java 1014 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.punchsettle.server.task;
  2. import java.time.LocalDate;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.scheduling.annotation.Scheduled;
  5. import org.springframework.stereotype.Component;
  6. import com.punchsettle.server.service.manager.ICalendarManager;
  7. import lombok.extern.slf4j.Slf4j;
  8. /**
  9. * @author tyuio
  10. * @version 1.0.0
  11. * @date 2025/4/14 12:57
  12. * @description 日历定时任务,每年1月1日零点零一秒执行
  13. */
  14. @Slf4j
  15. @Component
  16. public class CalendarTask {
  17. @Autowired
  18. private ICalendarManager calendarManager;
  19. @Scheduled(cron = "1 0 0 1 1 ?")
  20. public void execute() {
  21. log.info("========== 日历定时任务 开始执行 ==========");
  22. // 当前公历日期
  23. int currentYear = LocalDate.now().getYear();
  24. String gregorianDate = String.valueOf(currentYear);
  25. calendarManager.refreshCalendar(gregorianDate);
  26. log.info("========== 日历定时任务 结束执行 ==========");
  27. }
  28. }