| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | 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.*; |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | log.debug("-----------这里开始图片存入内存----------" + is); |
| | | |
| | | Base64.Encoder decoder = Base64.getEncoder(); |
| | | // BASE64Encoder encoder = new BASE64Encoder(); |
| | | // BASE64Encoder encoder = new BASE64Encoder(); |
| | | String png_base64 = decoder.encodeToString(jpegBuffer.array());//转换成base64串 |
| | | png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n |
| | | log.debug("-----------处理完成截图数据----------"); |
| | |
| | | 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; |
| | | } |
| | | } |