fix(接口测试): 修复场景调试历史报告内容为空问题

This commit is contained in:
fit2-zhao 2021-12-31 13:38:16 +08:00 committed by fit2-zhao
parent d3a19ff0a0
commit 72ae634e51
1 changed files with 12 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import io.metersphere.dto.JmeterRunRequestDTO;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.plugin.core.MsTestElement;
import io.metersphere.service.EnvironmentGroupProjectService;
import io.metersphere.track.service.TestPlanScenarioCaseService;
import io.metersphere.utils.LoggerUtil;
@ -376,13 +377,23 @@ public class ApiScenarioExecuteService {
} catch (Exception e) {
MSException.throwException(e.getMessage());
}
APIScenarioReportResult report = apiScenarioReportService.init(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(),
SessionUtils.getUserId(), request.getConfig(), request.getId());
apiScenarioReportMapper.insert(report);
if (request.isSaved()) {
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(request.getScenarioId());
apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null);
} else {
if (request.getTestElement() != null && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree())) {
ApiScenarioWithBLOBs scenario = new ApiScenarioWithBLOBs();
scenario.setId(request.getScenarioId());
MsTestElement testElement = request.getTestElement().getHashTree().get(0).getHashTree().get(0);
if (testElement != null) {
scenario.setName(testElement.getName());
scenario.setScenarioDefinition(JSON.toJSONString(testElement));
apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null);
}
}
}
uploadBodyFiles(request.getBodyFileRequestIds(), bodyFiles);
FileUtils.createBodyFiles(request.getScenarioFileIds(), scenarioFiles);