feat(任务中心): 系统&组织&项目后台任务列表修改状态
This commit is contained in:
parent
0a71bbea52
commit
1ad79d1c43
|
@ -149,4 +149,11 @@ public class ProjectTaskHubController {
|
||||||
public void deleteScheduleTask(@PathVariable String id) {
|
public void deleteScheduleTask(@PathVariable String id) {
|
||||||
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/project/task-center/schedule/delete/", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/project/task-center/schedule/delete/", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/schedule/switch/{id}")
|
||||||
|
@Operation(summary = "项目-任务中心-后台任务开启关闭")
|
||||||
|
@RequiresPermissions(PermissionConstants.PROJECT_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
|
public void enable(@PathVariable String id) {
|
||||||
|
baseTaskHubService.enable(id, SessionUtils.getUserId(), "/project/task-center/schedule/switch/", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||||
public static final String PROJECT_TASK_ITEM_STOP = "/project/task-center/exec-task/item/stop/";
|
public static final String PROJECT_TASK_ITEM_STOP = "/project/task-center/exec-task/item/stop/";
|
||||||
public static final String PROJECT_TASK_ITEM_BATCH_STOP = "/project/task-center/exec-task/item/batch-stop";
|
public static final String PROJECT_TASK_ITEM_BATCH_STOP = "/project/task-center/exec-task/item/batch-stop";
|
||||||
public static final String PROJECT_SCHEDULE_TASK_DELETE = "/project/task-center/schedule/delete/";
|
public static final String PROJECT_SCHEDULE_TASK_DELETE = "/project/task-center/schedule/delete/";
|
||||||
|
public static final String PROJECT_SCHEDULE_TASK_SWITCH = "/project/task-center/schedule/switch/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -223,4 +224,10 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
||||||
// 返回请求正常
|
// 返回请求正常
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(6)
|
||||||
|
public void projectScheduleTaskSwitch() throws Exception {
|
||||||
|
this.requestGet(PROJECT_SCHEDULE_TASK_SWITCH + "pro_wx_1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,4 +159,12 @@ public class OrganizationTaskHubController {
|
||||||
public void deleteScheduleTask(@PathVariable String id) {
|
public void deleteScheduleTask(@PathVariable String id) {
|
||||||
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/organization/task-center/schedule/delete/", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/organization/task-center/schedule/delete/", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/schedule/switch/{id}")
|
||||||
|
@Operation(summary = "组织-任务中心-后台任务开启关闭")
|
||||||
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
|
public void enable(@PathVariable String id) {
|
||||||
|
baseTaskHubService.enable(id, SessionUtils.getUserId(), "/organization/task-center/schedule/switch/", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,5 +162,12 @@ public class SystemTaskHubController {
|
||||||
public void deleteScheduleTask(@PathVariable String id) {
|
public void deleteScheduleTask(@PathVariable String id) {
|
||||||
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/system/task-center/schedule/delete/", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
baseTaskHubService.deleteScheduleTask(id, SessionUtils.getUserId(), "/system/task-center/schedule/delete/", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/schedule/switch/{id}")
|
||||||
|
@Operation(summary = "系统-任务中心-后台任务开启关闭")
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ_UPDATE)
|
||||||
|
public void enable(@PathVariable String id) {
|
||||||
|
baseTaskHubService.enable(id, SessionUtils.getUserId(), "/system/task-center/schedule/switch/", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||||
|
}
|
||||||
//TODO 系统&组织&项目 后台任务操作:删除 批量开启 批量关闭
|
//TODO 系统&组织&项目 后台任务操作:删除 批量开启 批量关闭
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.*;
|
import io.metersphere.system.mapper.*;
|
||||||
|
import io.metersphere.system.schedule.ApiScheduleNoticeService;
|
||||||
import io.metersphere.system.schedule.ScheduleService;
|
import io.metersphere.system.schedule.ScheduleService;
|
||||||
import io.metersphere.system.utils.PageUtils;
|
import io.metersphere.system.utils.PageUtils;
|
||||||
import io.metersphere.system.utils.Pager;
|
import io.metersphere.system.utils.Pager;
|
||||||
|
@ -46,6 +47,8 @@ import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionUtils;
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
|
import org.quartz.JobKey;
|
||||||
|
import org.quartz.TriggerKey;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -110,6 +113,8 @@ public class BaseTaskHubService {
|
||||||
private ExtSwaggerMapper extSwaggerMapper;
|
private ExtSwaggerMapper extSwaggerMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private OperationLogService operationLogService;
|
private OperationLogService operationLogService;
|
||||||
|
@Resource
|
||||||
|
ApiScheduleNoticeService apiScheduleNoticeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统-获取执行任务列表
|
* 系统-获取执行任务列表
|
||||||
|
@ -762,4 +767,19 @@ public class BaseTaskHubService {
|
||||||
}
|
}
|
||||||
return schedule;
|
return schedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enable(String id, String userId, String path, String module) {
|
||||||
|
Schedule schedule = checkScheduleExit(id);
|
||||||
|
schedule.setEnable(!schedule.getEnable());
|
||||||
|
scheduleService.editSchedule(schedule);
|
||||||
|
try {
|
||||||
|
scheduleService.addOrUpdateCronJob(schedule, new JobKey(schedule.getKey(), schedule.getJob()),
|
||||||
|
new TriggerKey(schedule.getKey(), schedule.getJob()), Class.forName(schedule.getJob()));
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
LogUtils.error(e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
apiScheduleNoticeService.sendScheduleNotice(schedule, userId);
|
||||||
|
saveLog(List.of(schedule), userId, path, HttpMethodConstants.GET.name(), module, OperationLogType.UPDATE.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
public static final String SYSTEM_TASK_ITEM_ORDER = "/system/task-center/exec-task/item/order";
|
public static final String SYSTEM_TASK_ITEM_ORDER = "/system/task-center/exec-task/item/order";
|
||||||
|
|
||||||
public static final String SYSTEM_SCHEDULE_TASK_DELETE = "/system/task-center/schedule/delete/";
|
public static final String SYSTEM_SCHEDULE_TASK_DELETE = "/system/task-center/schedule/delete/";
|
||||||
|
public static final String SYSTEM_SCHEDULE_TASK_SWITCH = "/system/task-center/schedule/switch/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -215,6 +216,12 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
this.requestPost(SYSTEM_TASK_BATCH_DELETE, request);
|
this.requestPost(SYSTEM_TASK_BATCH_DELETE, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(6)
|
||||||
|
public void systemScheduleTaskSwitch() throws Exception {
|
||||||
|
this.requestGet(SYSTEM_SCHEDULE_TASK_SWITCH + "wx_1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统执行任务停止
|
* 系统执行任务停止
|
||||||
|
@ -276,6 +283,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
public static final String ORG_TASK_ITEM_STOP = "/organization/task-center/exec-task/item/stop/";
|
public static final String ORG_TASK_ITEM_STOP = "/organization/task-center/exec-task/item/stop/";
|
||||||
public static final String ORG_TASK_ITEM_BATCH_STOP = "/organization/task-center/exec-task/item/batch-stop";
|
public static final String ORG_TASK_ITEM_BATCH_STOP = "/organization/task-center/exec-task/item/batch-stop";
|
||||||
public static final String ORG_SCHEDULE_TASK_DELETE = "/organization/task-center/schedule/delete/";
|
public static final String ORG_SCHEDULE_TASK_DELETE = "/organization/task-center/schedule/delete/";
|
||||||
|
public static final String ORG_SCHEDULE_TASK_SWITCH = "/organization/task-center/schedule/switch/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(20)
|
@Order(20)
|
||||||
|
@ -465,6 +473,12 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(27)
|
||||||
|
public void orgScheduleTaskSwitch() throws Exception {
|
||||||
|
this.requestGet(ORG_SCHEDULE_TASK_SWITCH + "wx_1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(21)
|
@Order(21)
|
||||||
|
|
|
@ -10,7 +10,7 @@ VALUES
|
||||||
|
|
||||||
INSERT INTO `schedule` (`id`, `key`, `type`, `value`, `job`, `resource_type`, `enable`, `resource_id`, `create_user`, `create_time`, `update_time`, `project_id`, `name`, `config`, `num`)
|
INSERT INTO `schedule` (`id`, `key`, `type`, `value`, `job`, `resource_type`, `enable`, `resource_id`, `create_user`, `create_time`, `update_time`, `project_id`, `name`, `config`, `num`)
|
||||||
VALUES
|
VALUES
|
||||||
('wx_1', 'wx_key_1', 'cron', '1233213', 'JobClass1', 'API_IMPORT', b'1', '123456', 'admin', 1640776000000, 1640777000000, '100001100001', 'Schedule 1', '{\"param1\": \"value1\", \"param2\": \"value2\"}', 100),
|
('wx_1', 'wx_key_1', 'cron', '1233213', 'io.metersphere.api.service.schedule.SwaggerUrlImportJob', 'API_IMPORT', b'1', '123456', 'admin', 1640776000000, 1640777000000, '100001100001', 'Schedule 1', '{\"param1\": \"value1\", \"param2\": \"value2\"}', 100),
|
||||||
('wx_2', 'wx_key_2', 'cron', '1231321231', 'JobClass15', 'BUG_SYNC', b'0', '234256', 'admin', 1640777400000, 1640778400000, '100001100001', 'Schedule 15', '', 101),
|
('wx_2', 'wx_key_2', 'cron', '1231321231', 'JobClass15', 'BUG_SYNC', b'0', '234256', 'admin', 1640777400000, 1640778400000, '100001100001', 'Schedule 15', '', 101),
|
||||||
('wx_3', 'wx_key_3', 'cron', '50 15 10 20 05 ?', 'JobClass22', 'DEMAND_SYNC', b'1', '4353', 'admin', 1640778100000, 1640779100000, '100001100001', 'Schedule 22', '', 102),
|
('wx_3', 'wx_key_3', 'cron', '50 15 10 20 05 ?', 'JobClass22', 'DEMAND_SYNC', b'1', '4353', 'admin', 1640778100000, 1640779100000, '100001100001', 'Schedule 22', '', 102),
|
||||||
('wx_4', 'wx_key_4', 'cron', '59 46 16 01 06 ?', 'JobClass29', 'API_SCENARIO', b'1', '1323235', 'admin', 1640778800000, 1640779800000, '100001100001', 'Schedule 29', '{\"param1\": \"value1\", \"param2\": \"value2\"}', 103),
|
('wx_4', 'wx_key_4', 'cron', '59 46 16 01 06 ?', 'JobClass29', 'API_SCENARIO', b'1', '1323235', 'admin', 1640778800000, 1640779800000, '100001100001', 'Schedule 29', '{\"param1\": \"value1\", \"param2\": \"value2\"}', 103),
|
||||||
|
|
Loading…
Reference in New Issue