czt
4 天以前 0f2fc0872069f0a5099cc535e6ff885b13937153
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
package com.fzzy.sys.controller.security;
 
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.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 java.util.ArrayList;
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.表示列表预览页面
     * @return
     */
    @RequestMapping("/aerial-video")
    public String aerialVideo(
            @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);
        List<Camera> listCamera = secManager.listCamera(deptId, user.getCompanyId());
 
        view.put("deptId", deptId);
        view.put("listCamera", listCamera);
 
        //默认监控列表页面
        String viewUrl = prefix + "/video-list";
 
        if (StringUtils.isNotBlank( type) && "1".equals(type)) {
            Dept dept = deptService.getDeptById(deptId);
            if (dept != null && StringUtils.isNotEmpty(dept.getImgPath())) {
                view.put("backgroundImg", dept.getImgPath());
                viewUrl = prefix + "/video-aerial";
            }
 
        }
        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 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";
    }
 
}