From 28b96fdf366982c4403d6e2cc1c117ef6df9c535 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 9 Jan 2023 17:11:08 +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=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=90=8E=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=80=9A=E7=9F=A5=E5=90=8E=E5=8F=B0=E6=8A=A5=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E8=B0=83=E7=94=A8=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/plan/service/TestPlanMessageService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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);