HolidayTask.java 1017 B

12345678910111213141516171819202122232425262728293031323334
  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.Async;
  7. import org.springframework.scheduling.annotation.Scheduled;
  8. import org.springframework.stereotype.Component;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. @Component
  12. @Slf4j
  13. public class HolidayTask {
  14. @Autowired
  15. private IHolidayDateService holidayDateService;
  16. /**
  17. * 定时拉取节假日数据
  18. */
  19. @Async
  20. @Scheduled(cron = "0 0 1 * * ?")
  21. public void RefreshHoliday() {
  22. System.out.printf("定时拉取节假日数据:%s", DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
  23. Date date = new Date();
  24. Calendar calendar = Calendar.getInstance();
  25. calendar.setTime(date);
  26. holidayDateService.initHoliday(calendar.get(Calendar.YEAR));
  27. }
  28. }