From 61c05433fa268c20e9d687299cfdf1af40134025 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 13 Nov 2024 18:38:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=BB=9F=E8=AE=A1=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/i18n/dashboard.properties | 15 + .../resources/i18n/dashboard_en_US.properties | 15 +- .../resources/i18n/dashboard_zh_CN.properties | 15 +- .../api/mapper/ExtApiDefinitionMapper.java | 9 +- .../api/mapper/ExtApiDefinitionMapper.xml | 21 +- .../api/mapper/ExtApiScenarioMapper.java | 5 +- .../api/mapper/ExtApiScenarioMapper.xml | 18 +- .../api/mapper/ExtApiTestCaseMapper.java | 6 +- .../api/mapper/ExtApiTestCaseMapper.xml | 19 +- .../metersphere/bug/mapper/ExtBugMapper.java | 6 +- .../metersphere/bug/mapper/ExtBugMapper.xml | 12 +- .../mapper/ExtCaseReviewMapper.java | 6 +- .../functional/mapper/ExtCaseReviewMapper.xml | 12 +- .../mapper/ExtFunctionalCaseMapper.java | 10 +- .../mapper/ExtFunctionalCaseMapper.xml | 21 +- .../controller/DashboardController.java | 54 ++- .../dashboard/service/DashboardService.java | 345 +++++++++++++++--- .../DashboardFrontPageControllerTests.java | 66 +++- .../src/test/resources/dml/init_dashboard.sql | 34 +- .../service/PermissionCheckService.java | 22 ++ .../project/service/ProjectService.java | 6 - .../system/mapper/ExtExecTaskItemMapper.java | 8 +- .../system/mapper/ExtExecTaskItemMapper.xml | 30 ++ .../plan/mapper/ExtTestPlanMapper.java | 4 +- .../plan/mapper/ExtTestPlanMapper.xml | 8 +- 25 files changed, 649 insertions(+), 118 deletions(-) diff --git a/backend/framework/sdk/src/main/resources/i18n/dashboard.properties b/backend/framework/sdk/src/main/resources/i18n/dashboard.properties index e8e94019e2..31ea3fa891 100644 --- a/backend/framework/sdk/src/main/resources/i18n/dashboard.properties +++ b/backend/framework/sdk/src/main/resources/i18n/dashboard.properties @@ -8,6 +8,21 @@ functional_case.unPass=未通过 functional_case.coverRate=覆盖率 functional_case.hasCover=已覆盖 functional_case.unCover=未覆盖 +api_definition.completionRate=完成率 +api_management.execTime=执行次数 +api_management.execCount=已执行 +api_management.unExecCount=未执行 +api_management.apiCaseCount=接口用例数 +api_management.apiScenarioCount=场景用例数 +api_management.fakeErrorCount=误报数 +api_management.apiCaseExecRate=用例执行率 +api_management.apiCasePassRate=用例通过率 +api_management.scenarioExecRate=场景执行率 +api_management.scenarioPassRate=场景通过率 +api_management.passCount=已通过 +api_management.unPassCount=未通过 + + diff --git a/backend/framework/sdk/src/main/resources/i18n/dashboard_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/dashboard_en_US.properties index 24add6337b..2040ceb806 100644 --- a/backend/framework/sdk/src/main/resources/i18n/dashboard_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/dashboard_en_US.properties @@ -4,7 +4,20 @@ functional_case.hasReview=Reviewed functional_case.unReview=Not reviewed functional_case.passRate=Pass rate functional_case.hasPass=Passed -functional_case.unPass=Un Pass +functional_case.unPass=Un pass functional_case.coverRate=Coverage functional_case.hasCover=Covered functional_case.unCover=Not covered +api_definition.completionRate=Completion rate +api_management.execTime=Execution times +api_management.execCount=Executed +api_management.unExecCount=Not executed +api_management.apiCaseCount=ApiCase count +api_management.apiScenarioCount=ApiScenario count +api_management.fakeErrorCount=FakeError count +api_management.apiCaseExecRate=Case execution rate +api_management.apiCasePassRate=Case pass rate +api_management.scenarioExecRate=Scenario execution rate +api_management.scenarioPassRate=Scenario pass rate +api_management.passCount=Passed +api_management.unPassCount=Un pass diff --git a/backend/framework/sdk/src/main/resources/i18n/dashboard_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/dashboard_zh_CN.properties index 742bb54a1b..a69108c27a 100644 --- a/backend/framework/sdk/src/main/resources/i18n/dashboard_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/dashboard_zh_CN.properties @@ -7,4 +7,17 @@ functional_case.hasPass=已通过 functional_case.unPass=未通过 functional_case.coverRate=覆盖率 functional_case.hasCover=已覆盖 -functional_case.unCover=未覆盖 \ No newline at end of file +functional_case.unCover=未覆盖 +api_definition.completionRate=完成率 +api_management.execTime=执行次数 +api_management.execCount=已执行 +api_management.unExecCount=未执行 +api_management.apiCaseCount=接口用例数 +api_management.apiScenarioCount=场景用例数 +api_management.fakeErrorCount=误报数 +api_management.apiCaseExecRate=用例执行率 +api_management.apiCasePassRate=用例通过率 +api_management.scenarioExecRate=场景执行率 +api_management.scenarioPassRate=场景通过率 +api_management.passCount=已通过 +api_management.unPassCount=未通过 diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java index 108d56d227..6e535aeaf4 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java @@ -111,9 +111,9 @@ public interface ExtApiDefinitionMapper { Long selectNumById(String id); - List projectApiCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + List projectApiCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); - List userCreateApiCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List userCreateApiCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); /** * 获取根据时间过滤有更新的api @@ -123,7 +123,10 @@ public interface ExtApiDefinitionMapper { * @param endTime 时间过滤条件 * @return List */ - List getUpdateApiList(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); + List getUpdateApiList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); List scenarioRefApiCount(@Param("projectId") String projectId, @Param("resourceIds") List resourceIds); + + List getCreateApiList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml index e798a01327..f2d4df7fa9 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml @@ -781,7 +781,9 @@ #{projectId} AND api_definition.deleted = false - AND api_definition.create_time BETWEEN #{startTime} AND #{endTime} + + AND api_definition.create_time BETWEEN #{startTime} AND #{endTime} + AND api_definition.create_user = #{userId} @@ -794,7 +796,9 @@ FROM api_definition WHERE api_definition.deleted = false AND api_definition.project_id = #{projectId} - AND api_definition.create_time BETWEEN #{startTime} AND #{endTime} + + AND api_definition.create_time BETWEEN #{startTime} AND #{endTime} + and api_definition.create_user in @@ -805,11 +809,11 @@ + diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java index fd0678cc3a..e2a6fd2ef0 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java @@ -102,9 +102,10 @@ public interface ExtApiScenarioMapper { List getNameInfo(@Param("ids") List ids); - List projectApiScenarioCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + List projectApiScenarioCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); - List userCreateApiScenarioCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List userCreateApiScenarioCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); + List getSimpleApiScenarioList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); List selectExecHistory(@Param("request") ExecutePageRequest request); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml index ad76028f3f..8589a23342 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml @@ -775,7 +775,9 @@ #{projectId} - AND api_scenario.create_time BETWEEN #{startTime} AND #{endTime} + + AND api_scenario.create_time BETWEEN #{startTime} AND #{endTime} + AND api_scenario.create_user = #{userId} @@ -788,7 +790,9 @@ FROM api_scenario WHERE api_scenario.deleted = false AND api_scenario.project_id = #{projectId} - AND api_scenario.create_time BETWEEN #{startTime} AND #{endTime} + + AND api_scenario.create_time BETWEEN #{startTime} AND #{endTime} + and api_scenario.create_user in @@ -797,6 +801,16 @@ group by api_scenario.create_user; + + \ No newline at end of file diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.java index aadc4ac757..298c81ec3e 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.java @@ -121,8 +121,8 @@ public interface ExtBugMapper { @BaseConditionFilter List getIdsByProvider(@Param("request") AssociateBugRequest request, @Param("deleted") boolean deleted); - List projectBugCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); - List userCreateBugCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List projectBugCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); + List userCreateBugCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); /** * 根据处理人排序的处理人状态统计 @@ -133,6 +133,6 @@ public interface ExtBugMapper { * @param platforms 平台筛选 * @return 项目用户状态数量DTO */ - List projectUserBugStatusCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") List userIds, @Param("platforms") Set platforms); + List projectUserBugStatusCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") List userIds, @Param("platforms") Set platforms); } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml index 8a19f2a1dd..36ba146440 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugMapper.xml @@ -399,7 +399,9 @@ #{projectId} - AND bug.create_time BETWEEN #{startTime} AND #{endTime} + + AND bug.create_time BETWEEN #{startTime} AND #{endTime} + AND bug.create_user = #{userId} @@ -412,7 +414,9 @@ FROM bug WHERE bug.deleted = false AND bug.project_id = #{projectId} - AND bug.create_time BETWEEN #{startTime} AND #{endTime} + + AND bug.create_time BETWEEN #{startTime} AND #{endTime} + and bug.create_user in @@ -428,7 +432,9 @@ FROM bug WHERE bug.deleted = false AND bug.project_id = #{projectId} - AND bug.create_time BETWEEN #{startTime} AND #{endTime} + + AND bug.create_time BETWEEN #{startTime} AND #{endTime} + AND bug.handle_user != '' AND bug.handle_user IN diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.java index c345f367b6..9bbb486ba3 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.java @@ -44,9 +44,9 @@ public interface ExtCaseReviewMapper { String getReviewPassRule(@Param("id") String id); - List projectReviewCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + List projectReviewCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); - List userCreateReviewCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List userCreateReviewCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); /** * 获取各种状态总数量的评审 @@ -55,6 +55,6 @@ public interface ExtCaseReviewMapper { * @param endTime 时间过滤条件 * @return ProjectUserStatusCountDTO userId 在这里不返回 */ - List statusReviewCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); + List statusReviewCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml index 073b2d86c1..188b969c08 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewMapper.xml @@ -358,7 +358,9 @@ #{projectId} - AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + + AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + AND case_review.create_user = #{userId} @@ -370,7 +372,9 @@ SELECT case_review.create_user as userId, count(case_review.id) as count FROM case_review WHERE case_review.project_id = #{projectId} - AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + + AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + and case_review.create_user in @@ -383,7 +387,9 @@ SELECT case_review.status as status, count(case_review.id) as count FROM case_review WHERE case_review.project_id = #{projectId} - AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + + AND case_review.create_time BETWEEN #{startTime} AND #{endTime} + group by case_review.status; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.java index ec66af3027..c6dcd1f9da 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.java @@ -117,14 +117,14 @@ public interface ExtFunctionalCaseMapper { List getProjectIdByIds(@Param("ids") List ids); - List projectCaseCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + List projectCaseCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); - List userCreateCaseCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List userCreateCaseCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); - List getStatisticListByProjectId(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); + List getStatisticListByProjectId(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); - long caseTestCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); + long caseTestCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); - long simpleCaseCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); + long simpleCaseCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml index 674f6d3473..0de7a830ec 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml @@ -903,7 +903,9 @@ LEFT JOIN functional_case_custom_field fccf ON fccf.case_id = fc.id LEFT JOIN custom_field cf ON cf.id = fccf.field_id WHERE fc.deleted = false - AND fc.create_time BETWEEN #{startTime} AND #{endTime} + + AND fc.create_time BETWEEN #{startTime} AND #{endTime} + AND fc.project_id = #{projectId} AND cf.name = 'functional_priority' AND cf.scene = 'FUNCTIONAL' @@ -919,7 +921,9 @@ where fct.project_id = #{projectId} and fc.project_id = #{projectId} and fc.deleted = false - and fc.create_time between #{startTime} and #{endTime} + + AND fc.create_time BETWEEN #{startTime} AND #{endTime} + + + \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java index ee00aa76f1..8597c43e42 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java @@ -73,9 +73,9 @@ public interface ExtTestPlanMapper { List selectIdByProjectIdAndWithoutList(@Param("projectId") String projectId, @Param("withoutList") List withoutList); - List projectPlanCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + List projectPlanCount(@Param("projectIds") Set projectIds, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userId") String userId); - List userCreatePlanCount(@Param("projectId") String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userIds") Set userIds); + List userCreatePlanCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") Set userIds); @BaseConditionFilter diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml index c4e39b5619..a69b7ae127 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml @@ -746,7 +746,9 @@ #{projectId} - AND test_plan.create_time BETWEEN #{startTime} AND #{endTime} + + AND test_plan.create_time BETWEEN #{startTime} AND #{endTime} + AND test_plan.create_user = #{userId} @@ -758,7 +760,9 @@ SELECT test_plan.create_user as userId, count(test_plan.id) as count FROM test_plan WHERE test_plan.project_id = #{projectId} - AND test_plan.create_time BETWEEN #{startTime} AND #{endTime} + + AND test_plan.create_time BETWEEN #{startTime} AND #{endTime} + and test_plan.create_user in