diff --git a/backend/src/main/java/io/metersphere/commons/utils/JsonStructUtils.java b/backend/src/main/java/io/metersphere/commons/utils/JsonStructUtils.java index a787ba7eaf..7a5980d20e 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/JsonStructUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/JsonStructUtils.java @@ -167,14 +167,19 @@ public class JsonStructUtils { return false; } else { for (int i = 0; i < matchArr.size(); i++) { - for (int j = i; j < sourceArr.size(); j++) { + boolean finalChack = false; + sourceForeach:for (int j = i; j < sourceArr.size(); j++) { Object matchItemObj = matchArr.get(i); Object sourceItemObj = sourceArr.get(j); boolean check = checkObjCompliance(sourceItemObj, matchItemObj); - if (!check) { - return check; + if (check) { + finalChack = true; + break; } } + if(!finalChack){ + return false; + } } return true; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java index e5581e0505..1ae461ef32 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java @@ -80,7 +80,24 @@ public class TestPlanLoadCaseService { public List list(LoadCaseRequest request) { request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders())); - return extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request); + List testPlanLoadCaseDTOList = extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(request); + this.syncReportStatus(testPlanLoadCaseDTOList); + return testPlanLoadCaseDTOList; + } + + private void syncReportStatus(List testPlanLoadCaseDTOList) { + for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { + if (StringUtils.isNotEmpty(dto.getLoadReportId()) && StringUtils.equalsIgnoreCase(dto.getStatus(), "run")) { + LoadTestReport report = loadTestReportMapper.selectByPrimaryKey(dto.getLoadReportId()); + if (report != null && StringUtils.equalsAnyIgnoreCase(report.getStatus(), "Starting", "Running", "Reporting")) { + dto.setStatus(report.getStatus()); + TestPlanLoadCaseWithBLOBs updateModel = new TestPlanLoadCaseWithBLOBs(); + updateModel.setId(dto.getId()); + updateModel.setStatus(report.getStatus()); + testPlanLoadCaseMapper.updateByPrimaryKeySelective(updateModel); + } + } + } } public List selectTestPlanLoadCaseIds(LoadCaseRequest request) { @@ -155,7 +172,7 @@ public class TestPlanLoadCaseService { if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { serialRun(request); } else { - ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(),new NamedThreadFactory("TestPlanLoadCaseService")); + ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(), new NamedThreadFactory("TestPlanLoadCaseService")); request.getRequests().forEach(item -> { executorService.submit(new ParallelExecTask(performanceTestService, testPlanLoadCaseMapper, item)); }); @@ -170,7 +187,7 @@ public class TestPlanLoadCaseService { } private void serialRun(RunBatchTestPlanRequest request) throws Exception { - ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(),new NamedThreadFactory("TestPlanLoadCaseService-serial")); + ExecutorService executorService = Executors.newFixedThreadPool(request.getRequests().size(), new NamedThreadFactory("TestPlanLoadCaseService-serial")); for (RunTestPlanRequest runTestPlanRequest : request.getRequests()) { Future future = executorService.submit(new SerialExecTask(performanceTestService, testPlanLoadCaseMapper, loadTestReportMapper, runTestPlanRequest, request.getConfig())); LoadTestReportWithBLOBs report = future.get(); @@ -378,8 +395,8 @@ public class TestPlanLoadCaseService { return buildCases(cases); } - public List getAllCases(Collection ids,String planId,String status) { - List cases = extTestPlanLoadCaseMapper.getCasesByIds(ids,planId, status); + public List getAllCases(Collection ids, String planId, String status) { + List cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, planId, status); return buildCases(cases); } @@ -438,6 +455,7 @@ public class TestPlanLoadCaseService { /** * 用例自定义排序 + * * @param request */ public void updateOrder(ResetOrderRequest request) { @@ -450,7 +468,7 @@ public class TestPlanLoadCaseService { public void checkStatusByDeleteLoadCaseReportId(String reportId) { List updatedId = extTestPlanLoadCaseMapper.selectIdByLoadCaseReportIdAndStatusIsRun(reportId); - if(CollectionUtils.isNotEmpty(updatedId)){ + if (CollectionUtils.isNotEmpty(updatedId)) { for (String id : updatedId) { extTestPlanLoadCaseMapper.updateStatusNullById(id); }