fix(测试计划): 修复定时任务执行测试计划后发送通知后台报服务调用错误的问题

This commit is contained in:
CaptainB 2023-01-09 17:11:08 +08:00 committed by 刘瑞斌
parent 582805e52b
commit 71336dda57
1 changed files with 6 additions and 3 deletions

View File

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