From c1130366410a1e6f1bf9a6c61b042b59a32fc4cd Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Wed, 4 Sep 2024 15:14:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E6=89=B9=E9=87=8F=E5=85=B3=E8=81=94&?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=BA=E9=99=B7=E6=97=B6=E6=9C=AA=E8=A7=84?= =?UTF-8?q?=E5=88=92=E6=A8=A1=E5=9D=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExtTestPlanFunctionalCaseMapper.java | 2 ++ .../ExtTestPlanFunctionalCaseMapper.xml | 25 +++++++++++++------ .../TestPlanFunctionalCaseMinderService.java | 14 ++++++++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java index b6c06889b2..191a780b2d 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java @@ -82,4 +82,6 @@ public interface ExtTestPlanFunctionalCaseMapper { List selectProjectByModuleIds(@Param("moduleIds") List moduleIds); Collection selectIdsByModuleIds(@Param("request") TestPlanCaseMinderRequest request, @Param("minderModuleIds") List minderModuleIds); + + Collection selectIdsByRootIds(@Param("rootIds") List rootIds, @Param("testPlanId") String testPlanId); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml index d9042b1ab3..9f778e14bf 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml @@ -688,14 +688,7 @@ FROM functional_case_module WHERE id IN - - - 'root' - - - #{moduleId} - - + #{moduleId} @@ -715,4 +708,20 @@ + + \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseMinderService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseMinderService.java index 6c1e524c7d..948b5bca12 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseMinderService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseMinderService.java @@ -9,6 +9,7 @@ import io.metersphere.plan.mapper.ExtTestPlanFunctionalCaseMapper; import io.metersphere.system.dto.sdk.BaseTreeNode; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -61,6 +62,11 @@ public class TestPlanFunctionalCaseMinderService { } //模块 if (CollectionUtils.isNotEmpty(request.getMinderModuleIds())) { + //处理未规划用例 + List rootIds = ids.stream().filter(id -> StringUtils.endsWith(id, "_root")).map(id -> id.replace("_root", "")).toList(); + if (CollectionUtils.isNotEmpty(rootIds)) { + ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByRootIds(rootIds, request.getTestPlanId())); + } //获取模块及子模块 List modules = extTestPlanFunctionalCaseMapper.selectProjectByModuleIds(request.getMinderModuleIds()); Map> moduleMaps = modules.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getProjectId)); @@ -68,14 +74,16 @@ public class TestPlanFunctionalCaseMinderService { moduleMaps.forEach((k, v) -> { buildIdsByModule(k, v, minderModuleIds); }); - - ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByModuleIds(request, minderModuleIds)); + if (CollectionUtils.isNotEmpty(minderModuleIds)) { + ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByModuleIds(request, minderModuleIds)); + } } //用例 if (CollectionUtils.isNotEmpty(request.getMinderCaseIds())) { ids.addAll(request.getMinderCaseIds()); } - return ids; + //去重 + return ids.stream().distinct().toList(); } }