From a767f8b7e2aabf9bb3bb98344e8c559c71c1d442 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期五, 11 八月 2023 14:40:28 +0800
Subject: [PATCH] 过滤通用光电报警只保留移动侦测、周界入侵报警、越界侦测报警 增加报警主机、门禁主机、通用光电数据同步

---
 src/main/java/com/ard/utils/hiksdk/service/impl/HikClientUtil.java |  124 +++++++++++++++++++++++++++++++++-------
 1 files changed, 101 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/ard/utils/hiksdk/service/impl/HikClientUtil.java b/src/main/java/com/ard/utils/hiksdk/service/impl/HikClientUtil.java
index 428c3fe..1faeb54 100644
--- a/src/main/java/com/ard/utils/hiksdk/service/impl/HikClientUtil.java
+++ b/src/main/java/com/ard/utils/hiksdk/service/impl/HikClientUtil.java
@@ -121,11 +121,8 @@
 
     /**
      * @鎻忚堪 娉ㄥ唽鐧诲綍 闆嗘垚浜嶯ET_DVR_Login_V30锛屾敮鎸佸悓姝ュ拰寮傛鐧诲綍
-     * @鍙傛暟 [dvrLogin]
-     * @杩斿洖鍊� java.lang.Integer
      * @鍒涘缓浜� 鍒樿嫃涔�
      * @鍒涘缓鏃堕棿 2023/1/17 16:12
-     * @淇敼浜哄拰鍏跺畠淇℃伅
      */
     public static void login(DeviceInfo deviceInfo) {
         // 鍒濆鍖�
@@ -173,12 +170,34 @@
     }
 
     /**
+     * @鎻忚堪 鐢ㄦ埛娉ㄩ攢
+     * @鍒涘缓浜� 鍒樿嫃涔�
+     * @鍒涘缓鏃堕棿 2023/1/17 16:12
+     */
+    public static void logout(DeviceInfo deviceInfo) {
+        String deviceIpPort = deviceInfo.getIp() + ":" + deviceInfo.getPort();
+        //鎾ら槻
+        if (GlobalVariable.alarmMap.containsKey(deviceInfo.getDeviceId())) {
+            Integer lAlarmHandle = GlobalVariable.alarmMap.get(deviceInfo.getDeviceId());
+            boolean b = hCNetSDK.NET_DVR_CloseAlarmChan_V30(lAlarmHandle);
+            if (b) {
+                log.debug("璁惧銆�" + deviceIpPort + "銆戞挙闃叉垚鍔�");
+            }
+        }
+        //鐧诲嚭
+        if (GlobalVariable.loginMap.containsKey(deviceInfo.getDeviceId())) {
+            Integer lUserID = GlobalVariable.loginMap.get(deviceInfo.getDeviceId());
+            boolean b = hCNetSDK.NET_DVR_Logout(lUserID);
+            if (b) {
+                log.debug("璁惧銆�" + deviceIpPort + "銆戞敞閿�鎴愬姛");
+            }
+        }
+    }
+
+    /**
      * @鎻忚堪 鐧诲綍鎵�鏈夌浉鏈�
-     * @鍙傛暟 []
-     * @杩斿洖鍊� void
      * @鍒涘缓浜� 鍒樿嫃涔�
      * @鍒涘缓鏃堕棿 2023/2/3 10:10
-     * @淇敼浜哄拰鍏跺畠淇℃伅
      */
     public static void loginAllCamera(List<ArdCameras> ardCameras) {
         try {
@@ -191,8 +210,30 @@
                 info.setUsername(camera.getUsername());
                 info.setPassword(camera.getPassword());
                 login(info);
-                String ip = camera.getIp();
-                GlobalVariable.cameraMap.put(ip, camera);
+                GlobalVariable.cameraMap.put(camera.getIp(), camera);
+            }
+        } catch (Exception ex) {
+            log.error("鍒濆鍖栫櫥褰曠浉鏈哄紓甯革細" + ex.getMessage());
+        }
+    }
+
+    /**
+     * @鎻忚堪 鐧诲嚭鎵�鏈夌浉鏈�
+     * @鍒涘缓浜� 鍒樿嫃涔�
+     * @鍒涘缓鏃堕棿 2023/2/3 10:10
+     */
+    public static void logoutAllCamera(List<ArdCameras> ardCameras) {
+        try {
+            for (ArdCameras camera : ardCameras) {
+                Thread.sleep(100);
+                DeviceInfo info = new DeviceInfo();
+                info.setDeviceId(camera.getId());
+                info.setIp(camera.getIp());
+                info.setPort(camera.getPort());
+                info.setUsername(camera.getUsername());
+                info.setPassword(camera.getPassword());
+                logout(info);
+                GlobalVariable.cameraMap.remove(camera.getIp());
             }
         } catch (Exception ex) {
             log.error("鍒濆鍖栫櫥褰曠浉鏈哄紓甯革細" + ex.getMessage());
@@ -201,11 +242,8 @@
 
     /**
      * @鎻忚堪 鐧诲綍鎵�鏈夋姤璀︿富鏈�
-     * @鍙傛暟 []
-     * @杩斿洖鍊� void
      * @鍒涘缓浜� 鍒樿嫃涔�
      * @鍒涘缓鏃堕棿 2023/2/3 10:10
-     * @淇敼浜哄拰鍏跺畠淇℃伅
      */
     public static void loginAllAlarmHost(List<ArdEquipExternal> ardEquipExternals) {
         try {
@@ -225,14 +263,34 @@
             log.error("鍒濆鍖栨姤璀︿富鏈哄紓甯革細" + ex.getMessage());
         }
     }
-
     /**
-     * @鎻忚堪 鐧诲綍鎵�鏈夐棬绂佷富鏈�
-     * @鍙傛暟 []
-     * @杩斿洖鍊� void
+     * @鎻忚堪 鐧诲嚭鎵�鏈夋姤璀︿富鏈�
      * @鍒涘缓浜� 鍒樿嫃涔�
      * @鍒涘缓鏃堕棿 2023/2/3 10:10
-     * @淇敼浜哄拰鍏跺畠淇℃伅
+     */
+    public static void logoutAllAlarmHost(List<ArdEquipExternal> ardEquipExternals)
+    {
+        try {
+            for (ArdEquipExternal alarmHost : ardEquipExternals) {
+                Thread.sleep(100);
+                DeviceInfo info = new DeviceInfo();
+                info.setDeviceId(alarmHost.getId());
+                info.setIp(alarmHost.getIp());
+                info.setPort(alarmHost.getPort());
+                info.setUsername(alarmHost.getUsername());
+                info.setPassword(alarmHost.getPassword());
+                logout(info);
+                String ip = alarmHost.getIp();
+                GlobalVariable.alarmHostMap.remove(ip);
+            }
+        } catch (Exception ex) {
+            log.error("鍒濆鍖栫櫥褰曠浉鏈哄紓甯革細" + ex.getMessage());
+        }
+    }
+    /**
+     * @鎻忚堪 鐧诲綍鎵�鏈夐棬绂佷富鏈�
+     * @鍒涘缓浜� 鍒樿嫃涔�
+     * @鍒涘缓鏃堕棿 2023/2/3 10:10
      */
     public static void loginAllAccessControlHost(List<ArdEquipExternal> ardEquipExternals) {
         try {
@@ -246,13 +304,35 @@
                 info.setPassword(accessControlHost.getPassword());
                 login(info);
                 String ip = accessControlHost.getIp();
-                GlobalVariable.alarmHostMap.put(ip, accessControlHost);
+                GlobalVariable.accessHostMap.put(ip, accessControlHost);
             }
         } catch (Exception ex) {
             log.error("鍒濆鍖栨姤璀︿富鏈哄紓甯革細" + ex.getMessage());
         }
     }
-
+    /**
+     * @鎻忚堪 鐧诲嚭鎵�鏈夐棬绂佷富鏈�
+     * @鍒涘缓浜� 鍒樿嫃涔�
+     * @鍒涘缓鏃堕棿 2023/2/3 10:10
+     */
+    public static void logoutAllAccessControlHost(List<ArdEquipExternal> ardEquipExternals) {
+        try {
+            for (ArdEquipExternal accessControlHost : ardEquipExternals) {
+                Thread.sleep(100);
+                DeviceInfo info = new DeviceInfo();
+                info.setDeviceId(accessControlHost.getId());
+                info.setIp(accessControlHost.getIp());
+                info.setPort(accessControlHost.getPort());
+                info.setUsername(accessControlHost.getUsername());
+                info.setPassword(accessControlHost.getPassword());
+                logout(info);
+                String ip = accessControlHost.getIp();
+                GlobalVariable.accessHostMap.remove(ip);
+            }
+        } catch (Exception ex) {
+            log.error("鍒濆鍖栨姤璀︿富鏈哄紓甯革細" + ex.getMessage());
+        }
+    }
     /**
      * @鎻忚堪 娉ㄩ攢鐧诲綍
      * @鍙傛暟 [dvrLogin]
@@ -324,10 +404,8 @@
                 log.error("璁惧銆�" + deviceIpPort + "銆戝竷闃插け璐ワ紝閿欒鐮�==========銆�" + hCNetSDK.NET_DVR_GetLastError());
                 // 娉ㄩ攢 閲婃斁sdk璧勬簮
                 logout(lUserID);
-                return lAlarmHandle;
             } else {
                 log.debug("璁惧銆�" + deviceIpPort + "銆戝竷闃叉垚鍔�");
-                return lAlarmHandle;
             }
         }
         return lAlarmHandle;
@@ -374,11 +452,11 @@
         //璁剧疆鍥剧墖澶у皬
         ByteBuffer jpegBuffer = ByteBuffer.allocate(1024 * 1024);
         // 鎶撳浘鍒板唴瀛橈紝鍗曞抚鏁版嵁鎹曡幏骞朵繚瀛樻垚JPEG瀛樻斁鍦ㄦ寚瀹氱殑鍐呭瓨绌洪棿涓�
-        log.debug("-----------杩欓噷寮�濮嬪皝瑁� NET_DVR_CaptureJPEGPicture_NEW---------");
+       // log.debug("-----------杩欓噷寮�濮嬪皝瑁� NET_DVR_CaptureJPEGPicture_NEW---------");
         boolean is = hCNetSDK.NET_DVR_CaptureJPEGPicture_NEW(userId, channelNum, jpeg, jpegBuffer, 1024 * 1024, a);
-        log.debug("-----------杩欓噷寮�濮嬪浘鐗囧瓨鍏ュ唴瀛�----------" + is);
+        //log.debug("-----------杩欓噷寮�濮嬪浘鐗囧瓨鍏ュ唴瀛�----------" + is);
         if (is) {
-            log.debug("hksdk(鎶撳浘)-缁撴灉鐘舵�佸��(0琛ㄧず鎴愬姛):" + hCNetSDK.NET_DVR_GetLastError());
+          //  log.debug("hksdk(鎶撳浘)-缁撴灉鐘舵�佸��(0琛ㄧず鎴愬姛):" + hCNetSDK.NET_DVR_GetLastError());
             byte[] array = jpegBuffer.array();
             //瀛樺偍鍒癿inio
 

--
Gitblit v1.9.3