fix(任务中心): 修复即时任务批量删除问题

--bug=1048270 --user=王旭 【系统设置】系统-任务中心-系统即时任务-全选所有页-删除-提示删除成功,实际一条数据都没删除掉 https://www.tapd.cn/55049933/s/1599907
This commit is contained in:
WangXu10 2024-10-29 10:24:58 +08:00 committed by Craftsman
parent 9e5348750a
commit fa81f2721f
6 changed files with 12 additions and 10 deletions

View File

@ -102,7 +102,7 @@ public class ProjectTaskHubController {
@Operation(summary = "项目-任务中心-用例执行任务-批量停止任务")
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_EXEC_STOP)
public void batchStopTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId());
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId(), true);
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), null, SessionUtils.getCurrentProjectId());
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), SessionUtils.getCurrentProjectId(), SessionUtils.getCurrentOrganizationId(),
"/project/task-center/exec-task/batch-stop", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
@ -127,7 +127,7 @@ public class ProjectTaskHubController {
@Operation(summary = "项目-任务中心-用例执行任务-批量删除任务")
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_DELETE)
public void batchDeleteTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId());
List<String> ids = baseTaskHubService.getTaskIds(request, null, SessionUtils.getCurrentProjectId(), false);
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), SessionUtils.getCurrentProjectId(), SessionUtils.getCurrentOrganizationId(),
"/project/task-center/exec-task/batch-delete", OperationLogModule.PROJECT_MANAGEMENT_TASK_CENTER);
baseTaskHubService.batchDeleteTask(ids, null, SessionUtils.getCurrentProjectId());

View File

@ -107,7 +107,7 @@ public class OrganizationTaskHubController {
@Operation(summary = "组织-任务中心-用例执行任务-批量停止任务")
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_EXEC_STOP)
public void batchStopTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null);
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null, true);
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), null);
//日志
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.ORGANIZATION, SessionUtils.getCurrentOrganizationId(),
@ -134,7 +134,7 @@ public class OrganizationTaskHubController {
@Operation(summary = "组织-任务中心-用例执行任务-批量删除任务")
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_DELETE)
public void batchDeleteTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null);
List<String> ids = baseTaskHubService.getTaskIds(request, SessionUtils.getCurrentOrganizationId(), null, false);
//日志
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), OperationLogConstants.ORGANIZATION, SessionUtils.getCurrentOrganizationId(),
"/organization/task-center/exec-task/batch-delete", OperationLogModule.SETTING_ORGANIZATION_TASK_CENTER);

View File

@ -106,7 +106,7 @@ public class SystemTaskHubController {
@Operation(summary = "系统-任务中心-用例执行任务-批量停止任务")
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_EXEC_STOP)
public void batchStopTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, null, null);
List<String> ids = baseTaskHubService.getTaskIds(request, null, null, true);
baseTaskHubService.batchStopTask(ids, SessionUtils.getUserId(), null, null);
//系統日志
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.STOP.name(), OperationLogConstants.SYSTEM, OperationLogConstants.SYSTEM,
@ -133,7 +133,7 @@ public class SystemTaskHubController {
@Operation(summary = "系统-任务中心-用例执行任务-批量删除任务")
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_DELETE)
public void batchDeleteTask(@Validated @RequestBody TableBatchProcessDTO request) {
List<String> ids = baseTaskHubService.getTaskIds(request, null, null);
List<String> ids = baseTaskHubService.getTaskIds(request, null, null, false);
//系統日志
baseTaskHubLogService.taskBatchLog(ids, SessionUtils.getUserId(), OperationLogType.DELETE.name(), OperationLogConstants.SYSTEM, OperationLogConstants.SYSTEM,
"/system/task-center/exec-task/batch-delete", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);

View File

@ -17,7 +17,7 @@ public interface ExtExecTaskMapper {
void deleteTaskByIds(@Param("ids") List<String> ids, @Param("orgId") String orgId, @Param("projectId") String projectId);
List<String> getIds(@Param("request") TableBatchProcessDTO request, @Param("organizationId") String organizationId, @Param("projectId") String projectId);
List<String> getIds(@Param("request") TableBatchProcessDTO request, @Param("organizationId") String organizationId, @Param("projectId") String projectId, @Param("flag") boolean flag);
void batchUpdateTaskStatus(@Param("ids") List<String> ids, @Param("userId") String userId, @Param("organizationId") String organizationId, @Param("projectId") String projectId, @Param("status") String status);

View File

@ -47,7 +47,9 @@
<select id="getIds" resultType="java.lang.String">
select id from exec_task
<where>
status = 'RUNNING'
<if test="flag">
and status = 'RUNNING'
</if>
<if test="projectId != null and projectId != ''">
and exec_task.project_id = #{projectId}
</if>

View File

@ -665,9 +665,9 @@ public class BaseTaskHubService {
}
public List<String> getTaskIds(TableBatchProcessDTO request, String orgId, String projectId) {
public List<String> getTaskIds(TableBatchProcessDTO request, String orgId, String projectId, boolean flag) {
if (request.isSelectAll()) {
List<String> ids = extExecTaskMapper.getIds(request, orgId, projectId);
List<String> ids = extExecTaskMapper.getIds(request, orgId, projectId, flag);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds());
}