From 8414c06b8e2f11b79a26828bea3e04292fd1ce48 Mon Sep 17 00:00:00 2001
From: aix <vip_xiaobin810@163.com>
Date: Thu, 25 Jul 2024 20:15:29 +0800
Subject: [PATCH] 日志
---
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java | 96 +++++++++++++++++++----------------------------
1 files changed, 39 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
index c1d2c61..9bd4a8c 100644
--- a/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
+++ b/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -112,20 +112,15 @@
}
@Override
- public Integer saveFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException {
+ public Integer saveFile(String workspaceId, FileUploadDTO file) {
MediaFileEntity fileEntity = this.fileUploadConvertToEntity(file);
fileEntity.setWorkspaceId(workspaceId);
fileEntity.setFileId(UUID.randomUUID().toString());
- if (!file.getObjectKey().endsWith(".mp4")){
- String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
- File file1 = TbFjServiceImpl.downloadFile(url);
- Object data = ImgUtil.getInfo(file1);
- fileEntity.setDroneData(data);
- }
return mapper.insert(fileEntity);
}
- public void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException {
+ public void saveNailFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException {
+ updateStatue(file.getName());
boolean endsWith = file.getObjectKey().endsWith(".mp4");
if (endsWith) {
MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity((file));
@@ -133,53 +128,35 @@
nailEntity.setFileId(UUID.randomUUID().toString());
nailMapper.insert(nailEntity);
} else {
- String endpoint = pojo.getEndpoint();
- String accessKey = pojo.getAccessKey();
- String secretKey = pojo.getSecretKey();
- String bucketName = pojo.getBucket();
String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
File file1 = TbFjServiceImpl.downloadFile(url);
File nailFile = new File(ImgZipUtil.compressImage(file1, 50).toURI());
MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity(file);
+ Object data = ImgUtil.getInfo(file1);
nailEntity.setIsOriginal(false);
+ nailEntity.setDronedata(data);
nailEntity.setWorkspaceId(workspaceId);
nailEntity.setFileName("nail" + file.getName());
nailEntity.setObjectKey("/nail" + file.getPath() + "/" + file.getName());
nailEntity.setFilePath("nail" + file.getPath());
String nailName = nailEntity.getObjectKey();
nailEntity.setFileId(UUID.randomUUID().toString());
- uploadFile(endpoint, accessKey, secretKey, bucketName, nailName, nailFile, "image/jpeg");
+ 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");
nailMapper.insert(nailEntity);
- try {
- if (file.getName().contains("~")) {
- String name = TimerUtil.getDkbh(file.getName());
- List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name));
- if (!lotInfos.isEmpty()) {
- LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
- updateWrapper.eq(LotInfo::getDkbh, name)
- .eq(LotInfo::getInvestigate, 0)
- .set(LotInfo::getInvestigate, 1);
- patchesMapper.update(null, updateWrapper);
- }
- }
- MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file);
- long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime());
- File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(),
- file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI());
- Object data = ImgUtil.getInfo(file1);
- mediaFileMarkEntity.setDronedata(data);
- mediaFileMarkEntity.setWorkspaceId(workspaceId);
- mediaFileMarkEntity.setIsadd(0);
- mediaFileMarkEntity.setIsOriginal(false);
- mediaFileMarkEntity.setFileId(UUID.randomUUID().toString());
- mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName());
- mediaFileMarkEntity.setFileName("mark" + file.getName());
- mediaFileMarkEntity.setFilePath("mark" + file.getPath());
- String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt"
- uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg");
- markMapper.insert(mediaFileMarkEntity);
- } catch (Exception e) {
- e.printStackTrace();
+ }
+ }
+
+ public void updateStatue(String filename) {
+ if (filename.contains("~")) {
+ String name = TimerUtil.getDkbh(filename);
+ List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, name));
+ if (!lotInfos.isEmpty()) {
+ LambdaUpdateWrapper<LotInfo> updateWrapper = new LambdaUpdateWrapper<>();
+ updateWrapper.eq(LotInfo::getDkbh, name)
+ .eq(LotInfo::getInvestigate, 0)
+ .set(LotInfo::getInvestigate, 1);
+ patchesMapper.update(null, updateWrapper);
}
}
}
@@ -208,11 +185,19 @@
return markEntity.getDronedata();
}
}
+ } else {
+ List<MediaFileNailEntity> entities = nailMapper.selectList(new LambdaQueryWrapper<MediaFileNailEntity>()
+ .eq(MediaFileNailEntity::getFileName, name));
+ if (entities != null && !entities.isEmpty()) {
+ for (MediaFileNailEntity NailEntity : entities) {
+ if (NailEntity.getDronedata() != null) {
+ return NailEntity.getDronedata();
+ }
+ }
+ }
}
-
return "null";
}
-
@Override
public List<MediaFileDTO> getAllFilesByWorkspaceId(String workspaceId) {
@@ -436,22 +421,18 @@
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(prefixes, localSaveDir);
-
- System.out.println("压缩文件已保存到:" + localSaveDir);
-
- } catch (Exception e) {
+ downloader.downloadAndZipFolders(jobIds, localSaveDir);
+ } catch (Exception e) {
e.printStackTrace();
- return ResponseResult.error("下载失败"+e.getMessage());
+ return ResponseResult.error("下载失败" + e.getMessage());
}
return ResponseResult.success("下载成功");
}
+
@Override
public List<String> getUniqueFilePaths(List<String> jobIds) {
return mapper.selectList(
@@ -462,6 +443,7 @@
.distinct()
.collect(Collectors.toList());
}
+
@Override
public List<MediaFileDTO> getFilesByWorkspaceAndJobId(String workspaceId, String jobId) {
return mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>()
@@ -524,6 +506,7 @@
if (file != null) {
builder.fileName(file.getName())
+ .filePath(file.getPath())
.fingerprint(file.getFingerprint())
.objectKey(file.getObjectKey())
.subFileType(file.getSubFileType())
@@ -553,6 +536,7 @@
.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());
@@ -823,6 +807,7 @@
e.printStackTrace();
}
}
+
@Override
public PaginationData<MediaFileEntity> getJobId(int pageNum, int pageSize, String workspaceId) {
List<MediaFileEntity> allRecords = new ArrayList<>();
@@ -877,8 +862,6 @@
}
-
-
@Override
public PaginationData<MediaFileEntity> getPhotoByJobId(int pageNum, int pageSize, String workspaceId, String jobId) {
@@ -916,7 +899,6 @@
return new PaginationData<>(pagedUniqueFiles, pagination);
}
-
public List<MediaFileEntity> getMedia(String jobId) {
--
Gitblit v1.9.3