修改航线文件存入、查看接口,新增根据任务ID查找航线接口。新增媒体文件根据任务ID去重、匹配图片。
| | |
| | | this.pageSize = page.getSize(); |
| | | this.total = page.getTotal(); |
| | | } |
| | | |
| | | } |
| | |
| | | return ResponseResult.success(entityList); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/getPhotoByJobId") |
| | | public ResponseResult getPhotoByJobId(@RequestParam String jobId, |
| | | @RequestParam(defaultValue = "1") int page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") int pageSize, |
| | | @PathVariable(name = "workspace_id") String workspaceId |
| | | ) { |
| | | return ResponseResult.success(fileService.getPhotoByJobId(page,pageSize,workspaceId, jobId)); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/getJobIds") |
| | | public ResponseResult getJobIds(@PathVariable(name = "workspace_id") String workspaceId, |
| | | @RequestParam(defaultValue = "1") int page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") int pageSize |
| | | ) { |
| | | return ResponseResult.success(fileService.getJobId(page,pageSize,workspaceId)); |
| | | } |
| | | |
| | | @PutMapping("/examine") |
| | | public ResponseResult examineData(@RequestParam String fileId) { |
| | | return fileService.updateExamByFileId(fileId); |
| | |
| | | public ResponseResult mediaInfo(@RequestParam String fileName) { |
| | | |
| | | Object info = fileService.mediaInfo(fileName); |
| | | if (info!=null){ |
| | | if (info != null) { |
| | | return ResponseResult.success(info); |
| | | } |
| | | return ResponseResult.success("图片正在加载"); |
| | | return ResponseResult.error("图片正在加载"); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/files/{job_id}") |
| | |
| | | return ResponseResult.success(fileService.mediaQuery(page, pageSize, updateStart, updateEnd, photoStart, photoEnd, jobName, workspaceId, type)); |
| | | |
| | | } |
| | | |
| | | @GetMapping("nailDataShow/{workspace_id}") |
| | | public ResponseResult getNailMeidaData(@PathVariable(name = "workspace_id") String workspaceId, |
| | | @RequestParam Integer page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, |
| | | @RequestParam(name = "photoStart", required = false) Long updateStart, |
| | | @RequestParam(name = "photoEnd", required = false) Long updateEnd, |
| | | @RequestParam(name = "updateStart", required = false) Long photoStart, |
| | | @RequestParam(name = "updateEnd", required = false) Long photoEnd, |
| | | @RequestParam(name = "jobName", required = false) String jobName, |
| | | @RequestParam(required = false) String type |
| | | @RequestParam Integer page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, |
| | | @RequestParam(name = "photoStart", required = false) Long updateStart, |
| | | @RequestParam(name = "photoEnd", required = false) Long updateEnd, |
| | | @RequestParam(name = "updateStart", required = false) Long photoStart, |
| | | @RequestParam(name = "updateEnd", required = false) Long photoEnd, |
| | | @RequestParam(name = "jobName", required = false) String jobName, |
| | | @RequestParam(required = false) String type |
| | | ) { |
| | | |
| | | return ResponseResult.success(fileService.mediaNailQuery(page, pageSize, updateStart, updateEnd, photoStart, photoEnd, jobName, workspaceId, type)); |
| | |
| | | */ |
| | | void saveMarkFile(String workspaceId, FileUploadDTO file) throws IOException, FontFormatException, ImageProcessingException; |
| | | void updateMarkMediaFileNames(String jobId); |
| | | PaginationData<MediaFileEntity> getJobId( int pageNum, int pageSize,String workspaceId); |
| | | PaginationData<MediaFileEntity> getPhotoByJobId(int page,int pageSize ,String workspaceId,String jobId); |
| | | |
| | | /** |
| | | * 获取媒体文件状态 |
| | | * @param fileId |
| | |
| | | patchesMapper.update(null, updateWrapper); |
| | | } |
| | | } |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setIsOriginal(false); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg"); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | MediaFileMarkEntity mediaFileMarkEntity = this.fileUploadConvertToMarkEntity(file); |
| | | long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime()); |
| | | File markFile = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(), |
| | | file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI()); |
| | | Object data = ImgUtil.getInfo(file1); |
| | | mediaFileMarkEntity.setDronedata(data); |
| | | mediaFileMarkEntity.setWorkspaceId(workspaceId); |
| | | mediaFileMarkEntity.setIsadd(0); |
| | | mediaFileMarkEntity.setIsOriginal(false); |
| | | mediaFileMarkEntity.setFileId(UUID.randomUUID().toString()); |
| | | mediaFileMarkEntity.setObjectKey("/mark" + file.getPath() + "/" + file.getName()); |
| | | mediaFileMarkEntity.setFileName("mark" + file.getName()); |
| | | mediaFileMarkEntity.setFilePath("mark" + file.getPath()); |
| | | String objectName = mediaFileMarkEntity.getObjectKey(); // 例如 "folder/file.txt" |
| | | uploadFile(endpoint, accessKey, secretKey, bucketName, objectName, markFile, "image/jpeg"); |
| | | markMapper.insert(mediaFileMarkEntity); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | @Override |
| | | public Object mediaInfo(String filename) { |
| | | String name = filename; |
| | | List<MediaFileEntity> entitys = mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getFileName, name)); |
| | | if (entitys != null && !entitys.isEmpty()) { |
| | | for (MediaFileEntity entity : entitys) { |
| | | if (entity.getDroneData() != null) { |
| | | return entity.getDroneData(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!filename.contains("mark")) { |
| | | name = "mark" + filename; |
| | | } |
| | | List<MediaFileMarkEntity> entity = markMapper.selectList(new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | .eq(MediaFileMarkEntity::getFileName, name)); |
| | | if (entity != null) { |
| | | return entity.get(0).getDronedata(); |
| | | } else { |
| | | List<MediaFileEntity> entitys = mapper.selectList(new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getFileName, name)); |
| | | return entitys.get(0).getDroneData(); |
| | | if (entity != null && !entity.isEmpty()) { |
| | | for (MediaFileMarkEntity markEntity : entity) { |
| | | if (markEntity.getDronedata() != null) { |
| | | return markEntity.getDronedata(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return "null"; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<MediaFileDTO> getAllFilesByWorkspaceId(String workspaceId) { |
| | |
| | | } |
| | | } |
| | | |
| | | public PaginationData<MediaFileEntity> getJobId( int pageNum, int pageSize,String workspaceId) { |
| | | // 分页查询 |
| | | Page<MediaFileEntity> page = new Page<>(pageNum, pageSize); |
| | | Page<MediaFileEntity> resultPage = mapper.selectPage(page, new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)); |
| | | |
| | | List<MediaFileEntity> result = resultPage.getRecords(); |
| | | |
| | | // 根据 fileName 字段进行去重并设置 JobName |
| | | Map<String, MediaFileEntity> uniqueFilesMap = result.stream() |
| | | .peek(mediaFile -> { |
| | | String taskNameResult = waylineJobService.getName(mediaFile.getJobId()); |
| | | mediaFile.setJobName(taskNameResult); |
| | | }) |
| | | .collect(Collectors.toMap( |
| | | MediaFileEntity::getFileName, |
| | | entity -> entity, |
| | | (existing, replacement) -> existing // 如果有重复的,保留已有的 |
| | | )); |
| | | |
| | | List<MediaFileEntity> uniqueFiles = new ArrayList<>(uniqueFilesMap.values()); |
| | | |
| | | // 使用分页对象构造 Pagination |
| | | Pagination pagination = new Pagination(resultPage); |
| | | return new PaginationData<>(uniqueFiles, pagination); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PaginationData<MediaFileEntity> getPhotoByJobId(int pageNum,int pageSize,String workspaceId, String jobId) { |
| | | |
| | | // 分页查询 |
| | | Page<MediaFileEntity> page = new Page<>(pageNum, pageSize); |
| | | Page<MediaFileEntity> resultPage = mapper.selectPage(page, new LambdaQueryWrapper<MediaFileEntity>() |
| | | .eq(MediaFileEntity::getJobId, jobId) |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)); |
| | | |
| | | List<MediaFileEntity> result = resultPage.getRecords(); |
| | | |
| | | // 根据 fileName 字段进行去重 |
| | | Map<String, MediaFileEntity> uniqueFilesMap = result.stream() |
| | | .collect(Collectors.toMap( |
| | | MediaFileEntity::getFileName, |
| | | entity -> entity, |
| | | (existing, replacement) -> existing // 如果有重复的,保留已有的 |
| | | )); |
| | | |
| | | List<MediaFileEntity> uniqueFiles = new ArrayList<>(uniqueFilesMap.values()); |
| | | |
| | | // 使用分页对象构造 Pagination |
| | | Pagination pagination = new Pagination(resultPage); |
| | | return new PaginationData<>(uniqueFiles, pagination); |
| | | |
| | | } |
| | | |
| | | |
| | | public void updateById(Integer id, MediaFileMarkEntity entity) { |
| | | entity.setIsadd(1); |
| | |
| | | @PostMapping("/patchesToWayline") |
| | | public ResponseResult patchesToWayline(@RequestBody List<LotInfo> lotInfos, |
| | | @RequestParam String waylineName, |
| | | @RequestParam String spotInFreckle, |
| | | @RequestParam String workspaceId, |
| | | @RequestParam String patchesId, |
| | | @RequestParam double lat, |
| | | @RequestParam double lon, |
| | | @RequestParam String isTemp, |
| | | HttpServletRequest request) throws IOException { |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | MultipartFile file = timerUtil.getFile(waylineName, lotInfos, lat, lon); |
| | | waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, spotInFreckle); |
| | | waylineFileService.importKmzFile(file, workspaceId, creator, patchesId,isTemp); |
| | | WaylineFileEntity entity = waylineFileService.selectByName(waylineName); |
| | | Map<String, String> infoMap = new HashMap<>(); |
| | | URL url = null; |
| | |
| | | return ResponseResult.success(data); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/formatWayline") |
| | | @SysLogAnnotation(operModul = "航线库", operType = "查询", operDesc = "根据查询条件查询临时航路线文件的基本数据") |
| | | public ResponseResult<PaginationData<WaylineFileDTO>> getShowWaylinesPagination(@RequestParam(name = "order_by") String orderBy, |
| | | @RequestParam(required = false) boolean favorited, @RequestParam Integer page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") Integer pageSize, |
| | | @RequestParam(name = "template_type", required = false) Integer[] templateType, |
| | | @PathVariable(name = "workspace_id") String workspaceId) { |
| | | WaylineQueryParam param = WaylineQueryParam.builder() |
| | | .favorited(favorited) |
| | | .page(page) |
| | | .pageSize(pageSize) |
| | | .orderBy(orderBy) |
| | | .templateType(templateType) |
| | | .build(); |
| | | PaginationData<WaylineFileDTO> data = waylineFileService.getShowWaylinesByParam(workspaceId, param); |
| | | return ResponseResult.success(data); |
| | | } |
| | | |
| | | /** |
| | | * 根据wayline文件id查询文件的下载地址; |
| | | * 和重定向到此地址直接下载。 |
| | |
| | | } catch (IOException | SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @GetMapping("/{workspace_id}/getWayline") |
| | | public ResponseResult getWaylineByJobId( |
| | | @PathVariable(name = "workspace_id") String workspaceId, |
| | | @RequestParam String jobId) { |
| | | return ResponseResult.success(waylineFileService.getWaylineByWaylineId(workspaceId,jobId)); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/waylines/{wayline_id}/urlData") |
| | |
| | | public ResponseResult importKmzFile(@PathVariable(name = "workspace_id") String workspaceId, |
| | | HttpServletRequest request, MultipartFile file, |
| | | @RequestParam(required = false) String patchesId, |
| | | @RequestParam(required = false) String spotInFreckle |
| | | @RequestParam(defaultValue = "1") String isTemp |
| | | ) { |
| | | if (Objects.isNull(file)) { |
| | | return ResponseResult.error("未上传文件"); |
| | | } |
| | | CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM); |
| | | String creator = customClaim.getUsername(); |
| | | String back = waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, spotInFreckle); |
| | | String back = waylineFileService.importKmzFile(file, workspaceId, creator, patchesId, isTemp); |
| | | if (back != null) { |
| | | return ResponseResult.error(back); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dji.sample.wayline.model.entity.WaylineFileEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author sean |
| | | * @version 0.3 |
| | | * @date 2021/12/22 |
| | | */ |
| | | @Mapper |
| | | public interface IWaylineFileMapper extends BaseMapper<WaylineFileEntity> { |
| | | } |
| | |
| | | private String patchesId; |
| | | |
| | | private String spotInFreckle; |
| | | |
| | | private String isTemp; |
| | | } |
| | |
| | | @TableField("spotIn_freckle") |
| | | private String spotInFreckle; |
| | | |
| | | @TableField("is_temp") |
| | | private String isTemp; |
| | | |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private Long createTime; |
| | | |
| | |
| | | */ |
| | | PaginationData<WaylineFileDTO> getWaylinesByParam(String workspaceId, WaylineQueryParam param); |
| | | |
| | | PaginationData<WaylineFileDTO> getShowWaylinesByParam(String workspaceId, WaylineQueryParam param); |
| | | |
| | | |
| | | |
| | | String getPatchesId(String waylineId); |
| | | /** |
| | | * Query the information of this wayline file according to the wayline file id. |
| | |
| | | * @return |
| | | */ |
| | | Integer saveWaylineFile(String workspaceId, WaylineFileDTO metadata); |
| | | Integer saveWaylineFiles(String workspaceId, WaylineFileDTO metadata,String patchesId); |
| | | Integer saveWaylineFiles(String workspaceId, WaylineFileDTO metadata,String patchesId,String isTemp); |
| | | /** |
| | | * Updates whether the file is collected or not based on the passed parameters. |
| | | * @param workspaceId |
| | |
| | | * @param creator |
| | | * @return |
| | | */ |
| | | String importKmzFile(MultipartFile file, String workspaceId, String creator,String patchesId,String spotInFreckle); |
| | | String importKmzFile(MultipartFile file, String workspaceId, String creator,String patchesId,String isTemp); |
| | | |
| | | |
| | | /** |
| | | * 创建航线,返回航线对象 |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private IWaylineFileMapper mapper; |
| | | |
| | | @Autowired |
| | | private OssServiceContext ossService; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PaginationData<WaylineFileDTO> getShowWaylinesByParam(String workspaceId, WaylineQueryParam param) { |
| | | // Paging Query |
| | | Page<WaylineFileEntity> page = mapper.selectPage( |
| | | new Page<WaylineFileEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getIsTemp,1) |
| | | .eq(param.isFavorited(), WaylineFileEntity::getFavorited, param.isFavorited()) |
| | | .and(param.getTemplateType() != null, wrapper -> { |
| | | for (Integer type : param.getTemplateType()) { |
| | | wrapper.like(WaylineFileEntity::getTemplateTypes, type).or(); |
| | | } |
| | | }) |
| | | // There is a risk of SQL injection |
| | | .last(StringUtils.hasText(param.getOrderBy()), " order by " + param.getOrderBy())); |
| | | |
| | | // Wrap the results of a paging query into a custom paging object. |
| | | List<WaylineFileDTO> records = page.getRecords() |
| | | .stream() |
| | | .map(this::entityConvertToDTO) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return new PaginationData<>(records, new Pagination(page)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String getPatchesId(String waylineId) { |
| | | WaylineFileEntity entity = mapper.selectOne(new LambdaQueryWrapper<WaylineFileEntity>() |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)); |
| | |
| | | .eq(WaylineFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(WaylineFileEntity::getWaylineId, waylineId)))); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public URL getObjectUrl(String workspaceId, String waylineId) throws SQLException { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer saveWaylineFiles(String workspaceId, WaylineFileDTO metadata, String patchesId) { |
| | | public Integer saveWaylineFiles(String workspaceId, WaylineFileDTO metadata, String patchesId, String isTemp) { |
| | | metadata.setPatchesId(patchesId); |
| | | WaylineFileEntity file = this.dtoConvertToEntity(metadata); |
| | | file.setWaylineId(UUID.randomUUID().toString()); |
| | | file.setWorkspaceId(workspaceId); |
| | | |
| | | file.setIsTemp(isTemp); |
| | | if (!StringUtils.hasText(file.getSign())) { |
| | | try (InputStream object = ossService.getObject(OssConfiguration.bucket, metadata.getObjectKey())) { |
| | | if (object.available() == 0) { |
| | |
| | | int insertId = mapper.insert(file); |
| | | return insertId > 0 ? file.getId() : insertId; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Boolean markFavorite(String workspaceId, List<String> waylineIds, Boolean isFavorite) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String importKmzFile(MultipartFile file, String workspaceId, String creator, String patchesId, String spotInFreckle) { |
| | | public String importKmzFile(MultipartFile file, String workspaceId, String creator, String patchesId, String isTemp) { |
| | | Optional<WaylineFileDTO> waylineFileOpt = validKmzFile(file); |
| | | if (waylineFileOpt.isEmpty()) { |
| | | throw new RuntimeException("文件格式错误"); |
| | |
| | | WaylineFileDTO waylineFile = waylineFileOpt.get(); |
| | | waylineFile.setWaylineId(workspaceId); |
| | | waylineFile.setUsername(creator); |
| | | waylineFile.setSpotInFreckle(spotInFreckle); |
| | | waylineFile.setIsTemp(isTemp); |
| | | back = ossService.putObject(OssConfiguration.bucket, waylineFile.getObjectKey(), file.getInputStream()); |
| | | if (back==null) { |
| | | this.saveWaylineFiles(workspaceId, waylineFile, patchesId); |
| | | if (back == null) { |
| | | this.saveWaylineFiles(workspaceId, waylineFile, patchesId, isTemp); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return back; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public WaylineFileDTO importKmzFileBack(MultipartFile file, String workspaceId, String creator) { |
| | |
| | | return builder.build(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int updateWayline(WaylineFileEntity entity) { |
| | | return mapper.update(entity, new LambdaQueryWrapper<WaylineFileEntity>() |