| | |
| | | package com.ruoyi.device.dhsdk.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.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 大华sdk接口 |
| | | * @ClassName: DhSdkController |
| | | * @Author: 刘苏义 |
| | | * @Date: 2023年10月14日10:34:58 |
| | | **/ |
| | | @Api(tags = "大华SDK接口") |
| | | @Controller |
| | | @RequestMapping("/dh") |
| | | @Anonymous |
| | | public class DhSdkController { |
| | | |
| | | @Resource |
| | | private IDhClientService sdk; |
| | | |
| | | /** |
| | | * @描述 初始加载大华库文件 |
| | | * @参数 [] |
| | | * @返回值 void |
| | | * @创建人 刘苏义 |
| | | * @创建时间 2023/1/17 16:13 |
| | | * @修改人和其它信息 if (Platform.isLinux()) |
| | | */ |
| | | @PostConstruct |
| | | public void initDHSDK() { |
| | | //初始化加载sdk库文件 |
| | | if (sdk.init()) |
| | | { |
| | | //登录所有相机 |
| | | sdk.loginAll(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "云台控制", notes = "Code:1-左上 2-上 3-右上 4-左 5-巡航 6-右 7-左下 8-下 9-右下 10-焦距变大 11-焦距变小\n" + |
| | | "12-焦点前调 13-焦点后调 14-光圈扩大 15-光圈缩小 ") |
| | | @PostMapping("/pTZControl") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"}) |
| | | @Log(title = "云台控制", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult pTZControl(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(sdk.pTZControl(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取PTZ") |
| | | @PostMapping("/getPTZ") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"}) |
| | | @Log(title = "获取PTZ", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = sdk.getPtz(cmd); |
| | | return AjaxResult.success("获取ptz", ptzMap); |
| | | } |
| | | package com.ruoyi.device.dhsdk.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.CameraCmd;
|
| | | import com.ruoyi.device.dhsdk.service.IDhClientService;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.ResponseBody;
|
| | | import javax.annotation.Resource;
|
| | | import java.util.Map;
|
| | |
|
| | | /**
|
| | | * @Description: 大华sdk接口
|
| | | * @ClassName: DhSdkController
|
| | | * @Author: 刘苏义
|
| | | * @Date: 2023年10月14日10:34:58
|
| | | **/
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("/dh")
|
| | | @Anonymous
|
| | | public class DhSdkController extends BaseController {
|
| | |
|
| | | @Resource
|
| | | private IDhClientService sdk;
|
| | |
|
| | |
|
| | | @ApiOperation(value = "云台控制", notes = "Code:1-左上 2-上 3-右上 4-左 5-巡航 6-右 7-左下 8-下 9-右下 10-焦距变大 11-焦距变小\n" +
|
| | | "12-焦点前调 13-焦点后调 14-光圈扩大 15-光圈缩小 ")
|
| | | @PostMapping("/pTZControl")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"})
|
| | | @Log(title = "云台控制", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult pTZControl(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.pTZControl(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("获取PTZ")
|
| | | @PostMapping("/getPTZ")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
|
| | | @Log(title = "获取PTZ", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | Map<String, Object> ptzMap = sdk.getPtz(cmd);
|
| | | return AjaxResult.success("获取ptz", ptzMap);
|
| | | }
|
| | | @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 = sdk.isOnLine(cmd);
|
| | | return AjaxResult.success(onLine);
|
| | | }
|
| | | @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(sdk.setPtz(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(sdk.setZeroPtz(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 url = sdk.picCutCate(cmd);
|
| | | return toAjaxString(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 = sdk.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 = sdk.recordStopToMinio(cmd);
|
| | | return AjaxResult.success(url);
|
| | | }
|
| | | } |