liurunyu
3 天以前 1875fa9ab399695010279ff21b082263de8e1d4b
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.dy.pipIrrRemote.video;
 
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoVi.ViYsApp;
import com.dy.pipIrrGlobal.util.CameraTypeEnum;
import com.dy.pipIrrGlobal.voVi.VoCamera;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2025/6/9 10:34
 * @Description
 */
@Slf4j
@Tag(name = "视频监控", description = "视频监控")
@RestController
@RequestMapping(path = "video")
@RequiredArgsConstructor
public class VideoCtrl {
    private VideoSv sv;
    private YsAppSv ysSv;
 
    @Value("${video.screen.count: 4}")
    private Integer pageSize;//每页显示条数
 
    @Value("${video.ys.requestVideoCommonUrl: https://open.ys7.com/console/jssdk/pc.html}")
    private String requestVideoCommonUrl;//
    @Value("${video.ys.requestVideoCameraPreUrl: ezopen://open.ys7.com/}")
    private String requestVideoCameraPreUrl;//
    @Value("${video.ys.requestVideoCameraTail4LiveUrl: /1.live}")
    private String requestVideoCameraTail4LiveUrl;//
    @Value("${video.ys.requestVideoCameraTail4ThemeIdUrl: themeId=}")
    private String requestVideoCameraTail4ThemeIdUrl;//
 
    @Autowired
    private void setSv(VideoSv sv, YsAppSv ysSv){
        this.sv = sv ;
        this.ysSv = ysSv ;
    }
 
 
    /**
     * 客户端请求得到一些摄像机数据
     * @return 所有摄像机数据
     */
    @Operation(summary = "获得一页摄像机数据", description = "返回一页摄像机数据数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页摄像机数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoCamera.class))}
            )
    })
    @GetMapping(path = "some")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoVideo>>> some(VideoQo queryQo){
        try {
            ViYsApp ysApp = this.ysSv.selectSingleton() ;
            if(ysApp == null){
                //remote模块的自动任务可能清空了,所以再查询一次
                ysApp = this.ysSv.selectSingleton() ;
            }
            List<VoVideo> list = new ArrayList<>() ;
            QueryResultVo<List<VoCamera>> resTmp = this.sv.some(queryQo, pageSize) ;
            if(resTmp != null && resTmp.obj != null){
                for(VoCamera vo : resTmp.obj){
                    VoVideo vvo = new VoVideo() ;
                    vvo.id = vo.id ;
                    vvo.name = vo.name ;
                    if(ysApp != null && vo.type != null && vo.type.byteValue() == CameraTypeEnum.YINGSHI.getType().byteValue()){
                        //萤石
                        StringBuilder sb = new StringBuilder();
                        sb.append(requestVideoCommonUrl);
                        sb.append("?accessToken=");
                        sb.append(ysApp.accessToken);
                        sb.append("&url=");
                        sb.append(requestVideoCameraPreUrl);
                        sb.append(vo.devNo);
                        sb.append(requestVideoCameraTail4LiveUrl);
                        sb.append("&");
                        sb.append(requestVideoCameraTail4ThemeIdUrl);
                        vvo.videoUrl4Simple = sb.toString() + "simple";
                        vvo.videoUrl4Standard = sb.toString() + "standard" ;
                        vvo.videoUrl4Security = sb.toString() + "security" ;
 
                        StringBuilder sb1 = new StringBuilder();
                        sb1.append(requestVideoCommonUrl);
                        sb1.append("?url=");
                        sb1.append(requestVideoCameraPreUrl);
                        sb1.append(vo.devNo);
                        sb1.append(requestVideoCameraTail4LiveUrl);
                        sb1.append("&accessToken=");
                        sb1.append(ysApp.accessToken);
                        sb1.append("&");
                        sb1.append(requestVideoCameraTail4ThemeIdUrl);
                        vvo.videoUrl4PcLive = sb1.toString() + "pcLive&env=" ;
                    }else{
                        vvo.videoUrl4Simple = "" ;
                        vvo.videoUrl4Standard = "" ;
                        vvo.videoUrl4Security = "" ;
                        vvo.videoUrl4PcLive = "" ;
                    }
                    list.add(vvo) ;
                }
            }
            QueryResultVo<List<VoVideo>> res = new QueryResultVo<>() ;
            resTmp.copyTo(res);
            res.obj = list ;
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询摄像机异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}