From 53e14c1919c4a3112f963689d0ce75fa08831021 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期六, 19 八月 2023 12:32:20 +0800 Subject: [PATCH] 增加通道管理业务 修改相机部分实体字段 --- ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java index 60c0b26..5c35e6d 100644 --- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/service/impl/HikClientServiceImpl.java @@ -1,9 +1,12 @@ package com.ruoyi.device.hiksdk.service.impl; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.annotation.SdkOperate; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.device.camera.domain.CameraCmd; import com.ruoyi.device.camera.service.IArdCamerasService; +import com.ruoyi.device.channel.domain.ArdChannel; +import com.ruoyi.device.channel.service.IArdChannelService; import com.ruoyi.device.hiksdk.common.GlobalVariable; import com.ruoyi.device.camera.domain.ArdCameras; import com.ruoyi.device.hiksdk.config.MinioClientSingleton; @@ -13,11 +16,14 @@ import com.ruoyi.device.hiksdk.util.hikSdkUtil.LoginResultCallBack; import com.ruoyi.storage.minio.utils.MinioUtils; import com.sun.jna.Native; +import com.sun.jna.NativeLong; import com.sun.jna.Platform; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; + import java.util.Base64; import javax.annotation.Resource; import java.io.*; @@ -26,6 +32,7 @@ import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; import static com.ruoyi.device.hiksdk.util.hikSdkUtil.HCNetSDK.*; @@ -125,7 +132,7 @@ GlobalVariable.loginMap.remove(camera.getId()); GlobalVariable.loginMap.put(camera.getId(), lUserID); camera.setLoginId(lUserID); - camera.setChannel((int) m_strDeviceInfo.byStartChan); + camera.setStartDChan((int) m_strDeviceInfo.byStartChan); return camera; } @@ -1093,7 +1100,7 @@ log.debug("-----------杩欓噷寮�濮嬪浘鐗囧瓨鍏ュ唴瀛�----------" + is); Base64.Encoder decoder = Base64.getEncoder(); - // BASE64Encoder encoder = new BASE64Encoder(); + // BASE64Encoder encoder = new BASE64Encoder(); String png_base64 = decoder.encodeToString(jpegBuffer.array());//杞崲鎴恇ase64涓� png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//鍒犻櫎 \r\n log.debug("-----------澶勭悊瀹屾垚鎴浘鏁版嵁----------"); @@ -1386,4 +1393,41 @@ log.error("褰曞儚鍋滄寮傚父" + ex.getMessage()); } } + + //鑾峰彇IP閫氶亾 + @Override + public List<ArdChannel> getCameraChannelList(ArdCameras camera) { + /*鑾峰彇閫氶亾*/ + List<ArdChannel> channelList = new ArrayList<>(); + try { + Integer chanNum = camera.getChanNum(); + Integer startDChan = camera.getStartDChan(); + if (chanNum > 0) { + // 鑾峰彇閫氶亾鍙� + for (int iChannum = 0; iChannum < chanNum; iChannum++) { + ArdChannel ardChannel = new ArdChannel(); + int channum = iChannum + startDChan+1; + HCNetSDK.NET_DVR_PICCFG_V40 strPicCfg = new HCNetSDK.NET_DVR_PICCFG_V40(); + strPicCfg.dwSize = strPicCfg.size(); + strPicCfg.write(); + Pointer pStrPicCfg = strPicCfg.getPointer(); + NativeLong lChannel = new NativeLong(channum); + IntByReference pInt = new IntByReference(0); + boolean b_GetPicCfg = hCNetSDK.NET_DVR_GetDVRConfig(camera.getLoginId(), HCNetSDK.NET_DVR_GET_PICCFG_V40, lChannel.intValue(), + pStrPicCfg, strPicCfg.size(), pInt); + if (b_GetPicCfg) { + strPicCfg.read(); + String channelName = new String(strPicCfg.sChanName, "GBK").trim(); + ardChannel.setName(channelName); + } + ardChannel.setDeviceId(camera.getId()); + ardChannel.setChanNo(iChannum + 1); + channelList.add(ardChannel); + } + } + } catch (Exception ex) { + log.error("鑾峰彇鐩告満閫氶亾寮傚父:" + ex.getMessage()); + } + return channelList; + } } \ No newline at end of file -- Gitblit v1.9.3