|
|
|
@ -12,6 +12,7 @@ import com.inspect.nvr.domain.algorithm.in.AnalyseRequest; |
|
|
|
import com.inspect.nvr.domain.algorithm.out.AnalyseResItem; |
|
|
|
import com.inspect.nvr.domain.algorithm.out.AnalyseResPoint; |
|
|
|
import com.inspect.nvr.domain.algorithm.out.AnalyseResult; |
|
|
|
import com.inspect.nvr.domain.camera.CameraPresetPoint; |
|
|
|
import com.inspect.nvr.hikVision.utils.AjaxResult; |
|
|
|
import com.inspect.nvr.hikVision.utils.StringUtils; |
|
|
|
import com.inspect.nvr.hikVision.utils.jna.HCNetSDK; |
|
|
|
@ -22,6 +23,7 @@ import com.inspect.nvr.tempCount.TempCount; |
|
|
|
import com.inspect.nvr.utils.DateUtils; |
|
|
|
import com.inspect.nvr.utils.redis.RedisService; |
|
|
|
import com.inspect.nvr.utils.sftp.SftpClient; |
|
|
|
import com.sun.jna.Memory; |
|
|
|
import com.sun.jna.Pointer; |
|
|
|
import com.sun.jna.ptr.IntByReference; |
|
|
|
import okhttp3.*; |
|
|
|
@ -33,6 +35,7 @@ import org.apache.commons.net.ftp.FTPSClient; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@ -43,6 +46,8 @@ import java.awt.image.BufferedImage; |
|
|
|
import java.io.*; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
import java.nio.ByteBuffer; |
|
|
|
import java.nio.ByteOrder; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
@ -95,6 +100,10 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
// @Value("${file.produceEnvironment:true}") |
|
|
|
private Boolean produceEnvironment = true; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
@ -1145,4 +1154,65 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
return AjaxResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//预置位获取-海康 |
|
|
|
@Override |
|
|
|
public String cameraYzwHikVision(Camera camera) { |
|
|
|
CameraPresetPoint cameraPreset = new CameraPresetPoint(); |
|
|
|
int lUserID = (int) redisTemplate.opsForValue().get(camera.getNvrip() + "_userId"); |
|
|
|
|
|
|
|
HCNetSDK.NET_DVR_PRESET_NAME[] presetNames = new HCNetSDK.NET_DVR_PRESET_NAME[HCNetSDK.MAX_PRESET_V30]; |
|
|
|
for (int i = 0; i < presetNames.length; i++) { |
|
|
|
presetNames[i] = new HCNetSDK.NET_DVR_PRESET_NAME(); |
|
|
|
presetNames[i].dwSize = presetNames[i].size(); |
|
|
|
presetNames[i].write(); |
|
|
|
} |
|
|
|
Pointer lpOutBuffer = new Memory(presetNames.length * presetNames[0].size()); |
|
|
|
int dwOutBufferSize = presetNames.length * presetNames[0].size(); |
|
|
|
IntByReference lpBytesReturned = new IntByReference(0); |
|
|
|
|
|
|
|
//boolean NET_DVR_GetDVRConfig(int lUserID, int dwCommand, int lChannel, Pointer lpOutBuffer, int dwOutBufferSize, IntByReference lpBytesReturned); |
|
|
|
boolean presetList = hcNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_PRESET_NAME, camera.getChannel(), lpOutBuffer, dwOutBufferSize, lpBytesReturned); |
|
|
|
if (!presetList) { |
|
|
|
System.out.println("获取预置位数据失败,错误码:" + hcNetSDK.NET_DVR_GetLastError()); |
|
|
|
} else { |
|
|
|
|
|
|
|
ByteBuffer byteBuffer = lpOutBuffer.getByteBuffer(0, lpBytesReturned.getValue()); |
|
|
|
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // 设置字节顺序 |
|
|
|
String presetName = ""; |
|
|
|
for (int i = 0; i < HCNetSDK.MAX_PRESET_V30; i++) { |
|
|
|
HCNetSDK.NET_DVR_PRESET_NAME presetNameStruct = new HCNetSDK.NET_DVR_PRESET_NAME(); |
|
|
|
|
|
|
|
presetNameStruct.dwSize = byteBuffer.getInt(); |
|
|
|
presetNameStruct.wPresetNum = byteBuffer.getShort(); |
|
|
|
byteBuffer.get(presetNameStruct.byRes1); // 读取保留字节 |
|
|
|
byteBuffer.get(presetNameStruct.byName); // 读取名称 |
|
|
|
presetNameStruct.wPanPos = byteBuffer.getShort();//水平参数 |
|
|
|
presetNameStruct.wTiltPos = byteBuffer.getShort();//垂直参数 |
|
|
|
presetNameStruct.wZoomPos = byteBuffer.getShort();//变倍参数 |
|
|
|
byteBuffer.get(presetNameStruct.byRes); // 读取保留字节 |
|
|
|
if (presetNameStruct.wPresetNum != 0) |
|
|
|
// 输出预置位数据 |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (Integer.valueOf(presetNameStruct.wPanPos) != 0 && Integer.valueOf(presetNameStruct.wTiltPos) != 0) { |
|
|
|
presetName = presetName + new String(presetNameStruct.byName, "GBK").trim() + ":" + presetNameStruct.wPresetNum + ","; |
|
|
|
} |
|
|
|
System.out.println("预置位 " + presetNameStruct.wPresetNum + " 名称:" + new String(presetNameStruct.byName, "GBK").trim()); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |