From e9fa95b1e96cb9fa46bbe9c1e9e3a52c3c362f9e Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 15 Nov 2024 14:59:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):?= =?UTF-8?q?=20=E8=BF=94=E5=9B=9E=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=88=A0=E9=99=A4=E5=88=A4=E6=96=AD=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CleanupTaskResultServiceImpl.java | 16 ++++++++++ .../system/dto/taskhub/TaskHubDTO.java | 3 ++ .../system/dto/taskhub/TaskHubItemDTO.java | 6 ++++ .../system/mapper/ExtExecTaskItemMapper.xml | 2 +- .../system/service/BaseTaskHubService.java | 30 +++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) 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 @@