diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 3d044fcb22..b367467eaa 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -88,10 +88,6 @@ public class TestPlanReportService { */ public TestPlanReport genTestPlanReport(TestPlanReportSaveRequest saveRequest) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(saveRequest.getPlanId()); - testPlan.setExecutionTimes(1); - testPlan.setExecutionTimes(testPlan.getExecutionTimes() + 1); - testPlanMapper.updateByPrimaryKey(testPlan); - String testPlanReportID = saveRequest.getReportID(); TestPlanReport testPlanReport = new TestPlanReport(); testPlanReport.setTestPlanId(saveRequest.getPlanId()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index e1da5af7a8..2c1ee4d556 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -122,7 +122,7 @@ public class TestPlanService { @Resource private ApiDefinitionMapper apiDefinitionMapper; @Resource - private TestPlanApiCaseMapper testPlanApiCaseMapper; + private TestPlanApiCaseMapper testPlanApiCaseMapper; @Resource private TestPlanApiScenarioMapper testPlanApiScenarioMapper; @Resource @@ -131,6 +131,8 @@ public class TestPlanService { private TestCaseTestMapper testCaseTestMapper; @Resource private ApiScenarioReportMapper apiScenarioReportMapper; + @Resource + private TestPlanReportMapper testPlanReportMapper; public synchronized String addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -385,6 +387,11 @@ public class TestPlanService { request.setProjectId(projectId); } List testPlans = extTestPlanMapper.list(request); + testPlans.forEach(item -> { + TestPlanReportExample example = new TestPlanReportExample(); + example.createCriteria().andTestPlanIdEqualTo(item.getId()); + item.setExecutionTimes((int) testPlanReportMapper.countByExample(example)); + }); calcTestPlanRate(testPlans); return testPlans; }