From 2587cb5656a988d580c1e3d45185ea3d1e7dd6d0 Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Mon, 01 Dec 2025 17:12:26 +0800
Subject: [PATCH] 1. 优化没有无人机类型 。 2. 优化没有航线类型。 3. 优化readOnly错误。
---
ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java | 114 +++++++++++++++-----------------------------------------
1 files changed, 31 insertions(+), 83 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 deab3a5..10f613c 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,11 +4,11 @@
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.KmzResultVo;
@@ -37,6 +37,7 @@
import static com.ard.route.util.RouteFileUtils.*;
import static com.ard.route.util.ToolUtils.*;
+import static com.ard.route.util.UavRouteReqUtils.kmzInfoVoToUavRouteReq;
/**
* Author:xia
@@ -178,54 +179,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.setPath(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.setPath(kmzFilePath);
- return result;
- } catch (Exception e) {
- throw new RuntimeException("KMZ文件生成或上传失败", e);
- }
+ } catch (Exception e) {
+ throw new RuntimeException("KMZ文件生成或上传失败", e);
}
}
@@ -253,42 +231,12 @@
return null;
}
+ /**
+ * KmzInfoVo实体类转换为UavRouteReq实体类
+ */
@Override
- public KmzResultVo updateKmzNew(UavRouteReq uavRouteReq, String oldFile, String newFile) {
- KmzResultVo result = new KmzResultVo();
- // 校验修改的文件是否存在
- ArdRouteInfo routeInformation = ardRouteInformationService.selectArdRouteInfoByName(oldFile);
- if ( routeInformation == null ){
- result.setData("修改航线文件失败,请检查文件是否存在");
- return result;
- }
-
- // 获取文件
- String minioUrl = subStringMinioUrlName(routeInformation.getPath());
- try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl);
- ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){
- ArchiveEntry entry;
- KmlInfo kmlInfo = new KmlInfo();
- KmlInfo wpmlInfo = new KmlInfo();
- KmlParams kmlParams = new KmlParams();
- while (!Objects.isNull(entry = archiveInputStream.getNextEntry())) {
- String name = entry.getName();
- if (name.toLowerCase().endsWith(".kml")) {
- kmlInfo = RouteFileUtils.parseKml(archiveInputStream);
- buildKmlParams(kmlParams, kmlInfo);
- this.handleRouteUpdate(kmlInfo, uavRouteReq, FileTypeConstants.KML, kmlParams);
- } else if (name.toLowerCase().endsWith(".wpml")) {
- wpmlInfo = RouteFileUtils.parseKml(archiveInputStream);
- this.handleRouteUpdate(wpmlInfo, uavRouteReq, FileTypeConstants.WPML, kmlParams);
- }
- }
- // 删除文件
- ossService.deleteObject(kmzPath, minioUrl);
- return buildKmzMethod(newFile, kmlInfo, wpmlInfo);
- } catch (Exception e) {
- result.setData("更新航线kmz文件失败");
- return result;
- }
+ public UavRouteReq kmzInfoVoToUavRouteReq(KmzInfoVo kmzInfoVo) {
+ return kmzInfoVoToUavRouteReq(kmzInfoVo);
}
}
--
Gitblit v1.9.3