Xiajijian
2026-03-10 f1eefdbe63b64afab32502785e9c46ffd35fc718
ard-route/src/main/java/com/ard/route/util/ToolUtils.java
@@ -1,8 +1,11 @@
package com.ard.route.util;
import com.ard.inspection.domain.ArdPointCloud;
import com.ard.route.domain.djuav.UavRouteReq;
import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
 * 工具类
@@ -84,6 +87,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);
@@ -96,6 +102,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();
        }
    }
@@ -125,7 +138,14 @@
        return Integer.valueOf(parts[1]);
    }
    /**
     * 截取字符串
     * 获取经纬度高度
     */
    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());
@@ -133,7 +153,27 @@
        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) {
        return "0-" + uavRouteReq.getDroneType() + "-0";
    }
}