图斑生成kmz航线文件,入库并返回前端,优化图斑模块
14 files modified
2 files deleted
1 files added
| | |
| | | <groupId>org.freemarker</groupId> |
| | | <artifactId>freemarker</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- MultipartFile文件类型转换 --> |
| | | <dependency> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-test</artifactId> |
| | | <version>5.0.8.RELEASE</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | |
| New file |
| | |
| | | package com.dji.sample.patches.controller; |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.common.util.MinioUrlUtils; |
| | | import com.dji.sample.log.aspect.SysLogAnnotation; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.patches.model.Param.PatchesParam; |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import com.dji.sample.patches.service.GetPatchesService; |
| | | import com.dji.sample.patches.service.impl.ShpToDataSourceServiceImpl; |
| | | import com.dji.sample.wayline.model.entity.WaylineFileEntity; |
| | | import com.dji.sample.wayline.service.IWaylineFileService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.net.URL; |
| | | import java.sql.SQLException; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | |
| | | @RequestMapping("${url.patches.prefix}${url.patches.version}/Patches") |
| | | @RestController |
| | | public class PatchesController { |
| | | @Autowired |
| | | private GetPatchesService getPatchesService; |
| | | @Autowired |
| | | private ShpToDataSourceServiceImpl shpToDataSourceServiceImpl; |
| | | @Autowired |
| | | private IWaylineFileService waylineFileService; |
| | | |
| | | @GetMapping("/getPatches") |
| | | @SysLogAnnotation(operModul = "图斑", operType = "查询", operDesc = "查询图斑的全部信息") |
| | | public ResponseResult<PaginationData<LotInfo>> page(@RequestParam Integer page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, |
| | | @RequestParam String workspaceId) { |
| | | //调用service分页查询 |
| | | PatchesParam param = PatchesParam.builder() |
| | | .page(page) |
| | | .workspaceId(workspaceId) |
| | | .pageSize(pageSize).build(); |
| | | PaginationData<LotInfo> data = getPatchesService.limitGet(param); |
| | | return ResponseResult.success(data); |
| | | } |
| | | |
| | | @DeleteMapping("/delPatches") |
| | | public ResponseResult del() { |
| | | getPatchesService.delPatches(); |
| | | return ResponseResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/GetPhoto") |
| | | public ResponseResult<PaginationData<MediaFileEntity>> GetPatchesPhoto(@RequestParam(name = "page", defaultValue = "1") Integer page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, |
| | | @RequestParam String workspaceId, |
| | | @RequestParam String dkbh) { |
| | | try { |
| | | PatchesParam param = PatchesParam.builder() |
| | | .page(page) |
| | | .workspaceId(workspaceId) |
| | | .pageSize(pageSize).build(); |
| | | PaginationData<MediaFileEntity> paginationData = getPatchesService.getPhoto(param, dkbh); |
| | | return ResponseResult.success(paginationData); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); // 记录异常信息到控制台 |
| | | return ResponseResult.error("未匹配到相关图片"); // 返回错误信息,可以根据实际情况自定义 |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/getGeo") |
| | | public ResponseResult getGeo(@RequestParam("file") MultipartFile file, |
| | | @RequestParam String workspaceId, |
| | | @RequestParam String waylineName, |
| | | @RequestParam double airportLat, |
| | | @RequestParam double airportLon, |
| | | HttpServletRequest request) throws Exception { |
| | | MultipartFile multipartFile = shpToDataSourceServiceImpl.insertGeo(file, workspaceId, waylineName, airportLat, airportLon); |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | waylineFileService.importKmzFileBack(multipartFile, workspaceId, creator); |
| | | WaylineFileEntity entity = waylineFileService.selectByName(waylineName); |
| | | URL url = null; |
| | | try { |
| | | url = waylineFileService.getObjectUrl(workspaceId, entity.getWaylineId()); |
| | | } catch (SQLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return ResponseResult.success(MinioUrlUtils.getUrl(url)); |
| | | } |
| | | } |
| | |
| | | public interface GetPatchesService { |
| | | PaginationData<LotInfo> limitGet(PatchesParam param); |
| | | void delPatches(); |
| | | |
| | | PaginationData<MediaFileEntity> getPhoto(PatchesParam param,String dkbh); |
| | | } |
| | |
| | | package com.dji.sample.patches.service; |
| | | |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import com.dji.sample.wayline.model.dto.WaylineFileDTO; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import java.util.List; |
| | | |
| | | public interface ShpToDataSourceService { |
| | | List<LotInfo> insertGeo(MultipartFile file ,String workspaceId,String waylineName) throws IOException; |
| | | ResponseEntity<Resource> backWayline(String waylineName) throws FileNotFoundException, UnsupportedEncodingException; |
| | | MultipartFile insertGeo(MultipartFile file , String workspaceId,String waylineName, double airportLat, double airportLon) throws Exception; |
| | | |
| | | } |
| | |
| | | import com.dji.sample.patches.utils.ShapeFileUtil; |
| | | import com.dji.sample.patches.xml.mode.XMLTemplateModel; |
| | | import com.dji.sample.patches.xml.utils.CreateWaylineFileUtils; |
| | | import com.dji.sample.wayline.service.IWaylineFileService; |
| | | import org.locationtech.jts.geom.Coordinate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.FileSystemResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import static com.dji.sample.common.error.CommonErrorEnum.ILLEGAL_ARGUMENT; |
| | | import static com.dji.sample.patches.utils.ZipUtil.compressToKMZ; |
| | | import static com.dji.sample.patches.utils.FormatConversionUtil.getCentros; |
| | | import static com.dji.sample.patches.utils.MultipartFileTOFileUtil.convert; |
| | | import static com.dji.sample.patches.utils.ZipUtil.*; |
| | | import static org.locationtech.jts.io.WKTConstants.POLYGON; |
| | | |
| | | @Service |
| | | public class ShpToDataSourceServiceImpl implements ShpToDataSourceService { |
| | | @Autowired |
| | | private ShpToDataSourceMapper mapper; |
| | | String head = POLYGON; |
| | | double airportLat = 28.624514734; // 机场纬度 |
| | | double airportLon = 115.856725497; // 机场经度 |
| | | |
| | | String kmlFilePath = "src/main/resources/template/wpmz/template.kml"; // KML文件路径 |
| | | String wpmlFilePath = "src/main/resources/template/wpmz/waylines.wpml"; // WPML文件路径 |
| | | String end = ".kmz"; |
| | | @Autowired |
| | | private IWaylineFileService service; |
| | | String head = POLYGON; |
| | | String sourceDir = "/home/drone/server/template/wpmz/"; // 源文件夹路径 |
| | | |
| | | MultipartFile multipartFile; |
| | | |
| | | String json; |
| | | |
| | | public List<LotInfo> insertGeo(MultipartFile file, String workspaceId, String waylineName) throws IOException { |
| | | public MultipartFile insertGeo(MultipartFile file, String workspaceId,String waylineName, double airportLat, double airportLon) throws Exception { |
| | | List<LotInfo> list = new ArrayList<>(); |
| | | MultipartFileTOFileUtil multipartFileTOFileUtil = new MultipartFileTOFileUtil(); |
| | | File file1 = multipartFileTOFileUtil.multipartFile2File(file); |
| | |
| | | lotInfo.setWorkspaceId(workspaceId); |
| | | lotInfo.setDkfw(json); |
| | | lotInfo.setDkbh("dkbh" + i); |
| | | list.add(lotInfo); |
| | | String strs=getCentros(list); |
| | | String end =strs.replaceAll("\\(","").replaceAll(", NaN\\)",""); |
| | | String[] points=end.split(","); |
| | | lotInfo.setXzb(Double.valueOf(points[0])); |
| | | lotInfo.setYzb(Double.valueOf(points[1])); |
| | | mapper.insert(lotInfo); |
| | | list.add(lotInfo); |
| | | System.out.println(lotInfo); |
| | | } |
| | | Coordinate[] coordinates = GeoToolsUtil.getRoutePointOrder(list, airportLat, airportLon); |
| | | XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, list); |
| | | CreateWaylineFileUtils.createWaylineFile(xmlModel); |
| | | String destinationKMZFilePath = "src/main/resources/template/kmz/" + waylineName + ".kmz"; |
| | | try { |
| | | compressToKMZ(kmlFilePath, wpmlFilePath, destinationKMZFilePath); |
| | | System.out.println("Files compressed to KMZ successfully."); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | System.out.println("Error compressing files to KMZ: " + e.getMessage()); |
| | | } |
| | | return list; |
| | | // 压缩文件夹中的内容 |
| | | String destKMZFile = "/home/drone/server/template/kmz/"+waylineName+".kmz"; // 输出的KMZ文件路径 |
| | | zipFolder(sourceDir, destKMZFile); |
| | | multipartFile = convert(new File("/home/drone/server/template/kmz/"+waylineName+".kmz")); |
| | | return multipartFile; |
| | | |
| | | } |
| | | |
| | | public ResponseEntity<Resource> backWayline(String fileName) { |
| | | String name = fileName + end; |
| | | try { |
| | | File kmzFile = new File("src/main/resources/template/kmz/" + name); |
| | | boolean kzm=(kmzFile.exists()); |
| | | System.out.println(kzm); |
| | | System.out.println(kmzFile); |
| | | if (!kzm) { |
| | | System.out.println(kzm); |
| | | // 如果文件不存在,返回404 Not Found响应 |
| | | return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); |
| | | } |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + name + "\""); |
| | | headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | return ResponseEntity.ok().headers(headers).contentLength(kmzFile.length()). |
| | | contentType(MediaType.APPLICATION_OCTET_STREAM).body(new FileSystemResource(kmzFile)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | package com.dji.sample.patches.utils; |
| | | |
| | | import java.util.List; |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.locationtech.jts.geom.Coordinate; |
| | | import org.locationtech.jts.geom.Geometry; |
| | | import org.locationtech.jts.geom.Point; |
| | | import org.locationtech.jts.io.ParseException; |
| | | import org.locationtech.jts.io.WKTReader; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | import static com.dji.sample.patches.utils.GeoToolsUtil.getCentro; |
| | | import static com.dji.sample.patches.utils.GeoToolsUtil.getExtremePoints; |
| | | |
| | | public class FormatConversionUtil { |
| | | static String str = ""; |
| | | //优化Polygon格式 |
| | | public static String[] formatConversion(List<String> s) { |
| | | String str = s.toString().trim(); |
| | | String ses = str.substring(1, str.length() - 2); |
| | |
| | | String[] arr1 = see.split("],"); |
| | | return arr1; |
| | | } |
| | | |
| | | //优化Polygon格式 |
| | | public static String modifySpacesAndCommas(String str) { |
| | | StringBuilder modified = new StringBuilder(); |
| | | for (char c : str.toCharArray()) { |
| | |
| | | } |
| | | return modified.toString(); |
| | | } |
| | | //获取Polygon的中心点,X轴和Y轴 |
| | | public static String getCentros(List<LotInfo> list) { |
| | | List<Coordinate> centros = new ArrayList<>(); |
| | | List<List<Coordinate>> extremePoints = new ArrayList<>(); |
| | | Map<Coordinate, List<Coordinate>> points = new HashMap<>(); |
| | | list.forEach(patche -> { |
| | | String wkt = patche.getDkfw(); |
| | | // 解析WKT字符串为多边形 |
| | | WKTReader wktReader = new WKTReader(JTSFactoryFinder.getGeometryFactory()); |
| | | Geometry polygon = null; |
| | | try { |
| | | polygon = wktReader.read(wkt); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | // 开始封装中心点坐标 |
| | | Coordinate coordinateCentro = getCentro(polygon); |
| | | centros.add(coordinateCentro); |
| | | str = coordinateCentro.toString(); |
| | | // 开始封装图斑4个航线 |
| | | List<Coordinate> coordinatePointList = getExtremePoints(polygon); |
| | | extremePoints.add(coordinatePointList); |
| | | points.put(coordinateCentro, coordinatePointList); |
| | | |
| | | }); |
| | | return str; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.dji.sample.patches.utils; |
| | | |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.tomcat.util.http.fileupload.FileItem; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.*; |
| | | import java.util.UUID; |
| | | |
| | | public class MultipartFileTOFileUtil { |
| | | |
| | | //MultiparFile转File |
| | | public File multipartFile2File(MultipartFile multipartFile) { |
| | | String tmpFileDir = null; |
| | | // 创建临时文件 |
| | | String randomFileName = UUID.randomUUID().toString(); |
| | | tmpFileDir = "/home/drone/server/temp/" + randomFileName; |
| | | tmpFileDir = "D:/tmp/" + randomFileName; |
| | | File file = new File(tmpFileDir); |
| | | InputStream inputStream = null; |
| | | FileOutputStream outputStream = null; |
| | |
| | | ZipUtil.deleteFiles(tmpFileDir); |
| | | return file; |
| | | } |
| | | |
| | | //File转MultiparFile |
| | | public static MultipartFile convert(File file) throws IOException { |
| | | FileInputStream input = new FileInputStream(file); |
| | | MultipartFile multipartFile = new MockMultipartFile("file", |
| | | file.getName(), "application/octet-stream", input); |
| | | return multipartFile; |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.*; |
| | | |
| | | public class ShapeFileUtil { |
| | | /* |
| | | * @param zipFile: 压缩包文件地址 |
| | | * @return FeatureCollection |
| | | * @author pangshicheng |
| | | * @description 解析shp压缩包,并返回解析出的 FeatureCollection |
| | | * @date 2023/7/18 16:02 |
| | | */ |
| | | |
| | | //将文件解压 |
| | | public static FeatureCollection getFeatureCollectionByShpFile(File zipFile) throws IOException { |
| | | try { |
| | | String tempDir = FileUtil.getTmpDirPath(); |
| | |
| | | /** |
| | | * @param zipFile: |
| | | * @return JSONObject |
| | | * @author pangshicheng |
| | | * @description 通过shp压缩文件,将其转换为GeoJson格式 |
| | | * @date 2023/7/18 16:04 |
| | | */ |
| | | //将解压后的文件转换成GeoJson格式 |
| | | public static List<String> shpToGeoJson(File zipFile) throws IOException { |
| | | FeatureJSON fjson = new FeatureJSON(); |
| | | JSONObject geoJsonObject = new JSONObject(); |
| | |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipFile; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * @author soulmate丶 |
| | | * @date 2021-10-26 |
| | | */ |
| | | @Configuration |
| | | public class ZipUtil { |
| | | |
| | | |
| | | /** |
| | | * 保存zip文件到本地并调用解压方法并返回解压出的文件的路径集合 |
| | | * |
| | | * @param file 文件 |
| | | * @return list //解压出的文件的路径合集 |
| | | */ |
| | | private static String zipPath = "D:/ceshi/tuban.zip";//zip根路径 |
| | | |
| | | /** |
| | | * zip解压 |
| | | * |
| | |
| | | // 空文件的删除 |
| | | file.delete(); |
| | | } |
| | | |
| | | // 定义一个公共的静态方法zipFolder,用于压缩文件夹 |
| | | // 参数sourceFolderPath是源文件夹的路径,zipFilePath是压缩后的zip文件路径 |
| | | public static boolean zipFolder(String sourceFolderPath, String zipFilePath) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | // 定义一个私有的静态方法zipFile,用于递归地压缩文件和文件夹 |
| | | // 将文件夹整体压缩 |
| | | // 参数fileToZip是需要被压缩的文件或文件夹,fileName是其在zip中的名称,zos是ZipOutputStream对象 |
| | | private static void zipFile(File fileToZip, String fileName, ZipOutputStream zos) throws IOException { |
| | | // 如果fileToZip是一个隐藏文件,则不进行压缩,直接返回 |
| | |
| | | // 关闭FileInputStream对象,释放资源 |
| | | fis.close(); |
| | | } |
| | | public static void compressAndRename(String sourceFilePath, String destinationZipFilePath, String newFileName) throws IOException { |
| | | FileOutputStream fos = new FileOutputStream(destinationZipFilePath); |
| | | ZipOutputStream zos = new ZipOutputStream(fos); |
| | | |
| | | File file = new File(sourceFilePath); |
| | | FileInputStream fis = new FileInputStream(file); |
| | | |
| | | ZipEntry zipEntry = new ZipEntry(newFileName); |
| | | zos.putNextEntry(zipEntry); |
| | | |
| | | byte[] bytes = new byte[1024]; |
| | | int length; |
| | | while ((length = fis.read(bytes)) >= 0) { |
| | | zos.write(bytes, 0, length); |
| | | } |
| | | |
| | | zos.closeEntry(); |
| | | fis.close(); |
| | | zos.close(); |
| | | } |
| | | |
| | | public static void compressToKMZ(String kmlFilePath, String wpmlFilePath, String destinationKMZFilePath) throws IOException { |
| | | FileOutputStream fos = new FileOutputStream(destinationKMZFilePath); |
| | | ZipOutputStream zos = new ZipOutputStream(fos); |
| | | |
| | | byte[] buffer = new byte[1024]; |
| | | |
| | | // 添加KML文件 |
| | | addFileToKMZ(zos, kmlFilePath, "doc.kml", buffer); |
| | | |
| | | // 添加WPML文件 |
| | | addFileToKMZ(zos, wpmlFilePath, "data.wpml", buffer); |
| | | |
| | | zos.close(); |
| | | } |
| | | |
| | | private static void addFileToKMZ(ZipOutputStream zos, String filePath, String entryName, byte[] buffer) throws IOException { |
| | | File file = new File(filePath); |
| | | FileInputStream fis = new FileInputStream(file); |
| | | ZipEntry zipEntry = new ZipEntry(entryName); |
| | | zos.putNextEntry(zipEntry); |
| | | |
| | | int length; |
| | | while ((length = fis.read(buffer)) > 0) { |
| | | zos.write(buffer, 0, length); |
| | | } |
| | | |
| | | fis.close(); |
| | | zos.closeEntry(); |
| | | } |
| | | public static void main(String[] args) throws IOException { |
| | | String kmzFileName="航线001"; |
| | | String kmlFilePath = "src/main/resources/template/wpmz/template.kml"; // KML文件路径 |
| | | String wpmlFilePath = "src/main/resources/template/wpmz/waylines.wpml"; // WPML文件路径 |
| | | String destinationKMZFilePath = "src/main/resources/template/zip/" + kmzFileName + ".kmz"; |
| | | try { |
| | | compressToKMZ(kmlFilePath, wpmlFilePath, destinationKMZFilePath); |
| | | System.out.println("Files compressed to KMZ successfully."); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | System.out.println("Error compressing files to KMZ: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * @param xmlModel |
| | | */ |
| | | public static void createWaylineFile(XMLTemplateModel xmlModel) { |
| | | xml2XmlDoc(xmlModel, "src\\main\\resources\\template\\template.xml", "src\\main\\resources\\template\\wpmz\\template.kml"); |
| | | xml2XmlDoc(xmlModel, "src\\main\\resources\\template\\waylines.xml", "src\\main\\resources\\template\\wpmz\\waylines.wpml"); |
| | | xml2XmlDoc(xmlModel, "home\\drone\\server\\template\\template.xml", "home\\drone\\server\\template\\wpmz\\template.kml"); |
| | | xml2XmlDoc(xmlModel, "home\\drone\\server\\template\\waylines.xml", "home\\drone\\server\\template\\wpmz\\waylines.wpml"); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("${url.summarize.prefix}${url.summarize.version}") |
| | | @RequestMapping("${url.summarize.prefix}${url.summarize.version}/Summarize") |
| | | public class SummarizeController { |
| | | @Autowired |
| | | private SummarizeService summarizeService; |
| | |
| | | */ |
| | | void importKmzFile(MultipartFile file, String workspaceId, String creator); |
| | | |
| | | WaylineFileDTO importKmzFileBack (MultipartFile file, String workspaceId, String creator); |
| | | WaylineFileEntity selectByName(String name); |
| | | |
| | | List<WaylineListDTO> waylineList(String workspaceId,String droneName); |
| | | |
| | | int updateWayline(WaylineFileEntity entity); |
| | |
| | | import com.dji.sample.component.oss.model.OssConfiguration; |
| | | import com.dji.sample.component.oss.service.impl.OssServiceContext; |
| | | import com.dji.sample.manage.model.enums.DeviceDomainEnum; |
| | | import com.dji.sample.summarize.model.entity.FlyInfo; |
| | | import com.dji.sample.wayline.dao.IWaylineFileMapper; |
| | | import com.dji.sample.wayline.model.dto.KmzFileProperties; |
| | | import com.dji.sample.wayline.model.dto.WaylineFileDTO; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URL; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public WaylineFileDTO importKmzFileBack(MultipartFile file, String workspaceId, String creator) { |
| | | WaylineFileDTO waylineFile=null; |
| | | Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file); |
| | | if (waylineFileOpt.isEmpty()) { |
| | | throw new RuntimeException("文件格式错误"); |
| | | } |
| | | |
| | | try { |
| | | waylineFile = waylineFileOpt.get(); |
| | | waylineFile.setWaylineId(workspaceId); |
| | | waylineFile.setUsername(creator); |
| | | |
| | | ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); |
| | | this.saveWaylineFile(workspaceId, waylineFile); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return waylineFile; |
| | | } |
| | | |
| | | @Override |
| | | public WaylineFileEntity selectByName(String name) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>().eq(WaylineFileEntity::getName,name)); |
| | | } |
| | | |
| | | @Override |
| | | public List<WaylineListDTO> waylineList(String workspaceId,String droneName) { |
| | | LambdaQueryChainWrapper<WaylineFileEntity> wrapper = |
| | | new LambdaQueryChainWrapper<>(mapper).eq(WaylineFileEntity::getWorkspaceId, workspaceId); |