From 0f5b969ddd52ca43ef003867b5a6749d74b7d71d Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Wed, 12 Nov 2025 17:52:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 ard-route/src/main/java/com/ard/route/util/ToolUtils.java |   63 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 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 3721f3f..5c11f9b 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,5 +1,6 @@
 package com.ard.route.util;
 
+import java.io.*;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 
@@ -7,6 +8,17 @@
  * 工具类
  */
 public class ToolUtils {
+
+    public static Boolean isLocal = false;
+
+    public static String localFilePath = "KmzFile/kmz/";
+
+    public static String kmzPath = "kmz";
+
+    /**
+     * XML 头部
+     */
+    public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
     /**
      * 生成KMZ文件名称规则
@@ -40,4 +52,55 @@
         return fileNameWithExt;
     }
 
+    /**
+     * 从URL中提取文件路径部分
+     * @param url 完整的URL字符串
+     * @return 文件路径部分
+     */
+    public static String extractFilePath(String url) {
+        if (url == null || url.isEmpty()) {
+            return "";
+        }
+
+        // 找到最后一个 "kmz/" 的位置,加上4以包含 "kmz/"
+        int index = url.lastIndexOf("kmz/");
+        if (index != -1) {
+            return url.substring(index + 4); // +4 跳过 "kmz/"
+        }
+
+        // 如果没有找到 "kmz/",尝试其他方式
+        return extractPathByDomain(url);
+    }
+
+    /**
+     * 备选方法:通过域名后的第一个斜杠来提取
+     */
+    private static String extractPathByDomain(String url) {
+        // 移除协议头
+        String withoutProtocol = url.replaceFirst("^https?://", "");
+        // 找到第一个斜杠位置
+        int slashIndex = withoutProtocol.indexOf("/");
+        if (slashIndex != -1) {
+            return withoutProtocol.substring(slashIndex + 1);
+        }
+        return "";
+    }
+
+    // 对象序列化为字节数组
+    public static byte[] serialize(Object obj) throws IOException {
+        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+             ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+            oos.writeObject(obj);
+            return baos.toByteArray();
+        }
+    }
+
+    // 字节数组反序列化为对象
+    public static Object deserialize(byte[] data) throws IOException, ClassNotFoundException {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+             ObjectInputStream ois = new ObjectInputStream(bais)) {
+            return ois.readObject();
+        }
+    }
+
 }

--
Gitblit v1.9.3