jiazx0107
2 天以前 036a6d241cf1cfc0345ddf28e748a3d6deda08df
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package com.fzzy.sys.controller.security;
 
import com.fzzy.igds.camera.data.ApiCameraData;
import com.fzzy.igds.camera.data.ApiCameraResp;
import com.fzzy.igds.constant.CameraPlayType;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.data.PageResponse;
import com.fzzy.igds.domain.Camera;
import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.service.CoreDeptService;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.SystemUtil;
import com.fzzy.sys.manager.security.SecManager;
import com.ruoyi.common.core.domain.entity.SysUser;
import lombok.extern.slf4j.Slf4j;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * @Description 安防controller层
 * @Author CZT
 * @Date 2025/12/9 9:12
 */
@Slf4j
@Controller
@RequestMapping("security")
public class SecurityController {
 
    private static final String prefix = "security";
 
    @Resource
    private SecManager secManager;
    @Resource
    private CoreDeptService deptService;
 
    /**
     * 库区安防页面
     * @param type 1.表示2.5D鸟瞰图页面预览;2.表示列表预览页面
     * @param view
     * @return
     */
    @RequestMapping("/video-dept")
    public String videoDept(@RequestParam(value = "type", required = false) String type,
                              ModelMap view) {
 
        if (StringUtils.isBlank(type)) {
            type = "2";
        }
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.put("deptId", deptId);
 
        List<Camera> listCamera = secManager.listCamera(deptId, user.getCompanyId());
        view.put("listCamera", listCamera);
 
        //默认监控列表页面
        String viewUrl = prefix + "/video-list-dept";
 
        if("1".equals(type)){
            viewUrl = prefix + "/video-aerial-dept";
 
            //鸟瞰图
            Dept dept = deptService.getDeptById(deptId);
            if (dept != null && StringUtils.isNotEmpty(dept.getImgPath())) {
                view.put("backgroundImg", dept.getImgPath());
            }
        }
        if("2".equals(type)){
            viewUrl = prefix + "/video-list-dept";
        }
 
        return viewUrl;
    }
 
    /**
     * 监管安防页面
     * @param type 1.表示2.5D鸟瞰图页面预览;2.表示列表预览页面
     * @param view
     * @return
     */
    @RequestMapping("/video-super")
    public String videoSuper(@RequestParam(value = "type", required = false) String type,
                             ModelMap view) {
 
        if (StringUtils.isBlank(type)) {
            type = "2";
        }
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.put("deptId", deptId);
 
        List<Camera> listCamera = secManager.listCamera(deptId, user.getCompanyId());
        view.put("listCamera", listCamera);
 
        //默认监控列表页面
        String viewUrl = prefix + "/video-list-dept";
 
        if("1".equals(type)){
            viewUrl = prefix + "/video-aerial-dept";
 
            //鸟瞰图
            Dept dept = deptService.getDeptById(deptId);
            if (dept != null && StringUtils.isNotEmpty(dept.getImgPath())) {
                view.put("backgroundImg", dept.getImgPath());
            }
        }
        if("2".equals(type)){
            viewUrl = prefix + "/video-list-dept";
        }
 
        return viewUrl;
    }
 
    /**
     * 鸟瞰图页面 -- 视频播放,通过播放参数不同跳转不同页面播放
     *
     * @param cameraId 摄像机系统ID
     * @param playType 配置的播放方式
     * @param time     时间参数,无具体含义
     * @return
     */
    @RequestMapping("/video-play")
    public String play(@RequestParam(value = "cameraId", required = true) String cameraId,
                       @RequestParam(value = "playType", required = false) String playType,
                       @RequestParam(value = "time", required = false) String time,
                       ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
 
        // 设置默认播放方式
        if (org.apache.commons.lang3.StringUtils.isEmpty(playType)) {
            playType = CameraPlayType.PLAY_TYPE_VLC.getCode();
        }
 
        // 设置摄像头信息
        Camera camera = secManager.getCameraById(null, cameraId);
        if (camera == null) {
            view.put("errorMsg", "获取视频设备出错,请先刷新缓存!");
        }
        view.put("cameraData", camera);
 
        String viewUrl = prefix + "/video-webrtc";
 
        //WEB-RTC播放
        if (CameraPlayType.PLAY_TYPE_WEB_RTC.getCode().equals(playType)) {
            viewUrl = prefix + "/video-webrtc";
        }
 
        return viewUrl;
    }
 
    /**
     * 获取视频播放地址
     *
     * @param param
     * @return
     */
    @RequestMapping("/get-media")
    @ResponseBody
    public ApiCameraResp getMedia(HttpServletRequest request, @RequestBody Camera param) {
        //获取请求方IP
        String ip = SystemUtil.getIP(request);
        return secManager.getPlayAddr(param, ip);
    }
 
    /**
     * 视频云台控制,所有类型的云台控制入口
     *
     * @param param 前端转换的参数
     * @return 执行结果
     */
    @RequestMapping("/ptz-media")
    @ResponseBody
    public ApiCameraResp ptzMedia(@RequestBody ApiCameraData param) {
 
        //log.debug("-----云台调用-----{}",param);
        return secManager.ptzMedia(param);
    }
 
 
    /**
     * 视频云台预置位设置
     *
     * @param param
     * @return
     */
    @RequestMapping("/ptz-preset")
    @ResponseBody
    public ApiCameraResp ptzPreset(@RequestBody ApiCameraData param) {
        return secManager.ptzPreset(param);
    }
 
    /***
     * 视频鸟瞰图中更改摄像头位置
     *
     * @param params
     * @return
     */
    @RequestMapping("/update-pos")
    @ResponseBody
    public PageResponse<String> updatePos(
            @RequestBody List<Camera> params) {
        return secManager.updatePos(params);
    }
 
 
 
    /**
     * 首页总览
     *
     * @return
     */
    @RequestMapping("/quantity")
    public String infrared(
            @RequestParam(value = "type", required = false) String type,
            ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.put("deptId", deptId);
//        List<InfraredCamera> listCamera = infraredManager.listCamera(deptId, user.getCompanyId());
//
//        if(null == listCamera){
//            listCamera = new ArrayList<>();
//            listCamera.add(new InfraredCamera());
//        }
//        view.put("listCamera", listCamera);
 
        return prefix + "/quantity";
    }
 
}