fix(消息通知): 计划执行失败通知的问题
--bug=1045197 --user=宋昌昌 【消息通知】测试计划执行失败的消息通知i中分享报告链接打开是假数据 https://www.tapd.cn/55049933/s/1563420
This commit is contained in:
parent
e3f73e8c27
commit
96190735b2
|
@ -128,4 +128,12 @@ test_plan.mind.case_count=用例数
|
||||||
test_plan.mind.environment=环境
|
test_plan.mind.environment=环境
|
||||||
test_plan.mind.test_resource_pool=资源池
|
test_plan.mind.test_resource_pool=资源池
|
||||||
test_plan.mind.collection_name_repeat=测试集名称重复
|
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=进行中
|
|
@ -132,3 +132,12 @@ test_plan.mind.environment=Environment
|
||||||
test_plan.mind.test_resource_pool=Resource pool
|
test_plan.mind.test_resource_pool=Resource pool
|
||||||
test_plan.mind.collection_name_repeat=Duplicate test set name
|
test_plan.mind.collection_name_repeat=Duplicate test set name
|
||||||
test_plan.collection_not_exist=Test plan collection does not exist
|
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
|
|
@ -132,3 +132,12 @@ test_plan.mind.environment=环境
|
||||||
test_plan.mind.test_resource_pool=资源池
|
test_plan.mind.test_resource_pool=资源池
|
||||||
test_plan.mind.collection_name_repeat=测试集名称重复
|
test_plan.mind.collection_name_repeat=测试集名称重复
|
||||||
test_plan.collection_not_exist=测试集不存在
|
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=进行中
|
|
@ -131,3 +131,12 @@ test_plan.mind.environment=環境
|
||||||
test_plan.mind.test_resource_pool=資源池
|
test_plan.mind.test_resource_pool=資源池
|
||||||
test_plan.mind.collection_name_repeat=測試集名稱重複
|
test_plan.mind.collection_name_repeat=測試集名稱重複
|
||||||
test_plan.collection_not_exist=測試集不存在
|
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=進行中
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ import io.metersphere.plan.dto.TestPlanShareInfo;
|
||||||
import io.metersphere.plan.dto.request.TestPlanCreateRequest;
|
import io.metersphere.plan.dto.request.TestPlanCreateRequest;
|
||||||
import io.metersphere.plan.dto.request.TestPlanReportShareRequest;
|
import io.metersphere.plan.dto.request.TestPlanReportShareRequest;
|
||||||
import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
|
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.TestPlanConfigMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
|
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
|
@ -64,6 +66,8 @@ public class TestPlanSendNoticeService {
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanReportShareService testPlanReportShareService;
|
private TestPlanReportShareService testPlanReportShareService;
|
||||||
|
@Resource
|
||||||
|
private TestPlanStatisticsService testPlanStatisticsService;
|
||||||
|
|
||||||
public void sendNoticeCase(List<String> relatedUsers, String userId, String caseId, String task, String event, String testPlanId) {
|
public void sendNoticeCase(List<String> relatedUsers, String userId, String caseId, String task, String event, String testPlanId) {
|
||||||
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId);
|
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId);
|
||||||
|
@ -232,6 +236,7 @@ public class TestPlanSendNoticeService {
|
||||||
*/
|
*/
|
||||||
private TestPlanMessageDTO buildMessageNotice(String planId, TestPlanReport report, String currentUser) {
|
private TestPlanMessageDTO buildMessageNotice(String planId, TestPlanReport report, String currentUser) {
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
|
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
|
||||||
|
TestPlanStatisticsResponse statistics = testPlanStatisticsService.calculateRate(List.of(planId)).getFirst();
|
||||||
// 报告URL
|
// 报告URL
|
||||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||||
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
|
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
|
||||||
|
@ -247,15 +252,15 @@ public class TestPlanSendNoticeService {
|
||||||
shareRequest.setShareType("TEST_PLAN_SHARE_REPORT");
|
shareRequest.setShareType("TEST_PLAN_SHARE_REPORT");
|
||||||
TestPlanShareInfo shareInfo = testPlanReportShareService.gen(shareRequest, currentUser);
|
TestPlanShareInfo shareInfo = testPlanReportShareService.gen(shareRequest, currentUser);
|
||||||
String reportShareUrl = baseSystemConfigDTO.getUrl() + "/#/share/shareReportTestPlan?type=" +
|
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()
|
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())
|
.createUser(testPlan.getCreateUser()).createTime(testPlan.getCreateTime()).updateUser(testPlan.getUpdateUser()).updateTime(testPlan.getUpdateTime())
|
||||||
.plannedStartTime(testPlan.getPlannedStartTime()).plannedEndTime(testPlan.getPlannedEndTime())
|
.plannedStartTime(testPlan.getPlannedStartTime()).plannedEndTime(testPlan.getPlannedEndTime())
|
||||||
.actualStartTime(testPlan.getActualStartTime()).actualEndTime(testPlan.getActualEndTime())
|
.actualStartTime(testPlan.getActualStartTime()).actualEndTime(testPlan.getActualEndTime())
|
||||||
.description(testPlan.getDescription()).reportName(report.getName()).reportUrl(reportUrl).reportShareUrl(reportShareUrl)
|
.description(testPlan.getDescription()).reportName(report.getName()).reportUrl(reportUrl).reportShareUrl(reportShareUrl)
|
||||||
.startTime(report.getStartTime()).endTime(report.getEndTime()).execStatus(report.getExecStatus()).resultStatus(report.getResultStatus())
|
.startTime(report.getStartTime()).endTime(report.getEndTime()).execStatus(TestPlanStatus.getI18nText(report.getExecStatus()))
|
||||||
.passRate(report.getPassRate()).passThreshold(report.getPassThreshold()).executeRate(report.getExecuteRate())
|
.resultStatus(TestPlanStatus.getI18nText(report.getResultStatus())).passRate(report.getPassRate()).passThreshold(report.getPassThreshold()).executeRate(report.getExecuteRate())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue