diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 4e092f5d34..de809824b7 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -222,16 +222,17 @@ public class PerformanceTestService { public String edit(EditTestPlanRequest request, List files) { checkQuota(request, false); // - LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId()); + String testId = request.getId(); + LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(testId); if (loadTest == null) { - MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId()); + MSException.throwException(Translator.get("edit_load_test_not_found") + testId); } if (StringUtils.containsAny(loadTest.getStatus(), PerformanceTestStatus.Running.name(), PerformanceTestStatus.Starting.name())) { MSException.throwException(Translator.get("cannot_edit_load_test_running")); } // 新选择了一个文件,删除原来的文件 List updatedFiles = request.getUpdatedFileList(); - List originFiles = getFileMetadataByTestId(request.getId()); + List originFiles = getFileMetadataByTestId(testId); List updatedFileIds = updatedFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); List originFileIds = originFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); @@ -240,13 +241,15 @@ public class PerformanceTestService { // 删除已经不相关的文件 if (!CollectionUtils.isEmpty(deleteFileIds)) { LoadTestFileExample example3 = new LoadTestFileExample(); - example3.createCriteria().andFileIdIn(deleteFileIds); + example3.createCriteria() + .andFileIdIn(deleteFileIds) + .andTestIdEqualTo(testId); loadTestFileMapper.deleteByExample(example3); } // 导入项目里其他的文件 List addFileIds = ListUtils.subtract(updatedFileIds, originFileIds); - this.importFiles(addFileIds, request.getId(), request.getFileSorts()); + this.importFiles(addFileIds, testId, request.getFileSorts()); // 处理新上传的文件 this.saveUploadFiles(files, loadTest, request.getFileSorts()); @@ -260,7 +263,7 @@ public class PerformanceTestService { loadTest.setStatus(PerformanceTestStatus.Saved.name()); loadTestMapper.updateByPrimaryKeySelective(loadTest); - return request.getId(); + return testId; } @Transactional(noRollbackFor = MSException.class)// 保存失败的信息