增加设备定时更新状态任务
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
package org.dromara.sis.api;
|
||||||
|
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface RemoteHikDeviceService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有的海康设备信息
|
||||||
|
* @return 返回海康设备列表
|
||||||
|
*/
|
||||||
|
List<RemoteSisDeviceManage> queryHikDevices();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备在线状态
|
||||||
|
* @param item 设备信息
|
||||||
|
* @return 返回是否操作成功
|
||||||
|
*/
|
||||||
|
Boolean updateDeviceState(RemoteSisDeviceManage item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备通道信息
|
||||||
|
* @param deviceIp 设备ip
|
||||||
|
* @return 返回通道列表
|
||||||
|
*/
|
||||||
|
List<RemoteSisDeviceChannel> queryDeviceChannels(String deviceIp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备通道在线状态
|
||||||
|
* @param deviceIp 设备ip
|
||||||
|
* @return 返回是否成功
|
||||||
|
*/
|
||||||
|
Boolean updateDeviceChannelState(String deviceIp, Integer onLineState);
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
package org.dromara.sis.api;
|
||||||
|
|
||||||
|
import org.dromara.sis.api.domain.RemoteSdkChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface RemoteHikSdkService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海康sdk 登录操作
|
||||||
|
* @param item 登录参数
|
||||||
|
* @return 是否登录成功
|
||||||
|
*/
|
||||||
|
Boolean deviceLogin(RemoteSisDeviceManage item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取nvr设备通道信息
|
||||||
|
* @param deviceIp 设备ip
|
||||||
|
* @return 返回通道信息
|
||||||
|
*/
|
||||||
|
List<RemoteSdkChannel> getDeviceChannel(String deviceIp);
|
||||||
|
}
|
@@ -0,0 +1,43 @@
|
|||||||
|
package org.dromara.sis.api.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RemoteSdkChannel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道id
|
||||||
|
*/
|
||||||
|
private Integer channelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道名称
|
||||||
|
*/
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道设备ip
|
||||||
|
*/
|
||||||
|
private String channelIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道设备端口
|
||||||
|
*/
|
||||||
|
private Short channelPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道账号
|
||||||
|
*/
|
||||||
|
private String channelAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道密码
|
||||||
|
*/
|
||||||
|
private String channelPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过状态 1: 在线,2:离线
|
||||||
|
*/
|
||||||
|
private Integer channelStatus;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,95 @@
|
|||||||
|
package org.dromara.sis.api.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RemoteSisDeviceChannel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道分组组id
|
||||||
|
*/
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ip
|
||||||
|
*/
|
||||||
|
private String deviceIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备端口
|
||||||
|
*/
|
||||||
|
private Integer devicePort;
|
||||||
|
|
||||||
|
private String factoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备账号
|
||||||
|
*/
|
||||||
|
private String deviceAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备密码
|
||||||
|
*/
|
||||||
|
private String devicePwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备
|
||||||
|
*/
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备通道编号
|
||||||
|
*/
|
||||||
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道状态.0-离线;1-在线
|
||||||
|
*/
|
||||||
|
private Integer channelState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 设备厂商编号
|
||||||
|
*/
|
||||||
|
private String nvrFactoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr设备ip
|
||||||
|
*/
|
||||||
|
private String nvrIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 端口
|
||||||
|
*/
|
||||||
|
private Integer nvrPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 账号
|
||||||
|
*/
|
||||||
|
private String nvrAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 密码
|
||||||
|
*/
|
||||||
|
private String nvrPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 通道编号
|
||||||
|
*/
|
||||||
|
private String nvrChannelNo;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
package org.dromara.sis.api.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备远程调用对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RemoteSisDeviceManage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ip
|
||||||
|
*/
|
||||||
|
private String deviceIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备端口
|
||||||
|
*/
|
||||||
|
private Integer devicePort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备
|
||||||
|
*/
|
||||||
|
private String deviceMac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备在线状态 0:离线 1:在线 2:未知
|
||||||
|
*/
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备账号
|
||||||
|
*/
|
||||||
|
private String deviceAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备密码
|
||||||
|
*/
|
||||||
|
private String devicePwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备类型
|
||||||
|
*/
|
||||||
|
private Integer deviceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备厂商编号
|
||||||
|
*/
|
||||||
|
private String factoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备组id
|
||||||
|
*/
|
||||||
|
private Long groupId;
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package org.dromara.sis.domain.enums;
|
package org.dromara.sis.api.enums;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
package org.dromara.sis.domain.enums;
|
package org.dromara.sis.api.enums;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
@@ -1,11 +1,9 @@
|
|||||||
package org.dromara.sis.controller.zkmedia;
|
package org.dromara.sis.controller.zkmedia;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
|
||||||
import cn.hutool.crypto.digest.MD5;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
import org.dromara.sis.api.enums.FactoryNoEnum;
|
||||||
import org.dromara.sis.sdk.zkmedia.MediaServerUtils;
|
import org.dromara.sis.sdk.zkmedia.MediaServerUtils;
|
||||||
import org.dromara.sis.sdk.zkmedia.ZLMediaKitService;
|
import org.dromara.sis.sdk.zkmedia.ZLMediaKitService;
|
||||||
import org.dromara.sis.sdk.zkmedia.model.AddStreamProxy;
|
import org.dromara.sis.sdk.zkmedia.model.AddStreamProxy;
|
||||||
@@ -52,7 +50,8 @@ public class ZKLmediaController {
|
|||||||
proxy.setApp("realtime");
|
proxy.setApp("realtime");
|
||||||
// 实时流不用每次都去拉流,流不存在的情况下在拉取
|
// 实时流不用每次都去拉流,流不存在的情况下在拉取
|
||||||
String streanStr = data.getVideoIp() + "_" + data.getChannelId();
|
String streanStr = data.getVideoIp() + "_" + data.getChannelId();
|
||||||
proxy.setStream(SecureUtil.md5(streanStr));
|
// proxy.setStream(SecureUtil.md5(streanStr));
|
||||||
|
proxy.setStream(IdUtil.fastSimpleUUID());
|
||||||
if (FactoryNoEnum.HIK.getCode().equals(data.getFactoryNo())) {
|
if (FactoryNoEnum.HIK.getCode().equals(data.getFactoryNo())) {
|
||||||
proxy.setUrl(String.format(HIK_REALTIME_RTSP_TEMPLATE, data.getAccount(), data.getPwd(), data.getVideoIp(), data.getVideoPort(), data.getChannelId()));
|
proxy.setUrl(String.format(HIK_REALTIME_RTSP_TEMPLATE, data.getAccount(), data.getPwd(), data.getVideoIp(), data.getVideoPort(), data.getChannelId()));
|
||||||
} else if (FactoryNoEnum.DAHUA.getCode().equals(data.getFactoryNo())) {
|
} else if (FactoryNoEnum.DAHUA.getCode().equals(data.getFactoryNo())) {
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
package org.dromara.sis.domain;
|
package org.dromara.sis.domain;
|
||||||
|
|
||||||
import org.dromara.common.tenant.core.TenantEntity;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.dromara.common.tenant.core.TenantEntity;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@@ -74,6 +75,11 @@ public class SisDeviceChannel extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String channelNo;
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道状态.0-离线;1-在线
|
||||||
|
*/
|
||||||
|
private Integer channelState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nvr 设备厂商编号
|
* nvr 设备厂商编号
|
||||||
*/
|
*/
|
||||||
|
@@ -41,7 +41,7 @@ public class SisDeviceManage extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 设备端口
|
* 设备端口
|
||||||
*/
|
*/
|
||||||
private Long devicePort;
|
private Integer devicePort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备
|
* 设备
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
package org.dromara.sis.domain.covert;
|
||||||
|
|
||||||
|
import org.dromara.sis.api.domain.RemoteSdkChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
import org.dromara.sis.domain.SisDeviceChannel;
|
||||||
|
import org.dromara.sis.domain.SisDeviceManage;
|
||||||
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface CommonBeanCovert {
|
||||||
|
|
||||||
|
CommonBeanCovert INSTANCE = Mappers.getMapper(CommonBeanCovert.class);
|
||||||
|
|
||||||
|
List<RemoteSisDeviceManage> entity2Remote(List<SisDeviceManage> sisDeviceManage);
|
||||||
|
|
||||||
|
SisDeviceManage Remote2Entity(RemoteSisDeviceManage remoteSisDeviceManage);
|
||||||
|
|
||||||
|
List<RemoteSisDeviceChannel> channelEntity2Remote(List<SisDeviceChannel> channels);
|
||||||
|
|
||||||
|
List<RemoteSdkChannel> sdkChannelEntity2Remote(List<DeviceInfo.DeviceChannelInfo> sdkChannels);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
package org.dromara.sis.dubbo;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.sis.api.RemoteHikDeviceService;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
import org.dromara.sis.domain.SisDeviceChannel;
|
||||||
|
import org.dromara.sis.domain.SisDeviceManage;
|
||||||
|
import org.dromara.sis.domain.covert.CommonBeanCovert;
|
||||||
|
import org.dromara.sis.service.ISisDeviceChannelService;
|
||||||
|
import org.dromara.sis.service.ISisDeviceManageService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海康设备远程服务调用
|
||||||
|
*
|
||||||
|
* @author lxj
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RemoteHikDeviceServiceImpl implements RemoteHikDeviceService {
|
||||||
|
|
||||||
|
private final ISisDeviceManageService deviceManageService;
|
||||||
|
private final ISisDeviceChannelService deviceChannelService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RemoteSisDeviceManage> queryHikDevices() {
|
||||||
|
List<SisDeviceManage> sisDeviceManages = deviceManageService.queryHikDevices();
|
||||||
|
return CommonBeanCovert.INSTANCE.entity2Remote(sisDeviceManages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateDeviceState(RemoteSisDeviceManage item) {
|
||||||
|
return deviceManageService.updateDeviceState(CommonBeanCovert.INSTANCE.Remote2Entity(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RemoteSisDeviceChannel> queryDeviceChannels(String deviceIp) {
|
||||||
|
List<SisDeviceChannel> channels = deviceChannelService.queryByDeviceIp(deviceIp);
|
||||||
|
return CommonBeanCovert.INSTANCE.channelEntity2Remote(channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateDeviceChannelState(String deviceIp, Integer onLineState) {
|
||||||
|
return deviceChannelService.updateDeviceChannelState(deviceIp, onLineState);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
package org.dromara.sis.dubbo;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.sis.api.RemoteHikSdkService;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSdkChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
import org.dromara.sis.domain.covert.CommonBeanCovert;
|
||||||
|
import org.dromara.sis.sdk.hik.HikApiService;
|
||||||
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Component
|
||||||
|
public class RemoteSdkServiceImpl implements RemoteHikSdkService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean deviceLogin(RemoteSisDeviceManage item) {
|
||||||
|
if (item == null) {
|
||||||
|
throw new RuntimeException("设备信息为null");
|
||||||
|
}
|
||||||
|
return HikApiService.getInstance().login(item.getDeviceIp(), item.getDevicePort().shortValue(), item.getDevicePwd(), item.getDeviceAccount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RemoteSdkChannel> getDeviceChannel(String deviceIp) {
|
||||||
|
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(deviceIp);
|
||||||
|
if (channelInfo == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(channelInfo.getChannelInfo())) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return CommonBeanCovert.INSTANCE.sdkChannelEntity2Remote(channelInfo.getChannelInfo());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,5 @@
|
|||||||
package org.dromara.sis.sdk.hik;
|
package org.dromara.sis.sdk.hik;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
import org.dromara.sis.sdk.hik.service.CamearService;
|
import org.dromara.sis.sdk.hik.service.CamearService;
|
||||||
@@ -58,7 +57,13 @@ public class HikApiService {
|
|||||||
int i = LoginService.loginDevice(ip, port, user, psw);
|
int i = LoginService.loginDevice(ip, port, user, psw);
|
||||||
boolean result = (i != SdkBaseServer.LOGIN_FAIL_CODE);
|
boolean result = (i != SdkBaseServer.LOGIN_FAIL_CODE);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
// 上次登录信息依然存在
|
||||||
|
if (CACHE.get(ip) != null && CACHE.get(ip) != i) {
|
||||||
|
loginOut(ip);
|
||||||
|
}
|
||||||
CACHE.put(ip, i);
|
CACHE.put(ip, i);
|
||||||
|
} else {
|
||||||
|
CACHE.remove(ip);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -146,25 +151,4 @@ public class HikApiService {
|
|||||||
Integer lHandel = CACHE.get(deviceIp);
|
Integer lHandel = CACHE.get(deviceIp);
|
||||||
return CamearService.getDeviceChannelInfo(lHandel);
|
return CamearService.getDeviceChannelInfo(lHandel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// String ip ="192.168.10.253";
|
|
||||||
// short port = 8000;
|
|
||||||
// String user = "admin";
|
|
||||||
// String wd ="ncqzfdl123";
|
|
||||||
|
|
||||||
String ip = "192.168.24.251";
|
|
||||||
short port = 8000;
|
|
||||||
String user = "admin";
|
|
||||||
String wd = "hik12345+";
|
|
||||||
|
|
||||||
SdkBaseServer.initSdk();
|
|
||||||
getInstance().login(ip, port, user, wd);
|
|
||||||
Integer lHandel = CACHE.get(ip);
|
|
||||||
DeviceInfo deviceChannelInfo = CamearService.getDeviceChannelInfo(lHandel);
|
|
||||||
System.out.println(JSONObject.toJSONString(deviceChannelInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package org.dromara.sis.sdk.hik.model;
|
package org.dromara.sis.sdk.hik.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
import org.dromara.sis.api.enums.FactoryNoEnum;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class DeviceInfo {
|
|||||||
private String channelPwd;
|
private String channelPwd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过状态
|
* 通过状态 1: 在线,2:离线
|
||||||
*/
|
*/
|
||||||
private Integer channelStatus;
|
private Integer channelStatus;
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@ public class CamearService extends SdkBaseServer {
|
|||||||
deviceInfo.setChannelInfo(channelInfo);
|
deviceInfo.setChannelInfo(channelInfo);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (int i = 0; i < lpOutBuffer.dwDChanNum; i++) {
|
for (int i = 0; i < lpOutBuffer.dwDChanNum; i++) {
|
||||||
|
|
||||||
HCNetSDK.NET_DVR_PICCFG_V30 dvrPiccfgV30 = new HCNetSDK.NET_DVR_PICCFG_V30();
|
HCNetSDK.NET_DVR_PICCFG_V30 dvrPiccfgV30 = new HCNetSDK.NET_DVR_PICCFG_V30();
|
||||||
dvrPiccfgV30.dwSize = dvrPiccfgV30.size();
|
dvrPiccfgV30.dwSize = dvrPiccfgV30.size();
|
||||||
IntByReference lpBytesReturned = new IntByReference(0);
|
IntByReference lpBytesReturned = new IntByReference(0);
|
||||||
@@ -59,13 +60,16 @@ public class CamearService extends SdkBaseServer {
|
|||||||
short wDVRPort = netDvrIpdevinfoV31.wDVRPort;
|
short wDVRPort = netDvrIpdevinfoV31.wDVRPort;
|
||||||
|
|
||||||
DeviceInfo.DeviceChannelInfo deviceChannelInfo = new DeviceInfo.DeviceChannelInfo();
|
DeviceInfo.DeviceChannelInfo deviceChannelInfo = new DeviceInfo.DeviceChannelInfo();
|
||||||
deviceChannelInfo.setChannelId( channelNum);
|
deviceChannelInfo.setChannelId(channelNum);
|
||||||
deviceChannelInfo.setChannelName(channelName);
|
deviceChannelInfo.setChannelName(channelName);
|
||||||
deviceChannelInfo.setChannelIp(ip);
|
deviceChannelInfo.setChannelIp(ip);
|
||||||
deviceChannelInfo.setChannelPort(wDVRPort);
|
deviceChannelInfo.setChannelPort(wDVRPort);
|
||||||
deviceChannelInfo.setChannelAccount(sUserName);
|
deviceChannelInfo.setChannelAccount(sUserName);
|
||||||
deviceChannelInfo.setChannelPwd(sPassword);
|
deviceChannelInfo.setChannelPwd(sPassword);
|
||||||
deviceChannelInfo.setChannelStatus(0);
|
deviceChannelInfo.setChannelStatus(0);
|
||||||
|
// 通道是否在线
|
||||||
|
byte byEnable = lpOutBuffer.struStreamMode[i].uGetStream.struChanInfo.byEnable;
|
||||||
|
deviceChannelInfo.setChannelStatus((int) byEnable);
|
||||||
channelInfo.add(deviceChannelInfo);
|
channelInfo.add(deviceChannelInfo);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ import org.dromara.sis.domain.SisDeviceChannel;
|
|||||||
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||||
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -98,4 +97,18 @@ public interface ISisDeviceChannelService {
|
|||||||
|
|
||||||
SisDeviceChannel queryByChannelIp(String channelIp);
|
SisDeviceChannel queryByChannelIp(String channelIp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过设备ip查询设备通道信息
|
||||||
|
*
|
||||||
|
* @param deviceIp 设备ip
|
||||||
|
* @return 返回通道列表
|
||||||
|
*/
|
||||||
|
List<SisDeviceChannel> queryByDeviceIp(String deviceIp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态
|
||||||
|
* @param deviceIp 设备ip
|
||||||
|
* @return 返回是否操作成功
|
||||||
|
*/
|
||||||
|
Boolean updateDeviceChannelState(String deviceIp, Integer onLineState);
|
||||||
}
|
}
|
||||||
|
@@ -90,4 +90,17 @@ public interface ISisDeviceManageService {
|
|||||||
* @return 返回设备报表
|
* @return 返回设备报表
|
||||||
*/
|
*/
|
||||||
List<SisDeviceManage> queryByIds(List<Long> deviceIds);
|
List<SisDeviceManage> queryByIds(List<Long> deviceIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有的海康设备
|
||||||
|
* @return 返回海康设备列表
|
||||||
|
*/
|
||||||
|
List<SisDeviceManage> queryHikDevices();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态信息
|
||||||
|
* @param sisDeviceManage 设备信息
|
||||||
|
* @return 是否操作成功
|
||||||
|
*/
|
||||||
|
Boolean updateDeviceState(SisDeviceManage sisDeviceManage);
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package org.dromara.sis.service.impl;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -13,10 +14,10 @@ import org.dromara.common.core.utils.StringUtils;
|
|||||||
import org.dromara.common.core.utils.TreeUtils;
|
import org.dromara.common.core.utils.TreeUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.sis.api.enums.DeviceTypeEnum;
|
||||||
import org.dromara.sis.domain.SisDeviceChannel;
|
import org.dromara.sis.domain.SisDeviceChannel;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||||
import org.dromara.sis.domain.enums.DeviceTypeEnum;
|
|
||||||
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
||||||
import org.dromara.sis.domain.vo.SisDeviceGroupVo;
|
import org.dromara.sis.domain.vo.SisDeviceGroupVo;
|
||||||
import org.dromara.sis.mapper.SisDeviceChannelMapper;
|
import org.dromara.sis.mapper.SisDeviceChannelMapper;
|
||||||
@@ -221,6 +222,8 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
channel.setDeviceMac(bo.getDeviceMac());
|
channel.setDeviceMac(bo.getDeviceMac());
|
||||||
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||||
channel.setTenantId(bo.getTenantId());
|
channel.setTenantId(bo.getTenantId());
|
||||||
|
// 默认设备在线
|
||||||
|
channel.setChannelState(1);
|
||||||
Boolean insert = this.insert(channel);
|
Boolean insert = this.insert(channel);
|
||||||
log.info("设备[{}]通道添加完成,result={}", bo.getDeviceIp(), insert);
|
log.info("设备[{}]通道添加完成,result={}", bo.getDeviceIp(), insert);
|
||||||
} else {
|
} else {
|
||||||
@@ -244,11 +247,12 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
channel.setDevicePort(Integer.valueOf(item.getChannelPort()));
|
channel.setDevicePort(Integer.valueOf(item.getChannelPort()));
|
||||||
channel.setDeviceAccount(item.getChannelAccount());
|
channel.setDeviceAccount(item.getChannelAccount());
|
||||||
channel.setFactoryNo(channelInfo.getFactoryNo());
|
channel.setFactoryNo(channelInfo.getFactoryNo());
|
||||||
|
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||||
|
channel.setChannelState(item.getChannelStatus());
|
||||||
if (StrUtil.isNotEmpty(item.getChannelPwd())) {
|
if (StrUtil.isNotEmpty(item.getChannelPwd())) {
|
||||||
channel.setDevicePwd(item.getChannelPwd());
|
channel.setDevicePwd(item.getChannelPwd());
|
||||||
}
|
}
|
||||||
// nvr 设备信息
|
// nvr 设备信息
|
||||||
channel.setNvrId(bo.getId());
|
|
||||||
channel.setNvrIp(bo.getDeviceIp());
|
channel.setNvrIp(bo.getDeviceIp());
|
||||||
channel.setNvrPort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
channel.setNvrPort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||||
channel.setNvrAccount(bo.getDeviceAccount());
|
channel.setNvrAccount(bo.getDeviceAccount());
|
||||||
@@ -298,4 +302,18 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
return baseMapper.delete(lqw);
|
return baseMapper.delete(lqw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SisDeviceChannel> queryByDeviceIp(String deviceIp) {
|
||||||
|
LambdaQueryWrapper<SisDeviceChannel> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.in(SisDeviceChannel::getDeviceIp, deviceIp);
|
||||||
|
return baseMapper.selectList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateDeviceChannelState(String deviceIp, Integer onLineState) {
|
||||||
|
LambdaUpdateWrapper<SisDeviceChannel> lqw = new LambdaUpdateWrapper<>();
|
||||||
|
lqw.set(SisDeviceChannel::getChannelState, onLineState);
|
||||||
|
lqw.eq(SisDeviceChannel::getDeviceIp, deviceIp);
|
||||||
|
return baseMapper.update(lqw) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package org.dromara.sis.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -12,9 +13,9 @@ import org.dromara.common.core.utils.SpringUtils;
|
|||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.sis.api.enums.FactoryNoEnum;
|
||||||
import org.dromara.sis.domain.SisDeviceManage;
|
import org.dromara.sis.domain.SisDeviceManage;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
|
||||||
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
||||||
import org.dromara.sis.mapper.SisDeviceManageMapper;
|
import org.dromara.sis.mapper.SisDeviceManageMapper;
|
||||||
import org.dromara.sis.sdk.hik.HikApiService;
|
import org.dromara.sis.sdk.hik.HikApiService;
|
||||||
@@ -23,8 +24,6 @@ import org.dromara.sis.service.ISisDeviceManageService;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -207,4 +206,19 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
|||||||
public List<SisDeviceManage> queryByIds(List<Long> deviceIds) {
|
public List<SisDeviceManage> queryByIds(List<Long> deviceIds) {
|
||||||
return baseMapper.selectByIds(deviceIds);
|
return baseMapper.selectByIds(deviceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SisDeviceManage> queryHikDevices() {
|
||||||
|
LambdaQueryWrapper<SisDeviceManage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(SisDeviceManage::getFactoryNo, FactoryNoEnum.HIK.getCode());
|
||||||
|
return baseMapper.selectList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateDeviceState(SisDeviceManage sisDeviceManage) {
|
||||||
|
LambdaUpdateWrapper<SisDeviceManage> lqw = Wrappers.lambdaUpdate();
|
||||||
|
lqw.set(SisDeviceManage::getDeviceStatus, sisDeviceManage.getDeviceStatus())
|
||||||
|
.eq(SisDeviceManage::getId, sisDeviceManage.getId());
|
||||||
|
return baseMapper.update(lqw) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ public class DataSyncTask {
|
|||||||
/**
|
/**
|
||||||
* 定时同步报警记录数据
|
* 定时同步报警记录数据
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedRate = 60 * 1000) // 每分钟执行一次
|
// @Scheduled(fixedRate = 60 * 1000) // 每分钟执行一次
|
||||||
public void syncAlarmRecords() {
|
public void syncAlarmRecords() {
|
||||||
log.info("开始同步报警记录数据...");
|
log.info("开始同步报警记录数据...");
|
||||||
|
|
||||||
|
@@ -69,6 +69,12 @@
|
|||||||
<groupId>org.dromara</groupId>
|
<groupId>org.dromara</groupId>
|
||||||
<artifactId>ruoyi-api-system</artifactId>
|
<artifactId>ruoyi-api-system</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara</groupId>
|
||||||
|
<artifactId>sis-api</artifactId>
|
||||||
|
<version>2.4.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
|
|||||||
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
|
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
|
||||||
import com.aizuda.snailjob.client.model.ExecuteResult;
|
import com.aizuda.snailjob.client.model.ExecuteResult;
|
||||||
import com.aizuda.snailjob.common.log.SnailJobLog;
|
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.job.entity.BillDto;
|
import org.dromara.job.entity.BillDto;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@@ -0,0 +1,119 @@
|
|||||||
|
package org.dromara.job.snailjob.sis;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
|
||||||
|
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
|
||||||
|
import com.aizuda.snailjob.client.model.ExecuteResult;
|
||||||
|
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.dromara.sis.api.RemoteHikDeviceService;
|
||||||
|
import org.dromara.sis.api.RemoteHikSdkService;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSdkChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceChannel;
|
||||||
|
import org.dromara.sis.api.domain.RemoteSisDeviceManage;
|
||||||
|
import org.dromara.sis.api.enums.DeviceTypeEnum;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海康设备定时监测状态任务
|
||||||
|
* 执行时间为每5分钟执行一次
|
||||||
|
*
|
||||||
|
* @author lxj
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@JobExecutor(name = "hikDeviceCheckStateTask")
|
||||||
|
public class HikDeviceCheckStateTask {
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private RemoteHikDeviceService remoteHikDeviceService;
|
||||||
|
@DubboReference
|
||||||
|
private RemoteHikSdkService remoteHikSdkService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 海康设备定时监测状态任务
|
||||||
|
*
|
||||||
|
* @param jobArgs 任务执行参数
|
||||||
|
* @return 返回是否执行成功
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
|
||||||
|
List<RemoteSisDeviceManage> device = remoteHikDeviceService.queryHikDevices();
|
||||||
|
if (CollUtil.isEmpty(device)) {
|
||||||
|
SnailJobLog.REMOTE.info("需要同步的hik设备数量为0,任务执行结束");
|
||||||
|
return ExecuteResult.success();
|
||||||
|
}
|
||||||
|
SnailJobLog.REMOTE.info("需要同步状态的设备数量", device.size());
|
||||||
|
device.forEach(item -> {
|
||||||
|
// ipc
|
||||||
|
if (DeviceTypeEnum.IPC.getType().equals(item.getDeviceType())) {
|
||||||
|
updateDeviceStatus(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DeviceTypeEnum.NVR.getType().equals(item.getDeviceType())) {
|
||||||
|
// 设备状态更新完成
|
||||||
|
boolean b = updateDeviceStatus(item);
|
||||||
|
if (b) {
|
||||||
|
updateDeviceChannelStatus(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return ExecuteResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新nvr设备通道信息
|
||||||
|
*
|
||||||
|
* @param sisDeviceManage 设备信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void updateDeviceChannelStatus(RemoteSisDeviceManage sisDeviceManage) {
|
||||||
|
// 查询设备通道信息
|
||||||
|
List<RemoteSisDeviceChannel> ls = remoteHikDeviceService.queryDeviceChannels(sisDeviceManage.getDeviceIp());
|
||||||
|
SnailJobLog.REMOTE.info("设备[{}]本地通道数量={}", sisDeviceManage.getDeviceIp(), ls.size());
|
||||||
|
List<RemoteSdkChannel> sdkChannels = remoteHikSdkService.getDeviceChannel(sisDeviceManage.getDeviceIp());
|
||||||
|
SnailJobLog.REMOTE.info("设备[{}]sdk通道数量={}", sisDeviceManage.getDeviceIp(), sdkChannels.size());
|
||||||
|
|
||||||
|
Map<String, RemoteSisDeviceChannel> data1 = ls.stream().collect(Collectors.toMap(RemoteSisDeviceChannel::getDeviceIp, item -> item));
|
||||||
|
Map<String, RemoteSdkChannel> data2 = sdkChannels.stream().collect(Collectors.toMap(RemoteSdkChannel::getChannelIp, item -> item));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备状态
|
||||||
|
*
|
||||||
|
* @param item 设备信息
|
||||||
|
* @return 返回设备是否在线
|
||||||
|
*/
|
||||||
|
private boolean updateDeviceStatus(RemoteSisDeviceManage item) {
|
||||||
|
// 调用设备登录验证次设备在线
|
||||||
|
Boolean isLogin = remoteHikSdkService.deviceLogin(item);
|
||||||
|
int onLineState = isLogin ? 1 : 0;
|
||||||
|
if (item.getDeviceStatus() != onLineState) {
|
||||||
|
SnailJobLog.REMOTE.info("设备[{}]在线状态变更,开始更新状态。 old={},new ={} ", item.getDeviceIp(), item.getDeviceStatus(), onLineState);
|
||||||
|
item.setDeviceStatus(onLineState);
|
||||||
|
Boolean result = remoteHikDeviceService.updateDeviceState(item);
|
||||||
|
SnailJobLog.REMOTE.info("设备[{}]在线状态变更,状态更新完成。 result={} ", item.getDeviceIp(), result);
|
||||||
|
|
||||||
|
// 监测当前设备是否存在通道,如果有则跟新通道信息
|
||||||
|
List<RemoteSisDeviceChannel> ls = remoteHikDeviceService.queryDeviceChannels(item.getDeviceIp());
|
||||||
|
if (CollUtil.isNotEmpty(ls)) {
|
||||||
|
Boolean r1 = remoteHikDeviceService.updateDeviceChannelState(item.getDeviceIp(), onLineState);
|
||||||
|
SnailJobLog.REMOTE.info("设备通道[{}]在线状态变更,状态更新完成。 result={} ", item.getDeviceIp(), r1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isLogin;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user