Xiajijian
2025-11-29 bd2ead7fc4642833ae6188574e5738407e988c1c
ard-route/src/main/java/com/ard/route/service/impl/UavRouteServiceImpl.java
@@ -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
@@ -230,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);
    }
}