rev:拍照初始化
This commit is contained in:
@@ -3,16 +3,10 @@ package org.nl.common.domain.constant;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.nl.common.hikvision.HikvisionSnapshotUtil;
|
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.annotation.Value;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* s
|
* s
|
||||||
@@ -40,22 +34,21 @@ public class DictConstantPool {
|
|||||||
@Value("${hikvison.channelSdk}")
|
@Value("${hikvison.channelSdk}")
|
||||||
public Integer channel;
|
public Integer channel;
|
||||||
|
|
||||||
@Resource( name = "meshandlerPool")
|
|
||||||
private ThreadPoolExecutor threadPoolExecutor;
|
|
||||||
|
|
||||||
public static final String DICT_SYS_CODE = "system_type";
|
public static final String DICT_SYS_CODE = "system_type";
|
||||||
public static final String DICT_SYS_NAME = "所属系统";
|
public static final String DICT_SYS_NAME = "所属系统";
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initHikvisonConfig(){
|
public void initHikvisonConfig(){
|
||||||
System.out.println("初始化海康卫视配置:"+ this);
|
System.out.println("初始化海康威视配置:"+ this);
|
||||||
HikvisionSnapshotUtil.ins = this.ins;
|
HikvisionSnapshotUtil.ins = this.ins;
|
||||||
HikvisionSnapshotUtil.path = this.path;
|
HikvisionSnapshotUtil.path = this.path;
|
||||||
HikvisionSnapshotUtil.ip = this.ip;
|
HikvisionSnapshotUtil.ip = this.ip;
|
||||||
HikvisionSnapshotUtil.port = this.port;
|
HikvisionSnapshotUtil.port = this.port;
|
||||||
HikvisionSnapshotUtil.username = this.username;
|
HikvisionSnapshotUtil.username = this.username;
|
||||||
|
HikvisionSnapshotUtil.password = this.password;
|
||||||
HikvisionSnapshotUtil.channelHttp = this.channelHttp;
|
HikvisionSnapshotUtil.channelHttp = this.channelHttp;
|
||||||
HikvisionSnapshotUtil.channel = this.channel;
|
HikvisionSnapshotUtil.channel = this.channel;
|
||||||
HikvisionSnapshotUtil.threadPoolExecutor = this.threadPoolExecutor;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -22,11 +21,28 @@ public class HikvisionSnapshotUtil {
|
|||||||
public static String password;//海康威视设备网络搜索应用中摄像头管理账密码nl1314520
|
public static String password;//海康威视设备网络搜索应用中摄像头管理账密码nl1314520
|
||||||
public static String channelHttp;//默认
|
public static String channelHttp;//默认
|
||||||
public static Integer channel;//默认1
|
public static Integer channel;//默认1
|
||||||
public static ThreadPoolExecutor threadPoolExecutor;
|
|
||||||
|
|
||||||
// HCNetSDK 接口映射
|
// HCNetSDK 接口映射
|
||||||
public interface HCNetSDK extends Library {
|
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 库
|
//初始化 SDK 库
|
||||||
boolean NET_DVR_Init();
|
boolean NET_DVR_Init();
|
||||||
@@ -115,7 +131,6 @@ public class HikvisionSnapshotUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sync截图(String imageName, String taskCode) {
|
public static void sync截图(String imageName, String taskCode) {
|
||||||
if (threadPoolExecutor != null) {
|
|
||||||
if (StringUtils.isEmpty(imageName)) {
|
if (StringUtils.isEmpty(imageName)) {
|
||||||
log.warn("图片名称未定义");
|
log.warn("图片名称未定义");
|
||||||
}
|
}
|
||||||
@@ -152,8 +167,5 @@ public class HikvisionSnapshotUtil {
|
|||||||
HCNetSDK.INSTANCE.NET_DVR_Logout(userId);
|
HCNetSDK.INSTANCE.NET_DVR_Logout(userId);
|
||||||
HCNetSDK.INSTANCE.NET_DVR_Cleanup();
|
HCNetSDK.INSTANCE.NET_DVR_Cleanup();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.warn("线程池未定义");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user