yangys
2024-09-28 d4212be4f036c5972e192a93e9a7f3a2e3bb2535
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
36
37
38
39
40
41
package com.qianwen.mdc.collect.job;
 
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.core.tool.utils.Func;
import com.qianwen.mdc.collect.cache.TimeSliceCache;
import com.qianwen.mdc.collect.dto.CacheBuildDTO;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
@Component
public class ProductionTimeCacheXxlJob {
    private static final Logger log = LoggerFactory.getLogger(ProductionTimeCacheXxlJob.class);
    
    @Autowired
    private TimeSliceCache timeSliceCache;
    
    @XxlJob("prodCalendarTimeCacheJobHandler")
    public ReturnT<String> productionTimeCacheJobHandler(String param) throws Exception {
        LocalDate targetDate = LocalDate.now().plusDays(1L);
        if (Func.isNotEmpty(param)) {
            targetDate = LocalDate.parse(param, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }
        XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建开始.....", new Object[0]);
        CacheBuildDTO cacheBuildDTO = CacheBuildDTO.builder().tenantIds(Sets.newHashSet(new String[]{"000000"})).targetDate(targetDate).build();
        if (Func.isNotEmpty(cacheBuildDTO)) {
            timeSliceCache.build(cacheBuildDTO);
        } else {
            log.error("[生产日历切片缓存构建失败...],构建时间{},构建租户:{}", targetDate, "000000");
        }
        XxlJobLogger.log("XXL-JOB, 定时构建生产日历切片缓存,构建结束", new Object[0]);
        return ReturnT.SUCCESS;
    }
}