代码调整

This commit is contained in:
2023-12-06 09:31:06 +08:00
parent 09bfde0103
commit 0101a85a38
4 changed files with 31 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ public enum SystemResponseEnum {
EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"), EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"),
NOT_EXISTED("A00361", "您查询的该条记录不存在"), NOT_EXISTED("A00361", "您查询的该条记录不存在"),
TIMER_NO_CLASS("A00361", "请检查定时任务是否添加"),
/** /**
* 定时任务执行类不存在 * 定时任务执行类不存在

View File

@@ -164,5 +164,19 @@ public class TimersController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); 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);
}
} }

View File

@@ -31,4 +31,6 @@ public interface ITimersService extends IService<Timers> {
void start(String id); void start(String id);
void stop(String id); void stop(String id);
void run(String id);
} }

View File

@@ -125,6 +125,19 @@ public class TimersServiceImpl extends ServiceImpl<TimersMapper, Timers> impleme
timerExeService.stopTimer(sysTimers.getId()); 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();
}
/** /**
* 获取定时任务 * 获取定时任务
* *