feat(scheduler): 增加crm重点表的4 5点调度

This commit is contained in:
v-zhangjc9
2024-06-17 18:49:24 +08:00
parent 4ffcfe3ab5
commit b787a4f393
2 changed files with 67 additions and 1 deletions

View File

@@ -1,6 +1,12 @@
package com.lanyuanxiaoyao.service.scheduler.configuration;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.*;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.CrmFocusScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.DailyScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.DistributeScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.FocusScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.FocusUnVersionUpdateScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.OdsFocusScheduleJob;
import com.lanyuanxiaoyao.service.scheduler.quartz.compaction.RemoveScheduledJob;
import com.lanyuanxiaoyao.service.scheduler.strategy.ScheduleStrategy;
import com.lanyuanxiaoyao.service.scheduler.strategy.ScheduleStrategyImpl;
import com.lanyuanxiaoyao.service.scheduler.strategy.ScheduleStrategyVO;
@@ -25,6 +31,8 @@ public class ScheduleStrategyProvider {
ScheduleStrategyImpl.simple("focus_evening_schedule", "晚间重点表调度", FocusScheduleJob.class, "0 50 20,21,22 * * ?"),
// ODS重点表调度
ScheduleStrategyImpl.simple("ods_focus_schedule", "ODS 重点表调度", OdsFocusScheduleJob.class, "0 30 23 * * ?"),
// CRM重点表调度
ScheduleStrategyImpl.simple("crm_focus_schedule", "CRM 重点表补充调度", CrmFocusScheduleJob.class, "0 15 3,4 * * ?"),
// 忙时调度
ScheduleStrategyImpl.simple("focus_schedule", "重点表跨天调度", FocusUnVersionUpdateScheduleJob.class, "0 0,10,20,40 0,1 * * ?"),
ScheduleStrategyImpl.simple(false, "remove_scheduled", "跨天调度时及时删除已完成跨天的任务", RemoveScheduledJob.class, "0 * 0,1 * * ?")

View File

@@ -0,0 +1,58 @@
package com.lanyuanxiaoyao.service.scheduler.quartz.compaction;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lanyuanxiaoyao.service.common.Constants;
import com.lanyuanxiaoyao.service.common.utils.TableMetaHelper;
import com.lanyuanxiaoyao.service.forest.service.HudiService;
import com.lanyuanxiaoyao.service.forest.service.InfoService;
import com.lanyuanxiaoyao.service.scheduler.utils.ScheduleHelper;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
/**
* 日常普通调度
*
* @author ZhangJiacheng
* @date 2023-05-11
*/
@DisallowConcurrentExecution
public class CrmFocusScheduleJob extends BaseScheduleJob {
private static final Logger logger = LoggerFactory.getLogger(CrmFocusScheduleJob.class);
private final DiscoveryClient discoveryClient;
private final InfoService infoService;
private final HudiService hudiService;
private final ObjectMapper mapper;
public CrmFocusScheduleJob(DiscoveryClient discoveryClient, InfoService infoService, HudiService hudiService, Jackson2ObjectMapperBuilder builder) {
this.discoveryClient = discoveryClient;
this.infoService = infoService;
this.hudiService = hudiService;
this.mapper = builder.build();
}
public static void schedule(DiscoveryClient discoveryClient, InfoService infoService, HudiService hudiService, ObjectMapper mapper, String comment) {
logger.info("Crm focus schedule");
ScheduleHelper.schedule(
discoveryClient,
infoService,
hudiService,
mapper,
meta -> TableMetaHelper.existsTag(meta.getTags(), Constants.TAGS_CRM_FOCUS),
comment
);
}
@Override
protected void executeInternal(JobExecutionContext context) {
String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
schedule(discoveryClient, infoService, hudiService, mapper, "Crm focus schedule for " + now);
}
}