czt
2026-01-29 633f9cd457a822d6b67b71d2f844c4bed4220c7f
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
package com.fzzy.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.GroupIndexData;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.data.PageResponse;
import com.fzzy.igds.data.PatrolSuperData;
import com.fzzy.igds.domain.*;
import com.fzzy.igds.response.BaseResponse;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.SystemUtil;
import com.fzzy.common.manager.CommonManager;
import com.fzzy.security.manager.SecManager;
import com.ruoyi.common.core.domain.entity.SysDept;
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.*;
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 CommonManager commonManager;
 
    /*------------------安防管理------------------*/
 
    /**
     * 库区安防页面
     *
     * @param type   1.表示2.5D鸟瞰图页面预览;2.表示列表预览页面
     * @param deptId
     * @param view
     * @return
     */
    @RequestMapping("/video-dept")
    public String videoDept(@RequestParam(value = "type", required = false) String type,
                            @RequestParam(value = "deptId", required = false) String deptId,
                            @RequestParam(value = "lan", required = false) String lan,
                            ModelMap view) {
 
        if (StringUtils.isBlank(type)) {
            type = "2";
        }
 
        if (StringUtils.isBlank(lan)) {
            //内网播放
            lan = "1";
        }
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        if (StringUtils.isBlank(deptId)) {
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        List<Camera> listCamera = secManager.listCamera(deptId, user.getCompanyId());
        view.put("listCamera", listCamera);
 
        SysDept sysDept = commonManager.getDeptById(deptId);
        view.put("dept", sysDept);
        view.put("type", type);
        view.put("lan", lan);
 
        //判断是否显示库区选择弹窗
        String showDeptList = "Y";
        if (Constant.USER_TYPE_30.equals(user.getUserType())) {
            showDeptList = "N";
        }
        view.put("showDeptList", showDeptList);
 
        //默认监控列表页面
        String viewUrl = prefix + "/video-list-dept";
 
        if ("1".equals(type)) {
            viewUrl = prefix + "/video-aerial-dept";
 
            view.put("backgroundImg", commonManager.isDeptImgExit(deptId));
        }
        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("/patrol-count")
    public String patrolCount(ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.put("deptId", deptId);
 
 
        PatrolSuperData patrolSuperData = secManager.patrolTrack();
        view.put("patrolSuperData", patrolSuperData);
 
        return prefix + "/patrol-count";
    }
 
 
    /*------------------数量检测------------------*/
 
    /**
     * 首页总览
     *
     * @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<QuantityConf> listCamera = secManager.getQuantityConfByDeptId(deptId);
        view.put("listCamera", listCamera);
 
        return prefix + "/quantity";
    }
 
    /**
     * 查询记录信息
     * @param param
     * @return
     */
    @RequestMapping("/quantity-list")
    @ResponseBody
    public PageResponse<List<Quantity>> quantityList(@RequestBody IgdsBaseParam param) {
        return secManager.quantityList(param);
    }
 
    /**
     * 查询曲线图信息
     * @param param
     * @return
     */
    @RequestMapping("/quantity-chart")
    @ResponseBody
    public PageResponse<GroupIndexData> getQuantityChart(@RequestBody IgdsBaseParam param) {
        return secManager.getQuantityChart(param);
    }
 
    /**
     * 查询曲线图信息
     * @param param
     * @return
     */
    @RequestMapping("/quantity-files")
    @ResponseBody
    public PageResponse<List<FileInfo>> getQuantityFiles(@RequestBody IgdsBaseParam param) {
        return secManager.getQuantityFiles(param);
    }
 
    /**
     * 数量监测-开始检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-single")
    @ResponseBody
    public BaseResponse checkSingle(@RequestBody IgdsBaseParam param) {
 
        return secManager.checkSingle(param);
    }
 
    /**
     * 数量监测-停止检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-stop")
    @ResponseBody
    public BaseResponse checkStop(@RequestBody IgdsBaseParam param) {
        return secManager.checkStop(param);
    }
 
    /*------------------料位计页面------------------*/
    /**
     * 料位总览
     *
     * @param deptId
     * @return
     */
    @RequestMapping("/height-all")
    public String oilAll(@RequestParam(value = "deptId", required = false) String deptId,
                         ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        // 获取当前用户所在的分库名称
        if(StringUtils.isBlank(deptId)){
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        // 获取当前部门下所有油罐列表信息
        List<Quantity> heightList = secManager.getHeightList(ContextUtil.subDeptId(user));
        view.put(Constant.MODEL_KEY_DEPOT_LIST, heightList);
 
        view.put("bizType", "quantity");
 
        return prefix + "/height-all";
    }
 
    /*------------------巡更轨迹页面------------------*/
    /**
     * 获取巡更记录页面
     *
     * @param patrolId
     * @param view
     * @return
     */
    @RequestMapping("/patrol-record")
    public String getPatrolRecordById(@RequestParam(value = "patrolId", required = true) String patrolId,
                                      ModelMap view) {
        IgdsBaseParam param = new IgdsBaseParam();
        param.setKey(patrolId);
        List<PatrolRecord> trackPoints = secManager.getRecordByPatrolId(patrolId);
        view.put("patrolRecordList", trackPoints);
 
        return prefix + "/patrol-record";
    }
 
}