From 2217289657c3a402e132490497b10f3876bc1aa1 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期一, 06 十一月 2023 10:17:36 +0800
Subject: [PATCH] 获取三一地址
---
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java | 1300 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 690 insertions(+), 610 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
index bc888e1..9fd7a40 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
@@ -1,610 +1,690 @@
-package com.ruoyi.device.camera.service.impl;
-
-import com.ruoyi.common.constant.CacheConstants;
-import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.device.camera.domain.ArdCameras;
-import com.ruoyi.device.camera.domain.CameraCmd;
-import com.ruoyi.device.camera.service.ICameraSdkService;
-import com.ruoyi.device.channel.domain.ArdChannel;
-import com.ruoyi.device.dhsdk.service.IDhClientService;
-import com.ruoyi.device.hiksdk.common.GlobalVariable;
-import com.ruoyi.device.hiksdk.service.IHikClientService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.NET_DVR_CHECK_USER_STATUS;
-
-
-/**
- * @Description: 鐩告満sdk涓氬姟
- * @ClassName: CameraSdkServiceImpl
- * @Author: 鍒樿嫃涔�
- * @Date: 2023骞�10鏈�16鏃�15:21:01
- **/
-@Service
-@Slf4j(topic = "SDK")
-public class CameraSdkServiceImpl implements ICameraSdkService {
- @Resource
- IHikClientService hikClientService;
- @Resource
- IDhClientService dhClientService;
- @Resource
- RedisCache redisCache;
-
- @Override
- public void initSDK() {
- //鍒濆鍖栧姞杞絪dk搴撴枃浠�
- boolean initHIK = hikClientService.init();
- if (initHIK) {
- hikClientService.loginAll();//鐧诲綍鍏ㄩ儴娴峰悍鐩告満
- }
- Boolean initDH = dhClientService.init();
- if (initDH) {
- dhClientService.loginAll();//鐧诲綍鍏ㄩ儴澶у崕鐩告満
- }
- }
-
- @Override
- public void syncLogin(ArdCameras cameras) {
-
- }
-
- @Override
- public void asyncLogin(ArdCameras cameras) {
-
- }
-
- @Override
- public void loginAll() {
-
- }
-
- @Override
- public boolean logout(String cameraId) {
- return false;
- }
-
- @Override
- public boolean isOnLine(CameraCmd cmd) {
- try {
- boolean onLine = false;
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- onLine = hikClientService.isOnLine(cmd);
- } else if (factory.equals("2")) {
- onLine = dhClientService.isOnLine(cmd);
- }
- }
- return onLine;
- } catch (Exception ex) {
- log.error("妫�娴嬪湪绾垮紓甯革細" + ex.getMessage());
- return false;
- }
- }
-
- @Override
- public boolean pTZControl(CameraCmd cmd) {
- try {
- boolean result = false;
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.pTZControlWithSpeed(cmd);
- } else if (factory.equals("2")) {
- result = dhClientService.pTZControl(cmd);
- }
- }
- return result;
- } catch (Exception ex) {
- log.error("ptz鎺у埗寮傚父锛�" + ex.getMessage());
- return false;
- }
- }
-
- //璁剧疆鑱氱劍鍊�
- @Override
- public boolean setFocusPos(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.setFocusPos(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("璁剧疆鑱氱劍鍊煎紓甯革細" + ex.getMessage());
-
- }
- return result;
- }
-
-
- //鑾峰彇鑱氱劍鍊�
- @Override
- public Map<String, Object> getFocusPos(CameraCmd cmd) {
- Map<String, Object> map = new HashMap<>();
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- map = hikClientService.getFocusPos(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇鑱氱劍鍊煎紓甯革細" + ex.getMessage());
- }
- return map;
- }
-
- //璁剧疆棰勭疆浣�
- @Override
- public boolean setPreset(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.setPreset(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("璁剧疆棰勭疆浣嶅紓甯革細" + ex.getMessage());
- }
- return result;
- }
-
- //璋冪敤棰勭疆浣�
- @Override
- public boolean gotoPreset(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.gotoPreset(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("璋冪敤棰勭疆浣嶅紓甯革細" + ex.getMessage());
- }
- return result;
- }
-
- //鑾峰彇鐮佹祦鍘嬬缉鍙傛暟
- @Override
- public Map<String, String> getVideoCompressionCfg(CameraCmd cmd) {
- Map<String, String> map = new HashMap<>();
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- map = hikClientService.getVideoCompressionCfg(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇鐮佹祦鍘嬬缉鍙傛暟寮傚父锛�" + ex.getMessage());
- }
- return map;
- }
-
- //閫忛浘寮�鍏�
- @Override
- public boolean controlDefogcfg(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlDefogcfg(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶閫忛浘寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //绾㈠寮�鍏�
- @Override
- public boolean controlInfrarecfg(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlInfrarecfg(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶绾㈠寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
-
- //鎵嬪姩/鑷姩鑱氱劍
- @Override
- public boolean controlFocusMode(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlFocusMode(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //鑾峰彇鑱氱劍妯″紡
- @Override
- public String getFocusMode(CameraCmd cmd) {
- String result = "";
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.getFocusMode(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //浜戝彴鍔犵儹
- @Override
- public boolean controlPTHeateRpwron(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlPTHeateRpwron(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //闀滃ご鍔犵儹
- @Override
- public boolean controlCameraDeicing(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlCameraDeicing(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //鎿嶆帶閿佸畾
- @Override
- public boolean controlLock(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlLock(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鎿嶆帶閿佸畾寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
-
- //璁剧疆瑙i攣
- @Override
- public boolean controlUnLock(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.controlUnLock(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("璁剧疆瑙i攣寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- //鑾峰彇浜戝彴閿佸畾淇℃伅
- @Override
- public int getPTZLockInfo(CameraCmd cmd) {
- int result = 99;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.getPTZLockInfo(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇浜戝彴閿佸畾淇℃伅寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- @Override
- public String captureJPEGPicture(CameraCmd cmd) {
- return null;
- }
-
- @Override
- public String picCutCate(CameraCmd cmd) {
- String url = "";
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- url = hikClientService.picCutCate(cmd);
- } else if (factory.equals("2")) {
- url = dhClientService.picCutCate(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("鎶撳浘寮傚父锛�" + ex.getMessage());
- }
- return url;
- }
- //鑾峰彇ptz
- @Override
- public Map<String, Object> getPtz(CameraCmd cmd) {
- Map<String, Object> map = new HashMap<>();
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- map = hikClientService.getPtz(cmd);
- } else if (factory.equals("2")) {
- map = dhClientService.getPtz(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇ptz寮傚父锛�" + ex.getMessage());
- }
- return map;
- }
-
- //鑾峰彇ptz鑼冨洿
- @Override
- public Map<String, Object> getPtzScope(CameraCmd cmd) {
- Map<String, Object> map = new HashMap<>();
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- map = hikClientService.getPtzScope(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇ptz鑼冨洿寮傚父锛�" + ex.getMessage());
- }
- return map;
- }
-
- @Override
- public boolean setPtz(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.setPtz(cmd);
- } else if (factory.equals("2")) {
- result = dhClientService.setPtz(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("璁剧疆ptz寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- @Override
- public boolean setZeroPtz(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.setZeroPtz(cmd);
- } else if (factory.equals("2")) {
- result = dhClientService.setZeroPtz(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("璁剧疆闆舵柟浣嶈寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
-
- //寮曞鎸囧悜鐩爣
- @Override
- public boolean guideTargetPosition(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.guideTargetPosition(cmd);
- } else if (factory.equals("2")) {
- result = dhClientService.guideTargetPosition(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("寮曞鎸囧悜鐩爣寮傚父锛�" + ex.getMessage());
- }
- return result;
- }
-
- @Override
- public boolean recordStart(CameraCmd cmd) {
- boolean result = false;
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- result = hikClientService.recordStart(cmd);
- } else if (factory.equals("2")) {
- result = dhClientService.recordStart(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("寮�濮嬪綍鍍忓紓甯革細" + ex.getMessage());
- }
- return result;
- }
-
- @Override
- public String recordStopToMinio(CameraCmd cmd) {
- String url = "";
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- url = hikClientService.recordStopToMinio(cmd);
- } else if (factory.equals("2")) {
- url = dhClientService.recordStopToMinio(cmd);
- }
- }
- } catch (Exception ex) {
- log.error("鍋滄褰曞儚寮傚父锛�" + ex.getMessage());
- }
- return url;
- }
-
- @Override
- public void recordStopNotToMinio(CameraCmd cmd) {
-
- }
-
- @Override
- public List<ArdChannel> getCameraChannelList(ArdCameras camera) {
- return null;
- }
-
- //鑾峰彇鐩告満鏋惰鍙傛暟
- @Override
- public Map<String, Object> getGisInfo(CameraCmd cmd) {
- Map<String, Object> map = new HashMap<>();
- try {
- String cameraId = cmd.getCameraId();
- ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- if (factory.equals("1")) {
- map = hikClientService.getGisInfo(cmd);
- } else if (factory.equals("2")) {
-
- }
- }
- } catch (Exception ex) {
- log.error("鑾峰彇鐩告満鏋惰鍙傛暟寮傚父锛�" + ex.getMessage());
- }
- return map;
- }
-}
+package com.ruoyi.device.camera.service.impl;
+
+import com.ruoyi.common.annotation.SdkOperate;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.core.redis.RedisCache;
+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.utils.sdk.dhsdk.service.IDhClientService;
+import com.ruoyi.utils.sdk.hiksdk.service.IHikClientService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @Description: 鐩告満sdk涓氬姟
+ * @ClassName: CameraSdkServiceImpl
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�10鏈�16鏃�15:21:01
+ **/
+@Service
+@Slf4j(topic = "SDK")
+public class CameraSdkServiceImpl implements ICameraSdkService, ApplicationRunner {
+ @Resource
+ private IArdCamerasService ardCamerasService;
+ @Resource
+ IHikClientService hikClientService;
+ @Resource
+ IDhClientService dhClientService;
+ @Resource
+ RedisCache redisCache;
+
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ try {
+ List<ArdCameras> ardCameras = ardCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
+ for (ArdCameras camera : ardCameras) {
+ if ("1".equals(camera.getFactory())) {
+ hikClientService.login(camera);
+ } else if ("2".equals(camera.getFactory())) {
+ dhClientService.login(camera);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鍒濆鍖栫櫥褰曠浉鏈哄紓甯革細" + ex.getMessage());
+ }
+ }
+
+ //鐧诲綍
+ @Override
+ public Boolean login(ArdCameras ardCamera) {
+ boolean result = false;
+ try {
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ hikClientService.login(ardCamera);
+ result = true;
+ } else if (factory.equals("2")) {
+ dhClientService.login(ardCamera);
+ result = true;
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鐧诲綍寮傚父锛�" + ex.getMessage());
+ return false;
+ }
+ return result;
+ }
+
+ //娉ㄩ攢
+ @Override
+ public boolean logout(String cameraId) {
+ boolean result = false;
+ try {
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.logout(cameraId);
+ } else if (factory.equals("2")) {
+ result = dhClientService.logout(cameraId);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("娉ㄩ攢寮傚父锛�" + ex.getMessage());
+ return false;
+ }
+ return result;
+ }
+
+ //鍦ㄧ嚎妫�娴�
+ @Override
+ public boolean isOnLine(CameraCmd cmd) {
+ try {
+ boolean onLine = false;
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ onLine = hikClientService.isOnLine(cmd);
+ } else if (factory.equals("2")) {
+ onLine = dhClientService.isOnLine(cmd);
+ }
+ }
+ return onLine;
+ } catch (Exception ex) {
+ log.error("妫�娴嬪湪绾垮紓甯革細" + ex.getMessage());
+ return false;
+ }
+ }
+
+ //浜戝彴鎺у埗
+ @SdkOperate
+ @Override
+ public boolean pTZControl(CameraCmd cmd) {
+ try {
+ boolean result = false;
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.pTZControlWithSpeed(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.pTZControl(cmd);
+ }
+ }
+ return result;
+ } catch (Exception ex) {
+ log.error("ptz鎺у埗寮傚父锛�" + ex.getMessage());
+ return false;
+ }
+ }
+
+ //璁剧疆鑱氱劍鍊�
+ @Override
+ public boolean setFocusPos(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setFocusPos(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setFocusPos(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆鑱氱劍鍊煎紓甯革細" + ex.getMessage());
+
+ }
+ return result;
+ }
+
+ //鑾峰彇鑱氱劍鍊�
+ @Override
+ public int getFocusPos(CameraCmd cmd) {
+ int result = 0;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.getFocusPos(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.getFocusPos(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鑱氱劍鍊煎紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //璁剧疆棰勭疆浣�
+ @Override
+ public boolean setPreset(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setPreset(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setPreset(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆棰勭疆浣嶅紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //璋冪敤棰勭疆浣�
+ @Override
+ public boolean gotoPreset(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.gotoPreset(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.gotoPreset(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璋冪敤棰勭疆浣嶅紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鑾峰彇鐮佹祦鍘嬬缉鍙傛暟
+ @Override
+ public Map<String, Object> getVideoCompressionCfg(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getVideoCompressionCfg(cmd);
+ } else if (factory.equals("2")) {
+ map = dhClientService.getVideoCompressionCfg(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鐮佹祦鍘嬬缉鍙傛暟寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+
+ //閫忛浘寮�鍏�
+ @Override
+ public boolean controlDefogcfg(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlDefogcfg(cmd);
+ } else if (factory.equals("2")) {
+ //涓嶆敮鎸�
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶閫忛浘寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //绾㈠寮�鍏�
+ @Override
+ public boolean controlInfrarecfg(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlInfrarecfg(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.controlInfrarecfg(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶绾㈠寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鎵嬪姩/鑷姩鑱氱劍
+ @Override
+ public boolean controlFocusMode(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlFocusMode(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.controlFocusMode(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鑾峰彇鑱氱劍妯″紡
+ @Override
+ public String getFocusMode(CameraCmd cmd) {
+ String result = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.getFocusMode(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.getFocusMode(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鑱氱劍妯″紡寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //浜戝彴鍔犵儹
+ @Override
+ public boolean controlPTHeateRpwron(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlPTHeateRpwron(cmd);
+ } else if (factory.equals("2")) {
+ //涓嶆敮鎸�
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //闀滃ご鍔犵儹
+ @Override
+ public boolean controlCameraDeicing(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.controlCameraDeicing(cmd);
+ } else if (factory.equals("2")) {
+ //涓嶆敮鎸�
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎿嶆帶浜戝彴鍔犵儹寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鑾峰彇浜戝彴閿佸畾淇℃伅
+ @Override
+ public int getPTZLockInfo(CameraCmd cmd) {
+ int result = 99;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.getPTZLockInfo(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇浜戝彴閿佸畾淇℃伅寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public String captureJPEGPicture(CameraCmd cmd) {
+ return null;
+ }
+
+ //鎶撳浘
+ @SdkOperate
+ @Override
+ public String picCutCate(CameraCmd cmd) {
+ String url = "";
+ try {
+ //鑾峰彇鎽勫儚澶碔D
+ String cameraId = cmd.getCameraId();
+ //浠巖edis涓幏鍙栨憚鍍忓ご淇℃伅
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ //鑾峰彇鎽勫儚澶村伐鍘�
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ //璋冪敤hikClientService鐨刾icCutCate鏂规硶
+ url = hikClientService.picCutCate(cmd);
+ } else if (factory.equals("2")) {
+ //璋冪敤dhClientService鐨刾icCutCate鏂规硶
+ url = dhClientService.picCutCate(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鎶撳浘寮傚父锛�" + ex.getMessage());
+ }
+ return url;
+ }
+
+ //鑾峰彇ptz
+ @Override
+ public Map<String, Object> getPtz(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getPtz(cmd);
+ } else if (factory.equals("2")) {
+ map = dhClientService.getPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇ptz寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+
+ //鑾峰彇ptz鑼冨洿
+ @Override
+ public Map<String, Object> getPtzScope(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getPtzScope(cmd);
+ } else if (factory.equals("2")) {
+
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇ptz鑼冨洿寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+
+ //璁剧疆ptz
+ @SdkOperate
+ @Override
+ public boolean setPtz(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setPtz(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆ptz寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //璁剧疆闆舵柟浣嶈
+ @SdkOperate
+ @Override
+ public boolean setZeroPtz(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.setZeroPtz(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.setZeroPtz(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("璁剧疆闆舵柟浣嶈寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //寮曞鎸囧悜鐩爣
+ @SdkOperate
+ @Override
+ public boolean guideTargetPosition(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.guideTargetPosition(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.guideTargetPosition(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("寮曞鎸囧悜鐩爣寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ /**
+ * @鎻忚堪 鎿嶆帶閿佸畾
+ * @鍙傛暟 [userId, channelNum]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/17 16:36
+ * @淇敼浜哄拰鍏跺畠淇℃伅 0-瑙i攣 1-閿佸畾
+ */
+ @Override
+ @SdkOperate
+ public boolean controlLock(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();//鐢宠閿佺殑鐩告満
+ ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cameraId);
+ Date now = new Date();
+ now.setTime(now.getTime() + cmd.getExpired() * 1000);
+ ardCameras.setOperatorExpired(now);//璁剧疆褰撳墠杩囨湡鏃堕棿
+ ardCamerasService.updateArdCameras(ardCameras);
+ return true;
+ }
+
+ /**
+ * @鎻忚堪 鎿嶆帶瑙i攣
+ * @鍙傛暟 [userId, channelNum]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/6/30 15:36
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ @Override
+ public boolean controlUnLock(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();//鐢宠瑙i攣鐨勭浉鏈�
+ String operator = cmd.getOperator();//鐢宠鑰�
+ ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cameraId);
+ if (ardCameras.getOperatorId().equals(operator)) {
+ //濡傛灉瑙i攣鐩告満鐨勫綋鍓嶇敤鎴锋槸鐢宠鑰咃紝鍒欐竻绌鸿鐩告満鐨勮繃鏈熸椂闂�
+ ardCameras.setOperatorExpired(null);
+ int i = ardCamerasService.updateArdCameras(ardCameras);
+ if (i > 0) {
+ log.debug(cameraId + "--瑙i攣鎴愬姛");
+ }
+ }
+ return true;
+ }
+
+
+ //褰曞儚
+ @SdkOperate
+ @Override
+ public String record(CameraCmd cmd) {
+ String url = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ url = hikClientService.record(cmd);
+ } else if (factory.equals("2")) {
+ url = dhClientService.record(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("褰曞儚寮傚父锛�" + ex.getMessage());
+ }
+ return url;
+ }
+
+ //寮�濮嬪綍鍍�
+ @Override
+ public boolean recordStart(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.recordStart(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.recordStart(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("寮�濮嬪綍鍍忓紓甯革細" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鍋滄褰曞儚骞跺瓨鍏inio
+ @Override
+ public String recordStopToMinio(CameraCmd cmd) {
+ String url = "";
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ url = hikClientService.recordStopToMinio(cmd);
+ } else if (factory.equals("2")) {
+ url = dhClientService.recordStopToMinio(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鍋滄褰曞儚寮傚父锛�" + ex.getMessage());
+ }
+ return url;
+ }
+
+ //鍋滄褰曞儚骞朵笉瀛樺叆minio
+ @Override
+ public boolean recordStopNotToMinio(CameraCmd cmd) {
+ boolean result = false;
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ result = hikClientService.recordStopNotToMinio(cmd);
+ } else if (factory.equals("2")) {
+ result = dhClientService.recordStopNotToMinio(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鍋滄褰曞儚寮傚父锛�" + ex.getMessage());
+ }
+ return result;
+ }
+
+ //鑾峰彇鐩告満鏋惰鍙傛暟
+ @Override
+ public Map<String, Object> getGisInfo(CameraCmd cmd) {
+ Map<String, Object> map = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ if (factory.equals("1")) {
+ map = hikClientService.getGisInfo(cmd);
+ } else if (factory.equals("2")) {
+ map = dhClientService.getGisInfo(cmd);
+ }
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇鐩告満鏋惰鍙傛暟寮傚父锛�" + ex.getMessage());
+ }
+ return map;
+ }
+
+
+}
--
Gitblit v1.9.3