From 7670b455f2935af0f5bea008079991b25428bb0a Mon Sep 17 00:00:00 2001 From: Jianguo-Genius Date: Thu, 18 Apr 2024 11:23:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F=E5=A4=8D=E5=88=B6=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=97=B6pos=E6=B2=A1=E6=9C=89=E7=B4=AF=E5=8A=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/scenario/ApiScenarioService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java index 28dd8f387b..b635f121a1 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java @@ -22,8 +22,6 @@ import io.metersphere.api.parser.step.StepParserFactory; import io.metersphere.api.service.ApiCommonService; import io.metersphere.api.service.ApiExecuteService; import io.metersphere.api.service.ApiFileResourceService; -import io.metersphere.system.notice.constants.NoticeConstants; -import io.metersphere.system.schedule.ApiScheduleNoticeService; import io.metersphere.api.service.definition.ApiDefinitionModuleService; import io.metersphere.api.service.definition.ApiDefinitionService; import io.metersphere.api.service.definition.ApiTestCaseService; @@ -70,6 +68,7 @@ import io.metersphere.system.dto.sdk.request.PosRequest; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.ScheduleMapper; +import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.schedule.ScheduleService; import io.metersphere.system.service.ApiPluginService; import io.metersphere.system.service.OperationHistoryService; @@ -2403,8 +2402,9 @@ public class ApiScenarioService extends MoveNodeService { return new ApiScenarioBatchOperationResponse(); } request.setSelectIds(scenarioIds); + AtomicLong nextScenarioPos = new AtomicLong(getNextOrder(request.getProjectId())); ApiScenarioBatchOperationResponse response = - ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> copyAndInsert(sublist, request, logInsertModule.getOperator())); + ApiScenarioBatchOperationUtils.executeWithBatchOperationResponse(scenarioIds, sublist -> copyAndInsert(sublist, nextScenarioPos, request, logInsertModule.getOperator())); apiScenarioLogService.saveBatchOperationLog(response, request.getProjectId(), OperationLogType.ADD.name(), logInsertModule, null, true); return response; } @@ -2474,7 +2474,7 @@ public class ApiScenarioService extends MoveNodeService { return response; } - private ApiScenarioBatchOperationResponse copyAndInsert(List scenarioIds, ApiScenarioBatchCopyMoveRequest request, String operator) { + private ApiScenarioBatchOperationResponse copyAndInsert(List scenarioIds, AtomicLong nextScenarioPos, ApiScenarioBatchCopyMoveRequest request, String operator) { ApiScenarioBatchOperationResponse response = new ApiScenarioBatchOperationResponse(); ApiScenarioExample example = new ApiScenarioExample(); @@ -2495,12 +2495,12 @@ public class ApiScenarioService extends MoveNodeService { MinioRepository minioRepository = CommonBeanFactory.getBean(MinioRepository.class); - operationList.forEach(apiScenario -> { + for (ApiScenario apiScenario : operationList) { ApiScenario copyScenario = new ApiScenario(); BeanUtils.copyBean(copyScenario, apiScenario); copyScenario.setId(IDGenerator.nextStr()); copyScenario.setNum(getNextNum(copyScenario.getProjectId())); - copyScenario.setPos(getNextOrder(copyScenario.getProjectId())); + copyScenario.setPos(nextScenarioPos.getAndAdd(DEFAULT_NODE_INTERVAL_POS)); copyScenario.setModuleId(request.getTargetModuleId()); copyScenario.setName(this.getScenarioCopyName(copyScenario.getName(), apiScenario.getNum(), copyScenario.getNum(), request.getTargetModuleId())); copyScenario.setCreateUser(operator); @@ -2565,7 +2565,7 @@ public class ApiScenarioService extends MoveNodeService { }); } response.addSuccessData(copyScenario.getId(), copyScenario.getNum(), copyScenario.getName()); - }); + } response.setSuccess(apiScenarioMapper.batchInsert(insertApiScenarioList)); if (CollectionUtils.isNotEmpty(insertApiScenarioBlobList)) {