diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanExecutionQueueProvider.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanExecutionQueueProvider.java index c7e2528caa..de2d7922aa 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanExecutionQueueProvider.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanExecutionQueueProvider.java @@ -7,7 +7,7 @@ import java.util.List; public class ExtTestPlanExecutionQueueProvider { public String insertListSql(List list) { StringBuffer sqlList = new StringBuffer(); - sqlList.append("insert into test_plan_execution_queue (id,report_id, run_mode, create_time) values "); + sqlList.append("insert into test_plan_execution_queue (id,report_id, run_mode, create_time, test_plan_id) values "); for (int i = 0; i < list.size(); i++) { TestPlanExecutionQueue result = list.get(i); sqlList.append(" (") @@ -19,6 +19,8 @@ public class ExtTestPlanExecutionQueueProvider { .append(result.getRunMode()) .append("','") .append(result.getCreateTime()) + .append("','") + .append(result.getTestPlanId()) .append("'") .append(")"); if (i < list.size() - 1) { 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 d5a4d96e2b..fac5827aa7 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -14,6 +14,7 @@ import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.*; import io.metersphere.commons.utils.*; +import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.dto.TestPlanExecuteReportDTO; import io.metersphere.dto.UserDTO; @@ -545,15 +546,15 @@ public class TestPlanReportService { testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId); List planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample); String runMode=null; - if(planExecutionQueues!=null&&planExecutionQueues.size()>0){ + if(CollectionUtils.isNotEmpty(planExecutionQueues)){ runMode = planExecutionQueues.get(0).getRunMode(); testPlanExecutionQueueMapper.deleteByExample(testPlanExecutionQueueExample); } - if(runMode!=null&&StringUtils.equalsIgnoreCase(runMode,"serial")){ + if(runMode!=null&&StringUtils.equalsIgnoreCase(runMode, RunModeConstants.SERIAL.name())){ TestPlanExecutionQueueExample queueExample = new TestPlanExecutionQueueExample(); queueExample.createCriteria().andReportIdIsNotNull(); - List planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample); - if(planExecutionQueueList==null||planExecutionQueueList.size()==0){ + List planExecutionQueueList = testPlanExecutionQueueMapper.selectByExample(queueExample); + if(CollectionUtils.isEmpty(planExecutionQueueList)){ return testPlanReport; } TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0); 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 48d941a75f..20d1645916 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -23,6 +23,7 @@ import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; +import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.*; import io.metersphere.i18n.Translator; import io.metersphere.log.utils.ReflexObjectUtil; @@ -954,7 +955,7 @@ public class TestPlanService { } if (runModeConfig == null) { runModeConfig = new RunModeConfigDTO(); - runModeConfig.setMode("serial"); + runModeConfig.setMode(RunModeConstants.SERIAL.name()); runModeConfig.setReportType("iddReport"); runModeConfig.setEnvMap(new HashMap<>()); runModeConfig.setOnSampleError(false); @@ -2074,7 +2075,8 @@ public class TestPlanService { List responseDTOS = new LinkedList<>(); Map planScheduleReportInfoDTOMap = new LinkedHashMap<>(); boolean startThread = true; - for (TestPlanWithBLOBs testPlan : planList) { + for (String id : ids) { + TestPlanWithBLOBs testPlan = testPlanMap.get(id); if(StringUtils.isBlank(testPlan.getRunModeConfig())){ startThread = false; MSException.throwException("请保存["+testPlan.getName()+"]的运行配置"); @@ -2118,17 +2120,17 @@ public class TestPlanService { } private void runByMode(boolean startThread, TestplanRunRequest request, Map testPlanMap, Map planScheduleReportInfoDTOMap, List planExecutionQueues) { - if (planExecutionQueues != null&& planExecutionQueues.size()>0) { + if (CollectionUtils.isNotEmpty(planExecutionQueues)) { Thread thread = new Thread(new Runnable() { @Override public void run() { Thread.currentThread().setName("TEST_PLAN_BATCH:" + System.currentTimeMillis()); - if(StringUtils.equalsIgnoreCase(request.getMode(),"serial")){ + if(StringUtils.equalsIgnoreCase(request.getMode(),RunModeConstants.SERIAL.name())){ TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0); TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId()); JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig()); TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject,TestplanRunRequest.class); - runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId())); + runRequest.setPlanScheduleReportInfoDTO(planScheduleReportInfoDTOMap.get(planExecutionQueue.getTestPlanId())); runPlan(runRequest); }else { for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) { diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index 4ff60b74b5..3bcff5938e 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -639,8 +639,8 @@ export default { param.userId = getCurrentUserId(); param.requestOriginator = "TEST_PLAN"; param.testPlanIds = ids; - this.$refs.taskCenter.open(); this.result = this.$post('/test/plan/run/batch/', param, () => { + this.$refs.taskCenter.open(); this.$success(this.$t('commons.run_success')); }, error => { // this.$error(error.message);