| 12345678910111213141516171819202122232425262728293031323334 |
- package com.xjrsoft.module.job;
- import com.xjrsoft.common.utils.DateUtils;
- import com.xjrsoft.module.holiday.service.IHolidayDateService;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Async;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import java.util.Calendar;
- import java.util.Date;
- @Component
- @Slf4j
- public class HolidayTask {
- @Autowired
- private IHolidayDateService holidayDateService;
- /**
- * 定时拉取节假日数据
- */
- @Async
- @Scheduled(cron = "0 0 1 * * ?")
- public void RefreshHoliday() {
- System.out.printf("定时拉取节假日数据:%s", DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
- Date date = new Date();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- holidayDateService.initHoliday(calendar.get(Calendar.YEAR));
- }
- }
|