diff --git a/backend/framework/sdk/src/main/resources/i18n/plan.properties b/backend/framework/sdk/src/main/resources/i18n/plan.properties index 57a9c064da..7d89aef490 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan.properties @@ -128,4 +128,12 @@ test_plan.mind.case_count=用例数 test_plan.mind.environment=环境 test_plan.mind.test_resource_pool=资源池 test_plan.mind.collection_name_repeat=测试集名称重复 - +# 计划状态国际化 +test_plan.status.pending=未执行 +test_plan.status.running=执行中 +test_plan.status.stopped=已停止 +test_plan.status.completed=已完成 +test_plan.status.success=成功 +test_plan.status.error=失败 +test_plan.status.prepared=未开始 +test_plan.status.underway=进行中 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties index d254aecdb2..937f72049b 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_en_US.properties @@ -132,3 +132,12 @@ test_plan.mind.environment=Environment test_plan.mind.test_resource_pool=Resource pool test_plan.mind.collection_name_repeat=Duplicate test set name test_plan.collection_not_exist=Test plan collection does not exist +# plan status i18n +test_plan.status.pending=Pending +test_plan.status.running=Running +test_plan.status.stopped=Stopped +test_plan.status.completed=Completed +test_plan.status.success=Success +test_plan.status.error=Error +test_plan.status.prepared=Prepared +test_plan.status.underway=Underway \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties index 082281ad48..36f53131ab 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_CN.properties @@ -132,3 +132,12 @@ test_plan.mind.environment=环境 test_plan.mind.test_resource_pool=资源池 test_plan.mind.collection_name_repeat=测试集名称重复 test_plan.collection_not_exist=测试集不存在 +# 计划状态国际化 +test_plan.status.pending=未执行 +test_plan.status.running=执行中 +test_plan.status.stopped=已停止 +test_plan.status.completed=已完成 +test_plan.status.success=成功 +test_plan.status.error=失败 +test_plan.status.prepared=未开始 +test_plan.status.underway=进行中 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties index 756040b9dc..063ba6ae3c 100644 --- a/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/plan_zh_TW.properties @@ -131,3 +131,12 @@ test_plan.mind.environment=環境 test_plan.mind.test_resource_pool=資源池 test_plan.mind.collection_name_repeat=測試集名稱重複 test_plan.collection_not_exist=測試集不存在 +# 计划状态国际化 +test_plan.status.pending=未執行 +test_plan.status.running=執行中 +test_plan.status.stopped=已停止 +test_plan.status.completed=已完成 +test_plan.status.success=成功 +test_plan.status.error=失敗 +test_plan.status.prepared=未開始 +test_plan.status.underway=進行中 \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/enums/TestPlanStatus.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/enums/TestPlanStatus.java new file mode 100644 index 0000000000..0a0ce27900 --- /dev/null +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/enums/TestPlanStatus.java @@ -0,0 +1,71 @@ +package io.metersphere.plan.enums; + +import io.metersphere.sdk.util.Translator; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +public enum TestPlanStatus { + + // 执行状态 (报告) + + /** + * 未执行 + */ + PENDING("PENDING", "test_plan.status.pending"), + /** + * 执行中 + */ + RUNNING("RUNNING", "test_plan.status.running"), + /** + * 已停止 + */ + STOPPED("STOPPED", "test_plan.status.stopped"), + /** + * 已完成 + */ + COMPLETED("COMPLETED", "test_plan.status.completed"), + + // 结果状态 (报告) + + /** + * 成功 + */ + SUCCESS("SUCCESS", "test_plan.status.success"), + /** + * 失败 + */ + ERROR("ERROR", "test_plan.status.error"), + + // 状态 (计划) + + /** + * 未开始 + */ + PREPARED("PREPARED", "test_plan.status.prepared"), + /** + * 进行中 + */ + UNDERWAY("UNDERWAY", "test_plan.status.underway"); + + @Getter + private final String name; + private final String i18nText; + + TestPlanStatus(String name, String i18nText) { + this.name = name; + this.i18nText = i18nText; + } + + public String getI18nText() { + return Translator.get(i18nText); + } + + public static String getI18nText(String name) { + for (TestPlanStatus status : TestPlanStatus.values()) { + if (StringUtils.equals(status.getName(), name)) { + return status.getI18nText(); + } + } + return name; + } +} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanSendNoticeService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanSendNoticeService.java index b6b312e734..f99c2971f3 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanSendNoticeService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanSendNoticeService.java @@ -8,6 +8,8 @@ import io.metersphere.plan.dto.TestPlanShareInfo; import io.metersphere.plan.dto.request.TestPlanCreateRequest; import io.metersphere.plan.dto.request.TestPlanReportShareRequest; import io.metersphere.plan.dto.request.TestPlanUpdateRequest; +import io.metersphere.plan.dto.response.TestPlanStatisticsResponse; +import io.metersphere.plan.enums.TestPlanStatus; import io.metersphere.plan.mapper.TestPlanConfigMapper; import io.metersphere.plan.mapper.TestPlanFollowerMapper; import io.metersphere.plan.mapper.TestPlanMapper; @@ -64,6 +66,8 @@ public class TestPlanSendNoticeService { private ProjectMapper projectMapper; @Resource private TestPlanReportShareService testPlanReportShareService; + @Resource + private TestPlanStatisticsService testPlanStatisticsService; public void sendNoticeCase(List relatedUsers, String userId, String caseId, String task, String event, String testPlanId) { FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId); @@ -232,6 +236,7 @@ public class TestPlanSendNoticeService { */ private TestPlanMessageDTO buildMessageNotice(String planId, TestPlanReport report, String currentUser) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); + TestPlanStatisticsResponse statistics = testPlanStatisticsService.calculateRate(List.of(planId)).getFirst(); // 报告URL Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId()); SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); @@ -247,15 +252,15 @@ public class TestPlanSendNoticeService { shareRequest.setShareType("TEST_PLAN_SHARE_REPORT"); TestPlanShareInfo shareInfo = testPlanReportShareService.gen(shareRequest, currentUser); String reportShareUrl = baseSystemConfigDTO.getUrl() + "/#/share/shareReportTestPlan?type=" + - (report.getIntegrated() ? TestPlanConstants.TEST_PLAN_TYPE_GROUP : TestPlanConstants.TEST_PLAN_TYPE_PLAN) + "shareId=" + shareInfo.getId(); + (report.getIntegrated() ? TestPlanConstants.TEST_PLAN_TYPE_GROUP : TestPlanConstants.TEST_PLAN_TYPE_PLAN) + "&shareId=" + shareInfo.getId(); return TestPlanMessageDTO.builder() - .num(testPlan.getNum().toString()).name(testPlan.getName()).status(testPlan.getStatus()).type(testPlan.getType()).tags(testPlan.getTags()) + .num(testPlan.getNum().toString()).name(testPlan.getName()).status(TestPlanStatus.getI18nText(statistics.getStatus())).type(testPlan.getType()).tags(testPlan.getTags()) .createUser(testPlan.getCreateUser()).createTime(testPlan.getCreateTime()).updateUser(testPlan.getUpdateUser()).updateTime(testPlan.getUpdateTime()) .plannedStartTime(testPlan.getPlannedStartTime()).plannedEndTime(testPlan.getPlannedEndTime()) .actualStartTime(testPlan.getActualStartTime()).actualEndTime(testPlan.getActualEndTime()) .description(testPlan.getDescription()).reportName(report.getName()).reportUrl(reportUrl).reportShareUrl(reportShareUrl) - .startTime(report.getStartTime()).endTime(report.getEndTime()).execStatus(report.getExecStatus()).resultStatus(report.getResultStatus()) - .passRate(report.getPassRate()).passThreshold(report.getPassThreshold()).executeRate(report.getExecuteRate()) + .startTime(report.getStartTime()).endTime(report.getEndTime()).execStatus(TestPlanStatus.getI18nText(report.getExecStatus())) + .resultStatus(TestPlanStatus.getI18nText(report.getResultStatus())).passRate(report.getPassRate()).passThreshold(report.getPassThreshold()).executeRate(report.getExecuteRate()) .build(); } }