rev:拍照初始化

This commit is contained in:
2025-12-03 11:06:29 +08:00
parent bd96ccbc28
commit 1b0f58ca26
2 changed files with 22 additions and 17 deletions

View File

@@ -3,16 +3,10 @@ package org.nl.common.domain.constant;
import lombok.Data;
import lombok.ToString;
import org.nl.common.hikvision.HikvisionSnapshotUtil;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;
/**
* s
@@ -40,22 +34,21 @@ public class DictConstantPool {
@Value("${hikvison.channelSdk}")
public Integer channel;
@Resource( name = "meshandlerPool")
private ThreadPoolExecutor threadPoolExecutor;
public static final String DICT_SYS_CODE = "system_type";
public static final String DICT_SYS_NAME = "所属系统";
@PostConstruct
public void initHikvisonConfig(){
System.out.println("初始化海康视配置:"+ this);
System.out.println("初始化海康视配置:"+ this);
HikvisionSnapshotUtil.ins = this.ins;
HikvisionSnapshotUtil.path = this.path;
HikvisionSnapshotUtil.ip = this.ip;
HikvisionSnapshotUtil.port = this.port;
HikvisionSnapshotUtil.username = this.username;
HikvisionSnapshotUtil.password = this.password;
HikvisionSnapshotUtil.channelHttp = this.channelHttp;
HikvisionSnapshotUtil.channel = this.channel;
HikvisionSnapshotUtil.threadPoolExecutor = this.threadPoolExecutor;
}
}

View File

@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.concurrent.ThreadPoolExecutor;
@Service
@Slf4j
@@ -22,11 +21,28 @@ public class HikvisionSnapshotUtil {
public static String password;//海康威视设备网络搜索应用中摄像头管理账密码nl1314520
public static String channelHttp;//默认
public static Integer channel;//默认1
public static ThreadPoolExecutor threadPoolExecutor;
// HCNetSDK 接口映射
public interface HCNetSDK extends Library {
HCNetSDK INSTANCE = Native.load(ins, HCNetSDK.class);
HCNetSDK INSTANCE = Holder.INSTANCE;
class Holder {
private static final HCNetSDK INSTANCE;
static {
if (StringUtils.isBlank(HikvisionSnapshotUtil.ins)) {
throw new RuntimeException("HCNetSDK.dll 路径未设置,请检查 hikvison.ins 配置");
}
try {
System.out.println("加载 HCNetSDK.dll => " + HikvisionSnapshotUtil.ins);
INSTANCE = Native.load("C:\\Users\\Administrator\\Desktop\\hik\\HCNetSDK.dll", HCNetSDK.class);
System.out.println("加载 HCNetSDK.dll 成功");
} catch (Throwable e) {
System.err.println("加载 HCNetSDK.dll 失败,路径:" + HikvisionSnapshotUtil.ins + "异常信息:" + e.getMessage());
throw e;
}
}
}
//初始化 SDK 库
boolean NET_DVR_Init();
@@ -115,7 +131,6 @@ public class HikvisionSnapshotUtil {
}
public static void sync截图(String imageName, String taskCode) {
if (threadPoolExecutor != null) {
if (StringUtils.isEmpty(imageName)) {
log.warn("图片名称未定义");
}
@@ -152,8 +167,5 @@ public class HikvisionSnapshotUtil {
HCNetSDK.INSTANCE.NET_DVR_Logout(userId);
HCNetSDK.INSTANCE.NET_DVR_Cleanup();
}
} else {
log.warn("线程池未定义");
}
}
}