球机判断是否连线,如果断连java记录修改

chengdu-mxbc-qsl
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 265da00472
commit df86ccb7ef

@ -25,7 +25,7 @@ public class Encryptor {
public static void main(String[] args)
{
String noEncrypt = "BFEBFBFF000A06550026_B728_2C38_69F5.";
String noEncrypt = "BFEBFBFF000A0671AK7211183";
String encrypt = Encryptor.encryptStr(noEncrypt);
System.out.println(encrypt);
}

@ -7,6 +7,8 @@ import com.zhehekeji.web.config.ConfigProperties;
import com.zhehekeji.web.entity.Camera;
import com.zhehekeji.web.lib.*;
import com.zhehekeji.web.lib.hik.HCNetSDK;
import com.zhehekeji.web.lib.hik.HikLoginModuleImpl;
import com.zhehekeji.web.lib.joyware.JoywareLoginModuleImpl;
import com.zhehekeji.web.lib.joyware.NetSDKLib;
import com.zhehekeji.web.mapper.CameraMapper;
import com.zhehekeji.web.service.CameraService;
@ -331,10 +333,21 @@ public class CameraControlController {
@Resource
private CameraService cameraService;
private void checkLogin(Integer cameraId){
if(CameraConnMap.getConnId(cameraId) == null){
private void checkLogin(Integer cameraId) {
if (CameraConnMap.getConnId(cameraId) == null) {
Boolean ok = false;
if (configProperties.getCameraConfig().getCameraType() == ConfigProperties.HIK_CAMERA) {
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(cameraId).intValue());
} else {
ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(cameraId));
}
if (!ok) {
{
CameraConnMap.disConn(cameraId);
Camera camera = cameraMapper.selectById(cameraId);
cameraService.cameraLogin(camera);
}
}
}
}
}

@ -39,6 +39,7 @@ public class CameraConnMap {
}
public static NetSDKLib.LLong getConnId(Integer cameraId){
return cameraMap.get(cameraId);
}

@ -50,7 +50,7 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
}
//设置登录超时时间和尝试次数,可选
int waitTime = 1000; //登录请求响应超时时间设置
int tryTimes = 1000; //登录时尝试建立链接次数
int tryTimes = 1000000; //登录时尝试建立链接次数
Boolean ok1 = hcNetsdk.NET_DVR_SetConnectTime(waitTime, tryTimes);
Boolean ok2 = hcNetsdk.NET_DVR_SetReconnect(500,Boolean.TRUE);
return true;
@ -58,6 +58,7 @@ public class HikLoginModuleImpl implements CameraControlLoginModule {
//检测球机连接状态
public static Boolean connectStatus(int userId){
return hcNetsdk.NET_DVR_RemoteControl(userId,20005,null,0);
}

@ -145,6 +145,7 @@ public class CameraService {
if(ok){
camera.setStatus("连接正常");
}else {
CameraConnMap.disConn(camera.getId());
camera.setStatus("未连接");
}
}catch (Exception e){

@ -7,7 +7,7 @@ spring:
maxWait: 60000
minEvictableIdleTimeMillis: 300000
minIdle: 15
password: Leaper@123
password: root
poolPreparedStatements: true
testOnBorrow: true
testOnReturn: false

Loading…
Cancel
Save