refactor(系统设置): 定时任务增加修改表达式

This commit is contained in:
wxg0103 2024-04-09 21:20:09 +08:00 committed by Craftsman
parent cbfb5e2221
commit 2022245d00
6 changed files with 20 additions and 4 deletions

View File

@ -251,7 +251,7 @@ public class ApiTaskCenterService {
String path,
String method,
String module) {
nodesList.forEach(node -> {
nodesList.parallelStream().forEach(node -> {
String endpoint = TaskRunnerClient.getEndpoint(node.getIp(), node.getPort());
//需要去除取消勾选的report
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {

View File

@ -2292,7 +2292,7 @@ public class ApiScenarioService extends MoveNodeService {
request.setSelectIds(scenarioIds);
ApiScenarioBatchOperationResponse response =
ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> copyAndInsert(sublist, request, logInsertModule.getOperator()));
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.COPY.name(), logInsertModule, null);
apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.ADD.name(), logInsertModule, null);
return response;
}

View File

@ -1753,7 +1753,7 @@ public class ApiScenarioControllerTests extends BaseTest {
//增加日志检查
operationScenarioIds.forEach(item -> {
LOG_CHECK_LIST.add(
new CheckLogModel(item, OperationLogType.COPY, "/api/scenario/batch-operation/copy")
new CheckLogModel(item, OperationLogType.ADD, "/api/scenario/batch-operation/copy")
);
});

View File

@ -65,6 +65,13 @@ public class TaskCenterController {
taskCenterService.enable(id);
}
@PostMapping("/schedule/update/{id}/{cron}")
@Operation(summary = "系统-任务中心-修改定时任务")
@CheckOwner(resourceId = "#id", resourceType = "schedule")
public void update(@PathVariable String id, @PathVariable String cron) {
taskCenterService.update(id, cron);
}
}

View File

@ -210,4 +210,12 @@ public class TaskCenterService {
}
public void update(String id, String cron) {
Schedule schedule = checkScheduleExit(id);
schedule.setValue(cron);
scheduleService.editSchedule(schedule);
scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()),
new TriggerKey(schedule.getKey(),schedule.getJob()), schedule.getJob().getClass());
}
}

View File

@ -192,6 +192,7 @@ class TaskCenterScheduleControllerTests extends BaseTest {
scheduleService.editSchedule(schedule);
scheduleService.getScheduleByResource(schedule.getResourceId(), schedule.getJob());
this.requestGet("/task/center/schedule/switch" + "test-schedule-switch");
this.requestGet("/task/center/schedule/switch" + "test-schedule-switch");
this.requestGet("/task/center/schedule/update/" + "test-schedule-switch" + "/0 0/2 * * * ?");
}
}