From 990705be3c2658a0aa7912a11aea0a22a1a61d23 Mon Sep 17 00:00:00 2001
From: fit2-zhao <yong.zhao@fit2cloud.com>
Date: Fri, 18 Jun 2021 16:45:29 +0800
Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?=
 =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=97=B6=E6=9B=B4=E6=94=B9=E6=8A=A5=E5=91=8A?=
 =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=A2=9E=E5=8A=A0=E4=BF=9D=E6=8A=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../api/service/ApiScenarioReportService.java | 48 ++++++++++---------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java
index 93056269e..f16989cfd 100644
--- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java
+++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java
@@ -337,26 +337,28 @@ public class ApiScenarioReportService {
             } catch (Exception e) {
                 list.add(reportId);
             }
-            ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
-            scenarioReportExample.createCriteria().andIdIn(list);
-            List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample);
-            SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
-            ApiScenarioReportMapper scenarioReportMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
-            if (CollectionUtils.isNotEmpty(reportList)) {
-                reportList.forEach(report -> {
-                    report.setUpdateTime(System.currentTimeMillis());
-                    String status = "Error";
-                    report.setStatus(status);
-                    scenarioReportMapper.updateByPrimaryKeySelective(report);
-                    // 鎶婁笂涓€鏉¤皟璇曠殑鏁版嵁鍐呭娓呯┖
-                    ApiScenarioReport prevResult = extApiScenarioReportMapper.selectPreviousReportByScenarioId(report.getScenarioId(), reportId);
-                    if (prevResult != null) {
-                        ApiScenarioReportDetailExample example = new ApiScenarioReportDetailExample();
-                        example.createCriteria().andReportIdEqualTo(prevResult.getId());
-                        apiScenarioReportDetailMapper.deleteByExample(example);
-                    }
-                });
-                sqlSession.flushStatements();
+            if (CollectionUtils.isNotEmpty(list)) {
+                ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
+                scenarioReportExample.createCriteria().andIdIn(list);
+                List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample);
+                SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
+                ApiScenarioReportMapper scenarioReportMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
+                if (CollectionUtils.isNotEmpty(reportList)) {
+                    reportList.forEach(report -> {
+                        report.setUpdateTime(System.currentTimeMillis());
+                        String status = "Error";
+                        report.setStatus(status);
+                        scenarioReportMapper.updateByPrimaryKeySelective(report);
+                        // 鎶婁笂涓€鏉¤皟璇曠殑鏁版嵁鍐呭娓呯┖
+                        ApiScenarioReport prevResult = extApiScenarioReportMapper.selectPreviousReportByScenarioId(report.getScenarioId(), reportId);
+                        if (prevResult != null) {
+                            ApiScenarioReportDetailExample example = new ApiScenarioReportDetailExample();
+                            example.createCriteria().andReportIdEqualTo(prevResult.getId());
+                            apiScenarioReportDetailMapper.deleteByExample(example);
+                        }
+                    });
+                    sqlSession.flushStatements();
+                }
             }
         }
     }
@@ -413,9 +415,9 @@ public class ApiScenarioReportService {
                     testResult.setScenarioSuccess(testResult.getScenarioSuccess() + scenarioResult.getScenarioSuccess());
                     testResult.setScenarioError(testResult.getScenarioError() + scenarioResult.getScenarioError());
                     testResult.setConsole(scenarioResult.getConsole());
-                    testResult.setScenarioStepError(scenarioResult.getScenarioStepError()+testResult.getScenarioStepError());
-                    testResult.setScenarioStepSuccess(scenarioResult.getScenarioStepSuccess()+testResult.getScenarioStepSuccess());
-                    testResult.setScenarioStepTotal(scenarioResult.getScenarioStepTotal()+testResult.getScenarioStepTotal());
+                    testResult.setScenarioStepError(scenarioResult.getScenarioStepError() + testResult.getScenarioStepError());
+                    testResult.setScenarioStepSuccess(scenarioResult.getScenarioStepSuccess() + testResult.getScenarioStepSuccess());
+                    testResult.setScenarioStepTotal(scenarioResult.getScenarioStepTotal() + testResult.getScenarioStepTotal());
                 } catch (Exception e) {
                     LogUtil.error(e.getMessage());
                 }
-- 
GitLab