From dd39e55f76c78e5e863c41f4e77f75d5365e003c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 26 Jan 2022 18:21:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/ApiScenarioExecuteService.java | 18 ++++++++---------- .../api/service/RemakeReportService.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 1f73659301..9604d9c7e9 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -119,7 +119,8 @@ public class ApiScenarioExecuteService { LoggerUtil.info("Scenario run-执行脚本装载-开始针对所有执行场景进行环境检查"); apiScenarioEnvService.checkEnv(request, apiScenarios); // 集合报告设置 - if (request.getConfig() != null && StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString()) && StringUtils.isNotEmpty(request.getConfig().getReportName())) { + if (request.getConfig() != null && StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString()) + && StringUtils.isNotEmpty(request.getConfig().getReportName())) { if (request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { request.setExecuteType(ExecuteType.Completed.name()); } else { @@ -159,7 +160,8 @@ public class ApiScenarioExecuteService { responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(scenarioIds), serialReportId, request.getRunMode())); // 增加并行集合报告 if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.PARALLEL.toString())) { - apiScenarioReportStructureService.save(apiScenarios, serialReportId, request.getConfig() != null ? request.getConfig().getReportType() : null); + apiScenarioReportStructureService.save(apiScenarios, serialReportId, request.getConfig() != null + ? request.getConfig().getReportType() : null); } } // 开始执行 @@ -278,16 +280,12 @@ public class ApiScenarioExecuteService { executeQueue.put(report.getId(), runModeDataDTO); } catch (Exception ex) { scenarioIds.remove(scenario.getId()); - if (StringUtils.equalsAny(request.getTriggerMode(), TriggerMode.BATCH.name(), TriggerMode.SCHEDULE.name())) { - remakeReportService.remakeScenario(request.getRunMode(), testPlanScenarioId, scenario, report); - } else { - MSException.throwException(ex); - } + executeQueue.remove(report.getId()); + remakeReportService.remakeScenario(request.getRunMode(), testPlanScenarioId, scenario, report); + continue; } } - scenarioNames.append(scenario.getName()).append(","); - // 生成文档结构 if (request.getConfig() == null || !StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())) { apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null); @@ -323,8 +321,8 @@ public class ApiScenarioExecuteService { runModeDataDTO.setReportId(report.getId()); executeQueue.put(report.getId(), runModeDataDTO); } else { - // 生成报告和HashTree try { + // 生成报告和HashTree RunModeDataDTO runModeDataDTO = new RunModeDataDTO(report, item.getId()); if (request.getConfig() != null && !request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { HashTree hashTree = GenerateHashTreeUtil.generateHashTree(item, StringUtils.isNotEmpty(serialReportId) ? serialReportId + "-" + i : reportId, request.getConfig().getEnvMap(), request.getConfig().getReportType()); diff --git a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java index 780a196192..03b4ec0c24 100644 --- a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java @@ -143,6 +143,6 @@ public class RemakeReportService { apiScenarioMapper.updateByPrimaryKey(scenarioWithBLOBs); } report.setStatus(APITestStatus.Error.name()); - apiScenarioReportMapper.insert(report); + apiScenarioReportMapper.updateByPrimaryKeySelective(report); } }