refactor(sis):
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

- E8平台授权逻辑调整
This commit is contained in:
zcxlsm 2025-07-01 21:17:22 +08:00
parent baf9502b61
commit a065d72724
2 changed files with 25 additions and 22 deletions

View File

@ -11,12 +11,12 @@ import lombok.Data;
public class AuthDoorDeviceFindRes {
/**
* id
* id
*/
private Long id;
/**
* deviceId
* 门禁Id
*/
private Long deviceId;
}

View File

@ -149,7 +149,6 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
Assert.notEmpty(acList, "门禁设备不存在!");
try {
log.info("开始对宇视盒子下发照片,图片:{}、设备:{}", bo.getImgIds(), eqpIds);
for (SisPersonLibImgVo imgVo : imgList) {
@ -239,34 +238,38 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
log.info("E8平台发行凭证完成!");
log.info("E8平台授权凭证");
// 查询所有e8设备并分组
List<AuthDoorDeviceFindRes> authDoor = e8DoorDeviceService.getPageAuthDoorDeviceList();
Map<Long, AuthDoorDeviceFindRes> authDoorMap = authDoor.stream().collect(Collectors.toMap(AuthDoorDeviceFindRes::getDeviceId, authDoorRes -> authDoorRes));
// 查询E8授权门列表
List<AuthDoorDeviceFindRes> authDoorList = e8DoorDeviceService.getPageAuthDoorDeviceList();
Assert.notEmpty(authDoorList, "E8平台授权门列表为空");
// E8 授权列表
List<CustomerAuthAddReq.AuthGroupData> authList = new ArrayList<>(acList.size());
// 授权记录
List<SisAuthRecord> recordList = new ArrayList<>(acList.size());
// E8授权门
AuthDoorDeviceFindRes authDoor = null;
for (SisAccessControlVo sisAccessControlVo : acList) {
if (sisAccessControlVo.getControlType() != 1 && sisAccessControlVo.getAccessType() != 2) {
SisAuthRecord authRecord = new SisAuthRecord();
CustomerAuthAddReq.AuthGroupData door = new CustomerAuthAddReq.AuthGroupData();
door.setType(0);
door.setGatewayType(1);
Long id = Long.parseLong(sisAccessControlVo.getOutCode());
door.setId(id);
authRecord.setDoorId(id);
// 如果 authDoorMap 中存在对应的 deviceId则更新 id
AuthDoorDeviceFindRes authDoorRes = authDoorMap.get(id);
if (authDoorRes != null) {
door.setId(authDoorRes.getId());
authRecord.setDeviceId(authDoorRes.getDeviceId());
// 通过门禁ID匹配授权门
authDoor = authDoorList.stream().filter(item -> item.getDeviceId() == Long.parseLong(sisAccessControlVo.getOutCode())).findFirst().orElse(null);
if (authDoor != null) {
CustomerAuthAddReq.AuthGroupData door = new CustomerAuthAddReq.AuthGroupData();
door.setType(0);
door.setGatewayType(1);
// E8授权传入ID为门ID非门禁ID
door.setId(authDoor.getId());
authList.add(door);
SisAuthRecord authRecord = new SisAuthRecord();
authRecord.setDoorId(authDoor.getId());
authRecord.setDeviceId(authDoor.getDeviceId());
authRecord.setLibId(imgVo.getLibId());
authRecord.setImgId(imgVo.getId());
authRecord.setAcId(sisAccessControlVo.getId());
recordList.add(authRecord);
}
authRecord.setLibId(imgVo.getLibId());
authRecord.setImgId(imgVo.getId());
authRecord.setAcId(sisAccessControlVo.getId());
recordList.add(authRecord);
}
}