流媒体服务接口逻辑更改
This commit is contained in:
parent
9ac415d6fc
commit
d3517de7b6
@ -1,6 +1,9 @@
|
|||||||
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.service.CamearService;
|
||||||
import org.dromara.sis.sdk.hik.service.DoorService;
|
import org.dromara.sis.sdk.hik.service.DoorService;
|
||||||
import org.dromara.sis.sdk.hik.service.LoginService;
|
import org.dromara.sis.sdk.hik.service.LoginService;
|
||||||
import org.dromara.sis.sdk.hik.service.SdkBaseServer;
|
import org.dromara.sis.sdk.hik.service.SdkBaseServer;
|
||||||
@ -139,10 +142,29 @@ public class HikApiService {
|
|||||||
* @param deviceIp 设备ip
|
* @param deviceIp 设备ip
|
||||||
* @return 范湖通道信息
|
* @return 范湖通道信息
|
||||||
*/
|
*/
|
||||||
public Object getChannelInfo(String deviceIp) {
|
public DeviceInfo getChannelInfo(String deviceIp) {
|
||||||
|
Integer lHandel = CACHE.get(deviceIp);
|
||||||
|
return CamearService.getDeviceChannelInfo(lHandel);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,6 @@ public class HikSdkConstans {
|
|||||||
|
|
||||||
public static final Integer DEFAULT_RTSP_PORT = 554;
|
public static final Integer DEFAULT_RTSP_PORT = 554;
|
||||||
|
|
||||||
|
public static final String DEFAULT_CHANNEL_PREFX = "01";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
package org.dromara.sis.sdk.hik;
|
package org.dromara.sis.sdk.hik;
|
||||||
|
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.sun.jna.Structure;
|
|
||||||
|
|
||||||
public class SDK_Structure extends Structure
|
public class SDK_Structure extends Structure {
|
||||||
{
|
protected List<String> getFieldOrder() {
|
||||||
protected List<String> getFieldOrder()
|
|
||||||
{
|
|
||||||
List<String> fieldOrderList = new ArrayList<String>();
|
List<String> fieldOrderList = new ArrayList<String>();
|
||||||
for (Class<?> cls = getClass();!cls.equals(SDK_Structure.class);cls = cls.getSuperclass())
|
for (Class<?> cls = getClass(); !cls.equals(SDK_Structure.class); cls = cls.getSuperclass()) {
|
||||||
{
|
|
||||||
Field[] fields = cls.getDeclaredFields();
|
Field[] fields = cls.getDeclaredFields();
|
||||||
int modifiers;
|
int modifiers;
|
||||||
for (Field field : fields)
|
for (Field field : fields) {
|
||||||
{
|
|
||||||
modifiers = field.getModifiers();
|
modifiers = field.getModifiers();
|
||||||
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers))
|
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fieldOrderList.add(field.getName());
|
fieldOrderList.add(field.getName());
|
||||||
@ -28,4 +24,5 @@ public class SDK_Structure extends Structure
|
|||||||
//System.out.println(fieldOrderList);
|
//System.out.println(fieldOrderList);
|
||||||
return fieldOrderList;
|
return fieldOrderList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.dromara.sis.sdk.hik.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备支持的总组数
|
||||||
|
*/
|
||||||
|
private Integer dwGroupNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大模拟通道个数
|
||||||
|
*/
|
||||||
|
private Integer dwAChanNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字通道个数
|
||||||
|
*/
|
||||||
|
private Integer dwDChanNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起始数字通道
|
||||||
|
*/
|
||||||
|
private Integer dwStartDChan;
|
||||||
|
|
||||||
|
private List<DeviceChannelInfo> channelInfo;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class DeviceChannelInfo {
|
||||||
|
/**
|
||||||
|
* 通道id
|
||||||
|
*/
|
||||||
|
private Integer channelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道名称
|
||||||
|
*/
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道设备ip
|
||||||
|
*/
|
||||||
|
private String channelIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道设备端口
|
||||||
|
*/
|
||||||
|
private Short channelPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道账号
|
||||||
|
*/
|
||||||
|
private String channelAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道密码
|
||||||
|
*/
|
||||||
|
private String channelPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过状态
|
||||||
|
*/
|
||||||
|
private Integer channelStatus;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,14 @@
|
|||||||
package org.dromara.sis.sdk.hik.service;
|
package org.dromara.sis.sdk.hik.service;
|
||||||
|
|
||||||
|
|
||||||
import com.sun.jna.ptr.IntByReference;
|
import com.sun.jna.ptr.IntByReference;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.sis.sdk.hik.HCNetSDK;
|
import org.dromara.sis.sdk.hik.HCNetSDK;
|
||||||
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.dromara.sis.sdk.hik.HCNetSDK.NET_DVR_GET_IPPARACFG_V40;
|
import static org.dromara.sis.sdk.hik.HCNetSDK.NET_DVR_GET_IPPARACFG_V40;
|
||||||
|
|
||||||
@ -15,7 +20,7 @@ public class CamearService extends SdkBaseServer {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Object getDeviceChannelInfo(int lUserID) {
|
public static DeviceInfo getDeviceChannelInfo(int lUserID) {
|
||||||
HCNetSDK.NET_DVR_IPPARACFG_V40 lpOutBuffer = new HCNetSDK.NET_DVR_IPPARACFG_V40();
|
HCNetSDK.NET_DVR_IPPARACFG_V40 lpOutBuffer = new HCNetSDK.NET_DVR_IPPARACFG_V40();
|
||||||
lpOutBuffer.read();
|
lpOutBuffer.read();
|
||||||
lpOutBuffer.dwSize = lpOutBuffer.size();
|
lpOutBuffer.dwSize = lpOutBuffer.size();
|
||||||
@ -24,7 +29,48 @@ public class CamearService extends SdkBaseServer {
|
|||||||
if (success) {
|
if (success) {
|
||||||
lpOutBuffer.read();
|
lpOutBuffer.read();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
DeviceInfo deviceInfo = new DeviceInfo();
|
||||||
|
deviceInfo.setDwGroupNum(lpOutBuffer.dwGroupNum);
|
||||||
|
deviceInfo.setDwAChanNum(lpOutBuffer.dwAChanNum);
|
||||||
|
deviceInfo.setDwDChanNum(lpOutBuffer.dwDChanNum);
|
||||||
|
deviceInfo.setDwStartDChan(lpOutBuffer.dwStartDChan);
|
||||||
|
|
||||||
|
List<DeviceInfo.DeviceChannelInfo> channelInfo = new ArrayList<>(64);
|
||||||
|
deviceInfo.setChannelInfo(channelInfo);
|
||||||
|
int num = 0;
|
||||||
|
for (int i = 0; i < lpOutBuffer.dwDChanNum; i++) {
|
||||||
|
HCNetSDK.NET_DVR_PICCFG_V30 dvrPiccfgV30 = new HCNetSDK.NET_DVR_PICCFG_V30();
|
||||||
|
dvrPiccfgV30.dwSize = dvrPiccfgV30.size();
|
||||||
|
IntByReference lpBytesReturned = new IntByReference(0);
|
||||||
|
int channelNum = i + lpOutBuffer.dwStartDChan;
|
||||||
|
getHcNetSDK().NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_PICCFG_V30, channelNum, dvrPiccfgV30.getPointer(), dvrPiccfgV30.dwSize, lpBytesReturned);
|
||||||
|
dvrPiccfgV30.read();
|
||||||
|
|
||||||
|
if (dvrPiccfgV30.dwSize == 0) {
|
||||||
|
// 代表此通道不存在数据那次此次不操作
|
||||||
|
log.info("通道[{}],无数据,不处理", channelNum);
|
||||||
|
} else {
|
||||||
|
String channelName = new String(dvrPiccfgV30.sChanName, Charset.forName("GBK")).trim();
|
||||||
|
HCNetSDK.NET_DVR_IPDEVINFO_V31 netDvrIpdevinfoV31 = lpOutBuffer.struIPDevInfo[num];
|
||||||
|
String sUserName = new String(netDvrIpdevinfoV31.sUserName, StandardCharsets.UTF_8).trim();
|
||||||
|
String sPassword = new String(netDvrIpdevinfoV31.sPassword, StandardCharsets.UTF_8).trim();
|
||||||
|
String ip = new String(netDvrIpdevinfoV31.struIP.sIpV4, StandardCharsets.UTF_8).trim();
|
||||||
|
short wDVRPort = netDvrIpdevinfoV31.wDVRPort;
|
||||||
|
|
||||||
|
DeviceInfo.DeviceChannelInfo deviceChannelInfo = new DeviceInfo.DeviceChannelInfo();
|
||||||
|
deviceChannelInfo.setChannelId( channelNum);
|
||||||
|
deviceChannelInfo.setChannelName(channelName);
|
||||||
|
deviceChannelInfo.setChannelIp(ip);
|
||||||
|
deviceChannelInfo.setChannelPort(wDVRPort);
|
||||||
|
deviceChannelInfo.setChannelAccount(sUserName);
|
||||||
|
deviceChannelInfo.setChannelPwd(sPassword);
|
||||||
|
deviceChannelInfo.setChannelStatus(0);
|
||||||
|
channelInfo.add(deviceChannelInfo);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,4 @@ public class SdkBaseServer {
|
|||||||
hcNetSDK.NET_DVR_Cleanup();
|
hcNetSDK.NET_DVR_Cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,6 @@ public class ZLMediaKitServiceImpl implements ZLMediaKitService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean delFFmpegSource(String key) {
|
public Boolean delFFmpegSource(String key) {
|
||||||
Map<String, Object> commonParams = getCommonParams();
|
Map<String, Object> commonParams = getCommonParams();
|
||||||
|
@ -21,6 +21,7 @@ import org.dromara.sis.domain.vo.SisDeviceGroupVo;
|
|||||||
import org.dromara.sis.mapper.SisDeviceChannelMapper;
|
import org.dromara.sis.mapper.SisDeviceChannelMapper;
|
||||||
import org.dromara.sis.sdk.hik.HikApiService;
|
import org.dromara.sis.sdk.hik.HikApiService;
|
||||||
import org.dromara.sis.sdk.hik.HikSdkConstans;
|
import org.dromara.sis.sdk.hik.HikSdkConstans;
|
||||||
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
import org.dromara.sis.service.ISisDeviceChannelService;
|
import org.dromara.sis.service.ISisDeviceChannelService;
|
||||||
import org.dromara.sis.service.ISisDeviceGroupService;
|
import org.dromara.sis.service.ISisDeviceGroupService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -195,13 +196,12 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean handleHikDeviceChannel(SisDeviceManageBo bo) {
|
public Boolean handleHikDeviceChannel(SisDeviceManageBo bo) {
|
||||||
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
|
|
||||||
// 只需要验证hik设备能能否登录即可
|
|
||||||
// 调用hik sdk登录
|
// 调用hik sdk登录
|
||||||
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
|
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
|
||||||
if (!isLogin) {
|
if (!isLogin) {
|
||||||
throw new RuntimeException("海康设备添加失败.");
|
throw new RuntimeException("海康设备添加失败.");
|
||||||
}
|
}
|
||||||
|
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
|
||||||
// 写入设备通道信息
|
// 写入设备通道信息
|
||||||
SisDeviceChannel channel = new SisDeviceChannel();
|
SisDeviceChannel channel = new SisDeviceChannel();
|
||||||
channel.setDeviceId(bo.getId());
|
channel.setDeviceId(bo.getId());
|
||||||
@ -216,10 +216,30 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||||
this.insert(channel);
|
this.insert(channel);
|
||||||
return true;
|
return true;
|
||||||
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType())) {
|
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType()) || DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
|
||||||
//TODO
|
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(bo.getDeviceIp());
|
||||||
} else if (DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
|
if (channelInfo != null && CollUtil.isNotEmpty(channelInfo.getChannelInfo())) {
|
||||||
|
List<SisDeviceChannel> channels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||||
|
channelInfo.getChannelInfo().forEach(item -> {
|
||||||
|
SisDeviceChannel channel = new SisDeviceChannel();
|
||||||
|
channel.setDeviceId(bo.getId());
|
||||||
|
channel.setGroupId(bo.getGroupId());
|
||||||
|
channel.setDeviceIp(bo.getDeviceIp());
|
||||||
|
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||||
|
channel.setFactoryNo(bo.getFactoryNo());
|
||||||
|
channel.setDeviceAccount(bo.getDeviceAccount());
|
||||||
|
channel.setDevicePwd(bo.getDevicePwd());
|
||||||
|
channel.setDeviceMac(bo.getDeviceMac());
|
||||||
|
|
||||||
|
channel.setChannelName(item.getChannelName());
|
||||||
|
channel.setChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
||||||
|
channels.add(channel);
|
||||||
|
});
|
||||||
|
this.baseMapper.insertBatch(channels);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
log.info("未知的设备类型,不处理。");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<module>ruoyi-resource</module>
|
<module>ruoyi-resource</module>
|
||||||
<module>ruoyi-workflow</module>
|
<module>ruoyi-workflow</module>
|
||||||
<module>Property</module>
|
<module>Property</module>
|
||||||
<!-- <module>Sis</module>-->
|
<module>Sis</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>ruoyi-modules</artifactId>
|
<artifactId>ruoyi-modules</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user