fix(测试跟踪): 导出自动化用例报告报告详情的分页逻辑

--bug=1027608 --user=宋昌昌 【测试跟踪】测试报告导出报错 https://www.tapd.cn/55049933/s/1392783
This commit is contained in:
song-cc-rock 2023-07-13 16:22:00 +08:00 committed by jianxing
parent 9e9b55ef63
commit 730eb1a244
4 changed files with 16 additions and 24 deletions

View File

@ -4,6 +4,7 @@ import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SubListUtil;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.plan.dto.*; import io.metersphere.plan.dto.*;
import io.metersphere.plan.request.api.ApiTestCaseRequest; import io.metersphere.plan.request.api.ApiTestCaseRequest;
@ -184,12 +185,9 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
} }
//分批处理参数时为了不影响初始参数这里使用新的对象进行处理 //分批处理参数时为了不影响初始参数这里使用新的对象进行处理
List<TestPlanApiDTO> returnList = new ArrayList<>(); List<TestPlanApiDTO> returnList = new ArrayList<>();
List<TestPlanApiDTO> paramList = new ArrayList<>(apiAllCases); SubListUtil.dealForSubList(apiAllCases, 200, (list) -> {
while (CollectionUtils.isNotEmpty(paramList)) { returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", list, TestPlanApiDTO.class));
List<TestPlanApiDTO> requestList = BatchProcessingUtil.subList(paramList, 20); });
returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", requestList, TestPlanApiDTO.class));
paramList.removeAll(requestList);
}
return returnList; return returnList;
} }

View File

@ -4,6 +4,7 @@ import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SubListUtil;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.plan.constant.ApiReportStatus; import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.*; import io.metersphere.plan.dto.*;
@ -197,13 +198,10 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
return null; return null;
} }
//分批处理参数时为了不影响初始参数这里使用新的对象进行处理 //分批处理参数时为了不影响初始参数这里使用新的对象进行处理
List<TestPlanScenarioDTO> paramList = new ArrayList<>(scenarioCases);
List<TestPlanScenarioDTO> returnList = new ArrayList<>(); List<TestPlanScenarioDTO> returnList = new ArrayList<>();
while (CollectionUtils.isNotEmpty(paramList)) { SubListUtil.dealForSubList(scenarioCases, 20, (list) -> {
List<TestPlanScenarioDTO> requestList = BatchProcessingUtil.subList(paramList, 5); returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", list, TestPlanScenarioDTO.class));
returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", scenarioCases, TestPlanScenarioDTO.class)); });
paramList.removeAll(requestList);
}
return returnList; return returnList;
} }

View File

@ -4,6 +4,7 @@ import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.constants.TestPlanLoadCaseStatus; import io.metersphere.commons.constants.TestPlanLoadCaseStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SubListUtil;
import io.metersphere.dto.PlanReportCaseDTO; import io.metersphere.dto.PlanReportCaseDTO;
import io.metersphere.dto.TestPlanLoadCaseDTO; import io.metersphere.dto.TestPlanLoadCaseDTO;
import io.metersphere.dto.TestPlanLoadResultReportDTO; import io.metersphere.dto.TestPlanLoadResultReportDTO;
@ -140,13 +141,10 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
return null; return null;
} }
//分批处理参数时为了不影响初始参数这里使用新的对象进行处理 //分批处理参数时为了不影响初始参数这里使用新的对象进行处理
List<TestPlanLoadCaseDTO> paramList = new ArrayList<>(loadCases);
List<TestPlanLoadCaseDTO> returnList = new ArrayList<>(); List<TestPlanLoadCaseDTO> returnList = new ArrayList<>();
while (CollectionUtils.isNotEmpty(paramList)) { SubListUtil.dealForSubList(loadCases, 20, (paramList) -> {
List<TestPlanLoadCaseDTO> requestList = BatchProcessingUtil.subList(paramList, 5); returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", paramList, TestPlanLoadCaseDTO.class));
returnList.addAll(microService.postForDataArray(serviceName, BASE_UEL + "/build/response", loadCases, TestPlanLoadCaseDTO.class)); });
paramList.removeAll(requestList);
}
return returnList; return returnList;
} }

View File

@ -6,6 +6,7 @@ import io.metersphere.base.domain.UiScenarioReportWithBLOBs;
import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SubListUtil;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.plan.constant.ApiReportStatus; import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.*; import io.metersphere.plan.dto.*;
@ -161,13 +162,10 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService {
} }
//分批处理参数时为了不影响初始参数这里使用新的对象进行处理 //分批处理参数时为了不影响初始参数这里使用新的对象进行处理
List<TestPlanUiScenarioDTO> paramList = new ArrayList<>(uiCases);
List<TestPlanUiScenarioDTO> returnList = new ArrayList<>(); List<TestPlanUiScenarioDTO> returnList = new ArrayList<>();
while (CollectionUtils.isNotEmpty(paramList)) { SubListUtil.dealForSubList(uiCases, 20, list -> {
List<TestPlanUiScenarioDTO> requestList = BatchProcessingUtil.subList(paramList, 5); returnList.addAll(microService.postForDataArray(serviceName, BASE_URL + "/build/response", list, TestPlanUiScenarioDTO.class));
returnList.addAll(microService.postForDataArray(serviceName, BASE_URL + "/build/response", uiCases, TestPlanUiScenarioDTO.class)); });
paramList.removeAll(requestList);
}
return returnList; return returnList;
} }