From 608dea1f05bb2e33df4df050380fa49602b6c3ff Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Sat, 17 Aug 2024 14:47:15 +0800
Subject: [PATCH] 图斑历史成果导出,媒体文件上传修改
---
src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java | 9 ++--
src/main/java/com/dji/sample/droneairport/utils/SM4Util.java | 22 ----------
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java | 57 +++++++++++-----------------
src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java | 5 +-
src/main/java/com/dji/sample/media/service/IFileService.java | 2
src/main/java/com/dji/sample/patches/service/GetPatchesService.java | 2
src/main/java/com/dji/sample/patches/utils/TimerUtil.java | 2
src/main/java/com/dji/sample/patches/controller/PatchesController.java | 7 ++-
8 files changed, 38 insertions(+), 68 deletions(-)
diff --git a/src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java b/src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java
index ff0632e..f1ea661 100644
--- a/src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java
+++ b/src/main/java/com/dji/sample/droneairport/service/impl/RegistServiceImpl.java
@@ -493,8 +493,9 @@
}
public String getBizidnameByTask(String taskId) {
- TaskInfo taskInfo = taskInfoMapper.selectOne(new LambdaQueryWrapper<TaskInfo>().eq(TaskInfo::getTaskId, taskId));
- return taskInfo.getName();
+ List<LotInfo> lotInfos = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getTaskId, taskId));
+ String taskName = lotInfos.get(0).getTaskName();
+ return taskName;
}
public static String enSM2(String data, String pubKey) throws InvalidCipherTextException, IOException {
diff --git a/src/main/java/com/dji/sample/droneairport/utils/SM4Util.java b/src/main/java/com/dji/sample/droneairport/utils/SM4Util.java
index 394e466..f952cb5 100644
--- a/src/main/java/com/dji/sample/droneairport/utils/SM4Util.java
+++ b/src/main/java/com/dji/sample/droneairport/utils/SM4Util.java
@@ -117,28 +117,8 @@
" \"1581F6QAD241800B6V95\",\n" +
" \"1581F6QAD241500BDZ3J\"\n" +
" ],\n" +
- " \"bizidname\": \"2023年度全国国土变更调查举证模块\",\n" +
+ " \"taskid\": \"f78aed9f-86cd-4a49-87da-bbb9c7a1941d\",\n" +
" \"tasklist\": [\n" +
- " {\n" +
- " \"bsm\": \"2028107171717717107171017\",\n" +
- " \"xzqdm\": \"310000\",\n" +
- " \"dkbh\": \"ndbg201102U0172710711\",\n" +
- " \"dklx\": \"ndbg2024\",\n" +
- " \"dkmc\": \"小桥头\",\n" +
- " \"dkmj\": 20.5,\n" +
- " \"dkfw\": \"MULTIPOLYGON(((115.85261028414699 28.628065910491646,115.85234952636368 28.627469892700983,115.85043542990357 28.628240439727712,115.85050295853954 28.62842805760428,115.85071376127738 28.628739229859185,115.85080329411801 28.628869938164858,115.85261028414699 28.628065910491646)))\",\n" +
- " \"bz\": null\n" +
- " },\n" +
- " {\n" +
- " \"bsm\": \"207\",\n" +
- " \"xzqdm\": \"31000\",\n" +
- " \"dkbh\": \"n1\",\n" +
- " \"dklx\": \"n4\",\n" +
- " \"dkmc\": \"小桥\",\n" +
- " \"dkmj\": 20.5,\n" +
- " \"dkfw\": \"MULTIPOLYGON(((115.86528871951153 28.625287925196325,115.86561708513025 28.625787612007546,115.86815834948467 28.624602640426623,115.86773004650362 28.62425999804172,115.86528871951153 28.625287925196325)))\",\n" +
- " \"bz\": null\n" +
- " },\n" +
" {\n" +
" \"bsm\": \"20281071717177177\",\n" +
" \"xzqdm\": \"31000\",\n" +
diff --git a/src/main/java/com/dji/sample/media/service/IFileService.java b/src/main/java/com/dji/sample/media/service/IFileService.java
index 94ff38b..8d09b4b 100644
--- a/src/main/java/com/dji/sample/media/service/IFileService.java
+++ b/src/main/java/com/dji/sample/media/service/IFileService.java
@@ -39,7 +39,7 @@
*/
Integer saveFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException;
- void saveFiles(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException;
+ void saveFiles(String workspaceId, FileUploadDTO file,File mediaFile);
// void saveNailFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException;
// void saveZipFile(String workspaceId, FileUploadDTO file) throws IOException, ImageProcessingException;
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 950203a..7873d13 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
@@ -144,33 +144,20 @@
Object data = ImgUtil.getInfo(downloadedFile);
fileEntity.setDroneData(data);
updateStatue(file.getName());
+ saveFiles(workspaceId,file,downloadedFile);
}
return mapper.insert(fileEntity);
}
- public void saveFiles(String workspaceId, FileUploadDTO file) {
+ public void saveFiles(String workspaceId, FileUploadDTO file,File mediaFile) {
// 更新文件状态
- updateStatue(file.getName());
+// updateStatue(file.getName());
try {
- // 下载文件
- boolean endsWithMp4 = file.getObjectKey().endsWith(".mp4");
-
- if (endsWithMp4) {
- // 处理视频文件
-// MediaFileZipEntity zipEntity = this.fileUploadConvertToZipEntity(file);
-// zipEntity.setWorkspaceId(workspaceId);
-// zipEntity.setFileId(UUID.randomUUID().toString());
-// zipMapper.insert(zipEntity);
-
- // 处理视频文件的其他逻辑(如果有)
- } else {
// 处理图片文件
- String url = pojo.getEndpoint() + "/" + pojo.getBucket() + file.getObjectKey();
- File downloadedFile = TbFjServiceImpl.downloadFile(url);
- File nailFile = new File(ImgZipUtil.compressImage(downloadedFile, 50).toURI());
+ File nailFile = new File(ImgZipUtil.compressImage(mediaFile, 50).toURI());
MediaFileNailEntity nailEntity = this.fileUploadConvertToNailEntity(file);
- Object data = ImgUtil.getInfo(downloadedFile);
- nailEntity.setIsadd(0);
+ Object data = ImgUtil.getInfo(mediaFile);
+// nailEntity.setIsadd(0);
nailEntity.setIsOriginal(false);
nailEntity.setDronedata(data);
nailEntity.setWorkspaceId(workspaceId);
@@ -181,27 +168,27 @@
nailEntity.setFileId(UUID.randomUUID().toString());
// 上传图片文件
-// uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", file.getObjectKey(), downloadedFile, "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");
+// uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket",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);
// 处理压缩后的图片文件(如果有)
-// File zipFile = new File(ImgZipUtil.compressImageAndGetFile(downloadedFile, 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 zipName = zipEntity.getObjectKey();
-// zipEntity.setFileId(UUID.randomUUID().toString());
+ File zipFile = new File(ImgZipUtil.compressImageAndGetFile(mediaFile, 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 zipName = zipEntity.getObjectKey();
+ zipEntity.setFileId(UUID.randomUUID().toString());
// 上传压缩文件
-// uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), zipName, zipFile, "image/jpeg");
-// uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", zipName, zipFile, "image/jpeg");
-// zipMapper.insert(zipEntity);
- }
+ uploadFile(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), zipName, zipFile, "image/jpeg");
+ uploadFile("http://139.196.74.78:9000", "sxkj", "sxkj2024", "cloud-bucket", zipName, zipFile, "image/jpeg");
+ zipMapper.insert(zipEntity);
+
} catch (IOException | ImageProcessingException e) {
// 处理异常
e.printStackTrace();
diff --git a/src/main/java/com/dji/sample/patches/controller/PatchesController.java b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
index 2bee9dc..78b2265 100644
--- a/src/main/java/com/dji/sample/patches/controller/PatchesController.java
+++ b/src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -273,9 +273,10 @@
}
@GetMapping("/getExcel")
- public ResponseEntity<byte[]> exportExcel(@RequestParam String workspaceId) {
- List<LotInfo> lotInfos = getPatchesService.listLotinfo(workspaceId);
+ public ResponseEntity<byte[]> exportExcel(@RequestParam String ids) {
+// List<LotInfo> lotInfos = getPatchesService.listLotinfo(workspaceId);
try {
+ List<LotInfo> lotInfos = getPatchesService.getLotInfosByIDs(ids);
ByteArrayInputStream excelStream = ExcelUtil.exportLotInfoToExcel(lotInfos);
byte[] excelData = excelStream.readAllBytes();
excelStream.close();
@@ -288,7 +289,7 @@
return new ResponseEntity<>(excelData, headers, HttpStatus.OK);
} catch (IOException e) {
e.printStackTrace();
- return new ResponseEntity<>(("Failed to generate Excel file.").getBytes(), HttpStatus.INTERNAL_SERVER_ERROR);
+ return new ResponseEntity<>(("生成excel失败.").getBytes(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
diff --git a/src/main/java/com/dji/sample/patches/service/GetPatchesService.java b/src/main/java/com/dji/sample/patches/service/GetPatchesService.java
index abcaf86..23ad54e 100644
--- a/src/main/java/com/dji/sample/patches/service/GetPatchesService.java
+++ b/src/main/java/com/dji/sample/patches/service/GetPatchesService.java
@@ -50,6 +50,6 @@
List<LotInfo>listLotinfo(String workspaceID);
void insertLotinfo(List<LotInfo> list);
-
+ List<LotInfo> getLotInfosByIDs(String idsStr);
LotInfo getLotinfoToDb(String dkbh);
}
diff --git a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
index 581b5f6..1207548 100644
--- a/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
+++ b/src/main/java/com/dji/sample/patches/service/impl/GetPatchesServiceImpl.java
@@ -17,10 +17,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -215,4 +212,8 @@
mapper.insert(list.get(i));
}
}
+ public List<LotInfo> getLotInfosByIDs(String idsStr) {
+ List<String> idList = Arrays.asList(idsStr.split(","));
+ return mapper.selectBatchIds(idList);
+ }
}
diff --git a/src/main/java/com/dji/sample/patches/utils/TimerUtil.java b/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
index b8c1fe2..0423dea 100644
--- a/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
+++ b/src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -324,7 +324,7 @@
entity.setSize(getFileSize(file)) ;
entity.setHash(sm3(bytesArray));
entity.setCount(dkbhSet.size());// 统计dkbh的数量
- entity.setUrl(territoryConfigPojo.getResultGtsave()+"/"+dbName);
+ entity.setUrl(territoryConfigPojo.getResultGtsave()+dbName);
entity.setRegioncode(code);
entity.setExtension(".db");
entity.setAttachmentCount(count);
--
Gitblit v1.9.3