yangys
2024-05-30 a3686cfa49bf53fb91a2ceb960cf15b3ebdac641
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.qianwen.smartman.modules.cps.jobHandler;
 
import com.google.common.collect.Sets;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.smartman.common.cache.cps.TimeSliceCache;
import com.qianwen.smartman.common.constant.DateConstant;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.dto.CacheBuildDTO;
import org.springframework.stereotype.Component;
/**
 * 生产日历切片缓存任务
 */
@Component
public class CalendarCacheXxlJob {
    private static final Logger log = LoggerFactory.getLogger(CalendarCacheXxlJob.class);
 
    @XxlJob("calendarCacheJobHandler")
    public ReturnT<String> calendarCacheJobHandler(String param) throws Exception {
        LocalDate targetDate = LocalDate.now().plusDays(1L);
        if (Func.isNotEmpty(param)) {
            targetDate = LocalDate.parse(param, DateTimeFormatter.ofPattern(DateConstant.PATTERN_DATE));
        }
        XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建开始.....", new Object[0]);
        CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build();//没有calendarCode?
        TimeSliceCache.build(cacheBuildDTO);
        XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建结束", new Object[0]);
        return ReturnT.SUCCESS;
    }
}