From 08aad6f49074849bbaa818689c8cfbef0cdd8af3 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 24 Jun 2024 14:53:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E5=91=8A=E9=80=9A=E7=9F=A5=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E6=8F=BD=E5=AD=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1042840 --user=宋昌昌 【测试计划】报告-删除-接收人为创建人-删除人为其他用户-只有钉钉企业内部应用收到消息通知了 https://www.tapd.cn/55049933/s/1534860 --- .../system/notice/sender/AbstractNoticeSender.java | 10 ++++++++++ .../plan/service/TestPlanReportService.java | 2 +- .../plan/service/TestPlanSendNoticeService.java | 9 ++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AbstractNoticeSender.java b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AbstractNoticeSender.java index 2d26402e43..f2818923e2 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AbstractNoticeSender.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AbstractNoticeSender.java @@ -16,8 +16,10 @@ import io.metersphere.functional.mapper.FunctionalCaseMapper; import io.metersphere.plan.domain.TestPlan; import io.metersphere.plan.domain.TestPlanFollower; import io.metersphere.plan.domain.TestPlanFollowerExample; +import io.metersphere.plan.domain.TestPlanReport; import io.metersphere.plan.mapper.TestPlanFollowerMapper; import io.metersphere.plan.mapper.TestPlanMapper; +import io.metersphere.plan.mapper.TestPlanReportMapper; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.domain.Schedule; @@ -74,6 +76,8 @@ public abstract class AbstractNoticeSender implements NoticeSender { private ApiScenarioReportMapper apiScenarioReportMapper; @Resource private ScheduleMapper scheduleMapper; + @Resource + private TestPlanReportMapper testPlanReportMapper; protected String getContext(MessageDetail messageDetail, NoticeModel noticeModel) { @@ -251,6 +255,12 @@ public abstract class AbstractNoticeSender implements NoticeSender { receiver = new Receiver(schedule.getCreateUser(), NotificationConstants.Type.SYSTEM_NOTICE.name()); } } + case NoticeConstants.TaskType.TEST_PLAN_REPORT_TASK -> { + TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(id); + if (report != null) { + receiver = new Receiver(report.getCreateUser(), NotificationConstants.Type.SYSTEM_NOTICE.name()); + } + } default -> { } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index c8bfb94eca..66acd8c1e2 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -487,7 +487,7 @@ public class TestPlanReportService { // 发送计划执行通知 if (!useManual) { - testPlanSendNoticeService.sendExecuteNotice(planReport.getCreateUser(), planReport.getTestPlanId(), planReport.getProjectId(), planReport.getResultStatus()); + testPlanSendNoticeService.sendExecuteNotice(planReport.getCreateUser(), planReport.getTestPlanId(), planReport.getProjectId(), planReport.getResultStatus(), planReport.getTriggerMode()); } } 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 6c5e9b228c..154fcce994 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 @@ -10,6 +10,7 @@ import io.metersphere.plan.mapper.TestPlanConfigMapper; import io.metersphere.plan.mapper.TestPlanFollowerMapper; import io.metersphere.plan.mapper.TestPlanMapper; import io.metersphere.sdk.constants.ReportStatus; +import io.metersphere.sdk.constants.TaskTriggerMode; import io.metersphere.sdk.constants.TestPlanConstants; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; @@ -178,7 +179,7 @@ public class TestPlanSendNoticeService { * @param executeResult 执行结果 */ @Async - public void sendExecuteNotice(String currentUser, String planId, String projectId, String executeResult) { + public void sendExecuteNotice(String currentUser, String planId, String projectId, String executeResult, String triggerMode) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); if (testPlan != null) { User user = userMapper.selectByPrimaryKey(currentUser); @@ -193,11 +194,13 @@ public class TestPlanSendNoticeService { paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user.getName()); paramMap.put("name", testPlan.getName()); paramMap.put("projectId", projectId); + paramMap.put("id", planId); paramMap.put("Language", user.getLanguage()); NoticeModel noticeModel = NoticeModel.builder().operator(currentUser).excludeSelf(false) .context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ? - NoticeConstants.Event.EXECUTE_SUCCESSFUL : NoticeConstants.Event.EXECUTE_FAIL).build(); - noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel); + NoticeConstants.Event.EXECUTE_SUCCESSFUL : NoticeConstants.Event.EXECUTE_FAILED).build(); + noticeSendService.send(StringUtils.equals(TaskTriggerMode.API.name(), triggerMode) ? + NoticeConstants.TaskType.JENKINS_TASK : NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel); } } }