perf(X-Pack): 定时报告

This commit is contained in:
fit2cloud-chenyw 2024-05-08 17:56:13 +08:00
parent 908d429772
commit 526bf6c5cb
4 changed files with 13 additions and 23 deletions

View File

@ -34,7 +34,7 @@ public class CronUtils {
return date;
}
public static String cron() {
public static String tempCron() {
Calendar instance = Calendar.getInstance();
instance.add(Calendar.SECOND, 5);
return instance.get(Calendar.SECOND) + " " +

View File

@ -10,8 +10,9 @@ import org.quartz.TriggerKey;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
@Component
@Component("deTaskExecutor")
public class DeTaskExecutor {
protected static final String IS_TEMP_TASK = "isTempTask";
@ -20,12 +21,7 @@ public class DeTaskExecutor {
private ScheduleManager scheduleManager;
@XpackInteract(value = "xpackTaskExecutor", replace = true)
public boolean execute(Long taskId) {
return false;
}
@XpackInteract(value = "xpackTaskExecutor", replace = true)
public boolean executeTemplate(Long taskId) {
public boolean execute(Map<String, Object> taskData) {
return false;
}
@ -44,7 +40,7 @@ public class DeTaskExecutor {
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, DeXpackScheduleJob.class, cron, new Date(startTime), end, jobDataMap);
}
public void fireNow(Long taskId) throws Exception{
public void fireNow(Long taskId) throws Exception {
String key = taskId.toString();
JobKey jobKey = new JobKey(key, key);
scheduleManager.fireNow(jobKey);
@ -56,7 +52,7 @@ public class DeTaskExecutor {
TriggerKey triggerKey = new TriggerKey(key, key);
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(IS_TEMP_TASK, true);
String cron = CronUtils.cron();
String cron = CronUtils.tempCron();
jobDataMap.put("taskId", taskId);
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, DeXpackScheduleJob.class, cron, new Date(startTime), null, jobDataMap);
}

View File

@ -1,5 +1,6 @@
package io.dataease.job.schedule;
import io.dataease.license.utils.LicenseUtil;
import io.dataease.utils.CommonBeanFactory;
import jakarta.annotation.Resource;
import org.quartz.*;
@ -9,26 +10,19 @@ import java.util.Objects;
@Component
public class DeXpackScheduleJob implements Job {
@Resource
private DeTaskExecutor deTaskExecutor;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
Trigger trigger = jobExecutionContext.getTrigger();
JobKey jobKey = trigger.getJobKey();
JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
Long taskId = jobDataMap.getLong("taskId");
boolean isTempTask = jobDataMap.getBoolean("isTempTask");
boolean taskLoaded = false;
if (isTempTask) {
taskLoaded = deTaskExecutor.executeTemplate(taskId);
} else {
taskLoaded = deTaskExecutor.execute(taskId);
}
DeTaskExecutor deTaskExecutor = CommonBeanFactory.getBean(DeTaskExecutor.class);
assert deTaskExecutor != null;
LicenseUtil.validate();
boolean taskLoaded = deTaskExecutor.execute(jobDataMap);
if (!taskLoaded) {
Objects.requireNonNull(CommonBeanFactory.getBean(ScheduleManager.class)).removeJob(jobKey, trigger.getKey());
}
}
}

@ -1 +1 @@
Subproject commit 1ce831779b69626bdb865b36454b7f91ce17eeb7
Subproject commit b61bcfc7325c5d9a1f30564d27dab3f098ac228c