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:
@@ -14,6 +14,7 @@
|
||||
<module>ruoyi-api-resource</module>
|
||||
<module>ruoyi-api-workflow</module>
|
||||
<module>property-api</module>
|
||||
<module>sis-api</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>ruoyi-api</artifactId>
|
||||
|
29
ruoyi-api/sis-api/pom.xml
Normal file
29
ruoyi-api/sis-api/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>sis-api</artifactId>
|
||||
|
||||
<description>
|
||||
安防api模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- RuoYi Common Core-->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,13 @@
|
||||
package org.dromara.sis.api;
|
||||
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteSisAuth
|
||||
* @since 2025/7/24
|
||||
*/
|
||||
public interface RemoteSisAuth {
|
||||
|
||||
Long personAuth(RemotePersonAuth personAuth);
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package org.dromara.sis.api.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemotePersonAuth
|
||||
* @since 2025/7/24
|
||||
*/
|
||||
@Data
|
||||
public class RemotePersonAuth {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer sex;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String email;
|
||||
|
||||
private Integer cardType = 1;
|
||||
|
||||
private String idCardNumber;
|
||||
|
||||
private String ossId;
|
||||
|
||||
private String carNumber;
|
||||
|
||||
private Long authGroupId;
|
||||
|
||||
private Date begDate;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
}
|
@@ -115,6 +115,12 @@
|
||||
<artifactId>property-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>sis-api</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -4,6 +4,7 @@ import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -27,17 +28,14 @@ public class ResidentPerson extends TenantEntity {
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@@ -50,67 +48,58 @@ public class ResidentPerson extends TenantEntity {
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Long gender;
|
||||
|
||||
/**
|
||||
* 人脸图片
|
||||
*/
|
||||
private String img;
|
||||
|
||||
/**
|
||||
* 所属单位id
|
||||
*/
|
||||
private Long unitId;
|
||||
|
||||
/**
|
||||
* 所属单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 入驻位置
|
||||
*/
|
||||
private String locathon;
|
||||
|
||||
/**
|
||||
* 入驻时间
|
||||
*/
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 车牌号码
|
||||
*/
|
||||
private String carNumber;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long state;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* e8平台id
|
||||
*/
|
||||
private Long eEightId;
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long createById;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
private Long updateById;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
|
@@ -27,12 +27,6 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@@ -44,16 +38,40 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
*/
|
||||
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String phone;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@NotNull(message = "性别不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long gender;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 证件号
|
||||
*/
|
||||
@NotBlank(message = "证件号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date begDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 人脸图片
|
||||
*/
|
||||
@@ -87,15 +105,8 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
// @NotNull(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long state=1L;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@@ -2,6 +2,7 @@ package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -11,12 +12,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.sis.api.RemoteSisAuth;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.ResidentPersonBo;
|
||||
import org.dromara.property.domain.vo.ResidentPersonVo;
|
||||
import org.dromara.property.domain.ResidentPerson;
|
||||
import org.dromara.property.mapper.ResidentPersonMapper;
|
||||
import org.dromara.property.service.IResidentPersonService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,6 +39,9 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
|
||||
private final ResidentPersonMapper baseMapper;
|
||||
|
||||
@DubboReference
|
||||
private final RemoteSisAuth remoteSisAuth;
|
||||
|
||||
/**
|
||||
* 查询入驻员工
|
||||
*
|
||||
@@ -76,7 +83,6 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(ResidentPerson::getId);
|
||||
lqw.eq(bo.getUserId() != null, ResidentPerson::getUserId, bo.getUserId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUserName()), ResidentPerson::getUserName, bo.getUserName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPhone()), ResidentPerson::getPhone, bo.getPhone());
|
||||
lqw.eq(bo.getGender() != null, ResidentPerson::getGender, bo.getGender());
|
||||
@@ -97,12 +103,34 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(ResidentPersonBo bo) {
|
||||
ResidentPerson add = MapstructUtils.convert(bo, ResidentPerson.class);
|
||||
Assert.notNull(add, "数据处理失败");
|
||||
// 唯一性校验
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "员工入驻失败!");
|
||||
if (flag) {
|
||||
log.info("开始写入授权记录, {}", bo.getUserName());
|
||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||
personAuth.setId(add.getId());
|
||||
personAuth.setName(bo.getUserName());
|
||||
personAuth.setSex(bo.getGender() != 1L ? 0 : 1);
|
||||
personAuth.setPhone(bo.getPhone());
|
||||
personAuth.setEmail(bo.getEmail());
|
||||
personAuth.setIdCardNumber(bo.getIdCard());
|
||||
personAuth.setOssId(bo.getImg());
|
||||
personAuth.setCarNumber(bo.getCarNumber());
|
||||
personAuth.setBegDate(bo.getBegDate());
|
||||
personAuth.setEndDate(bo.getEndDate());
|
||||
personAuth.setAuthGroupId(bo.getAuthGroupId());
|
||||
|
||||
Long personId = remoteSisAuth.personAuth(personAuth);
|
||||
Assert.notNull(personId, "新增授权记录失败");
|
||||
add.setEEightId(personId);
|
||||
bo.setId(add.getId());
|
||||
this.updateByBo(bo);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@@ -126,13 +154,17 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
private void validEntityBeforeUpdate(ResidentPerson entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ResidentPerson entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
boolean exists = baseMapper.exists(new LambdaQueryWrapper<ResidentPerson>().eq(ResidentPerson::getUserId, entity.getUserId()));
|
||||
Assert.isTrue(!exists,"该用户已入住!");
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(ResidentPerson::getIdCard, entity.getIdCard())
|
||||
.eq(ResidentPerson::getUnitId, entity.getUnitId());
|
||||
boolean exists = baseMapper.exists(lqw);
|
||||
Assert.isTrue(!exists, "当前单位,{}已入驻!", entity.getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +184,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
|
||||
/**
|
||||
* 获取单位人员数量
|
||||
*
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
|
@@ -106,11 +106,18 @@
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api-workflow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>property-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>sis-api</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hik</groupId>
|
||||
<artifactId>examples</artifactId>
|
||||
|
@@ -74,13 +74,13 @@ public class SisAuthRecordController extends BaseController {
|
||||
/**
|
||||
* 新增授权记录
|
||||
*/
|
||||
@SaCheckPermission("sis:authRecord:add")
|
||||
@Log(title = "人员库授权", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SisAuthRecordBo bo) {
|
||||
return toAjax(sisAuthRecordService.insertByBo(bo));
|
||||
}
|
||||
// @SaCheckPermission("sis:authRecord:add")
|
||||
// @Log(title = "人员库授权", businessType = BusinessType.INSERT)
|
||||
// @RepeatSubmit()
|
||||
// @PostMapping()
|
||||
// public R<Void> add(@Validated(AddGroup.class) @RequestBody SisAuthRecordBo bo) {
|
||||
// return toAjax(sisAuthRecordService.insertByBo(bo));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 修改授权记录
|
||||
@@ -111,18 +111,18 @@ public class SisAuthRecordController extends BaseController {
|
||||
*
|
||||
* @param libId 人像库id
|
||||
*/
|
||||
@GetMapping("/authDevice/{libId}")
|
||||
public R<List<SisAuthRecord>> queryAuthDevice(@PathVariable("libId") String libId) {
|
||||
return R.ok(sisAuthRecordService.queryAuthDevice(libId));
|
||||
}
|
||||
// @GetMapping("/authDevice/{libId}")
|
||||
// public R<List<SisAuthRecord>> queryAuthDevice(@PathVariable("libId") String libId) {
|
||||
// return R.ok(sisAuthRecordService.queryAuthDevice(libId));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询所有可授权设备
|
||||
*
|
||||
* @return List<TreeNode < Long>>
|
||||
*/
|
||||
@GetMapping("/authDevice/tree")
|
||||
public R<List<TreeNode<Long>>> tree() {
|
||||
return R.ok(sisAuthRecordService.authDeviceTree());
|
||||
}
|
||||
// @GetMapping("/authDevice/tree")
|
||||
// public R<List<TreeNode<Long>>> tree() {
|
||||
// return R.ok(sisAuthRecordService.authDeviceTree());
|
||||
// }
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -11,7 +13,7 @@ import java.io.Serial;
|
||||
* 授权记录对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-07-14
|
||||
* @date 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -28,19 +30,29 @@ public class SisAuthRecord extends TenantEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图像库id
|
||||
* 授权对象Id
|
||||
*/
|
||||
private Long libId;
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 设备id(门禁/电梯)
|
||||
* 对象类型:1-单位 2-人
|
||||
*/
|
||||
private Long deviceId;
|
||||
private Long targetType;
|
||||
|
||||
/**
|
||||
* 设备类型:1-门禁 2-电梯
|
||||
* 权限组id
|
||||
*/
|
||||
private Integer deviceType;
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date begDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endDate;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,14 +8,14 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 授权记录业务对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-07-14
|
||||
* @date 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -29,14 +29,34 @@ public class SisAuthRecordBo extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图像库id
|
||||
* 授权对象Id
|
||||
*/
|
||||
@NotNull(message = "图像库id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long libId;
|
||||
@NotNull(message = "授权对象Id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 授权设备idList
|
||||
* 对象类型:1-单位 2-人
|
||||
*/
|
||||
@NotEmpty(message = "授权设备idList不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private List<List<Long>> deviceIds;
|
||||
@NotNull(message = "对象类型:1-单位 2-人不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long targetType;
|
||||
|
||||
/**
|
||||
* 权限组id
|
||||
*/
|
||||
@NotNull(message = "权限组id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date begDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@NotNull(message = "结束时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date endDate;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package org.dromara.sis.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.sis.domain.SisAuthRecord;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
@@ -10,13 +12,15 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 授权记录视图对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-07-14
|
||||
* @date 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@@ -33,23 +37,34 @@ public class SisAuthRecordVo implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图像库id
|
||||
* 授权对象Id
|
||||
*/
|
||||
@ExcelProperty(value = "图像库id")
|
||||
private Long libId;
|
||||
@ExcelProperty(value = "授权对象Id")
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 设备id(门禁/电梯)
|
||||
* 对象类型:1-单位 2-人
|
||||
*/
|
||||
@ExcelProperty(value = "设备id", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "门禁/电梯")
|
||||
private Long deviceId;
|
||||
@ExcelProperty(value = "对象类型:1-单位 2-人")
|
||||
private Long targetType;
|
||||
|
||||
/**
|
||||
* 设备类型:1-门禁 2-电梯
|
||||
* 权限组id
|
||||
*/
|
||||
@ExcelProperty(value = "设备类型:1-门禁 2-电梯")
|
||||
private Integer deviceType;
|
||||
@ExcelProperty(value = "权限组id")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ExcelProperty(value = "开始时间")
|
||||
private Date begDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ExcelProperty(value = "结束时间")
|
||||
private Date endDate;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package org.dromara.sis.dubbo;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.sis.api.RemoteSisAuth;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.service.ISisAuthRecordService;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteSisAuthImpl
|
||||
* @since 2025/7/24
|
||||
*/
|
||||
@Slf4j
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class RemoteSisAuthImpl implements RemoteSisAuth {
|
||||
|
||||
private final ISisAuthRecordService sisAuthRecordService;
|
||||
|
||||
@Override
|
||||
public Long personAuth(RemotePersonAuth personAuth) {
|
||||
return 1L;
|
||||
}
|
||||
}
|
@@ -14,12 +14,12 @@ public class CustomerAuthAddReq {
|
||||
/**
|
||||
* 门禁授权类型 0:人员
|
||||
*/
|
||||
private Integer authType;
|
||||
private Integer authType = 0;
|
||||
|
||||
/**
|
||||
* 时区ID
|
||||
*/
|
||||
private Long scheduleId;
|
||||
private Long scheduleId = 1L;
|
||||
|
||||
/**
|
||||
* 人员ID集合
|
||||
@@ -46,6 +46,13 @@ public class CustomerAuthAddReq {
|
||||
*/
|
||||
private Integer dateType;
|
||||
|
||||
// 默认全覆盖
|
||||
private Integer accessAuthModel = 2;
|
||||
|
||||
// 默认全覆盖
|
||||
private Integer elevatorAuthModel = 2;
|
||||
|
||||
|
||||
@Data
|
||||
public static class AuthGroupData {
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
public class E8ApiUtil {
|
||||
|
||||
private static final String BASE_URL = "http://47.109.37.87:4000";
|
||||
private static final String BASE_URL = "http://192.168.24.8:50014";
|
||||
private static final String SECRET_KEY = "ZG4ocLq1";
|
||||
private static final String KEY = "b97c7090379f490bb4b2ead0f57fd1bf";
|
||||
|
||||
|
@@ -322,57 +322,57 @@ public class HikAlarmCallBack implements HCNetSDK.FMSGCallBack_V31 {
|
||||
log.info("人脸比对完成,personId={}", person);
|
||||
|
||||
// 授权记录
|
||||
List<SisAuthRecordVo> authVoList = authRecordService.checkAuth(person);
|
||||
// List<SisAuthRecordVo> authVoList = authRecordService.checkAuth(person);
|
||||
// 获取门禁id
|
||||
Collection<Long> acIds = authVoList.stream().filter(vo -> vo.getDeviceType() == 1).map(SisAuthRecordVo::getDeviceId).toList();
|
||||
if (CollUtil.isNotEmpty(acIds)) {
|
||||
acIds.forEach(id -> {
|
||||
Long deviceId = bindRefList.stream().filter(vo -> vo.getBindId().equals(id)).findFirst().map(SisDeviceBindRefVo::getDeviceId).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);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Collection<Long> acIds = authVoList.stream().filter(vo -> vo.getDeviceType() == 1).map(SisAuthRecordVo::getDeviceId).toList();
|
||||
// if (CollUtil.isNotEmpty(acIds)) {
|
||||
// acIds.forEach(id -> {
|
||||
// Long deviceId = bindRefList.stream().filter(vo -> vo.getBindId().equals(id)).findFirst().map(SisDeviceBindRefVo::getDeviceId).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);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// 获取电梯ids
|
||||
Collection<Long> eleIds = authVoList.stream().filter(vo -> vo.getDeviceType() == 2).map(SisAuthRecordVo::getDeviceId).toList();
|
||||
if (CollUtil.isNotEmpty(eleIds)) {
|
||||
eleIds.forEach(id -> {
|
||||
Long deviceId = bindRefList.stream().filter(vo -> vo.getBindId().equals(id)).findFirst().map(SisDeviceBindRefVo::getDeviceId).orElse(null);
|
||||
SisElevatorInfoVo ele = elevatorInfoService.queryById(deviceId);
|
||||
if (ele != null) {
|
||||
log.info("下发电梯权限");
|
||||
// 根据单元ID获取楼层信息
|
||||
List<RemoteFloorVo> floorInfo = remoteFloorService.queryByUnitId(ele.getUnitId());
|
||||
// 获取电梯⇄楼层关联信息
|
||||
List<SisElevatorFloorRefVo> floorRefList = elevatorFloorRefService.queryByAuthGroupId(deviceId);
|
||||
// 获取楼层数组
|
||||
List<Long> layerArray = floorInfo.stream().map(RemoteFloorVo::getId).sorted().toList();
|
||||
|
||||
layerArray.forEach(layer -> {
|
||||
SisElevatorFloorRefVo floorRef = floorRefList.stream()
|
||||
.filter(vo -> Objects.equals(vo.getFloorId(), layer)) // 直接使用 layer
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (floorRef == null) {
|
||||
HikApiService.getInstance().controlGateway(ele.getControlIp(), layer.intValue(), 3);
|
||||
} else {
|
||||
HikApiService.getInstance().controlGateway(ele.getControlIp(), layer.intValue(), 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// Collection<Long> eleIds = authVoList.stream().filter(vo -> vo.getDeviceType() == 2).map(SisAuthRecordVo::getDeviceId).toList();
|
||||
// if (CollUtil.isNotEmpty(eleIds)) {
|
||||
// eleIds.forEach(id -> {
|
||||
// Long deviceId = bindRefList.stream().filter(vo -> vo.getBindId().equals(id)).findFirst().map(SisDeviceBindRefVo::getDeviceId).orElse(null);
|
||||
// SisElevatorInfoVo ele = elevatorInfoService.queryById(deviceId);
|
||||
// if (ele != null) {
|
||||
// log.info("下发电梯权限");
|
||||
// // 根据单元ID获取楼层信息
|
||||
// List<RemoteFloorVo> floorInfo = remoteFloorService.queryByUnitId(ele.getUnitId());
|
||||
// // 获取电梯⇄楼层关联信息
|
||||
// List<SisElevatorFloorRefVo> floorRefList = elevatorFloorRefService.queryByAuthGroupId(deviceId);
|
||||
// // 获取楼层数组
|
||||
// List<Long> layerArray = floorInfo.stream().map(RemoteFloorVo::getId).sorted().toList();
|
||||
//
|
||||
// layerArray.forEach(layer -> {
|
||||
// SisElevatorFloorRefVo floorRef = floorRefList.stream()
|
||||
// .filter(vo -> Objects.equals(vo.getFloorId(), layer)) // 直接使用 layer
|
||||
// .findFirst()
|
||||
// .orElse(null);
|
||||
// if (floorRef == null) {
|
||||
// HikApiService.getInstance().controlGateway(ele.getControlIp(), layer.intValue(), 3);
|
||||
// } else {
|
||||
// HikApiService.getInstance().controlGateway(ele.getControlIp(), layer.intValue(), 2);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
log.info("权限下发执行完成,耗时:{}", System.currentTimeMillis() - s);
|
||||
// todo 做延时队列,关闭梯控授权
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class HuaWeiHttp {
|
||||
|
||||
private static final String BASE_URL = "https://47.109.37.87:18000";
|
||||
private static final String BASE_URL = "https://192.168.24.100:18531";
|
||||
private static final String USERNAME = "huawei";
|
||||
private static final String PASSWORD = "qweasd123";
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package org.dromara.sis.service;
|
||||
|
||||
import org.dromara.sis.domain.SisAuthGroupRef;
|
||||
import org.dromara.sis.domain.vo.SisAuthGroupRefVo;
|
||||
import org.dromara.sis.domain.bo.SisAuthGroupRefBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -13,7 +12,7 @@ import java.util.List;
|
||||
* 权限组⇄设备关联Service接口
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-23
|
||||
* @since 2025-07-23
|
||||
*/
|
||||
public interface ISisAuthGroupRefService {
|
||||
|
||||
@@ -66,4 +65,13 @@ public interface ISisAuthGroupRefService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过权限组id,查询授权设备列表
|
||||
*
|
||||
* @param groupId 权限id
|
||||
*/
|
||||
List<SisAuthGroupRefVo> queryListByGroupId(Long groupId);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.sis.service;
|
||||
|
||||
import org.dromara.common.core.domain.TreeNode;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.domain.SisAuthRecord;
|
||||
import org.dromara.sis.domain.vo.SisAuthRecordVo;
|
||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||
@@ -44,12 +45,12 @@ public interface ISisAuthRecordService {
|
||||
List<SisAuthRecordVo> queryList(SisAuthRecordBo bo);
|
||||
|
||||
/**
|
||||
* 新增授权记录
|
||||
* 新增个人授权记录(单个)
|
||||
*
|
||||
* @param bo 授权记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(SisAuthRecordBo bo);
|
||||
Long insertByPerson(RemotePersonAuth bo);
|
||||
|
||||
/**
|
||||
* 修改授权记录
|
||||
@@ -74,26 +75,26 @@ public interface ISisAuthRecordService {
|
||||
* @param libId 人像库id
|
||||
* @return List<SisAuthRecord>
|
||||
*/
|
||||
List<SisAuthRecord> queryAuthDevice(String libId);
|
||||
// List<SisAuthRecord> queryAuthDevice(String libId);
|
||||
|
||||
/**
|
||||
* 根据人像库id删除授权记录
|
||||
*
|
||||
* @param libId 人像库id
|
||||
*/
|
||||
Boolean deleteByLibId(Long libId);
|
||||
// Boolean deleteByLibId(Long libId);
|
||||
|
||||
/**
|
||||
* 查询所有可授权设备树
|
||||
*
|
||||
* @return List<TreeNode<Long>>
|
||||
*/
|
||||
List<TreeNode<Long>> authDeviceTree();
|
||||
// List<TreeNode<Long>> authDeviceTree();
|
||||
|
||||
/**
|
||||
* 根据人脸比对ID,返回授权记录
|
||||
*
|
||||
* @param personId 人脸比对ID
|
||||
*/
|
||||
List<SisAuthRecordVo> checkAuth(Long personId);
|
||||
// List<SisAuthRecordVo> checkAuth(Long personId);
|
||||
}
|
||||
|
@@ -131,4 +131,16 @@ public class SisAuthGroupRefServiceImpl implements ISisAuthGroupRefService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过权限组id,查询授权设备列表
|
||||
*
|
||||
* @param groupId 权限id
|
||||
*/
|
||||
@Override
|
||||
public List<SisAuthGroupRefVo> queryListByGroupId(Long groupId){
|
||||
LambdaQueryWrapper<SisAuthGroupRef> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SisAuthGroupRef::getGroupId, groupId);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,9 @@ package org.dromara.sis.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.domain.TreeNode;
|
||||
import org.dromara.common.core.constant.CodePrefixConstants;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -12,16 +13,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.api.RemoteFloorService;
|
||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorFloorRefBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.domain.bo.SisPersonLibImgBo;
|
||||
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||
import org.dromara.sis.domain.vo.SisAuthGroupRefVo;
|
||||
import org.dromara.sis.sdk.e8.E8PlatformApi;
|
||||
import org.dromara.sis.sdk.e8.domain.accessControl.req.CustomerAuthAddReq;
|
||||
import org.dromara.sis.sdk.e8.domain.custom.req.CustomAddReq;
|
||||
import org.dromara.sis.sdk.e8.domain.voucher.req.IssueVoucherReq;
|
||||
import org.dromara.sis.sdk.huawei.HuaWeiBoxApi;
|
||||
import org.dromara.sis.sdk.huawei.domain.AddHWPersonReq;
|
||||
import org.dromara.sis.service.ISisAccessControlService;
|
||||
import org.dromara.sis.service.ISisElevatorFloorRefService;
|
||||
import org.dromara.sis.service.ISisElevatorInfoService;
|
||||
import org.dromara.sis.service.ISisAuthGroupRefService;
|
||||
import org.dromara.sis.service.ISisPersonLibImgService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||
import org.dromara.sis.domain.vo.SisAuthRecordVo;
|
||||
@@ -30,30 +35,28 @@ import org.dromara.sis.mapper.SisAuthRecordMapper;
|
||||
import org.dromara.sis.service.ISisAuthRecordService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 授权记录Service业务层处理
|
||||
*
|
||||
* @author lsm
|
||||
* @since 2025-07-14
|
||||
* @since 2025-07-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
|
||||
private final HuaWeiBoxApi huaWeiBoxApi;
|
||||
private final E8PlatformApi e8PlatformApi;
|
||||
private final SisAuthRecordMapper baseMapper;
|
||||
|
||||
private final ISisElevatorFloorRefService elevatorFloorRefService;
|
||||
private final ISisAccessControlService accessControlService;
|
||||
private final ISisElevatorInfoService elevatorInfoService;
|
||||
private final ISisAuthGroupRefService sisAuthGroupRefService;
|
||||
private final ISisPersonLibImgService sisPersonLibImgService;
|
||||
private final ISisAccessControlService sisAccessControlService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteFloorService remoteFloorService;
|
||||
private final RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 查询授权记录
|
||||
@@ -96,81 +99,145 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(SisAuthRecord::getId);
|
||||
lqw.eq(bo.getLibId() != null, SisAuthRecord::getLibId, bo.getLibId());
|
||||
lqw.eq(bo.getTargetId() != null, SisAuthRecord::getTargetId, bo.getTargetId());
|
||||
lqw.eq(bo.getTargetType() != null, SisAuthRecord::getTargetType, bo.getTargetType());
|
||||
lqw.eq(bo.getGroupId() != null, SisAuthRecord::getGroupId, bo.getGroupId());
|
||||
lqw.eq(bo.getBegDate() != null, SisAuthRecord::getBegDate, bo.getBegDate());
|
||||
lqw.eq(bo.getEndDate() != null, SisAuthRecord::getEndDate, bo.getEndDate());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增授权记录
|
||||
* 新增个人授权记录(单个)
|
||||
*
|
||||
* @param bo 授权记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SisAuthRecordBo bo) {
|
||||
if (CollUtil.isEmpty(bo.getDeviceIds())) {
|
||||
return false;
|
||||
public Long insertByPerson(RemotePersonAuth bo) {
|
||||
SisAuthRecord add = new SisAuthRecord();
|
||||
add.setTargetType(2L);
|
||||
add.setTargetId(bo.getId());
|
||||
add.setGroupId(bo.getAuthGroupId());
|
||||
add.setBegDate(bo.getBegDate());
|
||||
add.setEndDate(bo.getEndDate());
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增授权记录失败");
|
||||
|
||||
|
||||
Long e8Id = null;
|
||||
try {
|
||||
byte[] imageByte = remoteFileService.downloadToByteArray(Long.parseLong(bo.getOssId()));
|
||||
|
||||
// 写入华为平台
|
||||
Long huaweiBoxId = syncHuaweiBox(bo, imageByte);
|
||||
|
||||
// 写入安防人像信息
|
||||
this.syncPersonImg(bo, huaweiBoxId);
|
||||
|
||||
// 写入E8平台
|
||||
e8Id = syncE8Plat(bo, imageByte);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
// 每次授权先删除上一次授权信息
|
||||
deleteByLibId(bo.getLibId());
|
||||
|
||||
//取出需要授权的门禁id、电梯id、楼层id
|
||||
List<Long> acIds = bo.getDeviceIds().get(0);
|
||||
List<Long> eleIds = bo.getDeviceIds().get(1);
|
||||
List<Long> floorIds = bo.getDeviceIds().get(2);
|
||||
|
||||
// 过滤不是设备的节点数据
|
||||
// 门禁设备
|
||||
List<SisAccessControlVo> acVoList = accessControlService.queryListByIds(acIds);
|
||||
// 电梯设备
|
||||
List<SisElevatorInfoVo> eleVoList = elevatorInfoService.queryListByIds(eleIds);
|
||||
// 楼层信息
|
||||
|
||||
if (CollUtil.isEmpty(acVoList) || CollUtil.isEmpty(eleVoList)) {
|
||||
return false;
|
||||
return e8Id;
|
||||
}
|
||||
|
||||
// 批量写入授权数据
|
||||
boolean flag = false;
|
||||
log.info("开始写入门禁授权记录,acIds:{}", acVoList);
|
||||
for (SisAccessControlVo ac : acVoList) {
|
||||
SisAuthRecord authRecord = new SisAuthRecord();
|
||||
|
||||
authRecord.setDeviceType(1);
|
||||
authRecord.setDeviceId(ac.getId());
|
||||
authRecord.setLibId(bo.getLibId());
|
||||
flag = baseMapper.insert(authRecord) > 0;
|
||||
Assert.isTrue(flag, "写入门禁授权记录失败!");
|
||||
private void syncPersonImg(RemotePersonAuth bo, Long huaweiBoxId){
|
||||
log.info("开始写入安防人像信息");
|
||||
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
||||
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
||||
personLibImg.setImgName(bo.getName());
|
||||
personLibImg.setSex(bo.getSex());
|
||||
personLibImg.setEmail(bo.getEmail());
|
||||
personLibImg.setTel(bo.getPhone());
|
||||
personLibImg.setCertificateType(bo.getCardType());
|
||||
personLibImg.setCertificateNo(bo.getIdCardNumber());
|
||||
personLibImg.setRemoteImgId(huaweiBoxId);
|
||||
sisPersonLibImgService.insertByBo(personLibImg);
|
||||
log.info("写入安防人像信息完成");
|
||||
}
|
||||
log.info("写入门禁授权记录完成");
|
||||
|
||||
log.info("开始写入电梯授权记录,eleIds:{}", eleVoList);
|
||||
for (SisElevatorInfoVo ele : eleVoList) {
|
||||
SisAuthRecord authRecord = new SisAuthRecord();
|
||||
SisElevatorFloorRefBo refBo = new SisElevatorFloorRefBo();
|
||||
private Long syncHuaweiBox(RemotePersonAuth bo, byte[] imgByte) {
|
||||
log.info("开始写入华为平台");
|
||||
AddHWPersonReq req = new AddHWPersonReq();
|
||||
req.setIndex(CodePrefixConstants.PERSON_LIB_IMAGE_CODE_PREFIX + IdUtil.getSnowflakeNextIdStr());
|
||||
req.setName(bo.getName());
|
||||
req.setGender(bo.getSex() == 1 ? "0" : bo.getSex() == 2 ? "1" : "-1");
|
||||
req.setCredentialType("0");
|
||||
req.setCredentialNumber(bo.getIdCardNumber());
|
||||
|
||||
authRecord.setDeviceType(2);
|
||||
authRecord.setLibId(bo.getLibId());
|
||||
authRecord.setDeviceId(ele.getElevatorId());
|
||||
flag = baseMapper.insert(authRecord) > 0;
|
||||
Assert.isTrue(flag, "写入电梯授权记录失败!");
|
||||
ArrayList<String> pictures = new ArrayList<>();
|
||||
pictures.add(Base64.getEncoder().encodeToString(imgByte));
|
||||
req.setPictures(pictures);
|
||||
|
||||
log.info("开始写入电梯⇄楼层关联关系");
|
||||
// 获取该电梯所在单元的楼层信息
|
||||
List<RemoteFloorVo> floorVoList = remoteFloorService.queryByUnitId(ele.getUnitId());
|
||||
// 该单元所有楼层id
|
||||
List<Long> allFloors = floorVoList.stream().map(RemoteFloorVo::getId).toList();
|
||||
// 对比找出授权楼层id
|
||||
List<Long> authFloors = floorIds.stream().filter(allFloors::contains).toList();
|
||||
refBo.setElevatorId(ele.getElevatorId());
|
||||
refBo.setFloorIds(authFloors);
|
||||
elevatorFloorRefService.insertByBo(refBo);
|
||||
Long pId = huaWeiBoxApi.addPerson(List.of(req));
|
||||
Assert.notNull(pId, "调用华为盒子新增图片失败");
|
||||
log.info("写入华为盒子完成,pId={}", pId);
|
||||
return pId;
|
||||
}
|
||||
log.info("写入电梯授权记录完成");
|
||||
|
||||
return flag;
|
||||
private Long syncE8Plat(RemotePersonAuth bo, byte[] imgByte) {
|
||||
|
||||
log.info("e8平台上传照片");
|
||||
String e8ImgUrl = e8PlatformApi.uploadFace(imgByte);
|
||||
Assert.notNull(e8ImgUrl, "图片上传E8平台失败");
|
||||
log.info("e8平台上传照片完成");
|
||||
|
||||
log.info("e8同步新建人员");
|
||||
CustomAddReq req = new CustomAddReq();
|
||||
req.setName(bo.getName());
|
||||
req.setGender(bo.getSex());
|
||||
req.setMobile(bo.getPhone());
|
||||
req.setEmail(bo.getEmail());
|
||||
req.setIdentityType(0);
|
||||
req.setIdentityNo(bo.getIdCardNumber());
|
||||
Long e8Id = e8PlatformApi.addCustomer(req).getId();
|
||||
Assert.notNull(e8Id, "e8同步新建人员失败");
|
||||
log.info("e8同步新建人员完成");
|
||||
|
||||
|
||||
log.info("e8平台开始发行凭证");
|
||||
IssueVoucherReq voucherReq = new IssueVoucherReq();
|
||||
voucherReq.setVoucherType(70);
|
||||
voucherReq.setPersonID(e8Id);
|
||||
voucherReq.setTxtData(e8ImgUrl);
|
||||
voucherReq.setStartTime(bo.getBegDate().toString());
|
||||
voucherReq.setEndTime(bo.getEndDate().toString());
|
||||
Long voucherId = e8PlatformApi.issueVoucher(voucherReq);
|
||||
Assert.notNull(voucherId, "e8平台发行凭证失败");
|
||||
log.info("e8平台发行凭证成功");
|
||||
|
||||
// 获取门禁
|
||||
List<SisAuthGroupRefVo> refVos = sisAuthGroupRefService.queryListByGroupId(bo.getAuthGroupId());
|
||||
Collection<Long> deviceIds = refVos.stream().filter(ref -> ref.getDeviceType() == 1).map(SisAuthGroupRefVo::getDeviceId).toList();
|
||||
if(CollUtil.isNotEmpty(deviceIds)){
|
||||
// 初始化赋值
|
||||
CustomerAuthAddReq authReq = new CustomerAuthAddReq();
|
||||
authReq.setPersonIds(List.of(e8Id));
|
||||
authReq.setStartTime(bo.getBegDate().toString());
|
||||
authReq.setEndTime(bo.getEndDate().toString());
|
||||
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);
|
||||
list.add(authData);
|
||||
}
|
||||
authReq.setAuthData(list);
|
||||
|
||||
log.info("e8平台开始授权");
|
||||
Boolean flag = e8PlatformApi.addCustomerAuth(authReq);
|
||||
Assert.isTrue(flag, "E8平台授权失败!");
|
||||
log.info("E8平台授权完成!");
|
||||
}
|
||||
return e8PlatformApi.addCustomer(req).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,120 +274,4 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库id授权的设备
|
||||
*
|
||||
* @param libId 人像库id
|
||||
* @return List<SisAuthRecord>
|
||||
*/
|
||||
@Override
|
||||
public List<SisAuthRecord> queryAuthDevice(String libId) {
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SisAuthRecord::getLibId, libId);
|
||||
return baseMapper.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据人像库id删除授权记录
|
||||
*
|
||||
* @param libId 人像库id
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteByLibId(Long libId) {
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SisAuthRecord::getLibId, libId);
|
||||
return baseMapper.delete(lqw) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有可授权设备树
|
||||
*
|
||||
* @return List<TreeNode < Long>>
|
||||
*/
|
||||
@Override
|
||||
public List<TreeNode<Long>> authDeviceTree() {
|
||||
// 暂时将所有数据放入写死的根节点中
|
||||
TreeNode<Long> root = new TreeNode<>();
|
||||
root.setLevel(0);
|
||||
root.setCode(0L);
|
||||
root.setParentCode(-1L);
|
||||
root.setTitle("授权设备");
|
||||
|
||||
// 创建门禁设备父节点
|
||||
TreeNode<Long> accessNode = new TreeNode<>();
|
||||
accessNode.setLevel(1);
|
||||
accessNode.setCode(1L);
|
||||
accessNode.setParentCode(0L);
|
||||
accessNode.setTitle("门禁设备");
|
||||
|
||||
// 创建电梯父节点
|
||||
TreeNode<Long> elevatorNode = new TreeNode<>();
|
||||
elevatorNode.setLevel(1);
|
||||
elevatorNode.setCode(2L);
|
||||
elevatorNode.setParentCode(0L);
|
||||
elevatorNode.setTitle("电梯设备");
|
||||
|
||||
|
||||
List<SisAccessControlVo> acVoList = accessControlService.queryList(new SisAccessControlBo());
|
||||
List<SisElevatorInfoVo> eleVoList = elevatorInfoService.queryList(new SisElevatorInfoBo());
|
||||
|
||||
|
||||
List<TreeNode<Long>> acChildrenList = acVoList.stream().map(item -> {
|
||||
TreeNode<Long> node = new TreeNode<>();
|
||||
node.setLevel(2);
|
||||
node.setCode(item.getId());
|
||||
node.setParentCode(1L);
|
||||
node.setLabel("accessControl");
|
||||
node.setTitle(item.getAccessName());
|
||||
return node;
|
||||
}).toList();
|
||||
|
||||
List<TreeNode<Long>> eleChildrenList = new ArrayList<>();
|
||||
eleVoList.forEach(item -> {
|
||||
// 电梯子节点
|
||||
TreeNode<Long> eleNode = new TreeNode<>();
|
||||
eleNode.setLevel(2);
|
||||
eleNode.setParentCode(2L);
|
||||
eleNode.setLabel("elevator");
|
||||
eleNode.setCode(item.getElevatorId());
|
||||
eleNode.setTitle(item.getElevatorName());
|
||||
|
||||
// 楼层节点
|
||||
List<TreeNode<Long>> floorTree = new ArrayList<>();
|
||||
// 获取楼层
|
||||
List<RemoteFloorVo> floorInfoList = remoteFloorService.queryByUnitId(item.getUnitId());
|
||||
floorInfoList.forEach(floor -> {
|
||||
TreeNode<Long> floorNode = new TreeNode<>();
|
||||
floorNode.setLevel(3);
|
||||
floorNode.setLabel("floor");
|
||||
floorNode.setCode(floor.getId());
|
||||
floorNode.setTitle(floor.getFloorName());
|
||||
floorNode.setParentCode(item.getElevatorId());
|
||||
floorTree.add(floorNode);
|
||||
});
|
||||
eleNode.setChildren(floorTree);
|
||||
eleChildrenList.add(eleNode);
|
||||
});
|
||||
|
||||
// 将子节点列表分别添加到对应的父节点
|
||||
accessNode.setChildren(acChildrenList);
|
||||
elevatorNode.setChildren(eleChildrenList);
|
||||
|
||||
|
||||
// 最后将两个父节点添加到根节点
|
||||
root.setChildren(List.of(accessNode, elevatorNode));
|
||||
return List.of(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据人脸比对ID,返回授权记录
|
||||
*
|
||||
* @param personId 人脸比对ID
|
||||
*/
|
||||
@Override
|
||||
public List<SisAuthRecordVo> checkAuth(Long personId) {
|
||||
return baseMapper.checkAuth(personId);
|
||||
}
|
||||
}
|
||||
|
@@ -119,46 +119,8 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
||||
public Boolean insertByBo(SisPersonLibImgBo bo) {
|
||||
SisPersonLibImg add = MapstructUtils.convert(bo, SisPersonLibImg.class);
|
||||
Assert.notNull(add, "数据处理失败");
|
||||
boolean flag;
|
||||
try {
|
||||
log.info("准备写入华为盒子,imgName={}", bo.getImgName());
|
||||
AddHWPersonReq req = new AddHWPersonReq();
|
||||
req.setIndex(CodePrefixConstants.PERSON_LIB_IMAGE_CODE_PREFIX + IdUtil.getSnowflakeNextIdStr());
|
||||
req.setName(bo.getImgName());
|
||||
req.setGender(bo.getSex() == 1 ? "0" : bo.getSex() == 2 ? "1" : "-1");
|
||||
req.setBornTime(bo.getBirthDate());
|
||||
req.setCredentialType("0");
|
||||
req.setCredentialNumber(bo.getCertificateNo());
|
||||
|
||||
byte[] imageByte = remoteFileService.downloadToByteArray(bo.getImgOssId());
|
||||
ArrayList<String> pictures = new ArrayList<>();
|
||||
pictures.add(Base64.getEncoder().encodeToString(imageByte));
|
||||
req.setPictures(pictures);
|
||||
|
||||
Long pId = huaWeiBoxApi.addPerson(List.of(req));
|
||||
Assert.notNull(pId, "调用华为盒子新增图片失败");
|
||||
log.info("写入华为盒子完成,pId={}", pId);
|
||||
|
||||
add.setRemoteImgId(pId);
|
||||
flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增人像失败");
|
||||
|
||||
log.info("开始写入人像⇄人像库关联表");
|
||||
List<SisLibImgRef> refs = new ArrayList<>();
|
||||
for (Long libId : bo.getLibIds()) {
|
||||
SisLibImgRef ref = new SisLibImgRef();
|
||||
ref.setLibId(libId);
|
||||
ref.setImgId(add.getId());
|
||||
refs.add(ref);
|
||||
}
|
||||
Boolean refFlag = sisLibImgRefService.addBatch(refs);
|
||||
Assert.isTrue(refFlag, "写入人像⇄人像库关联表失败!");
|
||||
log.info("写入人像⇄人像库关联表完成");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增数据失败");
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<module>ruoyi-resource</module>
|
||||
<module>ruoyi-workflow</module>
|
||||
<module>Property</module>
|
||||
<!-- <module>Sis</module>-->
|
||||
<module>Sis</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
|
Reference in New Issue
Block a user