src/main/java/com/dji/sample/media/dao/IZipMapper.java
New file @@ -0,0 +1,9 @@ package com.dji.sample.media.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dji.sample.media.model.MediaFileZipEntity; import org.apache.ibatis.annotations.Mapper; @Mapper public interface IZipMapper extends BaseMapper<MediaFileZipEntity> { } src/main/java/com/dji/sample/media/model/MediaFileZipEntity.java
New file @@ -0,0 +1,83 @@ package com.dji.sample.media.model; import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; @TableName(value = "media_file_zip", autoResultMap = true) @Data @Builder @AllArgsConstructor @NoArgsConstructor public class MediaFileZipEntity implements Serializable { @TableId(type = IdType.AUTO) private Integer id; @TableField("file_id") private String fileId; @TableField("file_name") private String fileName; @TableField("file_path") private String filePath; @TableField("workspace_id") private String workspaceId; @TableField("fingerprint") private String fingerprint; @TableField("tinny_fingerprint") private String tinnyFingerprint; @TableField("object_key") private String objectKey; @TableField("sub_file_type") private Integer subFileType; @TableField("is_original") private Boolean isOriginal; @TableField("drone") private String drone; @TableField("payload") private String payload; @TableField("job_id") private String jobId; @TableField(value = "create_time", fill = FieldFill.INSERT) private Long createTime; @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private Long updateTime; @TableField("collect_status") private Boolean collectStatus; @TableField("user_id") private String userId; @TableField(value = "metadata", typeHandler = FastjsonTypeHandler.class) private Object metadata; @TableField("examine") private Integer examine; @TableField("job_name") private String jobName; @TableField(value = "drone_data", typeHandler = FastjsonTypeHandler.class) private Object droneData; } src/main/java/com/dji/sample/media/service/IFileService.java
@@ -38,7 +38,9 @@ */ Integer saveFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; void saveNailFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; void updateMarkMediaFileNames(String jobId); void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException; void updateNailMediaFileNames(String jobId); PaginationData<MediaFileEntity> getJobId( int pageNum, int pageSize,String workspaceId); PaginationData<MediaFileEntity> getPhotoByJobId(int page,int pageSize ,String workspaceId,String jobId); src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -19,6 +19,7 @@ import com.dji.sample.media.dao.IFileMapper; import com.dji.sample.media.dao.IMarkMapper; import com.dji.sample.media.dao.INailMapper; import com.dji.sample.media.dao.IZipMapper; import com.dji.sample.media.model.*; import com.dji.sample.media.service.IFileService; import com.dji.sample.media.util.ImgUtil; @@ -74,6 +75,8 @@ private IMarkMapper markMapper; @Autowired private INailMapper nailMapper; @Autowired private IZipMapper zipMapper; @Autowired private GetPatchesMapper patchesMapper; @Autowired @@ -148,6 +151,32 @@ } } public void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException { updateStatue(file.getName()); boolean endsWith = file.getObjectKey().endsWith(".mp4"); if (endsWith) { MediaFileZipEntity nailEntity = this.fileUploadConvertToZipEntity((file)); nailEntity.setWorkspaceId(workspaceId); nailEntity.setFileId(UUID.randomUUID().toString()); zipMapper.insert(nailEntity); } else { String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey(); File file1 = TbFjServiceImpl.downloadFile(url); File nailFile = new File(ImgZipUtil.compressImageAndGetFile(file1, 0.5f).toURI()); MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file); zipEntity.setIsOriginal(false); zipEntity.setWorkspaceId(workspaceId); zipEntity.setFileName("zip" + file.getName()); zipEntity.setObjectKey("/zip" + file.getPath() + "/" + file.getName()); zipEntity.setFilePath("zip" + file.getPath()); String nailName = zipEntity.getObjectKey(); zipEntity.setFileId(UUID.randomUUID().toString()); uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), nailName, nailFile, "image/jpeg"); uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", nailName, nailFile, "image/jpeg"); zipMapper.insert(zipEntity); } } public void updateStatue(String filename) { if (filename.contains("~")) { String name = TimerUtil.getDkbh(filename); @@ -187,7 +216,7 @@ } } } else { String names = "nail" + filename; String names = "nail" + filename; List<MediaFileNailEntity> entities = nailMapper.selectList(new LambdaQueryWrapper<MediaFileNailEntity>() .eq(MediaFileNailEntity::getFileName, names)); if (entities != null && !entities.isEmpty()) { @@ -423,11 +452,11 @@ public ResponseResult downloadImages(List<String> jobIds) { try { String bucketPath = "/data/software/minio-data/cloud-bucket/"; // List<String> prefixes = getUniqueFilePaths(jobIds); List<String> prefixes = getUniqueFilePaths(jobIds); MinioFileDownloader downloader = new MinioFileDownloader(bucketPath); // 下载并压缩文件到本地目录 String localSaveDir = "/data/software/minio-data/zip-bucket/"; // 修改为你想保存的本地目录 downloader.downloadAndZipFolders(jobIds, localSaveDir); downloader.downloadAndZipFolders(prefixes, localSaveDir); } catch (Exception e) { e.printStackTrace(); return ResponseResult.error("下载失败" + e.getMessage()); @@ -531,6 +560,32 @@ private MediaFileNailEntity fileUploadConvertToNailEntity(FileUploadDTO file) { MediaFileNailEntity.MediaFileNailEntityBuilder builder = MediaFileNailEntity.builder(); if (file != null) { builder.fileName(file.getName()) .fingerprint(file.getFingerprint()) .objectKey(file.getObjectKey()) .subFileType(file.getSubFileType()) .isOriginal(file.getExt().getIsOriginal()) .filePath(file.getPath()) .jobId(file.getExt().getFlightId()) .drone(file.getExt().getSn()).metadata(file.getMetadata()) .tinnyFingerprint(file.getExt().getTinnyFingerprint()); // domain-type-subType int[] payloadModel = Arrays.stream(file.getExt().getPayloadModelKey().split("-")) .map(Integer::valueOf) .mapToInt(Integer::intValue) .toArray(); Optional<DeviceDictionaryDTO> payloadDict = deviceDictionaryService .getOneDictionaryInfoByTypeSubType(DeviceDomainEnum.PAYLOAD.getVal(), payloadModel[1], payloadModel[2]); payloadDict.ifPresent(payload -> builder.payload(payload.getDeviceName())); } return builder.build(); } private MediaFileZipEntity fileUploadConvertToZipEntity(FileUploadDTO file) { MediaFileZipEntity.MediaFileZipEntityBuilder builder = MediaFileZipEntity.builder(); if (file != null) { builder.fileName(file.getName()) @@ -706,9 +761,96 @@ } } public void updateMediaZipFileNames(String jobId) { // 查询符合条件的数据 List<MediaFileZipEntity> mediaFiles = zipMapper.selectList(new LambdaQueryWrapper<MediaFileZipEntity>() .eq(MediaFileZipEntity::getJobId, jobId)); boolean allContainTilde = mediaFiles.stream().allMatch(file -> file.getFileName().contains("~")); boolean noneContainTilde = mediaFiles.stream().noneMatch(file -> file.getFileName().contains("~")); // 如果所有 fileName 都包含 '~' 或者都不包含 '~',将 is_add 字段改为 1 if (allContainTilde || noneContainTilde) { return; } // 筛选出name字段不包含'~'的数据 List<MediaFileZipEntity> filteredFiles = mediaFiles.stream() .filter(file -> !file.getFileName().contains("~")) .collect(Collectors.toList()); for (MediaFileZipEntity currentFile : filteredFiles) { String currentName = currentFile.getFileName(); Map<String, Object> currentMetadata = JSON.parseObject(JSON.toJSONString(currentFile.getMetadata()), Map.class); Long currentCreatedTime = (Long) currentMetadata.get("createdTime"); // 找到metadata中的createdTime小于当前数据的createdTime且最接近的那条数据 Optional<MediaFileZipEntity> closestFileOpt = mediaFiles.stream() .filter(file -> { Map<String, Object> metadata = JSON.parseObject(JSON.toJSONString(file.getMetadata()), Map.class); Long createdTime = (Long) metadata.get("createdTime"); String filename = file.getFileName(); return createdTime < currentCreatedTime && filename.contains("~"); }) .min((file1, file2) -> { Map<String, Object> metadata1 = JSON.parseObject(JSON.toJSONString(file1.getMetadata()), Map.class); Map<String, Object> metadata2 = JSON.parseObject(JSON.toJSONString(file2.getMetadata()), Map.class); Long time1 = (Long) metadata1.get("createdTime"); Long time2 = (Long) metadata2.get("createdTime"); return Long.compare(currentCreatedTime - time1, currentCreatedTime - time2); }); if (closestFileOpt.isEmpty()) { // 找不到小于的文件,尝试找大于且最接近的文件 closestFileOpt = mediaFiles.stream() .filter(file -> { Map<String, Object> metadata = JSON.parseObject(JSON.toJSONString(file.getMetadata()), Map.class); Long createdTime = (Long) metadata.get("createdTime"); String filename = file.getFileName(); return createdTime > currentCreatedTime && filename.contains("~"); }) .min((file1, file2) -> { Map<String, Object> metadata1 = JSON.parseObject(JSON.toJSONString(file1.getMetadata()), Map.class); Map<String, Object> metadata2 = JSON.parseObject(JSON.toJSONString(file2.getMetadata()), Map.class); Long time1 = (Long) metadata1.get("createdTime"); Long time2 = (Long) metadata2.get("createdTime"); return Long.compare(time1 - currentCreatedTime, time2 - currentCreatedTime); }); } // 提取并替换name字段 closestFileOpt.ifPresent(closestFile -> { String closestName = closestFile.getFileName(); int startIndex = closestName.indexOf("V"); if (startIndex == -1) startIndex = closestName.indexOf("W"); if (startIndex == -1) startIndex = closestName.indexOf("Z"); if (startIndex == -1) startIndex = closestName.indexOf("T"); if (startIndex == -1) { return; } int endIndex = closestName.indexOf(".", startIndex); if (endIndex == -1) { return; } String replacement = closestName.substring(startIndex, endIndex); int currentStartIndex = currentName.indexOf("V"); if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("W"); if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("Z"); if (currentStartIndex == -1) currentStartIndex = currentName.indexOf("T"); if (currentStartIndex == -1) { return; } int currentEndIndex = currentName.indexOf(".", currentStartIndex); if (currentEndIndex == -1) { return; } String newName = currentName.substring(0, currentStartIndex) + replacement + currentName.substring(currentEndIndex); currentFile.setFileName(newName); updateZipById(currentFile.getId(), currentFile); }); } } @Override public void updateMarkMediaFileNames(String jobId) { public void updateNailMediaFileNames(String jobId) { try { // 查询符合条件的数据 List<MediaFileNailEntity> mediaFiles = nailMapper.selectList(new LambdaQueryWrapper<MediaFileNailEntity>() @@ -916,6 +1058,13 @@ nailMapper.update(entity, updateWrapper); } public void updateZipById(Integer id, MediaFileZipEntity entity) { UpdateWrapper<MediaFileZipEntity> updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("id", id); zipMapper.update(entity, updateWrapper); } public void updateMediaById(Integer id, MediaFileEntity entity) { UpdateWrapper<MediaFileEntity> updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("id", id); @@ -923,10 +1072,12 @@ } public void getNoaddFile() { List<MediaFileNailEntity> markEntities = nailMapper.selectList(new LambdaQueryWrapper<MediaFileNailEntity>().eq(MediaFileNailEntity::getIsadd, 0)); List<MediaFileNailEntity> markEntities = nailMapper.selectList( new LambdaQueryWrapper<MediaFileNailEntity>().eq(MediaFileNailEntity::getIsadd, 0)); for (MediaFileNailEntity mark : markEntities) { updateMarkMediaFileNames(mark.getJobId()); updateNailMediaFileNames(mark.getJobId()); updateMediaFileNames(mark.getJobId()); updateMediaZipFileNames(mark.getJobId()); } } src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
@@ -227,6 +227,7 @@ String objectKey = callback.getFile().getObjectKey(); callback.getFile().setPath(objectKey.substring(objectKey.indexOf("/") + 1, objectKey.lastIndexOf("/"))); fileService.saveNailFile(job.getWorkspaceId(), callback.getFile()); fileService.saveZipFile(job.getWorkspaceId(),callback.getFile()); return fileService.saveFile(job.getWorkspaceId(), callback.getFile()) > 0; } src/main/java/com/dji/sample/media/util/MinioFileDownloader.java
@@ -1,5 +1,11 @@ package com.dji.sample.media.util; import io.minio.MinioClient; import io.minio.RemoveObjectArgs; import io.minio.StatObjectArgs; import io.minio.StatObjectResponse; import io.minio.errors.MinioException; import java.io.*; import java.nio.file.*; import java.util.*; @@ -58,23 +64,49 @@ } } public static void main(String[] args) { try { String bucketPath = "/data/software/minio-data/cloud-bucket"; List<String> prefixes = List.of( "c88e9f12-9fab-4aca-8fc4-b02d0b0ce5f2/DJI_202407151726_001_c88e9f12-9fab-4aca-8fc4-b02d0b0ce5f2/" ); MinioFileDownloader downloader = new MinioFileDownloader(bucketPath); // 下载并压缩文件到本地目录 String localSaveDir = "/path/to/local/save/directory"; // 修改为你想保存的本地目录 downloader.downloadAndZipFolders(prefixes, localSaveDir); public static void main(String[] args) { boolean success = deleteFileFromMinio("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", "test/瑞金图片.jpeg"); if (!success) { System.out.println("File deletion failed or file did not exist."); } } System.out.println("压缩文件已保存到:" + localSaveDir); public static boolean deleteFileFromMinio(String endpoint, String accessKey, String secretKey, String bucketName, String objectName) { try { // 创建MinioClient实例 MinioClient minioClient = MinioClient.builder() .endpoint(endpoint) .credentials(accessKey, secretKey) .build(); } catch (Exception e) { e.printStackTrace(); // 检查文件是否存在 try { StatObjectResponse stat = minioClient.statObject(StatObjectArgs.builder() .bucket(bucketName) .object(objectName) .build()); System.out.println("File exists, proceeding with deletion."); // 删除文件 minioClient.removeObject(RemoveObjectArgs.builder() .bucket(bucketName) .object(objectName) .build()); System.out.println("File deleted successfully"); return true; } catch (Exception e) { // 如果文件不存在,则捕获异常 System.out.println("File does not exist or cannot be accessed: " + e.getMessage()); return false; } } catch (Exception e) { System.out.println("Unexpected error: " + e.getMessage()); return false; } } } } src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -68,8 +68,10 @@ @RequestParam(name = "xzqdm", required = false) String xzqdm, @RequestParam(name = "bsm", required = false) String bsm, @RequestParam(name = "xmc", required = false) String xmc, @RequestParam(name = "investigate", required = false) Integer investigate ) { @RequestParam(name = "investigate", required = false) Integer investigate, @RequestParam(name = "dkmj", required = false) Double dkmj, @RequestParam(name = "isPlan",required = false) Integer isPlan ) { fileService.getNoaddFile(); //调用service分页查询 PatchesParam param = PatchesParam.builder() @@ -81,6 +83,8 @@ .bsm(bsm) .xmc(xmc) .investigate(investigate) .dkmj(dkmj) .isPlan(isPlan) .build(); PaginationData<LotInfo> data = getPatchesService.limitGet(param); return ResponseResult.success(data); @@ -140,15 +144,15 @@ public ResponseResult patchesToWayline(@RequestBody List<LotInfo> lotInfos, @RequestParam String waylineName, @RequestParam String workspaceId, @RequestParam (required = false) String patchesId, @RequestParam(required = false) String patchesId, @RequestParam double lat, @RequestParam double lon, @RequestParam(defaultValue = "1",required = false) String isTemp, @RequestParam(defaultValue = "1", required = false) String isTemp, HttpServletRequest request) throws IOException { CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); String creator = customClaim.getUsername(); MultipartFile file = timerUtil.getFile(waylineName, lotInfos, lat, lon); waylineFileService.importKmzFile(file, workspaceId, creator, patchesId,isTemp); waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, isTemp); WaylineFileEntity entity = waylineFileService.selectByName(waylineName); Map<String, String> infoMap = new HashMap<>(); URL url = null; @@ -251,7 +255,7 @@ HttpServletRequest request) throws Exception { CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); String creator = customClaim.getUsername(); MultipartFile multipartFile = shpToDataSourceService.insertGeo(file, workspaceId, waylineName, airportLat, airportLon,creator); MultipartFile multipartFile = shpToDataSourceService.insertGeo(file, workspaceId, waylineName, airportLat, airportLon, creator); waylineFileService.importKmzFileBack(multipartFile, workspaceId, creator); WaylineFileEntity entity = waylineFileService.selectByName(waylineName); Map<String, String> infoMap = new HashMap<>(); src/main/java/com/dji/sample/patches/model/Param/PatchesParam.java
@@ -29,4 +29,6 @@ private String xmc; private Integer investigate; private Double dkmj; } src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -67,6 +67,12 @@ if (param.getBsm() != null && !param.getBsm().isEmpty()) { queryWrapper.like(LotInfo::getXmc, param.getBsm()); } if (param.getDkmj()!=null){ queryWrapper.eq(LotInfo::getDkmj,param.getDkmj()); } if (param.getIsPlan() != null) { queryWrapper.eq(LotInfo::getIsPlan, param.getIsPlan()); } // 执行分页查询 Page<LotInfo> resultPage = mapper.selectPage(page, queryWrapper); src/main/java/com/dji/sample/speak/service/serviceImpl/SpeakVoiceServiceImpl.java
@@ -98,7 +98,7 @@ fileDto.setName("河道危险"); dto.setPsdk_index(2); dto.setFile(fileDto); return messageSenderService.publishServicesTopic("4TADKCM0010016", VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult(); return messageSenderService.publishServicesTopic("7CTDM5E00BR787", VoiceEnums.SPEAKER_AUDIO_PLAY_START.getMethod(), dto).getResult(); } @Override src/main/java/com/dji/sample/territory/utils/ImgZipUtil.java
@@ -1,5 +1,7 @@ package com.dji.sample.territory.utils; import com.dji.sample.media.service.impl.FileServiceImpl; import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriter; @@ -22,7 +24,7 @@ BufferedImage image = ImageIO.read(inputFile); // 计算目标图片的尺寸 long targetSizeBytes = targetSizeKB * 1024; long targetSizeBytes = targetSizeKB * 1024L; long originalSizeBytes = getImageSize(image); double compressionRatio = (double) targetSizeBytes / originalSizeBytes; int targetWidth = (int) (image.getWidth() * Math.sqrt(compressionRatio)); @@ -54,4 +56,39 @@ return 0; } } /** * 图片压缩 * * @param originalImageFile * @param compressionQuality 图片压缩质量 0-1 * @return * @throws IOException */ public static File compressImageAndGetFile(File originalImageFile, float compressionQuality) throws IOException { BufferedImage originalImage = ImageIO.read(originalImageFile); try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); try (ImageOutputStream ios = new MemoryCacheImageOutputStream(baos)) { writer.setOutput(ios); ImageWriteParam param = writer.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality(compressionQuality); writer.write(null, new javax.imageio.IIOImage(originalImage, null, null), param); } finally { writer.dispose(); } InputStream in = new ByteArrayInputStream(baos.toByteArray()); File tempFile = File.createTempFile("compressed-", ".jpg"); tempFile.deleteOnExit(); Files.copy(in, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING); return tempFile; } } public static void main(String[] args) throws IOException { String name="test/瑞金图片.jpeg"; File file=compressImageAndGetFile(new File("D:\\ideawork\\used-car\\src\\main\\resources\\DJI_20240712113312_0007_V_航点dkbh2_null.jpeg"),0.5F); FileServiceImpl.uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", name, file, "image/jpeg"); } } src/main/java/com/dji/sample/wayline/plane/controller/CreateWayLineController.java
@@ -2,6 +2,8 @@ import com.dji.sample.common.model.CustomClaim; import com.dji.sample.common.model.ResponseResult; import com.dji.sample.media.model.MinioPojo; import com.dji.sample.media.util.MinioFileDownloader; import com.dji.sample.patches.config.pojo.PatchesConfigPojo; import com.dji.sample.patches.utils.MultipartFileTOFileUtil; import com.dji.sample.patches.utils.TimerUtil; @@ -33,6 +35,9 @@ private PatchesConfigPojo patchesConfigPojo; @Autowired private IWaylineFileService waylineFileService; @Autowired private MinioPojo pojo; @PostMapping("/createPoints") public ResponseResult createPoints(@RequestBody CreateWaylineParam param) { @@ -66,17 +71,17 @@ HttpServletRequest request) throws IOException { CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); String creator = customClaim.getUsername(); String newName = param.getWaylineName() + TimerUtil.getNowDay(); // 初始化模板对象 XMLTemplateModel xmlModel = XMLTemplateModel.initPolygon(param); // 生成航线文件 CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneTemplate(), patchesConfigPojo.getPlaneTargetTemplate()); CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneWaylines(), patchesConfigPojo.getPlaneTargetWaylines()); MinioFileDownloader.deleteFileFromMinio(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), param.getWaylineName()); // kmz、上传航线库 String destKMZFile = patchesConfigPojo.getPlaneKMZFile() + newName + ".kmz"; // 输出的KMZ文件路径 String destKMZFile = patchesConfigPojo.getPlaneKMZFile() + param.getWaylineName() + ".kmz"; // 输出的KMZ文件路径 ZipUtil.zipFolder(patchesConfigPojo.getSourceDir(), destKMZFile); MultipartFile multipartFile = MultipartFileTOFileUtil.convert(new File(destKMZFile)); waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, newName, id); waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, param.getWaylineName(), id); return ResponseResult.success(); } } src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
@@ -153,23 +153,6 @@ return insertId > 0 ? file.getId() : insertId; } public Integer updateWaylineFile(String workspaceId, String newName, String id) { String objectKey = "/" + newName; LambdaUpdateWrapper<WaylineFileEntity> updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(WaylineFileEntity::getWaylineId, id) .eq(WaylineFileEntity::getWorkspaceId, workspaceId) .set(WaylineFileEntity::getObjectKey, objectKey); // 使用 mapper 执行更新操作 boolean updated = mapper.update(null, updateWrapper) > 0; if (!updated) { throw new RuntimeException("更新 objectKey 失败"); } return updated ? 1 : 0; // 返回更新结果 } @Override public Integer saveWaylineFiles(String workspaceId, WaylineFileDTO metadata, String patchesId,String isTemp) { metadata.setPatchesId(patchesId); @@ -290,7 +273,6 @@ waylineFile.setWaylineId(workspaceId); waylineFile.setUsername(creator); ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); this.updateWaylineFile(workspaceId,newName,id); } catch (IOException e) { e.printStackTrace(); }