吉安感知网项目-后端
linwei
6 days ago d106e448314677988677cc0ee5263d2b6fa31670
add : 吉安支持查询待验收的接口
1 files modified
57 ■■■■ changed files
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/wrapper/GdTaskResultWrapper.java 57 ●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/wrapper/GdTaskResultWrapper.java
@@ -63,26 +63,24 @@
     * 将单个DTO转换为Entity
     * 处理geojson字段:将字符串数组格式转换为正确的JSON对象数组格式
     *
     * @param dto DTO对象
     * @param dto DTO对象,不能为null
     * @return Entity对象
     * @throws IllegalArgumentException 当dto为null时抛出
     */
    private GdTaskResultEntity convertDtoToEntity(GdTaskResultDTO dto) {
        // 步骤1:参数校验
        if (dto == null) {
            throw new IllegalArgumentException("dto不能为null");
        }
        // 步骤2:基础属性拷贝
        GdTaskResultEntity entity = BeanUtil.copy(dto, GdTaskResultEntity.class);
        // 步骤1:设置附件类型
        if (dto.getDateType() != null) {
            if (dto.getDateType().equals(1) && dto.getFileType().equals("视频")) {
                // 录像的视频
                entity.setAttachmentType(3);
            } else if (dto.getDateType().equals(3) && dto.getFileType().equals("视频")) {
                // 机巢+无人机录像视频
                entity.setAttachmentType(4);
            } else {
                entity.setAttachmentType(dto.getDateType());
            }
        }
        // 步骤3:设置附件类型
        Integer attachmentType = determineAttachmentType(dto);
        entity.setAttachmentType(attachmentType);
        // 步骤2:处理geojson字段,将字符串数组转换为正确的JSON格式
        // 步骤4:处理geojson字段,将字符串数组转换为正确的JSON格式
        String processedGeojson = processGeojson(dto.getGeojson());
        entity.setGeojson(processedGeojson);
@@ -90,6 +88,37 @@
    }
    /**
     * 根据DTO信息确定附件类型
     * 优先使用dateType判断,其次通过文件URL后缀判断
     *
     * @param dto DTO对象
     * @return 附件类型:1-图片,3-视频
     */
    private Integer determineAttachmentType(GdTaskResultDTO dto) {
        // 步骤1:优先使用dateType判断
        if (dto.getDateType() != null) {
            // 录像的视频特殊处理
            if ("视频".equals(dto.getFileType())) {
                return 3;
            }
            return dto.getDateType();
        }
        // 步骤2:通过URL后缀判断
        String resultUrl = dto.getResultUrl();
        if (StringUtil.isEmpty(resultUrl)) {
            return 1; // 默认返回图片类型
        }
        // 步骤3:根据文件扩展名判断类型
        String lowerUrl = resultUrl.toLowerCase();
        if (lowerUrl.endsWith(".mp4") || lowerUrl.endsWith(".m3u8")) {
            return 3; // 视频
        }
        return 1; // 图片(包含jpg、png及其他格式)
    }
    /**
     * 处理geojson字段,将字符串数组格式转换为正确的JSON对象数组格式
     * 解决问题:["{\"score\":0.88}"] -> [{"score":0.88}]
     *