rain
2024-06-14 5655be710d599928a1d03db792212da5bf1ce667
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
import com.dji.sample.patches.service.GetPatchesService;
import com.dji.sample.territory.model.entity.TbFjEntity;
import com.dji.sample.territory.service.ITbFJService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
 
@RestController
@Slf4j
@RequestMapping("/territory/tbfj")
public class TbFjController {
 
    @Autowired
    private ITbFJService tbFJService;
    @Autowired
    private GetPatchesService getPatchesService;
 
    /**
     * 将地块所保留的照片、视频信息保存到sqlite
     *
     * @param dkbh
     * @param workspaceId
     * @return
     * @throws IOException
     */
    @PostMapping("/insertDb")
    public ResponseResult insertDb(String dkbh, String workspaceId) throws Exception {
        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("上传失败");
    }
}