From b787a4f393a78a032413b8ccfb77d15f69ffcc8c Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Mon, 17 Jun 2024 18:49:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(scheduler):=20=E5=A2=9E=E5=8A=A0crm?= =?UTF-8?q?=E9=87=8D=E7=82=B9=E8=A1=A8=E7=9A=844=205=E7=82=B9=E8=B0=83?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScheduleStrategyProvider.java | 10 +++- .../compaction/CrmFocusScheduleJob.java | 58 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/compaction/CrmFocusScheduleJob.java diff --git a/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/configuration/ScheduleStrategyProvider.java b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/configuration/ScheduleStrategyProvider.java index 2f35dc9..7b51f71 100644 --- a/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/configuration/ScheduleStrategyProvider.java +++ b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/configuration/ScheduleStrategyProvider.java @@ -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 * * ?") diff --git a/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/compaction/CrmFocusScheduleJob.java b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/compaction/CrmFocusScheduleJob.java new file mode 100644 index 0000000..5eb2717 --- /dev/null +++ b/service-scheduler/src/main/java/com/lanyuanxiaoyao/service/scheduler/quartz/compaction/CrmFocusScheduleJob.java @@ -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); + } +}