ソースを参照

新增标注识别数据获取

xiewj 2 年 前
コミット
77ccc8378a

+ 87 - 0
src/main/java/com/fdkankan/scene/controller/SceneMarkShapeController.java

@@ -0,0 +1,87 @@
+package com.fdkankan.scene.controller;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.fdkankan.common.constant.CommonOperStatus;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.UploadFilePath;
+import com.fdkankan.scene.entity.SceneMarkShape;
+import com.fdkankan.scene.entity.ScenePlus;
+import com.fdkankan.scene.entity.ScenePlusExt;
+import com.fdkankan.scene.service.ISceneMarkShapeService;
+import com.fdkankan.scene.service.IScenePlusExtService;
+import com.fdkankan.scene.service.IScenePlusService;
+import com.fdkankan.scene.vo.FileParamVO;
+import com.fdkankan.scene.vo.SceneMarkShapeParamVO;
+import com.fdkankan.web.controller.BaseController;
+import com.fdkankan.web.response.Result;
+import com.fdkankan.web.response.ResultData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 初始化接口
+ *
+ * @author fdkk
+ */
+@RestController
+@RequestMapping("/scene/sceneMarkShape")
+public class SceneMarkShapeController extends BaseController
+{
+
+    @Autowired
+    private ISceneMarkShapeService sceneMarkShapeService;
+    @Resource
+    private FYunFileServiceInterface fYunFileService;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Value("${fyun.host}")
+    private String ossUrlPrefix;
+
+    /**
+     * 获取场景全景图路径连接
+     */
+    @PostMapping("/getPanorama")
+    public ResultData getPanorama(@RequestBody @Validated  SceneMarkShapeParamVO param) {
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
+        if(ObjectUtil.isNotNull(scenePlus)) {
+            ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+            if (ObjectUtil.isNotNull(scenePlus)) {
+                String publicUserPath = String.format(UploadFilePath.scene_result_data_path, param.getNum());
+                List<String> panoramaList = fYunFileService.listRemoteFiles(scenePlusExt.getYunFileBucket(), publicUserPath + "caches/images/");
+                List<String> panoramaListUrl = panoramaList.stream().filter(f -> FileUtil.extName(f).equals("jpg")).map(s -> ossUrlPrefix + s).collect(Collectors.toList());
+                return ResultData.ok(panoramaListUrl);
+            }
+        }
+        return ResultData.ok("场景数据不存在");
+    }
+    /**
+     * 根据场景码和图片名称获取数据
+     */
+    @PostMapping("/getInfo")
+    public ResultData getInfo(@RequestBody @Validated  SceneMarkShapeParamVO param) {
+        SceneMarkShape res=  sceneMarkShapeService.findByNumAndImagePath(param.getNum(),param.getImagePath());
+        return ResultData.ok(res);
+    }
+
+    /**
+     * 保存或者修改
+     */
+    @PostMapping("/saveOrEdit")
+    public ResultData save(@RequestParam(value = "num") String num,@RequestParam("file") MultipartFile file) throws IOException {
+        sceneMarkShapeService.saveFileToDB(file,num);
+        return ResultData.ok();
+    }
+
+}

+ 66 - 0
src/main/java/com/fdkankan/scene/entity/SceneMarkShape.java

@@ -0,0 +1,66 @@
+package com.fdkankan.scene.entity;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 场景标记多边形识别数据
+ * </p>
+ *
+ * @author Xiewj
+ * @date 2023/3/30
+ */
+@Data
+@TableName(value = "t_scene_mark_shape",autoResultMap = true)
+@Accessors(chain = true)
+public class SceneMarkShape implements Serializable {
+
+      /**
+       * 主键
+       */
+      @TableId(value = "id", type = IdType.AUTO)
+      private Long id;
+
+      @TableField("version")
+      private String version;
+      @TableField(typeHandler = FastjsonTypeHandler.class, value = "flag")
+      private JSONObject flag;
+
+      @TableField(typeHandler = FastjsonTypeHandler.class, value = "shapes")
+      private List<JSONObject> shapes;
+
+      @TableField("image_path")
+      private String imagePath;
+      @TableField("image_height")
+      private Integer imageHeight;
+      @TableField("image_width")
+
+      private Integer imageWidth;
+      @TableField("num")
+      private String num;
+
+
+      @TableField("create_time")
+      private Date createTime;
+
+      @TableField("update_time")
+      private Date updateTime;
+
+      /**
+       * 记录的状态,A: 生效,I: 禁用
+       */
+      @TableField("rec_status")
+      @TableLogic(value = "A", delval = "I")
+      private String recStatus;
+
+}

+ 16 - 0
src/main/java/com/fdkankan/scene/mapper/MarkShapeMapper.java

@@ -0,0 +1,16 @@
+package com.fdkankan.scene.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fdkankan.scene.entity.SceneMarkShape;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Xiewj
+ * @date 2021/11/22
+ */
+@Mapper
+@Component("MarkShapeMapper")
+public interface MarkShapeMapper extends BaseMapper<SceneMarkShape> {
+}
+

+ 18 - 0
src/main/java/com/fdkankan/scene/service/ISceneMarkShapeService.java

@@ -0,0 +1,18 @@
+package com.fdkankan.scene.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.scene.entity.SceneMarkShape;
+import com.fdkankan.scene.vo.SceneMarkShapeParamVO;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+
+/**
+ * Created by Xiewj on 2021/11/23 0026 10:14
+ */
+public interface ISceneMarkShapeService extends IService<SceneMarkShape> {
+    void saveFileToDB(MultipartFile inPath, String num) throws IOException;
+
+    SceneMarkShape findByNumAndImagePath(String num, String imagePath);
+}

+ 71 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneMarkShapeServiceImpl.java

@@ -0,0 +1,71 @@
+package com.fdkankan.scene.service.impl;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.scene.entity.SceneMarkShape;
+import com.fdkankan.scene.entity.ScenePlusExt;
+import com.fdkankan.scene.mapper.IScenePlusExtMapper;
+import com.fdkankan.scene.mapper.MarkShapeMapper;
+import com.fdkankan.scene.service.ISceneMarkShapeService;
+import com.fdkankan.scene.service.IScenePlusExtService;
+import com.fdkankan.scene.vo.SceneMarkShapeParamVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Created by Xiewj on 2021/11/23 0026 10:14
+ */
+@Slf4j
+@Service
+public class SceneMarkShapeServiceImpl extends ServiceImpl<MarkShapeMapper, SceneMarkShape> implements ISceneMarkShapeService {
+
+    @Override
+    public SceneMarkShape findByNumAndImagePath(String num, String imagePath) {
+        LambdaQueryWrapper<SceneMarkShape> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(SceneMarkShape::getNum,num);
+        wrapper.eq(SceneMarkShape::getImagePath,imagePath);
+        return getOne(wrapper);
+    }
+
+    @Override
+    public void saveFileToDB(MultipartFile file, String num) throws IOException {
+        String uuid = UUID.randomUUID().toString();
+        String fileName = file.getOriginalFilename();
+        String extName = cn.hutool.core.io.FileUtil.extName(fileName);
+        String tempFileName = uuid + "." + extName;
+        String srcPath = ConstantFilePath.SCENE_V4_PATH + num + "/markShapes/" + tempFileName;
+        File tempFile = new File(srcPath);
+        if(!tempFile.getParentFile().exists()){
+            tempFile.getParentFile().mkdirs();
+        }
+        file.transferTo(tempFile);
+        String s = FileUtil.readUtf8String(tempFile);
+        JSONObject jsonObject = JSONObject.parseObject(s);
+        tempFile.delete();
+        SceneMarkShape sceneMarkShape= JSON.toJavaObject(jsonObject,SceneMarkShape.class);
+        sceneMarkShape.setNum(num);
+        SceneMarkShape shape = findByNumAndImagePath(sceneMarkShape.getNum(), sceneMarkShape.getImagePath());
+        if (ObjectUtil.isNotNull(shape)){
+            log.info("shape-替换id修改---{}",sceneMarkShape);
+            sceneMarkShape.setId(shape.getId());
+            updateById(sceneMarkShape);
+        }else {
+            log.info("新增-替换id修改---{}",sceneMarkShape);
+            log.info("MarkShapeMapper---{}",sceneMarkShape);
+            save(sceneMarkShape);
+        }
+    }
+}

+ 36 - 0
src/main/java/com/fdkankan/scene/vo/SceneMarkShapeParamVO.java

@@ -0,0 +1,36 @@
+package com.fdkankan.scene.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/1/19
+ **/
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneMarkShapeParamVO {
+
+    /**
+     * 场景码
+     */
+    @NotBlank(message = "场景码不能为空")
+    private String num;
+
+    /**
+     * 图片名称路径
+     */
+    private String imagePath;
+
+
+}