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 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; } }