diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java index 49337e204f..f66cba0b91 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.java @@ -80,12 +80,13 @@ public interface ExtBugRelateCaseMapper { */ long countByCaseId(String caseId); - List getBugCountByIds(@Param("ids") List ids); + List getBugCountByIds(@Param("ids") List ids, @Param("testPlanId") String testPlanId); List getTestPlanAssociateBugs(@Param("request") AssociateBugPageRequest request, @Param("sort") String sort); /** * 获取计划关联的缺陷ID集合(去重) + * * @param planId 计划ID * @return 缺陷ID集合 */ diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml index 7fac96b98e..f7b33f5a3f 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml @@ -272,6 +272,7 @@ #{id} + and bug_relation_case.test_plan_id = #{testPlanId} ORDER BY bug.pos DESC diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index a76bbd4b39..7ceb26a88f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -204,7 +204,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { Map> collect = functionalCaseService.getCaseCustomFiledMap(ids, projectId); Set userIds = extractUserIds(functionalCaseLists); List relateIds = functionalCaseLists.stream().map(TestPlanCasePageResponse::getId).collect(Collectors.toList()); - Map> bugListMap = getBugData(relateIds); + Map> bugListMap = getBugData(relateIds, functionalCaseLists.get(0).getTestPlanId()); Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); functionalCaseLists.forEach(testPlanCasePageResponse -> { testPlanCasePageResponse.setCustomFields(collect.get(testPlanCasePageResponse.getCaseId())); @@ -220,8 +220,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { } - private Map> getBugData(List ids) { - List bugList = bugRelateCaseMapper.getBugCountByIds(ids); + private Map> getBugData(List ids, String testPlanId) { + List bugList = bugRelateCaseMapper.getBugCountByIds(ids, testPlanId); return bugList.stream().collect(Collectors.groupingBy(CaseRelateBugDTO::getCaseId)); }