fix(项目设置): 执行测试计划消息模板通知stage, status字段翻译

--bug=1028176 --user=宋昌昌 【测试跟踪】执行测试计划-通知中的stage字段值仍是英文 https://www.tapd.cn/55049933/s/1398452
This commit is contained in:
song-cc-rock 2023-07-27 11:50:37 +08:00 committed by 刘瑞斌
parent 366ee0a820
commit e52feb6814
4 changed files with 39 additions and 14 deletions

View File

@ -36,8 +36,6 @@ public class AfterReturningNoticeSendService {
paramMap.putIfAbsent("projectId", currentProjectId);
// 占位符
handleDefaultValues(paramMap);
// 处理resource中特殊值
handleSpecialValues(paramMap);
String context = getContext(sendNotice, paramMap);
@ -61,14 +59,6 @@ public class AfterReturningNoticeSendService {
paramMap.put("planShareUrl", StringUtils.EMPTY); // 占位符
}
private void handleSpecialValues(Map paramMap) {
// 翻译${stage}占位符
String key = "stage";
if (paramMap.containsKey(key) && paramMap.get(key) != null) {
paramMap.put(key, StatusReference.statusMap.get(paramMap.get("stage").toString()));
}
}
private String getContext(SendNotice sendNotice, Map<String, Object> paramMap) {
String operation = "";
switch (sendNotice.event()) {

View File

@ -12,6 +12,7 @@ import io.metersphere.dto.TestPlanDTOWithMetric;
import io.metersphere.dto.TestPlanRerunParametersDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.log.vo.StatusReference;
import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import io.metersphere.plan.dto.TestPlanDTO;
@ -133,7 +134,10 @@ public class TestPlanController {
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.CREATE, subject = "测试计划通知")
public TestPlan addTestPlan(@RequestBody AddTestPlanRequest testPlan) {
testPlan.setId(UUID.randomUUID().toString());
return testPlanService.addTestPlan(testPlan);
TestPlan result = testPlanService.addTestPlan(testPlan);
result.setStage(StatusReference.statusMap.containsKey(result.getStage()) ? StatusReference.statusMap.get(result.getStage()) : result.getStage());
result.setStatus(StatusReference.statusMap.containsKey(result.getStatus()) ? StatusReference.statusMap.get(result.getStatus()) : result.getStatus());
return result;
}
@PostMapping("/edit")
@ -141,7 +145,10 @@ public class TestPlanController {
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.UPDATE, subject = "测试计划通知")
public TestPlan editTestPlan(@RequestBody AddTestPlanRequest testPlanDTO) {
return testPlanService.editTestPlanWithRequest(testPlanDTO);
TestPlan testPlan = testPlanService.editTestPlanWithRequest(testPlanDTO);
testPlan.setStage(StatusReference.statusMap.containsKey(testPlan.getStage()) ? StatusReference.statusMap.get(testPlan.getStage()) : testPlan.getStage());
testPlan.setStatus(StatusReference.statusMap.containsKey(testPlan.getStatus()) ? StatusReference.statusMap.get(testPlan.getStatus()) : testPlan.getStatus());
return testPlan;
}
@PostMapping("/fresh/{planId}")
@ -179,7 +186,7 @@ public class TestPlanController {
@PostMapping("/delete/{testPlanId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_DELETE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, target = "#targetClass.get(#testPlanId)", targetClass = TestPlanService.class,
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, target = "#targetClass.getTransferPlan(#testPlanId)", targetClass = TestPlanService.class,
event = NoticeConstants.Event.DELETE, subject = "测试计划通知")
public int deleteTestPlan(@PathVariable String testPlanId) {
checkPermissionService.checkTestPlanOwner(testPlanId);
@ -228,7 +235,10 @@ public class TestPlanController {
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.COPY, content = "#msClass.getLogDetails(#id)", msClass = TestPlanService.class)
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.CREATE, subject = "测试计划通知")
public TestPlan copy(@PathVariable String id) {
return testPlanService.copy(id);
TestPlan result = testPlanService.copy(id);
result.setStage(StatusReference.statusMap.containsKey(result.getStage()) ? StatusReference.statusMap.get(result.getStage()) : result.getStage());
result.setStatus(StatusReference.statusMap.containsKey(result.getStatus()) ? StatusReference.statusMap.get(result.getStatus()) : result.getStatus());
return result;
}
@PostMapping("/api/case/env")

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.HttpHeaderUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.*;
import io.metersphere.log.vo.StatusReference;
import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.plan.dto.TestPlanReportDataStruct;
@ -123,6 +124,7 @@ public class TestPlanMessageService {
String testPlanShareUrl = getTestPlanShareUrl(testPlanReport.getId(), creator);
// 分享经过网关需要带上前缀
paramMap.put("planShareUrl", baseSystemConfigDTO.getUrl() + "/track/share-plan-report" + testPlanShareUrl);
handleSpecialValues(paramMap);
/**
* 测试计划的消息通知配置包括 完成成功失败
@ -171,6 +173,19 @@ public class TestPlanMessageService {
return baseShareInfoService.conversionShareInfoToDTO(shareInfo).getShareUrl();
}
private void handleSpecialValues(Map paramMap) {
// 翻译${stage}占位符
String stageKey = "stage";
if (paramMap.containsKey(stageKey) && paramMap.get(stageKey) != null) {
paramMap.put(stageKey, StatusReference.statusMap.get(paramMap.get(stageKey).toString()));
}
// 翻译${status}占位符
String statusKey = "status";
if (paramMap.containsKey(statusKey) && paramMap.get(statusKey) != null) {
paramMap.put(statusKey, StatusReference.statusMap.get(paramMap.get(statusKey).toString()));
}
}
private Map<String, Long> calculateCaseCount(TestPlanReportDataStruct report) {
Map<String, Long> result = new HashMap<>();
// 功能用例

View File

@ -20,6 +20,7 @@ import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.StatusReference;
import io.metersphere.log.vo.track.TestPlanReference;
import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.TestPlanDTO;
@ -215,6 +216,15 @@ public class TestPlanService {
return testPlanMapper.selectByPrimaryKey(testPlanId);
}
public TestPlanWithBLOBs getTransferPlan(String testPlanId) {
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanId);
if (testPlan != null) {
testPlan.setStage(StatusReference.statusMap.containsKey(testPlan.getStage()) ? StatusReference.statusMap.get(testPlan.getStage()) : testPlan.getStage());
testPlan.setStatus(StatusReference.statusMap.containsKey(testPlan.getStatus()) ? StatusReference.statusMap.get(testPlan.getStatus()) : testPlan.getStatus());
}
return testPlan;
}
public TestPlan editTestPlanWithRequest(AddTestPlanRequest request) {
List<String> principals = request.getPrincipals();
if (!CollectionUtils.isEmpty(principals)) {