Xiajijian
2025-11-25 e778750214d72d7aa9ce42d9e0b55dcc60fc41ca
1.增加行点总数字段。
5 files modified
88 ■■■■■ changed files
ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java 3 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java 63 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/util/ToolUtils.java 4 ●●●●● patch | view | raw | blame | history
ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml 9 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java
@@ -64,4 +64,7 @@
    /** 航线数据 */
    private byte[] routeData;
    /** 行点总数 */
    private Integer pointCount;
}
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
@@ -122,6 +122,7 @@
        KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName());
        ardRouteInfo.setPath(kmzResult.getPath());
        ardRouteInfo.setReadOnly("0");
        ardRouteInfo.setPointCount(getPointCount(ardRouteInfo));
        ardRouteInfoMapper.insertArdRouteInfo(ardRouteInfo);
        return kmzResult.getPath();
    }
@@ -150,9 +151,17 @@
            }
            ardRouteInfo.setPath(kmzResult.getPath());
        }
        ardRouteInfo.setPointCount(getPointCount(ardRouteInfo));
        return ardRouteInfoMapper.updateArdRouteInfo(ardRouteInfo);
    }
    private Integer getPointCount(ArdRouteInfo ardRouteInfo) {
        if (ardRouteInfo.getUavRouteReq().getRoutePointList() != null) {
            return ardRouteInfo.getUavRouteReq().getRoutePointList().size();
        }
        return 0;
    }
    /**
     * 批量删除航线(kmz)
     * 
ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java
@@ -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.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);
        }
    }
ard-route/src/main/java/com/ard/route/util/ToolUtils.java
@@ -9,10 +9,6 @@
 */
public class ToolUtils {
    public static Boolean isLocal = false;
    public static String localFilePath = "KmzFile/kmz/";
    public static String kmzPath = "kmz";
    /**
ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml
@@ -18,6 +18,7 @@
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="pointCount"    column="point_count"    />
    </resultMap>
    <sql id="selectArdRouteInfoVo">
@@ -33,7 +34,8 @@
               create_by,
               create_time,
               update_by,
               update_time
               update_time,
               point_count
        from ard_route_info
    </sql>
@@ -74,6 +76,7 @@
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="pointCount != null">point_count,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
@@ -89,6 +92,7 @@
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="pointCount != null">#{pointCount},</if>
         </trim>
    </insert>
@@ -107,6 +111,7 @@
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="pointCount != null">point_count = #{pointCount},</if>
        </trim>
        where id = #{id}
    </update>
@@ -135,7 +140,7 @@
    </delete>
    <select id="selectArdRouteInfoByGroupId" parameterType="String" resultMap="ArdRouteInfoResult">
        select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time from ard_route_info
        select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time,point_count from ard_route_info
        <where>
            <if test="groupId != null "> and group_id = #{groupId}</if>
        </where>