liusuyi
2026-05-12 59b5859e049628aaeb1b971057a7a0427f92eb16
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
package com.ard.qs.controller;
 
import com.ard.common.core.web.controller.BaseController;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.common.core.web.page.TableDataInfo;
import com.ard.common.log.annotation.Log;
import com.ard.common.log.enums.BusinessType;
import com.ard.common.security.annotation.RequiresPermissions;
import com.ard.common.security.utils.SecurityUtils;
import com.ard.qs.api.domain.QsDevice;
import com.ard.qs.domain.*;
import com.ard.qs.service.IQsDeviceService;
import com.ard.qs.utils.VideoSnapshotUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 视频监控设备Controller
 *
 * @author fengcheng
 * @date 2026-03-27
 */
@Slf4j
@Tag(name = "视频监控设备")
@RestController
@RequestMapping("/device")
public class QsDeviceController extends BaseController {
    @Autowired
    private IQsDeviceService qsDeviceService;
 
    /**
     * 查询视频监控设备列表
     */
    @Operation(summary = "查询视频监控设备列表")
    @GetMapping("/list")
    public TableDataInfo list(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.selectQsDeviceList(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 根据行政区域获取视频监控设备列表
     */
    @Operation(summary = "根据行政区域获取视频监控设备列表")
    @GetMapping("/queryListByCivilCode")
    public TableDataInfo queryListByCivilCode(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.queryListByCivilCode(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 获取视频监控设备详细信息
     */
    @Operation(summary = "获取视频监控设备详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(qsDeviceService.selectQsDeviceById(id));
    }
 
    /**
     * 新增视频监控设备
     */
    @Operation(summary = "新增视频监控设备")
    @Log(title = "视频监控设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QsDevice qsDevice) {
        return toAjax(qsDeviceService.insertQsDevice(qsDevice));
    }
 
    /**
     * 修改视频监控设备
     */
    @Operation(summary = "修改视频监控设备")
    @Log(title = "视频监控设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QsDevice qsDevice) {
        return toAjax(qsDeviceService.updateQsDevice(qsDevice));
    }
 
    /**
     * 删除视频监控设备
     */
    @Operation(summary = "删除视频监控设备")
    @Log(title = "视频监控设备", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(qsDeviceService.deleteQsDeviceByIds(ids));
    }
 
    /**
     * 状态修改
     */
    @Operation(summary = "状态修改")
    @Log(title = "视频监控设备", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody QsDevice qsDevice) {
        qsDevice.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(qsDeviceService.updateQsDeviceStatus(qsDevice));
    }
 
    /**
     * 获取计划记录对应的视频监控设备
     */
    @GetMapping("/listPlanRecord")
    public TableDataInfo listPlanRecordQsDevice(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.listPlanRecordQsDevice(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 设备关联录制计划
     *
     * @param param
     * @return
     */
    @PostMapping("/link")
    public AjaxResult link(@RequestBody RecordPlanParam param) {
        if (param.getAllLink() != null) {
            if (param.getAllLink()) {
                qsDeviceService.linkAll(param.getPlanId());
            } else {
                qsDeviceService.cleanAll(param.getPlanId());
            }
            return success();
        }
 
        if (param.getDeviceIds() == null) {
            throw new RuntimeException("设备ID不可都为NULL");
        }
 
        qsDeviceService.link(param.getDeviceIds(), param.getPlanId());
 
        return success();
    }
 
 
    /**
     * 设备设置行政区划
     *
     * @param param
     */
    @Operation(summary = "设备设置行政区划")
    @PostMapping("/region/add")
    public AjaxResult addChannelToRegion(@RequestBody DeviceToRegionParam param) {
        Assert.notEmpty(param.getDeviceIds(), "设备ID不可为空");
        Assert.hasLength(param.getCivilCode(), "未添加行政区划");
        qsDeviceService.addDeviceToRegion(param.getCivilCode(), param.getDeviceIds());
        return success();
    }
 
    /**
     * 设备删除行政区划
     *
     * @param param
     */
    @Operation(summary = "设备删除行政区划")
    @PostMapping("/region/delete")
    public AjaxResult deleteDeviceToRegion(@RequestBody DeviceToRegionParam param) {
        Assert.isTrue(!param.getDeviceIds().isEmpty() || !ObjectUtils.isEmpty(param.getCivilCode()), "参数异常");
        qsDeviceService.deleteDeviceToRegion(param.getCivilCode(), param.getDeviceIds());
        return success();
    }
 
 
    /**
     * 存在行政区划但无法挂载的设备列表
     */
    @Operation(summary = "存在行政区划但无法挂载的设备列表")
    @GetMapping("/civilCode/unusual/list")
    public TableDataInfo queryListByCivilCodeForUnusual(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.queryListByCivilCodeForUnusual(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 清除存在行政区划但无法挂载的设备列表
     *
     * @param param
     */
    @Operation(summary = "清除存在行政区划但无法挂载的设备列表")
    @PostMapping("/civilCode/unusual/clear")
    public AjaxResult clearDeviceCivilCode(@RequestBody DeviceToRegionParam param) {
        qsDeviceService.clearDeviceCivilCode(param.getAll(), param.getDeviceIds());
        return success();
    }
 
    /**
     * 获取编码列表
     *
     * @return
     */
    @Operation(summary = "获取编码列表")
    @GetMapping("/network/identification/list")
    public AjaxResult getNetworkIdentificationTypeList() {
        List<NetworkIdentificationType> list = qsDeviceService.getNetworkIdentificationTypeList();
        return success(list);
    }
 
    /**
     * 获取编码列表
     *
     * @return
     */
    @Operation(summary = "获取编码列表")
    @GetMapping("/type/list")
    public AjaxResult getDeviceTypeList() {
        List<DeviceType> list = qsDeviceService.getDeviceTypeList();
        return success(list);
    }
 
    /**
     * 获取行业编码列表
     *
     * @return
     */
    @GetMapping("/industry/list")
    public AjaxResult getIndustryCodeList() {
        List<IndustryCodeType> list = qsDeviceService.getIndustryCodeList();
        return success(list);
    }
 
    /**
     * 获取关联业务分组设备列表
     */
    @GetMapping("/parent/list")
    public TableDataInfo queryListByParentId(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.queryListByParentId(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 设备设置业务分组
     *
     * @param param
     */
    @PostMapping("/group/add")
    public AjaxResult addChannelToGroup(@RequestBody DeviceToGroupParam param) {
        Assert.notEmpty(param.getDeviceIds(), "设备ID不可为空");
        Assert.hasLength(param.getParentId(), "未添加上级分组编号");
        Assert.hasLength(param.getBusinessGroup(), "未添加业务分组");
        qsDeviceService.addChannelToGroup(param.getParentId(), param.getBusinessGroup(), param.getDeviceIds());
        return success();
    }
 
    /**
     * 删除业务分组设备
     *
     * @param param
     */
    @PostMapping("/group/delete")
    public AjaxResult deleteDeviceToGroup(@RequestBody DeviceToGroupParam param) {
        Assert.isTrue(!param.getDeviceIds().isEmpty() || (!ObjectUtils.isEmpty(param.getParentId()) && !ObjectUtils.isEmpty(param.getBusinessGroup())), "参数异常");
        qsDeviceService.deleteDeviceToGroup(param.getParentId(), param.getBusinessGroup(), param.getDeviceIds());
        return success();
    }
 
    /**
     * 存在父节点编号但无法挂载的设备列表
     */
    @GetMapping("/parent/unusual/list")
    public TableDataInfo queryListByParentForUnusual(QsDevice qsDevice) {
        startPage();
        List<QsDevice> list = qsDeviceService.queryListByParentForUnusual(qsDevice);
        return getDataTable(list);
    }
 
    /**
     * 清除存在分组节点但无法挂载的设备列表
     *
     * @param param
     */
    @PostMapping("/parent/unusual/clear")
    public AjaxResult clearDeviceParent(@RequestBody DeviceToGroupParam param) {
        qsDeviceService.clearDeviceParent(param.getAll(), param.getDeviceIds());
        return success();
    }
 
    /**
     * 获取本地mp4截图
     */
    @RequiresPermissions("qs:device:edit")
    @Log(title = "视频监控设备", businessType = BusinessType.UPDATE)
    @PutMapping("/getVideoSnapshot/{id}")
    public AjaxResult getVideoSnapshot(@PathVariable("id") Long id) {
 
 
        return success();
    }
 
    /**
     * 开始云台控制
     *
     * @param id           设备id
     * @param direction    方向
     * @param controlSpeed 控制速度
     * @return 结果
     */
    @Log(title = "云台控制", businessType = BusinessType.OTHER)
    @GetMapping("/startPtz/{id}")
    public AjaxResult startPtz(@PathVariable Long id, @RequestParam String direction, @RequestParam Integer controlSpeed) {
        qsDeviceService.startPtz(id, direction, controlSpeed);
        return AjaxResult.success();
    }
 
    /**
     * 结束云台控制
     *
     * @param id           设备id
     * @param direction    方向
     * @param controlSpeed 控制速度
     * @return 结果
     */
    @Log(title = "云台控制", businessType = BusinessType.OTHER)
    @GetMapping("/endPtz/{id}")
    public AjaxResult endPtz(@PathVariable Long id, @RequestParam String direction, @RequestParam Integer controlSpeed) {
        qsDeviceService.endPtz(id, direction, controlSpeed);
        return AjaxResult.success();
    }
 
    /**
     * 获取预置点列表
     *
     * @param id         设备id
     * @param channelId  通道id
     * @return 预置点列表
     */
    @Log(title = "预置点控制", businessType = BusinessType.OTHER)
    @GetMapping("/preset/list/{id}")
    public AjaxResult getPresetList(@PathVariable Long id, @RequestParam(required = false) Integer channelId) {
        List<Preset> presetList = qsDeviceService.getPresetList(id, channelId);
        return AjaxResult.success(presetList);
    }
 
    /**
     * 设置预置点
     *
     * @param id          设备id
     * @param channelId   通道id
     * @param presetIndex 预置点索引
     * @param presetName  预置点名称
     * @return 结果
     */
    @Log(title = "预置点控制", businessType = BusinessType.OTHER)
    @GetMapping("/preset/set/{id}")
    public AjaxResult setPreset(@PathVariable Long id, @RequestParam(required = false) Integer channelId, @RequestParam Integer presetIndex, @RequestParam(required = false) String presetName) {
        qsDeviceService.setPreset(id, channelId, presetIndex, presetName);
        return AjaxResult.success();
    }
 
    /**
     * 调用预置点
     *
     * @param id          设备id
     * @param channelId   通道id
     * @param presetIndex 预置点索引
     * @param speed       速度
     * @return 结果
     */
    @Log(title = "预置点控制", businessType = BusinessType.OTHER)
    @GetMapping("/preset/goto/{id}")
    public AjaxResult gotoPreset(@PathVariable Long id, @RequestParam(required = false) Integer channelId, @RequestParam Integer presetIndex, @RequestParam(required = false) Integer speed) {
        qsDeviceService.gotoPreset(id, channelId, presetIndex, speed);
        return AjaxResult.success();
    }
 
    /**
     * 删除预置点
     *
     * @param id          设备id
     * @param channelId   通道id
     * @param presetIndex 预置点索引
     * @return 结果
     */
    @Log(title = "预置点控制", businessType = BusinessType.OTHER)
    @GetMapping("/preset/delete/{id}")
    public AjaxResult deletePreset(@PathVariable Long id, @RequestParam(required = false) Integer channelId, @RequestParam Integer presetIndex) {
        qsDeviceService.deletePreset(id, channelId, presetIndex);
        return AjaxResult.success();
    }
}