From 3cac84c2a2912aeee01f4121b65805d6723c109b Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 25 Aug 2021 15:37:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=8F=91=E9=80=81=E7=BB=93=E6=9D=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/notice/PerformanceNoticeEvent.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java index 187ca9a659..5860fce7fa 100644 --- a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java +++ b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeEvent.java @@ -8,9 +8,11 @@ import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.consumer.LoadTestFinishEvent; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.BaseSystemConfigDTO; +import io.metersphere.dto.LoadTestDTO; import io.metersphere.i18n.Translator; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; +import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.ProjectService; import io.metersphere.service.SystemParameterService; import org.apache.commons.beanutils.BeanMap; @@ -29,6 +31,8 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent { private NoticeSendService noticeSendService; @Resource private ProjectService projectService; + @Resource + private PerformanceTestService performanceTestService; public void sendNotice(LoadTestReport loadTestReport) { @@ -55,11 +59,14 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent { if (PerformanceTestStatus.Error.name().equals(loadTestReport.getStatus())) { event = NoticeConstants.Event.EXECUTE_FAILED; } + + LoadTestDTO loadTestDTO = performanceTestService.get(loadTestReport.getTestId()); + Map paramMap = new HashMap<>(); paramMap.put("operator", loadTestReport.getUserId()); paramMap.put("type", "performance"); paramMap.put("url", baseSystemConfigDTO.getUrl()); - paramMap.putAll(new BeanMap(loadTestReport)); + paramMap.putAll(new BeanMap(loadTestDTO)); NoticeModel noticeModel = NoticeModel.builder() .operator(loadTestReport.getUserId()) .successContext(successContext) @@ -73,13 +80,13 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent { .paramMap(paramMap) .build(); - Organization organization = projectService.getOrganizationByProjectId(loadTestReport.getProjectId()); if (StringUtils.equals(ReportTriggerMode.API.name(), loadTestReport.getTriggerMode()) || StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), loadTestReport.getTriggerMode())) { noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel); } else { - String context = "${operator}执行了性能测试: ${name}, 执行结果: ${status}"; + Organization organization = projectService.getOrganizationByProjectId(loadTestReport.getProjectId()); + String context = "${operator}执行性能测试完成: ${name}"; NoticeModel noticeModel2 = NoticeModel.builder() .operator(loadTestReport.getUserId()) .context(context)