代码调整
This commit is contained in:
@@ -45,6 +45,7 @@ public enum SystemResponseEnum {
|
||||
|
||||
EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"),
|
||||
NOT_EXISTED("A00361", "您查询的该条记录不存在"),
|
||||
TIMER_NO_CLASS("A00361", "请检查定时任务是否添加"),
|
||||
|
||||
/**
|
||||
* 定时任务执行类不存在
|
||||
|
||||
@@ -164,5 +164,19 @@ public class TimersController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行一次定时任务
|
||||
*
|
||||
* @author hongawen
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/run")
|
||||
@ApiOperation("执行一次定时任务")
|
||||
public HttpResult<Object> run(String id) {
|
||||
String methodDescribe = getMethodDescribe("run");
|
||||
timersService.run(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,4 +31,6 @@ public interface ITimersService extends IService<Timers> {
|
||||
void start(String id);
|
||||
|
||||
void stop(String id);
|
||||
|
||||
void run(String id);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TimersServiceImpl extends ServiceImpl<TimersMapper, Timers> impleme
|
||||
// 更新库中的状态
|
||||
LambdaUpdateWrapper<Timers> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.set(Timers::getJobStatus, TimerJobStatusEnum.RUNNING.getCode())
|
||||
.eq(Timers::getId,id);
|
||||
.eq(Timers::getId, id);
|
||||
this.update(wrapper);
|
||||
|
||||
// 添加定时任务调度
|
||||
@@ -125,6 +125,19 @@ public class TimersServiceImpl extends ServiceImpl<TimersMapper, Timers> impleme
|
||||
timerExeService.stopTimer(sysTimers.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String id) {
|
||||
Timers sysTimers = this.queryTimers(id);
|
||||
String actionClass = sysTimers.getActionClass();
|
||||
TimerTaskRunner timerTaskRunner;
|
||||
try {
|
||||
timerTaskRunner = (TimerTaskRunner) SpringUtil.getBean(Class.forName(actionClass));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new BusinessException(SystemResponseEnum.TIMER_NO_CLASS);
|
||||
}
|
||||
timerTaskRunner.action();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定时任务
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user