feat(任务中心): 组织&项目任务中心任务详情停止/批量停止
This commit is contained in:
parent
6cec903a59
commit
2442965a53
|
@ -7,9 +7,11 @@ import io.metersphere.system.dto.taskhub.ResourcePoolOptionsDTO;
|
|||
import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
||||
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemBatchRequest;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||
import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.BaseTaskHubLogService;
|
||||
import io.metersphere.system.service.BaseTaskHubService;
|
||||
|
@ -92,7 +94,8 @@ public class ProjectTaskHubController {
|
|||
public void batchStopTask(@Validated @RequestBody TableBatchProcessDTO request) {
|
||||
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId());
|
||||
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), null, SessionUtils.getCurrentProjectId());
|
||||
baseTaskHubLogService.projectBatchStopLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), SessionUtils.getCurrentProjectId(), SessionUtils.getCurrentOrganizationId(),
|
||||
"/project/task-center/exec-task/batch-stop", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
||||
}
|
||||
|
||||
@PostMapping("/exec-task/item/order")
|
||||
|
@ -116,6 +119,27 @@ public class ProjectTaskHubController {
|
|||
public void batchDeleteTask(@Validated @RequestBody TableBatchProcessDTO request) {
|
||||
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId());
|
||||
baseTaskHubService.batchDeleteTask(ids, null, SessionUtils.getCurrentProjectId());
|
||||
baseTaskHubLogService.projectBatchDeleteLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), SessionUtils.getCurrentProjectId(), SessionUtils.getCurrentOrganizationId(),
|
||||
"/project/task-center/exec-task/batch-delete", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/exec-task/item/stop/{id}")
|
||||
@Operation(summary = "项目-任务中心-用例任务详情-停止任务")
|
||||
@Log(type = OperationLogType.STOP, expression = "#msClass.projectStopItemLog(#id)", msClass = BaseTaskHubLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_EXEC_STOP)
|
||||
public void stopTaskItem(@PathVariable String id) {
|
||||
baseTaskHubService.stopTaskItem(id, SessionUtils.getUserId(), null, null);
|
||||
}
|
||||
|
||||
@PostMapping("/exec-task/item/batch-stop")
|
||||
@Operation(summary = "项目-任务中心-用例任务详情-批量停止任务")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_EXEC_STOP)
|
||||
public void batchStopTaskItem(@Validated @RequestBody TaskHubItemBatchRequest request) {
|
||||
List<String> itemIds = baseTaskHubService.getTaskItemIds(request, null, null);
|
||||
baseTaskHubService.batchStopTaskItem(itemIds, SessionUtils.getUserId(), null, null);
|
||||
baseTaskHubLogService.taskItemBatchLog(itemIds, SessionUtils.getUserId(), OperationLogType.STOP.name(), SessionUtils.getCurrentProjectId(), SessionUtils.getCurrentOrganizationId(),
|
||||
"/project/task-center/exec-task/item/batch-stop", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.system.base.BaseTest;
|
|||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemBatchRequest;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Order;
|
||||
|
@ -28,9 +29,11 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
|||
public static final String PROJECT_RESOURCE_POOL_OPTIONS = "/project/task-center/resource-pool/options";
|
||||
public static final String PROJECT_TASK_STOP = "/project/task-center/exec-task/stop/";
|
||||
public static final String PROJECT_TASK_DELETE = "/project/task-center/exec-task/delete/";
|
||||
public static final String PROJECT_TASK_BATCH_STOP = "/project/task-center/exec-task/batch-stop/";
|
||||
public static final String PROJECT_TASK_BATCH_STOP = "/project/task-center/exec-task/batch-stop";
|
||||
public static final String PROJECT_TASK_ITEM_ORDER = "/project/task-center/exec-task/item/order";
|
||||
public static final String PROJECT_TASK_BATCH_DELETE = "/organization/task-center/exec-task/batch-delete/";
|
||||
public static final String PROJECT_TASK_BATCH_DELETE = "/organization/task-center/exec-task/batch-delete";
|
||||
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";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
|
@ -177,4 +180,31 @@ public class ProjectTaskHubControllerTests extends BaseTest {
|
|||
request.setSelectIds(List.of("1"));
|
||||
this.requestPost(PROJECT_TASK_BATCH_DELETE, request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 项目执行任务项停止
|
||||
*/
|
||||
@Test
|
||||
@Order(4)
|
||||
public void projectTaskItemStop() throws Exception {
|
||||
this.requestGet(PROJECT_TASK_ITEM_STOP + "pro_1");
|
||||
MvcResult mvcResult = this.requestGetWithOkAndReturn(PROJECT_TASK_ITEM_STOP + "pro_2");
|
||||
// 获取返回值
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
// 返回请求正常
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void projectTaskItemBatchStop() throws Exception {
|
||||
TaskHubItemBatchRequest request = new TaskHubItemBatchRequest();
|
||||
request.setSelectAll(false);
|
||||
request.setSelectIds(List.of("pro_1", "pro_2"));
|
||||
this.requestPostWithOkAndReturn(PROJECT_TASK_ITEM_BATCH_STOP, request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
|
@ -8,9 +9,11 @@ import io.metersphere.system.dto.taskhub.ResourcePoolOptionsDTO;
|
|||
import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
||||
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemBatchRequest;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||
import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.BaseProjectMapper;
|
||||
import io.metersphere.system.service.BaseTaskHubLogService;
|
||||
|
@ -100,7 +103,8 @@ public class OrganizationTaskHubController {
|
|||
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null);
|
||||
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
|
||||
//日志
|
||||
baseTaskHubLogService.orgBatchStopLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.ORGANIZATION, SessionUtils.getCurrentOrganizationId(),
|
||||
"/organization/task-center/exec-task/batch-stop", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
||||
}
|
||||
|
||||
@PostMapping("/exec-task/item/order")
|
||||
|
@ -126,6 +130,25 @@ public class OrganizationTaskHubController {
|
|||
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null);
|
||||
baseTaskHubService.batchDeleteTask(ids, SessionUtils.getCurrentOrganizationId(), null);
|
||||
//日志
|
||||
baseTaskHubLogService.orgBatchDeleteLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), OperationLogConstants.ORGANIZATION, SessionUtils.getCurrentOrganizationId(),
|
||||
"/organization/task-center/exec-task/batch-delete", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
||||
}
|
||||
|
||||
@GetMapping("/exec-task/item/stop/{id}")
|
||||
@Operation(summary = "组织-任务中心-用例任务详情-停止任务")
|
||||
@Log(type = OperationLogType.STOP, expression = "#msClass.orgStopItemLog(#id)", msClass = BaseTaskHubLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_EXEC_STOP)
|
||||
public void stopTaskItem(@PathVariable String id) {
|
||||
baseTaskHubService.stopTaskItem(id, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
|
||||
}
|
||||
|
||||
@PostMapping("/exec-task/item/batch-stop")
|
||||
@Operation(summary = "组织-任务中心-用例任务详情-批量停止任务")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_EXEC_STOP)
|
||||
public void batchStopTaskItem(@Validated @RequestBody TaskHubItemBatchRequest request) {
|
||||
List<String> itemIds = baseTaskHubService.getTaskItemIds(request, SessionUtils.getCurrentOrganizationId(), null);
|
||||
baseTaskHubService.batchStopTaskItem(itemIds, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
|
||||
baseTaskHubLogService.taskItemBatchLog(itemIds, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.ORGANIZATION, SessionUtils.getCurrentOrganizationId(),
|
||||
"/organization/task-center/exec-task/item/batch-stop", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
|
@ -8,6 +9,7 @@ import io.metersphere.system.dto.taskhub.request.TaskHubItemBatchRequest;
|
|||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||
import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.BaseTaskHubLogService;
|
||||
import io.metersphere.system.service.BaseTaskHubService;
|
||||
|
@ -100,7 +102,8 @@ public class SystemTaskHubController {
|
|||
List<String> ids = baseTaskHubService.getTaskIds(request, null, null);
|
||||
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), null, null);
|
||||
//系統日志
|
||||
baseTaskHubLogService.systemBatchStopLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.SYSTEM, OperationLogConstants.SYSTEM,
|
||||
"/system/task-center/exec-task/batch-stop", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||
}
|
||||
|
||||
@PostMapping("/exec-task/item/order")
|
||||
|
@ -126,7 +129,8 @@ public class SystemTaskHubController {
|
|||
List<String> ids = baseTaskHubService.getTaskIds(request, null, null);
|
||||
baseTaskHubService.batchDeleteTask(ids, SessionUtils.getCurrentOrganizationId(), null);
|
||||
//系統日志
|
||||
baseTaskHubLogService.systemBatchDeleteLog(ids);
|
||||
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), OperationLogConstants.SYSTEM, OperationLogConstants.SYSTEM,
|
||||
"/system/task-center/exec-task/batch-delete", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||
}
|
||||
|
||||
//TODO 系统&组织&项目 任务按钮操作:失败重跑 查看报告 批量失败重跑
|
||||
|
@ -142,12 +146,12 @@ public class SystemTaskHubController {
|
|||
|
||||
@PostMapping("/exec-task/item/batch-stop")
|
||||
@Operation(summary = "系统-任务中心-用例任务详情-批量停止任务")
|
||||
@Log(type = OperationLogType.STOP, expression = "#msClass.systemBatchStopItemLog(#request)", msClass = BaseTaskHubLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_EXEC_STOP)
|
||||
public void batchStopTaskItem(@Validated @RequestBody TaskHubItemBatchRequest request) {
|
||||
List<String> itemIds = baseTaskHubService.getTaskItemIds(request, null, null);
|
||||
baseTaskHubService.batchStopTaskItem(itemIds, SessionUtils.getUserId(), null, null);
|
||||
baseTaskHubLogService.systemBatchStopItemLog(itemIds);
|
||||
baseTaskHubLogService.taskItemBatchLog(itemIds, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.SYSTEM, OperationLogConstants.SYSTEM,
|
||||
"/system/task-center/exec-task/item/batch-stop", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
|
||||
|
||||
}
|
||||
//TODO 系统&组织&项目 任务详情按钮操作:查看
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.system.domain.ExecTask;
|
||||
import io.metersphere.system.domain.ExecTaskExample;
|
||||
import io.metersphere.system.domain.ExecTaskItem;
|
||||
import io.metersphere.system.domain.ExecTaskItemExample;
|
||||
import io.metersphere.system.dto.builder.LogDTOBuilder;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
|
@ -54,36 +56,6 @@ public class BaseTaskHubLogService {
|
|||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统批量停止任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void systemBatchStopLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.SYSTEM,
|
||||
OperationLogConstants.SYSTEM,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.SETTING_SYSTEM_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组织停止任务日志
|
||||
|
@ -108,37 +80,6 @@ public class BaseTaskHubLogService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组织批量停止任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void orgBatchStopLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
null,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目停止任务日志
|
||||
*
|
||||
|
@ -162,37 +103,6 @@ public class BaseTaskHubLogService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目批量停止任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void projectBatchStopLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统删除任务日志
|
||||
*
|
||||
|
@ -215,35 +125,6 @@ public class BaseTaskHubLogService {
|
|||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统批量删除任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void systemBatchDeleteLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.SYSTEM,
|
||||
OperationLogConstants.SYSTEM,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.SETTING_SYSTEM_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织删除任务日志
|
||||
|
@ -267,36 +148,6 @@ public class BaseTaskHubLogService {
|
|||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织批量删除任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void orgBatchDeleteLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
null,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目删除任务日志
|
||||
*
|
||||
|
@ -320,37 +171,6 @@ public class BaseTaskHubLogService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目批量删除任务日志
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public void projectBatchDeleteLog(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER,
|
||||
item.getTaskName());
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统停止任务项日志
|
||||
*
|
||||
|
@ -375,33 +195,125 @@ public class BaseTaskHubLogService {
|
|||
|
||||
|
||||
/**
|
||||
* 系统批量停止任务项日志
|
||||
* 任务项 批量操作日志统一记录
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
* @param userId
|
||||
* @param operationType
|
||||
* @param projectId
|
||||
* @param organizationId
|
||||
* @param url
|
||||
* @param module
|
||||
*/
|
||||
public void systemBatchStopItemLog(List<String> ids) {
|
||||
public void taskItemBatchLog(List<String> ids, String userId, String operationType, String projectId, String organizationId, String url, String module) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskItemExample example = new ExecTaskItemExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTaskItem> execTasks = execTaskItemMapper.selectByExample(example);
|
||||
List<ExecTaskItem> execTaskItems = execTaskItemMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.SYSTEM,
|
||||
OperationLogConstants.SYSTEM,
|
||||
item.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.SETTING_SYSTEM_TASK_CENTER,
|
||||
item.getResourceName());
|
||||
if (CollectionUtils.isNotEmpty(execTaskItems)) {
|
||||
execTaskItems.forEach(item -> {
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(projectId)
|
||||
.organizationId(organizationId)
|
||||
.type(operationType)
|
||||
.module(module)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path(url)
|
||||
.sourceId(item.getId())
|
||||
.content(item.getResourceName())
|
||||
.createUser(userId)
|
||||
.build().getLogDTO();
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组织停止任务项日志
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public LogDTO orgStopItemLog(String id) {
|
||||
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(id);
|
||||
LogDTO dto = null;
|
||||
if (execTaskItem != null) {
|
||||
dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
null,
|
||||
execTaskItem.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER,
|
||||
execTaskItem.getResourceName());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 项目停止任务项日志
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public LogDTO projectStopItemLog(String id) {
|
||||
ExecTaskItem execTaskItem = execTaskItemMapper.selectByPrimaryKey(id);
|
||||
LogDTO dto = null;
|
||||
if (execTaskItem != null) {
|
||||
dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
null,
|
||||
execTaskItem.getId(),
|
||||
null,
|
||||
OperationLogType.STOP.name(),
|
||||
OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER,
|
||||
execTaskItem.getResourceName());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务批量 操作日志统一处理
|
||||
*
|
||||
* @param ids
|
||||
* @param userId
|
||||
* @param operationType
|
||||
* @param projectId
|
||||
* @param organizationId
|
||||
* @param url
|
||||
* @param module
|
||||
*/
|
||||
public void taskBatchLog(List<String> ids, String userId, String operationType, String projectId, String organizationId, String url, String module) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
ExecTaskExample example = new ExecTaskExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ExecTask> execTasks = execTaskMapper.selectByExample(example);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(execTasks)) {
|
||||
execTasks.forEach(item -> {
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(projectId)
|
||||
.organizationId(organizationId)
|
||||
.type(operationType)
|
||||
.module(module)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path(url)
|
||||
.sourceId(item.getId())
|
||||
.content(item.getTaskName())
|
||||
.createUser(userId)
|
||||
.build().getLogDTO();
|
||||
logDTOList.add(dto);
|
||||
});
|
||||
}
|
||||
operationLogService.batchAdd(logDTOList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.system.domain.ExecTask;
|
|||
import io.metersphere.system.domain.ExecTaskItem;
|
||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemBatchRequest;
|
||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.system.service.BaseTaskHubService;
|
||||
|
@ -44,8 +45,8 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
|||
public static final String SYSTEM_RESOURCE_POOL_STATUS = "/system/task-center/resource-pool/status";
|
||||
public static final String SYSTEM_TASK_STOP = "/system/task-center/exec-task/stop/";
|
||||
public static final String SYSTEM_TASK_DELETE = "/system/task-center/exec-task/delete/";
|
||||
public static final String SYSTEM_TASK_BATCH_STOP = "/system/task-center/exec-task/batch-stop/";
|
||||
public static final String SYSTEM_TASK_BATCH_DELETE = "/system/task-center/exec-task/batch-delete/";
|
||||
public static final String SYSTEM_TASK_BATCH_STOP = "/system/task-center/exec-task/batch-stop";
|
||||
public static final String SYSTEM_TASK_BATCH_DELETE = "/system/task-center/exec-task/batch-delete";
|
||||
public static final String SYSTEM_TASK_ITEM_STOP = "/system/task-center/exec-task/item/stop/";
|
||||
public static final String SYSTEM_TASK_ITEM_BATCH_STOP = "/system/task-center/exec-task/item/batch-stop";
|
||||
public static final String SYSTEM_TASK_ITEM_ORDER = "/system/task-center/exec-task/item/order";
|
||||
|
@ -252,9 +253,11 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
|||
public static final String ORG_RESOURCE_POOL_OPTIONS = "/organization/task-center/resource-pool/options";
|
||||
public static final String ORG_TASK_STOP = "/organization/task-center/exec-task/stop/";
|
||||
public static final String ORG_TASK_DELETE = "/organization/task-center/exec-task/delete/";
|
||||
public static final String ORG_TASK_BATCH_STOP = "/organization/task-center/exec-task/batch-stop/";
|
||||
public static final String ORG_TASK_BATCH_DELETE = "/organization/task-center/exec-task/batch-delete/";
|
||||
public static final String ORG_TASK_BATCH_STOP = "/organization/task-center/exec-task/batch-stop";
|
||||
public static final String ORG_TASK_BATCH_DELETE = "/organization/task-center/exec-task/batch-delete";
|
||||
public static final String ORG_TASK_ITEM_ORDER = "/organization/task-center/exec-task/item/order";
|
||||
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";
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
|
@ -354,6 +357,21 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
|||
testResourcePoolMapper.deleteByPrimaryKey("2");
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织执行任务项停止
|
||||
*/
|
||||
@Test
|
||||
@Order(23)
|
||||
public void orgTaskItemStop() throws Exception {
|
||||
this.requestGet(ORG_TASK_ITEM_STOP + "1");
|
||||
MvcResult mvcResult = this.requestGetWithOkAndReturn(ORG_TASK_ITEM_STOP + "2");
|
||||
// 获取返回值
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
// 返回请求正常
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统执行任务停止
|
||||
|
@ -381,6 +399,15 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
|||
Assertions.assertNotNull(resultData);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
public void orgTaskItemBatchStop() throws Exception {
|
||||
TaskHubItemBatchRequest request = new TaskHubItemBatchRequest();
|
||||
request.setSelectAll(false);
|
||||
request.setSelectIds(List.of("1", "2"));
|
||||
this.requestPostWithOkAndReturn(ORG_TASK_ITEM_BATCH_STOP, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
public void orgBatchTaskDelete() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue