feat(sis): 实现人脸识别后远程开门功能(测试)
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
@@ -2,6 +2,7 @@ package org.dromara.sis.sdk.hik.calback;
|
||||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -36,6 +37,7 @@ public class HikAlarmCallBack implements HCNetSDK.FMSGCallBack_V31 {
|
||||
|
||||
private final HuaWeiBoxApi huaWeiBoxApi;
|
||||
private final ISisAuthRecordService authRecordService;
|
||||
private final ISisAuthGroupRefService authGroupRefService;
|
||||
private final ISisElevatorInfoService elevatorInfoService;
|
||||
private final ISisDeviceBindRefService deviceBindRefService;
|
||||
private final ISisAccessControlService accessControlService;
|
||||
@@ -321,6 +323,44 @@ public class HikAlarmCallBack implements HCNetSDK.FMSGCallBack_V31 {
|
||||
}
|
||||
log.info("人脸比对完成,personId={}", person);
|
||||
|
||||
// TODO 测试逻辑,只针对门禁
|
||||
|
||||
// 授权纪录
|
||||
SisAuthRecordVo authRecord = authRecordService.checkAuth(person);
|
||||
if (authRecord == null) {
|
||||
log.info("当前人脸未授权,暂不处理。");
|
||||
return true;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
if(DateUtil.compare(now, authRecord.getEndDate()) > 0){
|
||||
log.info("当前人脸已过期,暂不处理。");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 授权设备列表
|
||||
List<SisAuthGroupRefVo> authGroupRefVos = authGroupRefService.queryListByGroupId(authRecord.getGroupId());
|
||||
// 获取门禁id
|
||||
Collection<Long> acIds = authGroupRefVos.stream().filter(vo -> vo.getDeviceType() == 1).map(SisAuthGroupRefVo::getDeviceId).toList();
|
||||
if (CollUtil.isNotEmpty(acIds)) {
|
||||
acIds.forEach(id -> {
|
||||
// controlType 1-门禁
|
||||
Long deviceId = bindRefList.stream().filter(vo -> vo.getBindId().equals(id) && vo.getControlType() == 1).findFirst().map(SisDeviceBindRefVo::getBindId).orElse(null);
|
||||
SisAccessControlVo ac = accessControlService.queryById(deviceId);
|
||||
if (ac != null) {
|
||||
log.info("调用门禁服务远程开门,doorName:{}", ac.getAccessName());
|
||||
RemoteOpenDoorReq req = new RemoteOpenDoorReq();
|
||||
req.setType(0);
|
||||
RemoteOpenDoorReq.ControlData data = new RemoteOpenDoorReq.ControlData();
|
||||
data.setDeviceId(Long.parseLong(ac.getOutCode()));
|
||||
data.setDoorId(Long.parseLong(ac.getOutCode()));
|
||||
req.setControlList(List.of(data));
|
||||
Boolean flag = e8PlatformApi.remoteOpenDoor(req);
|
||||
log.info("远程开门结果,result={}", flag);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 授权记录
|
||||
// List<SisAuthRecordVo> authVoList = authRecordService.checkAuth(person);
|
||||
// 获取门禁id
|
||||
|
@@ -86,7 +86,7 @@ public interface ISisAuthRecordService {
|
||||
/**
|
||||
* 查询所有可授权设备树
|
||||
*
|
||||
* @return List<TreeNode<Long>>
|
||||
* @return List<TreeNode < Long>>
|
||||
*/
|
||||
List<TreeNode<Long>> authDeviceTree();
|
||||
|
||||
@@ -95,12 +95,12 @@ public interface ISisAuthRecordService {
|
||||
*
|
||||
* @param personId 人脸比对ID
|
||||
*/
|
||||
// List<SisAuthRecordVo> checkAuth(Long personId);
|
||||
SisAuthRecordVo checkAuth(Long personId);
|
||||
|
||||
/**
|
||||
* 根据权限组ID,人员id,返回授权记录
|
||||
*
|
||||
* @param groupId 权限组ID
|
||||
* @param groupId 权限组ID
|
||||
* @param personId 人员id
|
||||
* @return SisAuthRecordVo
|
||||
*/
|
||||
|
@@ -123,7 +123,7 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void syncPersonImg(RemotePersonAuth bo){
|
||||
private void syncPersonImg(RemotePersonAuth bo) {
|
||||
log.info("开始写入安防人像信息");
|
||||
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
||||
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
||||
@@ -250,17 +250,27 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
return List.of(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据人脸比对ID,返回授权记录
|
||||
*
|
||||
* @param personId 人脸比对ID
|
||||
*/
|
||||
@Override
|
||||
public SisAuthRecordVo checkAuth(Long personId) {
|
||||
return baseMapper.checkAuth(personId).get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据权限组ID,人员id,返回授权记录
|
||||
*
|
||||
* @param groupId 权限组ID
|
||||
* @param groupId 权限组ID
|
||||
* @param personId 人员id
|
||||
* @return SisAuthRecordVo
|
||||
*/
|
||||
public SisAuthRecordVo queryByGroupIdAndPersonId(Long groupId, Long personId){
|
||||
public SisAuthRecordVo queryByGroupIdAndPersonId(Long groupId, Long personId) {
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SisAuthRecord::getGroupId, groupId)
|
||||
.eq(SisAuthRecord::getTargetId, personId);
|
||||
.eq(SisAuthRecord::getTargetId, personId);
|
||||
return baseMapper.selectVoOne(lqw);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user