| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.ard.common.utils.SecurityUtils; |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.route.constant.FileTypeConstants; |
| | | import com.ard.route.domain.RoutePointReq; |
| | |
| | | import com.ard.route.domain.WaypointHeadingReq; |
| | | import com.ard.route.domain.WaypointTurnReq; |
| | | import com.ard.route.domain.kml.*; |
| | | import com.ard.route.domain.route.ArdRouteInformation; |
| | | import com.ard.route.domain.route.ArdRouteInfor; |
| | | 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.IArdRouteInformationService; |
| | | import com.ard.route.util.FileUtils; |
| | | import com.ard.route.service.IArdRouteInforService; |
| | | import com.ard.route.util.InitializationUtils; |
| | | import com.ard.route.util.RouteFileUtils; |
| | | import com.ard.route.service.UavRouteService; |
| | |
| | | import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private OssServiceContext ossService; |
| | | |
| | | @Resource |
| | | private IArdRouteInformationService ardRouteInformationService; |
| | | private IArdRouteInforService ardRouteInformationService; |
| | | |
| | | InitializationUtils init = new InitializationUtils(); |
| | | |
| | |
| | | public KmzResultVo updateKmz(UavRouteReq uavRouteReq,String fileName){ |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInformation routeInformation = ardRouteInformationService.selectArdRouteInformationByName(fileName); |
| | | ArdRouteInfor routeInformation = ardRouteInformationService.selectArdRouteInforByName(fileName); |
| | | if ( routeInformation == null ){ |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrl = routeInformation.getMinioUpPath(); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl); |
| | | String minioUrlName = subStringMinioUrlName(routeInformation.getUpPath()); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrlName); |
| | | ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){ |
| | | ArchiveEntry entry; |
| | | KmlInfo kmlInfo = new KmlInfo(); |
| | |
| | | } |
| | | } |
| | | // 删除文件 |
| | | ossService.deleteObject(kmzPath, minioUrl); |
| | | return buildKmzMethod(routeInformation.getFileName(), kmlInfo, wpmlInfo); |
| | | ossService.deleteObject(kmzPath, minioUrlName); |
| | | return buildKmzMethod(routeInformation.getKmzName(), kmlInfo, wpmlInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | result.setData("更新航线kmz文件失败"); |
| | |
| | | * 生成kmz文件(带航点) |
| | | */ |
| | | @Override |
| | | public KmzResultVo buildKmz(UavRouteReq uavRouteReq, String fileName) { |
| | | public KmzResultVo buildKmz(UavRouteReq uavRouteReq, String kmzName) { |
| | | // 赋值默认参数 |
| | | init.initialization(uavRouteReq); |
| | | KmlParams kmlParams = new KmlParams(); |
| | | BeanUtils.copyProperties(uavRouteReq, kmlParams); |
| | | kmlParams.setRoutePointList(BeanUtil.copyToList(uavRouteReq.getRoutePointList(), RoutePointInfo.class)); |
| | | return buildKmz(fileName, kmlParams); |
| | | return buildKmz(kmzName, kmlParams); |
| | | } |
| | | |
| | | /** |
| | |
| | | new ByteArrayInputStream(baos.toByteArray()) |
| | | ); |
| | | String kmzFilePath = ossService.upload(kmzPath,multipartFile); |
| | | result.setFileNameNew(getFileNameWithoutExtension(kmzFilePath)); |
| | | result.setMinioUpPath(extractFilePath(kmzFilePath)); |
| | | result.setUpPath(kmzFilePath); |
| | | result.setUpFileSize(fileSize); |
| | | return result; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("KMZ文件生成或上传失败", e); |
| | |
| | | public KmzResultVo updateKmzNew(UavRouteReq uavRouteReq, String oldFile, String newFile) { |
| | | KmzResultVo result = new KmzResultVo(); |
| | | // 校验修改的文件是否存在 |
| | | ArdRouteInformation routeInformation = ardRouteInformationService.selectArdRouteInformationByName(oldFile); |
| | | ArdRouteInfor routeInformation = ardRouteInformationService.selectArdRouteInforByName(oldFile); |
| | | if ( routeInformation == null ){ |
| | | result.setData("修改航线文件失败,请检查文件是否存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 获取文件 |
| | | String minioUrl = routeInformation.getMinioUpPath(); |
| | | String minioUrl = subStringMinioUrlName(routeInformation.getUpPath()); |
| | | try (InputStream inputStream = ossService.getObject(kmzPath,minioUrl); |
| | | ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){ |
| | | ArchiveEntry entry; |