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); } } }