From 3f43e40ed1a1e9f66b3ad2862da9dbc4b710c712 Mon Sep 17 00:00:00 2001
From: nishiwei <13126973358@163.com>
Date: Fri, 23 Oct 2026 14:09:47 +0800
Subject: [PATCH] 智云3.0机场1适配内容提交

---
 ard-route/src/main/java/com/ard/route/util/ToolUtils.java |   72 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/ard-route/src/main/java/com/ard/route/util/ToolUtils.java b/ard-route/src/main/java/com/ard/route/util/ToolUtils.java
index 2d34f6c..ef51939 100644
--- a/ard-route/src/main/java/com/ard/route/util/ToolUtils.java
+++ b/ard-route/src/main/java/com/ard/route/util/ToolUtils.java
@@ -1,17 +1,18 @@
 package com.ard.route.util;
 
+import com.ard.inspection.domain.ArdPointCloud;
+import com.ard.route.domain.djuav.UavRouteReq;
+import com.ard.route.enums.kml.DroneEnumValueEnums;
 import java.io.*;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 工具类
  */
 public class ToolUtils {
-
-    public static Boolean isLocal = false;
-
-    public static String localFilePath = "KmzFile/kmz/";
 
     public static String kmzPath = "kmz";
 
@@ -88,6 +89,9 @@
 
     // 对象序列化为字节数组
     public static byte[] serialize(Object obj) throws IOException {
+        if (obj == null) {
+            return null;
+        }
         try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(baos)) {
             oos.writeObject(obj);
@@ -100,6 +104,13 @@
         try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
              ObjectInputStream ois = new ObjectInputStream(bais)) {
             return ois.readObject();
+        }
+    }
+
+    public static List<ArdPointCloud> deserializeLs(byte[] data) throws IOException, ClassNotFoundException {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+             ObjectInputStream ois = new ObjectInputStream(bais)) {
+            return (List<ArdPointCloud>) ois.readObject();
         }
     }
 
@@ -129,4 +140,57 @@
         return Integer.valueOf(parts[1]);
     }
 
+    /**
+     * 截取机型子类型
+     * 参数: "0-67-1" 返回 1;格式不足三段时返回 0
+     */
+    public static Integer subStringSubDroneType(String str) {
+        String[] parts = str.split("-");
+        return parts.length > 2 ? Integer.valueOf(parts[2]) : 0;
+    }
+
+    /**
+     * 截取字符串
+     * 获取经纬度高度
+     */
+    public static Double getDoublePoint(String str,String type) {
+        if (str == null || str.isEmpty()) {
+            return null;
+        }
+        String[] parts = str.split(",");
+        if ("lon".equals(type)) {
+            return Double.parseDouble(parts[0].trim());
+        }
+        if ("lat".equals(type)){
+            return Double.parseDouble(parts[1].trim());
+        }
+        if ("alt".equals(type)){
+            return Double.parseDouble(parts[2].trim());
+        }
+        return null;
+    }
+
+    /**
+     * 获取航线类型方法
+     */
+    public static String templateTypeData(UavRouteReq uavRouteReq) {
+        if ("waypoint".equals(uavRouteReq.getTemplateType())){
+            return "0";
+        }
+        return "1";
+    }
+
+    /**
+     * 获取无人机类型方法
+     */
+    public static String droneTypeData(UavRouteReq uavRouteReq) {
+        // 机场1:M30(67-0) / M30T(67-1) 需要保留 subType,避免航线记录的 aircraft 都变成 0-67-0。
+        // 其它机型保持原有返回值,机场2/3 不受影响。
+        if (Objects.equals(DroneEnumValueEnums.M30_M30T.getValue(), uavRouteReq.getDroneType())) {
+            return "0-" + uavRouteReq.getDroneType() + "-"
+                    + (uavRouteReq.getSubDroneType() == null ? 0 : uavRouteReq.getSubDroneType());
+        }
+        return "0-" + uavRouteReq.getDroneType() + "-0";
+    }
+
 }

--
Gitblit v1.9.3