HolidayTask.java 950 B

1234567891011121314151617181920212223242526272829303132
  1. package com.xjrsoft.module.job;
  2. import com.xjrsoft.common.utils.DateUtils;
  3. import com.xjrsoft.module.holiday.service.IHolidayDateService;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.scheduling.annotation.Scheduled;
  7. import org.springframework.stereotype.Component;
  8. import java.util.Calendar;
  9. import java.util.Date;
  10. @Component
  11. @Slf4j
  12. public class HolidayTask {
  13. @Autowired
  14. private IHolidayDateService holidayDateService;
  15. /**
  16. * 定时拉取节假日数据
  17. */
  18. @Scheduled(cron = "0 0 1 * * ?")
  19. public void RefreshHoliday() {
  20. System.out.printf("定时拉取节假日数据:%s", DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
  21. Date date = new Date();
  22. Calendar calendar = Calendar.getInstance();
  23. calendar.setTime(date);
  24. holidayDateService.initHoliday(calendar.get(Calendar.YEAR));
  25. }
  26. }