diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java index ff2f3baf23..faa4e78a44 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java @@ -57,6 +57,8 @@ public class TestPlanMessageService { report = testPlanReportService.checkTestPlanReportHasErrorCase(report, testPlanReportContent); } if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting() && !report.getIsUiScenarioExecuting()) { + // 异步发送通知需要指定调用其他服务的user + HttpHeaderUtils.runAsUser(report.getCreator()); //更新TestPlan状态为完成 TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId()); if (testPlan != null @@ -76,11 +78,13 @@ public class TestPlanMessageService { } } catch (Exception e) { LogUtil.error(e); + } finally { + HttpHeaderUtils.clearUser(); } } } - public String calcTestPlanStatusWithPassRate(TestPlanWithBLOBs testPlan) { + private String calcTestPlanStatusWithPassRate(TestPlanWithBLOBs testPlan) { try { // 计算通过率 TestPlanDTOWithMetric testPlanDTOWithMetric = BeanUtils.copyBean(new TestPlanDTOWithMetric(), testPlan); @@ -114,8 +118,7 @@ public class TestPlanMessageService { return TestPlanStatus.Underway.name(); } - @Async - public void sendMessage(TestPlan testPlan, TestPlanReport testPlanReport, String projectId) { + private void sendMessage(TestPlan testPlan, TestPlanReport testPlanReport, String projectId) { assert testPlan != null; SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); NoticeSendService noticeSendService = CommonBeanFactory.getBean(NoticeSendService.class);