| | |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.media.model.MinioPojo; |
| | | import com.dji.sample.media.util.MinioFileDownloader; |
| | | import com.dji.sample.patches.config.pojo.PatchesConfigPojo; |
| | | import com.dji.sample.patches.utils.MultipartFileTOFileUtil; |
| | | import com.dji.sample.patches.utils.TimerUtil; |
| | |
| | | private PatchesConfigPojo patchesConfigPojo; |
| | | @Autowired |
| | | private IWaylineFileService waylineFileService; |
| | | |
| | | @Autowired |
| | | private MinioPojo pojo; |
| | | |
| | | @PostMapping("/createPoints") |
| | | public ResponseResult createPoints(@RequestBody CreateWaylineParam param) { |
| | |
| | | HttpServletRequest request) throws IOException { |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | String newName = param.getWaylineName() + TimerUtil.getNowDay(); |
| | | // 初始化模板对象 |
| | | XMLTemplateModel xmlModel = XMLTemplateModel.initPolygon(param); |
| | | // 生成航线文件 |
| | | CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneTemplate(), patchesConfigPojo.getPlaneTargetTemplate()); |
| | | CreateWaylineFileUtils.createWaylineFileByPolygon(xmlModel, patchesConfigPojo.getPlaneWaylines(), patchesConfigPojo.getPlaneTargetWaylines()); |
| | | MinioFileDownloader.deleteFileFromMinio(pojo.getEndpoint(), pojo.getAccessKey(), pojo.getSecretKey(), pojo.getBucket(), param.getWaylineName()); |
| | | // kmz、上传航线库 |
| | | String destKMZFile = patchesConfigPojo.getPlaneKMZFile() + newName + ".kmz"; // 输出的KMZ文件路径 |
| | | String destKMZFile = patchesConfigPojo.getPlaneKMZFile() + param.getWaylineName() + ".kmz"; // 输出的KMZ文件路径 |
| | | ZipUtil.zipFolder(patchesConfigPojo.getSourceDir(), destKMZFile); |
| | | MultipartFile multipartFile = MultipartFileTOFileUtil.convert(new File(destKMZFile)); |
| | | waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, newName, id); |
| | | waylineFileService.importPlaneKmzFile(multipartFile, workspaceId, creator, param.getWaylineName(), id); |
| | | return ResponseResult.success(); |
| | | } |
| | | } |