| | |
| | | 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 com.ruoyi.device.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | public class CameraSdkController extends BaseController { |
| | | |
| | | @Resource |
| | | private IHikClientService hikClientService; |
| | | @Resource |
| | | private IDhClientService dhClientService; |
| | | private ICameraSdkService cameraSdkService; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | |
| | | /** |
| | | * @描述 初始加载海康库文件 |
| | | * @参数 [] |
| | | * @描述 初始加载SDK库文件 |
| | | * @返回值 void |
| | | * @创建人 刘苏义 |
| | | * @创建时间 2023/1/17 16:13 |
| | | * @修改人和其它信息 if (Platform.isLinux()) |
| | | */ |
| | | @PostConstruct |
| | | public void initHCNetSDK() { |
| | | //初始化加载sdk库文件 |
| | | hikClientService.loadHCNetSDKLib(); |
| | | //登录所有相机 |
| | | hikClientService.loginAll(); |
| | | public void initSDK() { |
| | | cameraSdkService.initSDK(); |
| | | } |
| | | |
| | | @RequestMapping("/preview") |
| | |
| | | @Log(title = "获取码流压缩参数", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) { |
| | | return AjaxResult.success(hikClientService.getVideoCompressionCfg(cmd)); |
| | | return AjaxResult.success(cameraSdkService.getVideoCompressionCfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("在线状态") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getOnlineState(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | boolean onLine = hikClientService.isOnLine(cmd); |
| | | boolean onLine = cameraSdkService.isOnLine(cmd); |
| | | return AjaxResult.success(onLine); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.pTZControlWithSpeed(cmd)); |
| | | return toAjax(cameraSdkService.pTZControl(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("调用预置点") |
| | |
| | | public @ResponseBody |
| | | AjaxResult gotoPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.gotoPreset(cmd)); |
| | | return toAjax(cameraSdkService.gotoPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置预置点") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPreset(cmd)); |
| | | return toAjax(cameraSdkService.setPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取聚焦值") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> Map = hikClientService.getFocusPos(cmd); |
| | | return AjaxResult.success("获取聚焦值", Map); |
| | | int focus = cameraSdkService.getFocusPos(cmd); |
| | | return AjaxResult.success("获取聚焦值", focus); |
| | | } |
| | | |
| | | @ApiOperation("设置聚焦值") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setFocusPos(cmd)); |
| | | return toAjax(cameraSdkService.setFocusPos(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取PTZ") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = hikClientService.getPtz(cmd); |
| | | Map<String, Object> ptzMap = cameraSdkService.getPtz(cmd); |
| | | return AjaxResult.success("获取ptz", ptzMap); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZScope(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = hikClientService.getPtzScope(cmd); |
| | | Map<String, Object> ptzMap = cameraSdkService.getPtzScope(cmd); |
| | | return AjaxResult.success("获取ptz范围", ptzMap); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPtz(cmd)); |
| | | return toAjax(cameraSdkService.setPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("指向目标") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.guideTargetPosition(cmd)); |
| | | return toAjax(cameraSdkService.guideTargetPosition(cmd)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("设置零方位角") |
| | | @PostMapping("/setZeroPTZ") |
| | | @Log(title = "设置零方位角", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.cmd.chanNo"}) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setZeroPtz(cmd)); |
| | | return toAjax(cameraSdkService.setZeroPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置锁定") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置解锁") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlUnLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlUnLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("获取云台锁定信息") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | int byWorkMode = hikClientService.getPTZLockInfo(cmd); |
| | | int byWorkMode = cameraSdkService.getPTZLockInfo(cmd); |
| | | if (byWorkMode == 0) { |
| | | return AjaxResult.success("云台锁定状态:解锁"); |
| | | } else if (byWorkMode == 1) { |
| | |
| | | public @ResponseBody |
| | | AjaxResult defogcfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlDefogcfg(cmd)); |
| | | return toAjax(cameraSdkService.controlDefogcfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("红外开关") |
| | |
| | | public @ResponseBody |
| | | AjaxResult infrarecfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlInfrarecfg(cmd)); |
| | | return toAjax(cameraSdkService.controlInfrarecfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation(value = "手动/自动聚焦", notes = "true手动flase自动") |
| | |
| | | public @ResponseBody |
| | | AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlFocusMode(cmd)); |
| | | 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 = hikClientService.getFocusMode(cmd); |
| | | String focusMode = cameraSdkService.getFocusMode(cmd); |
| | | return AjaxResult.success(focusMode); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult heateRpwron(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlPTHeateRpwron(cmd)); |
| | | return toAjax(cameraSdkService.controlPTHeateRpwron(cmd)); |
| | | } |
| | | |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlCameraDeicing(cmd)); |
| | | } |
| | | |
| | | @PostMapping("/captureJPEGPicture") |
| | | public @ResponseBody |
| | | AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String base64Str = hikClientService.captureJPEGPicture(cmd); |
| | | return toAjaxString(base64Str, "相机抓图"); |
| | | return toAjax(cameraSdkService.controlCameraDeicing(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("相机抓图") |
| | |
| | | public @ResponseBody |
| | | AjaxResult picCutCate(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String path = hikClientService.picCutCate(cmd); |
| | | String path = cameraSdkService.picCutCate(cmd); |
| | | return toAjaxString(path, "相机抓图"); |
| | | } |
| | | |
| | | @ApiOperation("手动录像") |
| | | @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) |
| | | @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 path = hikClientService.record(cmd); |
| | | return toAjaxString(path, "手动录像"); |
| | | String url = cameraSdkService.record(cmd); |
| | | return AjaxResult.success(url); |
| | | } |
| | | |
| | | @ApiOperation("获取相机架设参数") |
| | | @PostMapping("/getCameraSetupCFG") |
| | | @Log(title = "获取相机架设参数", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | @ApiOperation("手动录像开始") |
| | | @PostMapping("/recordStart") |
| | | @Log(title = "手动录像开始", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) { |
| | | AjaxResult recordStart(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.getGisInfo(cmd)); |
| | | 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); |
| | | } |
| | | } |