Merge branch 'develop_master' into FOTON

This commit is contained in:
zyd
2022-10-24 22:32:24 +08:00
11 changed files with 150 additions and 16 deletions
@@ -9,6 +9,7 @@ package com.adc.da.search.conf;
import com.adc.da.slrs.tsTask.dao.TbTaskDao;
import com.adc.da.slrs.tsTask.entity.TbTask;
import com.adc.da.slrs.tsTask.service.ITbTaskService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -95,7 +96,7 @@ public class SchedulerConf {
log.info("{},任务启动!", taskId);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
log.error("{},任务启动失败...", taskId);
e.printStackTrace();
log.error(e.getMessage(),e);
}
}
@@ -113,6 +114,28 @@ public class SchedulerConf {
log.info("{},任务停止...", taskId);
}
public TbTask manualRunTask(String taskId){
TbTask task = iTbTaskService.getById(taskId);
if(task!=null){
try {
//获取并实例化Runnable任务类
Class<?> clazz = Class.forName(task.getTaskClass());
Runnable runnable = (Runnable) clazz.newInstance();
Thread runTaskThread = new Thread(runnable);
runTaskThread.start();
log.info("{},任务开始启动执行!", task.getTaskDesc());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
log.error("{},任务启动失败...", task.getTaskDesc());
log.error(e.getMessage(),e);
}
return task;
}else{
return null;
}
}
/**
* 根据ip开启定时任务
*/