diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupTaskResultServiceImpl.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupTaskResultServiceImpl.java index 5d5fffa709..a383a39c16 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupTaskResultServiceImpl.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupTaskResultServiceImpl.java @@ -1,7 +1,9 @@ package io.metersphere.api.service; +import io.metersphere.api.domain.ApiReportRelateTaskExample; import io.metersphere.sdk.constants.ProjectApplicationType; import io.metersphere.sdk.util.LogUtils; +import io.metersphere.sdk.util.SubListUtils; import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTaskExample; import io.metersphere.system.domain.ExecTaskItem; @@ -11,10 +13,12 @@ import io.metersphere.system.mapper.ExecTaskMapper; import io.metersphere.system.mapper.ExtExecTaskItemMapper; import io.metersphere.system.mapper.ExtExecTaskMapper; import io.metersphere.system.service.BaseCleanUpReport; +import org.apache.commons.collections4.ListUtils; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import io.metersphere.api.mapper.ApiReportRelateTaskMapper; import java.util.List; import java.util.Map; @@ -35,6 +39,8 @@ public class CleanupTaskResultServiceImpl implements BaseCleanUpReport { @Resource private ExecTaskMapper execTaskMapper; @Resource + private ApiReportRelateTaskMapper apiReportRelateTaskMapper; + @Resource private ExecTaskItemMapper execTaskItemMapper; @@ -59,6 +65,16 @@ public class CleanupTaskResultServiceImpl implements BaseCleanUpReport { execTaskItem.setDeleted(true); execTaskItemMapper.updateByExampleSelective(execTaskItem, example); } + List cleanIds = ListUtils.union(cleanTaskIds, cleanTaskItemIds); + LogUtils.info("清理当前项目[" + projectId + "]任务中心执行结果, 共[" + cleanIds.size() + "]条"); + if (CollectionUtils.isNotEmpty(cleanIds)) { + // 清理任务-报告关系表 + SubListUtils.dealForSubList(cleanIds, 100, ids -> { + ApiReportRelateTaskExample example = new ApiReportRelateTaskExample(); + example.createCriteria().andTaskResourceIdIn(cleanIds); + apiReportRelateTaskMapper.deleteByExample(example); + }); + } LogUtils.info("清理当前项目[" + projectId + "]任务中心执行结果结束!"); } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubDTO.java index ab8436e2ac..bbc135f7fb 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubDTO.java @@ -24,4 +24,7 @@ public class TaskHubDTO extends ExecTask { @Schema(description = "报告ID") private String reportId; + @Schema(description = "结果是否被删除") + private Boolean resultDeleted = true; + } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubItemDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubItemDTO.java index 793430244c..2e83cd5fb1 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubItemDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskhub/TaskHubItemDTO.java @@ -39,4 +39,10 @@ public class TaskHubItemDTO extends ExecTaskItem { @Schema(description = "错误信息") private String errorMessage; + + @Schema(description = "是否集合报告") + private Boolean integrated; + + @Schema(description = "结果是否被删除") + private Boolean resultDeleted = true; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml index ad48393ad6..058e2d9948 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml @@ -2,7 +2,7 @@