rain
2024-08-17 61b91c80f3d7526eb3caa04e6e781e591f48ec93
src/main/java/com/dji/sample/wayline/controller/WaylineFileController.java
@@ -41,8 +41,9 @@
    /**
     * 根据查询条件查询航路线文件的基本数据。
     * pilot中的查询条件字段是固定的。
     * @param orderBy   排序的字段。在sql语句的末尾拼接。
     * @param favorited 路径线文件是否为收藏夹。
     *
     * @param orderBy      排序的字段。在sql语句的末尾拼接。
     * @param favorited    路径线文件是否为收藏夹。
     * @param page
     * @param pageSize
     * @param templateType
@@ -52,10 +53,10 @@
    @GetMapping("/{workspace_id}/waylines")
    @SysLogAnnotation(operModul = "航线库", operType = "查询", operDesc = "根据查询条件查询航路线文件的基本数据")
    public ResponseResult<PaginationData<WaylineFileDTO>> getWaylinesPagination(@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) {
                                                                                @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)
@@ -67,9 +68,28 @@
        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查询文件的下载地址;
     * 和重定向到此地址直接下载。
     *
     * @param workspaceId
     * @param waylineId
     * @param response
@@ -77,7 +97,7 @@
    @GetMapping("/{workspace_id}/waylines/{wayline_id}/url")
    @SysLogAnnotation(operModul = "航线库", operType = "查询", operDesc = "根据wayline文件id查询文件的下载地址1")
    public void getFileUrl(@PathVariable(name = "workspace_id") String workspaceId,
                                @PathVariable(name = "wayline_id") String waylineId, HttpServletResponse response) {
                           @PathVariable(name = "wayline_id") String waylineId, HttpServletResponse response) {
        try {
            URL url = waylineFileService.getObjectUrl(workspaceId, waylineId);
@@ -87,11 +107,17 @@
            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")
    @SysLogAnnotation(operModul = "航线库", operType = "查询", operDesc = "根据wayline文件id查询文件的下载地址2")
    public ResponseResult getFileUrlData(@PathVariable(name = "workspace_id") String workspaceId,
                           @PathVariable(name = "wayline_id") String waylineId, HttpServletResponse response) {
                                         @PathVariable(name = "wayline_id") String waylineId, HttpServletResponse response) {
        URL url = null;
        try {
@@ -105,6 +131,7 @@
    /**
     * 当航路线文件被飞行员上传到存储服务器时,
     * 通过该接口报告文件的基本信息。
     *
     * @param request
     * @param workspaceId
     * @param uploadFile
@@ -116,7 +143,7 @@
                                         @PathVariable(name = "workspace_id") String workspaceId,
                                         @RequestBody WaylineFileUploadDTO uploadFile) {
        CustomClaim customClaim = (CustomClaim)request.getAttribute(TOKEN_CLAIM);
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        WaylineFileDTO metadata = uploadFile.getMetadata();
        metadata.setUsername(customClaim.getUsername());
@@ -130,14 +157,15 @@
    /**
     * 根据路径线文件id收藏路径线文件。
     *
     * @param workspaceId
     * @param ids   wayline file id
     * @param ids         wayline file id
     * @return
     */
    @PostMapping("/{workspace_id}/favorites")
    @SysLogAnnotation(operModul = "航线库", operType = "修改", operDesc = "根据路径线文件id收藏路径线文件")
    public ResponseResult markFavorite(@PathVariable(name = "workspace_id") String workspaceId,
                             @RequestParam(name = "id") List<String> ids) {
                                       @RequestParam(name = "id") List<String> ids) {
        boolean isMark = waylineFileService.markFavorite(workspaceId, ids, true);
        return isMark ? ResponseResult.success() : ResponseResult.error();
@@ -145,14 +173,15 @@
    /**
     * 根据航路线文件id删除此航路线文件的收藏夹。
     *
     * @param workspaceId
     * @param ids wayline file id
     * @param ids         wayline file id
     * @return
     */
    @DeleteMapping("/{workspace_id}/favorites")
    @SysLogAnnotation(operModul = "航线库", operType = "删除", operDesc = "根据航路线文件id删除此航路线文件的收藏夹")
    public ResponseResult unmarkFavorite(@PathVariable(name = "workspace_id") String workspaceId,
                             @RequestParam(name = "id") List<String> ids) {
                                         @RequestParam(name = "id") List<String> ids) {
        boolean isMark = waylineFileService.markFavorite(workspaceId, ids, false);
        return isMark ? ResponseResult.success() : ResponseResult.error();
@@ -161,6 +190,7 @@
    /**
     * 根据航路线名称检查名称是否已经存在,必须保证航路线名称的唯一性。
     * 此接口将在上传航路线时被调用,并且必须可用。
     *
     * @param workspaceId
     * @param names
     * @return
@@ -176,6 +206,7 @@
    /**
     * 根据航路线id删除工作区中的航路线文件。
     *
     * @param workspaceId
     * @param waylineId
     * @return
@@ -190,6 +221,7 @@
    /**
     * 上传kmz航线文件
     *
     * @param file
     * @return
     */
@@ -197,31 +229,36 @@
    @SysLogAnnotation(operModul = "航线库", operType = "上传", operDesc = "上传kmz航线文件")
    public ResponseResult importKmzFile(@PathVariable(name = "workspace_id") String workspaceId,
                                        HttpServletRequest request, MultipartFile file,
                                        @RequestParam String patchesId) {
                                        @RequestParam(required = false) String patchesId,
                                        @RequestParam(defaultValue = "1",required = false) String isTemp
    ) {
        if (Objects.isNull(file)) {
            return ResponseResult.error("未上传文件");
        }
        CustomClaim customClaim = (CustomClaim)request.getAttribute(TOKEN_CLAIM);
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        String creator = customClaim.getUsername();
        waylineFileService.importKmzFile(file, workspaceId, creator,patchesId);
        return ResponseResult.success();
        String back = waylineFileService.importKmzFile(file, workspaceId, creator, patchesId,isTemp);
        if (back != null) {
            return ResponseResult.error(back);
        }
        return ResponseResult.success(back);
    }
    @GetMapping("/{workspace_id}/waylines_list")
    @SysLogAnnotation(operModul = "航线库", operType = "查询", operDesc = "查询当前工作区航线库列表")
    public ResponseResult<List<WaylineListDTO>> waylineList(@PathVariable(name = "workspace_id") String workspaceId,String droneName) {
        return ResponseResult.success(waylineFileService.waylineList(workspaceId,droneName)) ;
    public ResponseResult<List<WaylineListDTO>> waylineList(@PathVariable(name = "workspace_id") String workspaceId, String droneName) {
        return ResponseResult.success(waylineFileService.waylineList(workspaceId, droneName));
    }
    @PutMapping("/{workspace_id}/wayline_update")
    public ResponseResult upWayline(@RequestParam String waylineId,@RequestParam String name){
        WaylineFileEntity entity=WaylineFileEntity
    public ResponseResult upWayline(@RequestParam String waylineId, @RequestParam String name) {
        WaylineFileEntity entity = WaylineFileEntity
                .builder()
                .waylineId(waylineId)
                .name(name)
                .build();
        if(waylineFileService.updateWayline(entity)==0){
        if (waylineFileService.updateWayline(entity) == 0) {
            return ResponseResult.error("更新失败");
        }else return ResponseResult.success();
        } else return ResponseResult.success();
    }
}