From c0d933b94b6f89e674d754c5221cf41aa2275fee Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Tue, 3 Nov 2020 18:30:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A8=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/notice/service/MailService.java | 13 ++++++++----- .../performance/service/PerformanceTestService.java | 1 - .../track/service/TestCaseReviewService.java | 10 ++++++---- .../metersphere/track/service/TestPlanService.java | 11 +++++++---- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index d750768e89..b39564c1e7 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -1,9 +1,7 @@ package io.metersphere.notice.service; -import io.metersphere.base.domain.ApiTestReport; -import io.metersphere.base.domain.LoadTestReportWithBLOBs; -import io.metersphere.base.domain.SystemParameter; -import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.UserMapper; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.ParamConstants; @@ -46,6 +44,8 @@ public class MailService { private UserService userService; @Resource private SystemParameterService systemParameterService; + @Resource + private UserMapper userMapper; //接口和性能测试 public void sendLoadNotification(MessageDetail messageDetail, LoadTestReportWithBLOBs loadTestReport, String eventType) { @@ -297,7 +297,8 @@ public class MailService { Map context = new HashMap<>(); BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); context.put("url", baseSystemConfigDTO.getUrl()); - context.put("creator", reviewRequest.getCreator()); + User user = userMapper.selectByPrimaryKey(reviewRequest.getCreator()); + context.put("creator", user.getName()); context.put("reviewName", reviewRequest.getName()); context.put("start", start); context.put("end", end); @@ -328,6 +329,8 @@ public class MailService { context.put("start", start); context.put("end", end); context.put("id", testPlan.getId()); + User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); + context.put("creator", user.getName()); return context; } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 96b1123c33..d342ec32c6 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -229,7 +229,6 @@ public class PerformanceTestService { startEngine(loadTest, engine, request.getTriggerMode()); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(engine.getReportId()); - loadTestReport.setTriggerMode("API"); if (StringUtils.equals(NoticeConstants.API, loadTestReport.getTriggerMode()) || StringUtils.equals(NoticeConstants.SCHEDULE, loadTestReport.getTriggerMode())) { performanceNoticeTask.registerNoticeTask(loadTestReport); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index a08e4de8f8..8a76212498 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -561,7 +561,9 @@ public class TestCaseReviewService { } /*编辑,新建,完成,删除通知内容*/ - private static String getReviewContext(SaveTestCaseReviewRequest reviewRequest, String type) { + private String getReviewContext(SaveTestCaseReviewRequest reviewRequest, String type) { + + User user = userMapper.selectByPrimaryKey(reviewRequest.getCreator()); Long startTime = reviewRequest.getCreateTime(); Long endTime = reviewRequest.getEndTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -577,11 +579,11 @@ public class TestCaseReviewService { } String context = ""; if (StringUtils.equals(NoticeConstants.CREATE, type)) { - context = "测试评审任务通知:" + reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; + context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { - context = "测试评审任务通知:" + reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; + context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; } else if (StringUtils.equals(NoticeConstants.DELETE, type)) { - context = "测试评审任务通知:" + reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; + context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; } return context; diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 4467628bcf..1f38e75c0d 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -93,6 +93,8 @@ public class TestPlanService { DingTaskService dingTaskService; @Resource WxChatTaskService wxChatTaskService; + @Resource + UserMapper userMapper; public void addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -534,7 +536,8 @@ public class TestPlanService { return projectName; } - private static String getTestPlanContext(AddTestPlanRequest testPlan, String type) { + private String getTestPlanContext(AddTestPlanRequest testPlan, String type) { + User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); Long startTime = testPlan.getPlannedStartTime(); Long endTime = testPlan.getPlannedEndTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -554,11 +557,11 @@ public class TestPlanService { } String context = ""; if (StringUtils.equals(NoticeConstants.CREATE, type)) { - context = "测试计划任务通知:" + testPlan.getCreator() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { - context = "测试计划任务通知:" + testPlan.getCreator() + "创建的" + "'" + testPlan.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; } else if (StringUtils.equals(NoticeConstants.DELETE, type)) { - context = "测试计划任务通知:" + testPlan.getCreator() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; } return context; }