Merge remote-tracking branch 'origin/master'
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
2025-07-25 23:19:44 +08:00
10 changed files with 207 additions and 50 deletions

View File

@@ -106,7 +106,7 @@ public class CustomAddReq {
/**
* 组织ID以;分隔)
*/
private String organIds;
private String organIds = "1";
/**
* 客户明细

View File

@@ -1,6 +1,9 @@
package org.dromara.sis.sdk.hik;
import com.alibaba.fastjson2.JSONObject;
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.LoginService;
import org.dromara.sis.sdk.hik.service.SdkBaseServer;
@@ -139,10 +142,29 @@ public class HikApiService {
* @param deviceIp 设备ip
* @return 范湖通道信息
*/
public Object getChannelInfo(String deviceIp) {
return null;
public DeviceInfo getChannelInfo(String deviceIp) {
Integer lHandel = CACHE.get(deviceIp);
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));
}
}

View File

@@ -9,4 +9,6 @@ public class HikSdkConstans {
public static final Integer DEFAULT_RTSP_PORT = 554;
public static final String DEFAULT_CHANNEL_PREFX = "01";
}

View File

@@ -1,31 +1,28 @@
package org.dromara.sis.sdk.hik;
import com.sun.jna.Structure;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.Structure;
public class SDK_Structure extends Structure
{
protected List<String> getFieldOrder()
{
List<String> fieldOrderList = new ArrayList<String>();
for (Class<?> cls = getClass();!cls.equals(SDK_Structure.class);cls = cls.getSuperclass())
{
Field[] fields = cls.getDeclaredFields();
int modifiers;
for (Field field : fields)
{
modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers))
{
continue;
}
fieldOrderList.add(field.getName());
}
}
//System.out.println(fieldOrderList);
return fieldOrderList;
}
public class SDK_Structure extends Structure {
protected List<String> getFieldOrder() {
List<String> fieldOrderList = new ArrayList<String>();
for (Class<?> cls = getClass(); !cls.equals(SDK_Structure.class); cls = cls.getSuperclass()) {
Field[] fields = cls.getDeclaredFields();
int modifiers;
for (Field field : fields) {
modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
continue;
}
fieldOrderList.add(field.getName());
}
}
//System.out.println(fieldOrderList);
return fieldOrderList;
}
}

View File

@@ -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;
}
}

View File

@@ -1,9 +1,14 @@
package org.dromara.sis.sdk.hik.service;
import com.sun.jna.ptr.IntByReference;
import lombok.extern.slf4j.Slf4j;
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;
@@ -15,7 +20,7 @@ public class CamearService extends SdkBaseServer {
*
* @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();
lpOutBuffer.read();
lpOutBuffer.dwSize = lpOutBuffer.size();
@@ -24,7 +29,48 @@ public class CamearService extends SdkBaseServer {
if (success) {
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;
}
}

View File

@@ -136,6 +136,4 @@ public class SdkBaseServer {
hcNetSDK.NET_DVR_Cleanup();
}
}
}

View File

@@ -199,7 +199,6 @@ public class ZLMediaKitServiceImpl implements ZLMediaKitService {
return null;
}
@Override
public Boolean delFFmpegSource(String key) {
Map<String, Object> commonParams = getCommonParams();

View File

@@ -1,6 +1,7 @@
package org.dromara.sis.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import org.apache.dubbo.config.annotation.DubboReference;
@@ -35,6 +36,7 @@ import org.dromara.sis.mapper.SisAuthRecordMapper;
import org.dromara.sis.service.ISisAuthRecordService;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -181,7 +183,7 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
return pId;
}
private Long syncE8Plat(RemotePersonAuth bo, byte[] imgByte) {
private Long syncE8Plat(RemotePersonAuth bo, byte[] imgByte) throws Exception {
log.info("e8平台上传照片");
String e8ImgUrl = e8PlatformApi.uploadFace(imgByte);
@@ -206,8 +208,7 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
voucherReq.setVoucherType(70);
voucherReq.setPersonID(e8Id);
voucherReq.setTxtData(e8ImgUrl);
voucherReq.setStartTime(bo.getBegDate().toString());
voucherReq.setEndTime(bo.getEndDate().toString());
voucherReq.setCardType(34);
Long voucherId = e8PlatformApi.issueVoucher(voucherReq);
Assert.notNull(voucherId, "e8平台发行凭证失败");
log.info("e8平台发行凭证成功");
@@ -219,15 +220,16 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
// 初始化赋值
CustomerAuthAddReq authReq = new CustomerAuthAddReq();
authReq.setPersonIds(List.of(e8Id));
authReq.setStartTime(bo.getBegDate().toString());
authReq.setEndTime(bo.getEndDate().toString());
authReq.setStartTime(DateUtil.format(bo.getBegDate(), "yyyy-MM-dd HH:mm:ss"));
authReq.setEndTime(DateUtil.format(bo.getEndDate(), "yyyy-MM-dd HH:mm:ss"));
List<CustomerAuthAddReq.AuthGroupData> list = new ArrayList<>();
SisAccessControlVo accessControlVo;
for(Long deviceId : deviceIds){
accessControlVo = sisAccessControlService.queryById(deviceId);
CustomerAuthAddReq.AuthGroupData authData = new CustomerAuthAddReq.AuthGroupData();
authData.setId(Long.parseLong(accessControlVo.getOutDoorCode()));
authData.setType(1);
authData.setType(0);
authData.setGatewayType(1);
list.add(authData);
}
authReq.setAuthData(list);
@@ -237,7 +239,7 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
Assert.isTrue(flag, "E8平台授权失败");
log.info("E8平台授权完成!");
}
return e8PlatformApi.addCustomer(req).getId();
return e8Id;
}
/**

View File

@@ -21,6 +21,7 @@ import org.dromara.sis.domain.vo.SisDeviceGroupVo;
import org.dromara.sis.mapper.SisDeviceChannelMapper;
import org.dromara.sis.sdk.hik.HikApiService;
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.ISisDeviceGroupService;
import org.springframework.stereotype.Service;
@@ -195,13 +196,12 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
@Override
public Boolean handleHikDeviceChannel(SisDeviceManageBo bo) {
// 调用hik sdk登录
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
if (!isLogin) {
throw new RuntimeException("海康设备添加失败.");
}
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
// 只需要验证hik设备能能否登录即可
// 调用hik sdk登录
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
if (!isLogin) {
throw new RuntimeException("海康设备添加失败.");
}
// 写入设备通道信息
SisDeviceChannel channel = new SisDeviceChannel();
channel.setDeviceId(bo.getId());
@@ -216,10 +216,30 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
this.insert(channel);
return true;
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType())) {
//TODO
} else if (DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType()) || DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(bo.getDeviceIp());
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;
}