diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index 5897ea2cda..9a5e8bc63d 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -13,6 +13,7 @@ import io.metersphere.functional.mapper.*; import io.metersphere.functional.request.*; import io.metersphere.functional.result.CaseManagementResultCode; import io.metersphere.plan.domain.TestPlanCaseExecuteHistoryExample; +import io.metersphere.plan.domain.TestPlanFunctionalCase; import io.metersphere.plan.domain.TestPlanFunctionalCaseExample; import io.metersphere.plan.mapper.TestPlanCaseExecuteHistoryMapper; import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper; @@ -410,7 +411,13 @@ public class FunctionalCaseService { //获取已关联测试计划数量 TestPlanFunctionalCaseExample testPlanFunctionalCaseExample = new TestPlanFunctionalCaseExample(); testPlanFunctionalCaseExample.createCriteria().andFunctionalCaseIdEqualTo(functionalCaseDetailDTO.getId()); - functionalCaseDetailDTO.setTestPlanCount((int) testPlanFunctionalCaseMapper.countByExample(testPlanFunctionalCaseExample)); + List testPlanFunctionalCases = testPlanFunctionalCaseMapper.selectByExample(testPlanFunctionalCaseExample); + if (CollectionUtils.isNotEmpty(testPlanFunctionalCases)) { + Map> planMap = testPlanFunctionalCases.stream().collect(Collectors.groupingBy(TestPlanFunctionalCase::getTestPlanId)); + functionalCaseDetailDTO.setTestPlanCount(planMap.size()); + } else { + functionalCaseDetailDTO.setTestPlanCount(0); + } //获取评论总数量数量 CaseReviewHistoryExample caseReviewHistoryExample = new CaseReviewHistoryExample();