‘liusuyi’
2023-10-25 348cd918b61fb2bd31f1855ec4d25db98cf85d67
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
package com.ruoyi.device.camera.controller;
 
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.camera.service.ICameraSdkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * @Description: 相机通用SDK接口
 * @ClassName: CameraSdkController
 * @Author: 刘苏义
 * @Date: 2023年10月14日17:02:56
 **/
 
@Api(tags = "相机通用SDK接口")
@Controller
@RequestMapping("/cameraSdk")
@Anonymous
public class CameraSdkController extends BaseController {
 
    @Resource
    private ICameraSdkService cameraSdkService;
    @Resource
    private IArdCamerasService ardCamerasService;
 
 
    @RequestMapping("/preview")
    private String preview() {
        return "preview";
    }
 
    @RequestMapping("/index")
    private String index() {
        return "test";
    }
 
    @GetMapping("/list")
    public @ResponseBody
    AjaxResult list(ArdCameras ardCamera) {
        List<ArdCameras> list = ardCamerasService.selectArdCamerasListNoDataScope(ardCamera);
        return AjaxResult.success("相机列表:", list);
    }
 
    @ApiOperation("获取码流压缩参数")
    @PostMapping("/getVideoCompressionCfg")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    @Log(title = "获取码流压缩参数", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) {
        return AjaxResult.success(cameraSdkService.getVideoCompressionCfg(cmd));
    }
 
    @ApiOperation("在线状态")
    @PostMapping("/state")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
    @Log(title = "在线状态", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        boolean onLine = cameraSdkService.isOnLine(cmd);
        return AjaxResult.success(onLine);
    }
 
    @ApiOperation(value = "云台控制", notes = "Code:1-左上 2-上 3-右上 4-左 5-巡航 6-右 7-左下 8-下 9-右下 10-焦距变大 11-焦距变小\n" +
            "12-焦点前调 13-焦点后调 14-光圈扩大 15-光圈缩小 16-雨刷开启")
    @PostMapping("/PTZControlWithSpeed")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"})
    @Log(title = "云台控制", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.pTZControl(cmd));
    }
 
    @ApiOperation("调用预置点")
    @PostMapping("/gotoPreset")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
    @Log(title = "调用预置点", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.gotoPreset(cmd));
    }
 
    @ApiOperation("设置预置点")
    @PostMapping("/setPreset")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
    @Log(title = "设置预置点", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult setPreset(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.setPreset(cmd));
    }
 
    @ApiOperation("获取聚焦值")
    @PostMapping("/getFocusPos")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    @Log(title = "获取聚焦值", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        int focus = cameraSdkService.getFocusPos(cmd);
        return AjaxResult.success("获取聚焦值", focus);
    }
 
    @ApiOperation("设置聚焦值")
    @PostMapping("/setFocusPos")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.dwFocusPos"})
    @Log(title = "设置聚焦值", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.setFocusPos(cmd));
    }
 
    @ApiOperation("获取PTZ")
    @PostMapping("/getPTZ")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    @Log(title = "获取PTZ", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        Map<String, Object> ptzMap = cameraSdkService.getPtz(cmd);
        return AjaxResult.success("获取ptz", ptzMap);
    }
    @ApiOperation("获取PTZ范围")
    @PostMapping("/getPTZScope")
    @Log(title = "获取PTZ范围", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult getPTZScope(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        Map<String, Object> ptzMap = cameraSdkService.getPtzScope(cmd);
        return AjaxResult.success("获取ptz范围", ptzMap);
    }
 
    @ApiOperation("设置PTZ")
    @PostMapping("/setPTZ")
    @Log(title = "设置PTZ", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.ptzMap"})
    public @ResponseBody
    AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.setPtz(cmd));
    }
 
    @ApiOperation("指向目标")
    @PostMapping("/setTargetPosition")
    @Log(title = "指向目标", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.targetPosition"})
    public @ResponseBody
    AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.guideTargetPosition(cmd));
    }
 
 
    @ApiOperation("设置零方位角")
    @PostMapping("/setZeroPTZ")
    @Log(title = "设置零方位角", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.setZeroPtz(cmd));
    }
 
    @ApiOperation("设置锁定")
    @PostMapping("/setPTZLock")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.expired"})
    @Log(title = "设置锁定", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult setPTZLock(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return AjaxResult.success(cameraSdkService.controlLock(cmd));
    }
 
    @ApiOperation("设置解锁")
    @PostMapping("/setPTZUnLock")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
    @Log(title = "设置解锁", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return AjaxResult.success(cameraSdkService.controlUnLock(cmd));
    }
 
    @ApiOperation("获取云台锁定信息")
    @PostMapping("/getPTZLockInfo")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    @Log(title = "获取云台锁定信息", businessType = BusinessType.CONTROL)
    public @ResponseBody
    AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        int byWorkMode = cameraSdkService.getPTZLockInfo(cmd);
        if (byWorkMode == 0) {
            return AjaxResult.success("云台锁定状态:解锁");
        } else if (byWorkMode == 1) {
            return AjaxResult.success("云台锁定状态:锁定");
        } else {
            return AjaxResult.error("云台锁定状态:失败");
        }
    }
 
    @ApiOperation("透雾开关")
    @PostMapping("/defogcfg")
    @Log(title = "透雾开关", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.controlDefogcfg(cmd));
    }
 
    @ApiOperation("红外开关")
    @PostMapping("/infrarecfg")
    @Log(title = "红外开关", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.controlInfrarecfg(cmd));
    }
 
    @ApiOperation(value = "手动/自动聚焦", notes = "true手动flase自动")
    @PostMapping("/focusMode")
    @Log(title = "手动/自动聚焦", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.controlFocusMode(cmd));
    }
 
    @ApiOperation(value = "获取聚焦模式", notes = "1手动2自动")
    @PostMapping("/getFocusMode")
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        String focusMode = cameraSdkService.getFocusMode(cmd);
        return AjaxResult.success(focusMode);
    }
 
    @ApiOperation("云台加热")
    @PostMapping("/heateRpwron")
    @Log(title = "云台加热", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult heateRpwron(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.controlPTHeateRpwron(cmd));
    }
 
 
    @ApiOperation("镜头加热")
    @PostMapping("/cameraDeicing")
    @Log(title = "镜头加热", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return toAjax(cameraSdkService.controlCameraDeicing(cmd));
    }
 
    @ApiOperation("相机抓图")
    @PostMapping("/picCutCate")
    @Log(title = "相机抓图", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        String path = cameraSdkService.picCutCate(cmd);
        return toAjaxString(path, "相机抓图");
    }
 
    @ApiOperation("获取相机架设参数")
    @PostMapping("/getGisInfo")
    @Log(title = "获取相机架设参数", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult getGisInfo(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        return AjaxResult.success(cameraSdkService.getGisInfo(cmd));
    }
 
    @ApiOperation("录像")
    @PostMapping("/record")
    @Log(title = "手动录像开始", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
    public @ResponseBody
    AjaxResult record(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        String url = cameraSdkService.record(cmd);
        return AjaxResult.success(url);
    }
 
    @ApiOperation("手动录像开始")
    @PostMapping("/recordStart")
    @Log(title = "手动录像开始", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
    public @ResponseBody
    AjaxResult recordStart(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        boolean b = cameraSdkService.recordStart(cmd);
        return toAjax(b);
    }
 
    @ApiOperation("手动录像停止")
    @PostMapping("/recordStop")
    @Log(title = "手动录像停止", businessType = BusinessType.CONTROL)
    @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.recordBucketName", "cmd.recordObjectName"})
    public @ResponseBody
    AjaxResult recordStop(@RequestBody CameraCmd cmd) {
        cmd.setOperator(SecurityUtils.getUserId());
        String url = cameraSdkService.recordStopToMinio(cmd);
        return AjaxResult.success(url);
    }
}