From 49207386ea4a3d663628347eef443af9c7cc7f39 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 17 十月 2023 17:20:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java |  584 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 584 insertions(+), 0 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
new file mode 100644
index 0000000..97591be
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
@@ -0,0 +1,584 @@
+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 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")) {
+                    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, 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")) {
+                    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")) {
+
+                }
+            }
+        } 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;
+    }
+    //璁剧疆ptz
+    @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;
+    }
+    //鍋滄褰曞儚骞跺瓨鍏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 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;
+    }
+}

--
Gitblit v1.9.3