| | |
| | | * 编辑kmz文件 |
| | | */ |
| | | @Override |
| | | public String updateKmz(UavRouteReq uavRouteReq,String fileName){ |
| | | public KmzResultVo updateKmz(UavRouteReq uavRouteReq,String fileName){ |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInformation routeInformation = ardRouteInformationService.selectArdRouteInformationByName(fileName); |
| | | if ( routeInformation == null ){ |
| | | return "修改航线文件失败,请检查文件是否存在"; |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrl = routeInformation.getMinioUpPath(); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl); |
| | |
| | | this.handleRouteUpdate(wpmlInfo, uavRouteReq, FileTypeConstants.WPML, kmlParams); |
| | | } |
| | | } |
| | | // 删除minio的文件 |
| | | |
| | | // 插入修改好的minio文件 |
| | | |
| | | return RouteFileUtils.buildKmz("更新航线kmz文件111111", kmlInfo, wpmlInfo, kmzPath); |
| | | // 删除文件 |
| | | ossService.deleteObject(kmzPath, minioUrl); |
| | | return buildKmzMethod(routeInformation.getFileName(), kmlInfo, wpmlInfo); |
| | | } catch (Exception e) { |
| | | return "更新航线kmz文件失败"; |
| | | e.printStackTrace(); |
| | | result.setData("更新航线kmz文件失败"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | |
| | | public KmzResultVo buildKmz(String fileName, KmlParams kmlParams) { |
| | | KmlInfo kmlInfo = buildKml(kmlParams); |
| | | KmlInfo wpmlInfo = buildWpml(kmlParams); |
| | | return buildKmz(fileName, kmlInfo, wpmlInfo); |
| | | return buildKmzMethod(fileName, kmlInfo, wpmlInfo); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param wpmlInfo wpml 文件信息 |
| | | * @return 本地文件路径 |
| | | */ |
| | | public KmzResultVo buildKmz(String fileName, KmlInfo kmlInfo, KmlInfo wpmlInfo) { |
| | | public KmzResultVo buildKmzMethod(String fileName, KmlInfo kmlInfo, KmlInfo wpmlInfo) { |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(KmlInfo.class); |
| | | xStream.addImplicitCollection(KmlActionGroup.class, "action"); |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public KmzResultVo updateKmzNew(UavRouteReq uavRouteReq, String oldFile, String newFile) { |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInformation routeInformation = ardRouteInformationService.selectArdRouteInformationByName(oldFile); |
| | | if ( routeInformation == null ){ |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrl = routeInformation.getMinioUpPath(); |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | } |