diff --git a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/EnterpriseTestReportService.java b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/EnterpriseTestReportService.java index bade9257b5..ee57067baf 100644 --- a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/EnterpriseTestReportService.java +++ b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/EnterpriseTestReportService.java @@ -374,8 +374,8 @@ public class EnterpriseTestReportService { } reportContent.append(previweContent); } else if (isReportStep(step.getType())) { - if (isSchedule) { - //定时任务触发的数据,需要检查图片是否需要重新生成。如果生成不成功就不贴图 + if (isSchedule && syncReportMap.containsKey(step.getReportRecordId())) { + //定时任务触发的数据,需要检查图片是否需要重新生成。如果生成失败,syncReportMap里有对应的步骤id,但是没有图片数据 String imageFile = syncReportMap.get(step.getReportRecordId()); if (StringUtils.isNotEmpty(imageFile)) { step.setRecordImageContent(imageFile); diff --git a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/utils/ChromeUtil.java b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/utils/ChromeUtil.java index 75f0bf6624..8943985821 100644 --- a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/utils/ChromeUtil.java +++ b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/utils/ChromeUtil.java @@ -47,10 +47,6 @@ public class ChromeUtil { try { driver = new RemoteWebDriver(new URL(seleniumUrl), options); } catch (Exception e) { - if (driver != null) { - driver.quit(); - driver = null; - } LogUtil.error(e); } return driver; @@ -66,6 +62,7 @@ public class ChromeUtil { for (Map.Entry urlEntry : request.getUrlMap().entrySet()) { String id = urlEntry.getKey(); String url = urlEntry.getValue(); + String files = null; try { driver.get(url); driver.manage().window().fullscreen(); @@ -77,20 +74,14 @@ public class ChromeUtil { " imageUrl = chartsCanvas && chartsCanvas.toDataURL('image/png');" + "return imageUrl;" + "}"; - String files = ((JavascriptExecutor) driver).executeScript(js).toString(); - if (StringUtils.isNotEmpty(files)) { - returnMap.put(id, files); - } + files = ((JavascriptExecutor) driver).executeScript(js).toString(); Thread.sleep(1 * 1000); } catch (Exception e) { LogUtil.error("使用selenium获取图片报错!", e); } - - } - - if (driver != null) { - driver.quit(); + returnMap.put(id, files); } + driver.quit(); } return returnMap; } diff --git a/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue b/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue index 24df618694..8889441c1d 100644 --- a/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue +++ b/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue @@ -1,12 +1,16 @@