fix(测试跟踪): 修复测试跟踪首页7天失败用例查询不到执行测试计划时的场景用例的问题

--bug=1021365 --user=宋天阳 【测试跟踪】首页-过去7天测试计划失败用例TOP 10-没统计失败的场景和性能用例
https://www.tapd.cn/55049933/s/1320810
This commit is contained in:
song-tianyang 2022-12-29 16:31:10 +08:00 committed by 建国
parent f043506e42
commit 5639088349
1 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import io.metersphere.api.exec.scenario.ApiEnvironmentRunningParamService;
import io.metersphere.api.jmeter.utils.ReportStatusUtil;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.PropertyConstant;
@ -53,6 +54,8 @@ public class TestResultService {
private ApiScenarioReportStructureService apiScenarioReportStructureService;
@Resource
private ApiTestCaseService apiTestCaseService;
@Resource
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
// 场景
private static final List<String> scenarioRunModes = new ArrayList<>() {{
@ -209,6 +212,14 @@ public class TestResultService {
environment = apiScenarioReportService.getEnvironment(apiScenario);
userName = apiAutomationService.getUser(apiScenario.getUserId());
principal = apiAutomationService.getUser(apiScenario.getPrincipal());
} else {
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(scenarioReport.getScenarioId());
if (testPlanApiScenario != null) {
apiScenario = apiScenarioMapper.selectByPrimaryKey(testPlanApiScenario.getApiScenarioId());
if (apiScenario != null) {
scenarioExecutionInfoService.insertExecutionInfo(testPlanApiScenario.getId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode(), scenarioReport.getProjectId() == null ? apiScenario.getProjectId() : scenarioReport.getProjectId(), ExecutionExecuteTypeEnum.TEST_PLAN.name(), apiScenario.getVersionId());
}
}
}
//报告内容