From cfbe54413112ef0d1ce0f1396e4d67e6362af9c3 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 26 Oct 2022 15:06:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=85=B3=E8=81=94=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=90=8E=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/remote/TestPlanController.java | 6 +-- .../service/plan/TestPlanApiCaseService.java | 21 +++----- .../plan/TestPlanScenarioCaseService.java | 18 +++---- .../service/plan/remote/TestPlanService.java | 18 +++++++ .../service/plan/remote/TrackService.java | 15 ++++++ .../plan/service/TestPlanLoadCaseService.java | 54 ++++++++----------- .../plan/service/remote/TestPlanService.java | 18 +++++++ .../plan/service/remote/TrackService.java | 15 ++++++ .../controller/TestPlanController.java | 4 ++ .../plan/service/TestPlanService.java | 27 +++++----- .../service/TestReviewTestCaseService.java | 33 ------------ 11 files changed, 124 insertions(+), 105 deletions(-) create mode 100644 api-test/backend/src/main/java/io/metersphere/service/plan/remote/TestPlanService.java create mode 100644 api-test/backend/src/main/java/io/metersphere/service/plan/remote/TrackService.java create mode 100644 performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TestPlanService.java create mode 100644 performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TrackService.java diff --git a/api-test/backend/src/main/java/io/metersphere/controller/remote/TestPlanController.java b/api-test/backend/src/main/java/io/metersphere/controller/remote/TestPlanController.java index a522ef9c47..8b6f04f508 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/remote/TestPlanController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/remote/TestPlanController.java @@ -15,7 +15,7 @@ import java.util.List; @RestController public class TestPlanController { @Resource - private RemoteTestPlanService testPlanService; + private RemoteTestPlanService remoteTestPlanService; public static final List EXCLUDE_APIS = new ArrayList<>(2) {{ add("test/plan/api/case"); @@ -25,13 +25,13 @@ public class TestPlanController { @GetMapping("/**") public List getStageOption(HttpServletRequest request) { excludeApi(request.getRequestURI()); - return testPlanService.get(request.getRequestURI()); + return remoteTestPlanService.get(request.getRequestURI()); } @PostMapping("/**") public List getPage(HttpServletRequest request, @RequestBody QueryTestPlanRequest params) { excludeApi(request.getRequestURI()); - return testPlanService.post(request.getRequestURI(), params); + return remoteTestPlanService.post(request.getRequestURI(), params); } /** diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java index 9f197b7ea0..ef00db7752 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java @@ -16,7 +16,6 @@ import io.metersphere.api.dto.plan.TestPlanApiCaseBatchRequest; import io.metersphere.api.dto.plan.TestPlanApiCaseInfoDTO; import io.metersphere.api.exec.api.ApiCaseExecuteService; import io.metersphere.api.exec.api.ApiExecuteService; -import io.metersphere.api.exec.scenario.ApiScenarioEnvService; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ApiTestCaseMapper; @@ -40,6 +39,7 @@ import io.metersphere.service.definition.ApiDefinitionExecResultService; import io.metersphere.service.definition.ApiDefinitionService; import io.metersphere.service.definition.ApiModuleService; import io.metersphere.service.definition.ApiTestCaseService; +import io.metersphere.service.plan.remote.TestPlanService; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; @@ -94,9 +94,6 @@ public class TestPlanApiCaseService { ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper; @Lazy @Resource - private ApiScenarioEnvService apiScenarioEnvService; - @Lazy - @Resource private ApiModuleService apiModuleService; @Resource BaseProjectService baseProjectService; @@ -104,6 +101,8 @@ public class TestPlanApiCaseService { private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper; @Resource private ApiExecuteService apiExecuteService; + @Resource + private TestPlanService testPlanService; public TestPlanApiCase getInfo(String caseId, String testPlanId) { TestPlanApiCaseExample example = new TestPlanApiCaseExample(); @@ -586,15 +585,7 @@ public class TestPlanApiCaseService { } } - // todo check -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); -// if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name()) -// || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { -// testPlan.setStatus(TestPlanStatus.Underway.name()); -// testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新 -// testPlan.setActualEndTime(null); -// testPlanMapper.updateByPrimaryKey(testPlan); -// } + testPlanService.statusReset(request.getPlanId()); sqlSession.flushStatements(); } @@ -602,8 +593,8 @@ public class TestPlanApiCaseService { TestPlanApiCase t = new TestPlanApiCase(); Long nextApiOrder = ServiceUtils.getNextOrder(planId, extTestPlanApiCaseMapper::getLastOrder); for (String id : ids) { - ApiTestCaseWithBLOBs apitest = apiTestCaseMapper.selectByPrimaryKey(id); - if (null != apitest) { + ApiTestCaseWithBLOBs apiTest = apiTestCaseMapper.selectByPrimaryKey(id); + if (null != apiTest) { t.setId(UUID.randomUUID().toString()); t.setTestPlanId(planId); t.setApiCaseId(id); diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index a1af7b1cdb..a8bd43c728 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -11,10 +11,8 @@ import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.plan.*; import io.metersphere.api.exec.scenario.ApiScenarioEnvService; import io.metersphere.base.domain.*; -import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiTestEnvironmentMapper; -import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper; import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper; import io.metersphere.base.mapper.plan.ext.ExtTestPlanApiCaseMapper; @@ -40,6 +38,7 @@ import io.metersphere.service.BaseProjectService; import io.metersphere.service.BaseUserService; import io.metersphere.service.ServiceUtils; import io.metersphere.service.definition.ApiDefinitionExecResultService; +import io.metersphere.service.plan.remote.TestPlanService; import io.metersphere.service.scenario.ApiScenarioModuleService; import io.metersphere.service.scenario.ApiScenarioReportService; import io.metersphere.service.scenario.ApiScenarioService; @@ -89,10 +88,6 @@ public class TestPlanScenarioCaseService { @Resource private TestPlanApiCaseService testPlanApiCaseService; @Resource - private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper; - @Resource - private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper; - @Resource private ApiScenarioEnvService apiScenarioEnvService; @Resource private ApiDefinitionExecResultService apiDefinitionExecResultService; @@ -105,6 +100,8 @@ public class TestPlanScenarioCaseService { @Lazy @Resource private ApiScenarioModuleService apiScenarioModuleService; + @Resource + private TestPlanService testPlanService; public List list(TestPlanScenarioRequest request) { request.setProjectId(null); @@ -221,6 +218,7 @@ public class TestPlanScenarioCaseService { nextOrder += ServiceUtils.ORDER_STEP; testPlanApiScenarioMapper.insert(testPlanApiScenario); } + testPlanService.statusReset(request.getPlanId()); } public int delete(String id) { @@ -465,10 +463,9 @@ public class TestPlanScenarioCaseService { TestPlanApiScenario scenario = testPlanApiScenarioMapper.selectByPrimaryKey(id); if (scenario != null) { ApiScenarioWithBLOBs testCase = apiScenarioMapper.selectByPrimaryKey(scenario.getApiScenarioId()); - // todo check -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(scenario.getTestPlanId()); -// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), testCase.getName(), scenario.getCreateUser(), new LinkedList<>()); -// return JSON.toJSONString(details); + TestPlan testPlan = testPlanService.get(scenario.getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), testCase.getName(), scenario.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); } return null; } @@ -686,6 +683,7 @@ public class TestPlanScenarioCaseService { } } } + testPlanService.statusReset(planId); } public void copyPlan(String sourcePlanId, String targetPlanId) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TestPlanService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TestPlanService.java new file mode 100644 index 0000000000..6b31d78670 --- /dev/null +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TestPlanService.java @@ -0,0 +1,18 @@ +package io.metersphere.service.plan.remote; + +import io.metersphere.base.domain.TestPlan; +import org.springframework.stereotype.Service; + +@Service +public class TestPlanService extends TrackService { + + private static final String BASE_UEL = "/test/plan"; + + public TestPlan get(String id) { + return microService.getForData(serviceName, BASE_UEL + "/get/" + id, TestPlan.class); + } + + public void statusReset(String id) { + microService.getForData(serviceName, BASE_UEL + "/status/reset/" + id); + } +} diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TrackService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TrackService.java new file mode 100644 index 0000000000..a44d32bd6e --- /dev/null +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/remote/TrackService.java @@ -0,0 +1,15 @@ +package io.metersphere.service.plan.remote; + +import io.metersphere.commons.constants.MicroServiceName; +import io.metersphere.service.RemoteService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TrackService extends RemoteService { + + public TrackService() { + super(MicroServiceName.TEST_TRACK); + } +} diff --git a/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java b/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java index 6f2e666b84..78a9b96c3f 100644 --- a/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java +++ b/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java @@ -22,6 +22,7 @@ import io.metersphere.plan.request.LoadCaseReportBatchRequest; import io.metersphere.plan.request.LoadCaseReportRequest; import io.metersphere.plan.request.LoadCaseRequest; import io.metersphere.plan.request.RunBatchTestPlanRequest; +import io.metersphere.plan.service.remote.TestPlanService; import io.metersphere.request.*; import io.metersphere.service.*; import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService; @@ -41,8 +42,6 @@ import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) public class TestPlanLoadCaseService { - // @Resource -// TestPlanMapper testPlanMapper; @Resource private TestPlanLoadCaseMapper testPlanLoadCaseMapper; @Resource @@ -57,8 +56,8 @@ public class TestPlanLoadCaseService { private ExtLoadTestReportMapper extLoadTestReportMapper; @Resource private LoadTestMapper loadTestMapper; - // @Resource -// private TestPlanService testPlanService; + @Resource + private TestPlanService testPlanService; @Resource private MetricQueryService metricQueryService; @Resource @@ -135,14 +134,8 @@ public class TestPlanLoadCaseService { testPlanLoadCaseMapper.insert(t); } -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId()); -// if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name()) -// || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { -// testPlan.setStatus(TestPlanStatus.Underway.name()); -// testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新 -// testPlan.setActualEndTime(null); -// testPlanMapper.updateByPrimaryKey(testPlan); -// } + testPlanService.statusReset(request.getTestPlanId()); + sqlSession.flushStatements(); if (sqlSession != null && sqlSessionFactory != null) { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); @@ -281,13 +274,12 @@ public class TestPlanLoadCaseService { public String getLogDetails(String id) { TestPlanLoadCase bloBs = testPlanLoadCaseMapper.selectByPrimaryKey(id); if (bloBs != null) { - // todo -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(bloBs.getTestPlanId()); -// LoadTest test = loadTestMapper.selectByPrimaryKey(bloBs.getLoadCaseId()); -// if (test != null && testPlan != null) { -// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), test.getName(), bloBs.getCreateUser(), new LinkedList<>()); -// return JSON.toJSONString(details); -// } + TestPlan testPlan = testPlanService.get(bloBs.getTestPlanId()); + LoadTest test = loadTestMapper.selectByPrimaryKey(bloBs.getLoadCaseId()); + if (test != null && testPlan != null) { + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), test.getName(), bloBs.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } } return null; } @@ -297,14 +289,13 @@ public class TestPlanLoadCaseService { caseExample.createCriteria().andIdIn(ids); List cases = testPlanLoadCaseMapper.selectByExample(caseExample); if (CollectionUtils.isNotEmpty(cases)) { - // todo -// LoadTestExample example = new LoadTestExample(); -// example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList())); -// List loadTests = loadTestMapper.selectByExample(example); -// List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId()); -// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); -// return JSON.toJSONString(details); + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList())); + List loadTests = loadTestMapper.selectByExample(example); + List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanService.get(cases.get(0).getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); } return null; } @@ -318,11 +309,10 @@ public class TestPlanLoadCaseService { example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList())); List loadTests = loadTestMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(loadTests)) { - // todo -// List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); -// TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId()); -// OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); -// return JSON.toJSONString(details); + List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanService.get(cases.get(0).getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); } } return null; diff --git a/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TestPlanService.java b/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TestPlanService.java new file mode 100644 index 0000000000..5bc32b376e --- /dev/null +++ b/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TestPlanService.java @@ -0,0 +1,18 @@ +package io.metersphere.plan.service.remote; + +import io.metersphere.base.domain.TestPlan; +import org.springframework.stereotype.Service; + +@Service +public class TestPlanService extends TrackService { + + private static final String BASE_UEL = "/test/plan"; + + public TestPlan get(String id) { + return microService.getForData(serviceName, BASE_UEL + "/get/" + id, TestPlan.class); + } + + public void statusReset(String id) { + microService.getForData(serviceName, BASE_UEL + "/status/reset/" + id); + } +} diff --git a/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TrackService.java b/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TrackService.java new file mode 100644 index 0000000000..ccd4a1c6fd --- /dev/null +++ b/performance-test/backend/src/main/java/io/metersphere/plan/service/remote/TrackService.java @@ -0,0 +1,15 @@ +package io.metersphere.plan.service.remote; + +import io.metersphere.commons.constants.MicroServiceName; +import io.metersphere.service.RemoteService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TrackService extends RemoteService { + + public TrackService() { + super(MicroServiceName.TEST_TRACK); + } +} diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java index 8d22ea917d..2d1c07be4a 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -348,4 +348,8 @@ public class TestPlanController { return testPlanRerunService.rerun(request); } + @GetMapping(value = "/status/reset/{planId}") + public void resetStatus(@PathVariable String planId) { + testPlanService.resetStatus(planId); + } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index 41d6e0c8b2..fe3c24bcff 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -281,12 +281,11 @@ public class TestPlanService { testPlan.setActualStartTime(System.currentTimeMillis()); } - int i; if (testPlan.getName() == null) {// 若是点击该测试计划,则仅更新了updateTime,其它字段全为null,使用updateByPrimaryKeySelective - i = testPlanMapper.updateByPrimaryKeySelective(testPlan); + testPlanMapper.updateByPrimaryKeySelective(testPlan); } else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey baseScheduleService.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name - i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新 + testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新 } return testPlanMapper.selectByPrimaryKey(testPlan.getId()); } @@ -329,7 +328,7 @@ public class TestPlanService { public void calcTestPlanRate(List testPlans) { // 速度太慢 todo - testPlans.forEach(testPlan -> calcTestPlanRate(testPlan)); + testPlans.forEach(this::calcTestPlanRate); } public void calcTestPlanRate(TestPlanDTOWithMetric testPlan) { @@ -579,13 +578,7 @@ public class TestPlanService { caseTestRelevance(request, testCaseIds); - if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name()) - || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { - testPlan.setStatus(TestPlanStatus.Underway.name()); - testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新 - testPlan.setActualEndTime(null); - testPlanMapper.updateByPrimaryKey(testPlan); - } + resetStatus(testPlan.getId()); sqlSession.flushStatements(); if (sqlSession != null && sqlSessionFactory != null) { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); @@ -856,7 +849,6 @@ public class TestPlanService { uiScenarioReportMap = this.executeUiScenarioCase(planReportId, testPlanID, projectID, runModeConfig, triggerMode, userId, reportInfoDTO.getUiScenarioIdMap()); } -// if (apiCaseReportMap != null && scenarioReportMap != null && loadCaseReportMap != null && uiScenarioReportMap != null) todo 需要判断? LoggerUtil.info("开始生成测试计划报告内容 " + planReportId); testPlanReportService.createTestPlanReportContentReportIds(planReportId, apiCaseReportMap, scenarioReportMap, loadCaseReportMap, uiScenarioReportMap); @@ -1846,4 +1838,15 @@ public class TestPlanService { baseScheduleService.addSchedule(schedule); baseScheduleService.addOrUpdateCronJob(request, jobKey, triggerKey, clazz); } + + public void resetStatus(String planId) { + TestPlan testPlan = get(planId); + if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name()) + || StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) { + testPlan.setStatus(TestPlanStatus.Underway.name()); + testPlan.setActualStartTime(System.currentTimeMillis()); // 将状态更新为进行中时,开始时间也要更新 + testPlan.setActualEndTime(null); + testPlanMapper.updateByPrimaryKey(testPlan); + } + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java index 4540ec72c9..0d055407bb 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java @@ -171,42 +171,9 @@ public class TestReviewTestCaseService { public TestReviewCaseDTO get(String reviewId) { TestReviewCaseDTO testReviewCaseDTO = extTestReviewCaseMapper.get(reviewId); -// List testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testReviewCaseDTO.getCaseId()); -// testCaseTestDTOS.forEach(dto -> { -// setTestName(dto); -// }); -// testReviewCaseDTO.setList(testCaseTestDTOS); return testReviewCaseDTO; } - // todo check -// private void setTestName(TestCaseTestDTO dto) { -// String type = dto.getTestType(); -// String id = dto.getTestId(); -// switch (type) { -// case "performance": -// LoadTest loadTest = loadTestMapper.selectByPrimaryKey(id); -// if (loadTest != null) { -// dto.setTestName(loadTest.getName()); -// } -// break; -// case "testcase": -// ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id); -// if (apiTestCaseWithBLOBs != null) { -// dto.setTestName(apiTestCaseWithBLOBs.getName()); -// } -// break; -// case "automation": -// ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id); -// if (apiScenarioWithBLOBs != null) { -// dto.setTestName(apiScenarioWithBLOBs.getName()); -// } -// break; -// default: -// break; -// } -// } - public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) { ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extTestReviewCaseMapper.selectTestCaseIds((QueryCaseReviewRequest) query));