| | |
| | | import com.ard.route.domain.WaypointHeadingReq; |
| | | import com.ard.route.domain.WaypointTurnReq; |
| | | import com.ard.route.domain.kml.*; |
| | | import com.ard.route.domain.route.ArdRouteInfor; |
| | | import com.ard.route.domain.vo.KmzInfoVO; |
| | | import com.ard.route.domain.route.ArdRouteInfo; |
| | | import com.ard.route.domain.vo.KmzInfoVo; |
| | | import com.ard.route.domain.vo.KmzResultVo; |
| | | import com.ard.route.enums.kml.ExitOnRCLostEnums; |
| | | import com.ard.route.service.IArdRouteInforService; |
| | | import com.ard.route.service.IArdRouteInfoService; |
| | | import com.ard.route.util.InitializationUtils; |
| | | import com.ard.route.util.RouteFileUtils; |
| | | import com.ard.route.service.UavRouteService; |
| | |
| | | private OssServiceContext ossService; |
| | | |
| | | @Resource |
| | | private IArdRouteInforService ardRouteInformationService; |
| | | private IArdRouteInfoService ardRouteInformationService; |
| | | |
| | | InitializationUtils init = new InitializationUtils(); |
| | | |
| | |
| | | public KmzResultVo updateKmz(UavRouteReq uavRouteReq,String fileName){ |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInfor routeInformation = ardRouteInformationService.selectArdRouteInforByName(fileName); |
| | | ArdRouteInfo routeInformation = ardRouteInformationService.selectArdRouteInfoByName(fileName); |
| | | if ( routeInformation == null ){ |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrlName = subStringMinioUrlName(routeInformation.getUpPath()); |
| | | String minioUrlName = subStringMinioUrlName(routeInformation.getPath()); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrlName); |
| | | ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){ |
| | | ArchiveEntry entry; |
| | |
| | | } |
| | | // 删除文件 |
| | | ossService.deleteObject(kmzPath, minioUrlName); |
| | | return buildKmzMethod(routeInformation.getKmzName(), kmlInfo, wpmlInfo); |
| | | return buildKmzMethod(routeInformation.getName(), kmlInfo, wpmlInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | result.setData("更新航线kmz文件失败"); |
| | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | result.setUpPath(localFilePath + fileName + ".kmz"); |
| | | result.setPath(localFilePath + fileName + ".kmz"); |
| | | return result; |
| | | }else { |
| | | try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | |
| | | new ByteArrayInputStream(baos.toByteArray()) |
| | | ); |
| | | String kmzFilePath = ossService.upload(kmzPath,multipartFile); |
| | | result.setUpPath(kmzFilePath); |
| | | result.setPath(kmzFilePath); |
| | | return result; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("KMZ文件生成或上传失败", e); |
| | |
| | | * 解析kmz文件 |
| | | */ |
| | | @Override |
| | | public KmzInfoVO parseKmz(String fileUrl){ |
| | | KmzInfoVO kmzInfoVO = new KmzInfoVO(); |
| | | public KmzInfoVo parseKmz(String fileUrl){ |
| | | KmzInfoVo kmzInfoVO = new KmzInfoVo(); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,fileUrl); |
| | | ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){ |
| | | ArchiveEntry entry; |
| | |
| | | public KmzResultVo updateKmzNew(UavRouteReq uavRouteReq, String oldFile, String newFile) { |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInfor routeInformation = ardRouteInformationService.selectArdRouteInforByName(oldFile); |
| | | ArdRouteInfo routeInformation = ardRouteInformationService.selectArdRouteInfoByName(oldFile); |
| | | if ( routeInformation == null ){ |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrl = subStringMinioUrlName(routeInformation.getUpPath()); |
| | | String minioUrl = subStringMinioUrlName(routeInformation.getPath()); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl); |
| | | ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){ |
| | | ArchiveEntry entry; |