rain
2024-05-06 bc16d0f0fc46ca6cb7d9bfb8496ad8f20ffba677
src/main/java/com/dji/sample/territory/controller/TbFjController.java
@@ -1,4 +1,5 @@
package com.dji.sample.territory.controller;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.media.model.MediaFileEntity;
import com.dji.sample.patches.model.entity.LotInfo;
@@ -10,6 +11,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
@@ -21,19 +23,29 @@
    @Autowired
    private ITbFJService tbFJService;
    @Autowired
    private GetPatchesService getPatches;
    private GetPatchesService getPatchesService;
    /**
     * 将地块所保留的照片、视频信息保存到sqlite
     *
     * @param dkbh
     * @param workspaceId
     * @return
     * @throws IOException
     */
    @PostMapping("/insertDb")
    public ResponseResult insertDb(String dkbh, String workspaceId) throws IOException {
        List<MediaFileEntity> list = getPatches.listPohto(dkbh, workspaceId);
        if(list.size()==0){
            return ResponseResult.error("未找到该照片、视频信息");}
        LotInfo lotInfo = getPatches.getLotinfo(dkbh, workspaceId);
        if(lotInfo==null){
            return ResponseResult.error("未找到该图斑信息");}
        TbFjEntity entity=tbFJService.insertData(list, lotInfo);
        if (entity!=null){
            return ResponseResult.success("上传成功");
        List<MediaFileEntity> list = getPatchesService.listPohto(dkbh, workspaceId);
        if (list.size() == 0) {
            return ResponseResult.error("未找到该照片、视频信息");
        }
        LotInfo lotInfo = getPatchesService.getLotinfo(dkbh, workspaceId);
        if (lotInfo == null) {
            return ResponseResult.error("未找到该图斑信息");
        }
        int num = tbFJService.insertData(list, lotInfo);
        if (num != 0) {
            return ResponseResult.success("上传成功,上传了" + num + "个文件");
        }
        return ResponseResult.error("上传失败");
    }