From e778750214d72d7aa9ce42d9e0b55dcc60fc41ca Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Tue, 25 Nov 2025 13:39:34 +0800
Subject: [PATCH] 1.增加行点总数字段。
---
ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java | 83 +++++++++++++++--------------------------
1 files changed, 30 insertions(+), 53 deletions(-)
diff --git a/ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java b/ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java
index 9cbc064..1a8b76e 100644
--- a/ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java
+++ b/ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java
@@ -4,13 +4,13 @@
import cn.hutool.core.collection.CollectionUtil;
import com.ard.oss.service.impl.OssServiceContext;
import com.ard.route.constant.FileTypeConstants;
-import com.ard.route.domain.RoutePointReq;
-import com.ard.route.domain.UavRouteReq;
-import com.ard.route.domain.WaypointHeadingReq;
-import com.ard.route.domain.WaypointTurnReq;
-import com.ard.route.domain.kml.*;
+import com.ard.route.domain.djuav.RoutePointReq;
+import com.ard.route.domain.djuav.UavRouteReq;
+import com.ard.route.domain.djuav.WaypointHeadingReq;
+import com.ard.route.domain.djuav.WaypointTurnReq;
+import com.ard.route.domain.djuav.kml.*;
import com.ard.route.domain.route.ArdRouteInfo;
-import com.ard.route.domain.vo.KmzInfoVO;
+import com.ard.route.domain.vo.KmzInfoVo;
import com.ard.route.domain.vo.KmzResultVo;
import com.ard.route.enums.kml.ExitOnRCLostEnums;
import com.ard.route.service.IArdRouteInfoService;
@@ -67,7 +67,7 @@
}
// 获取文件
- String minioUrlName = subStringMinioUrlName(routeInformation.getUpPath());
+ String minioUrlName = subStringMinioUrlName(routeInformation.getPath());
try (InputStream inputStream = ossService.getObject(kmzPath,minioUrlName);
ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){
ArchiveEntry entry;
@@ -178,54 +178,31 @@
String kml = XML_HEADER + xStream.toXML(kmlInfo);
String wpml = XML_HEADER + xStream.toXML(wpmlInfo);
-
KmzResultVo result = new KmzResultVo();
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zipOutputStream = new ZipOutputStream(baos)) {
+ zipOutputStream.setLevel(0);
- // 判断本地生成kmz文件
- if (isLocal) {
- try (FileOutputStream fileOutputStream = new FileOutputStream(localFilePath + fileName + ".kmz");
- ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream)) {
- zipOutputStream.setLevel(0); // 0 表示不压缩,存储方式
+ // 创建 wpmz 目录中的 template.kml 文件条目
+ buildZipFile("wpmz/template.kml", zipOutputStream, kml);
+ // 创建 wpmz 目录中的 waylines.wpml 文件条目
+ buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml);
- // 创建KMZ文件内容
- buildZipFile("wpmz/template.kml", zipOutputStream, kml);
- buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml);
+ zipOutputStream.finish();
+ zipOutputStream.flush();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- result.setUpPath(localFilePath + fileName + ".kmz");
+ // 创建MultipartFile对象
+ MultipartFile multipartFile = new MockMultipartFile(
+ fileName + ".kmz",
+ fileName + ".kmz",
+ "application/vnd.google-earth.kmz",
+ new ByteArrayInputStream(baos.toByteArray())
+ );
+ String kmzFilePath = ossService.upload(kmzPath,multipartFile);
+ result.setPath(kmzFilePath);
return result;
- }else {
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ZipOutputStream zipOutputStream = new ZipOutputStream(baos)) {
- zipOutputStream.setLevel(0);
-
- // 创建 wpmz 目录中的 template.kml 文件条目
- buildZipFile("wpmz/template.kml", zipOutputStream, kml);
-
- // 创建 wpmz 目录中的 waylines.wpml 文件条目
- buildZipFile("wpmz/waylines.wpml", zipOutputStream, wpml);
-
- zipOutputStream.finish();
- zipOutputStream.flush();
-
- // 获取文件大小
- Double fileSize = (double) baos.size(); // 字节数
-
- // 创建MultipartFile对象
- MultipartFile multipartFile = new MockMultipartFile(
- fileName + ".kmz",
- fileName + ".kmz",
- "application/vnd.google-earth.kmz",
- new ByteArrayInputStream(baos.toByteArray())
- );
- String kmzFilePath = ossService.upload(kmzPath,multipartFile);
- result.setUpPath(kmzFilePath);
- return result;
- } catch (Exception e) {
- throw new RuntimeException("KMZ文件生成或上传失败", e);
- }
+ } catch (Exception e) {
+ throw new RuntimeException("KMZ文件生成或上传失败", e);
}
}
@@ -233,8 +210,8 @@
* 解析kmz文件
*/
@Override
- public KmzInfoVO parseKmz(String fileUrl){
- KmzInfoVO kmzInfoVO = new KmzInfoVO();
+ public KmzInfoVo parseKmz(String fileUrl){
+ KmzInfoVo kmzInfoVO = new KmzInfoVo();
try (InputStream inputStream = ossService.getObject(kmzPath,fileUrl);
ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){
ArchiveEntry entry;
@@ -264,7 +241,7 @@
}
// 获取文件
- String minioUrl = subStringMinioUrlName(routeInformation.getUpPath());
+ String minioUrl = subStringMinioUrlName(routeInformation.getPath());
try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl);
ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){
ArchiveEntry entry;
--
Gitblit v1.9.3