feat(auth): 人员授权相关功能修改
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package org.dromara.sis.config.timer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.property.api.RemoteResidentPersonService;
|
||||
import org.dromara.property.api.domain.vo.RemoteResidentPersonVo;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote AuthTimer
|
||||
* @since 2025/7/26
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class AuthTimer {
|
||||
|
||||
@DubboReference
|
||||
private RemoteResidentPersonService remoteResidentPersonService;
|
||||
|
||||
/**
|
||||
* 每两分钟执行一次
|
||||
*/
|
||||
@Scheduled(cron = "0 */2 * * * ?")
|
||||
public void autoAuth(){
|
||||
List<RemoteResidentPersonVo> unAuthPerson = remoteResidentPersonService.queryUnAuthPerson();
|
||||
if (CollUtil.isNotEmpty(unAuthPerson)){
|
||||
for(RemoteResidentPersonVo person : unAuthPerson){
|
||||
log.info("开始授权:{}", person.getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,7 +7,6 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.core.domain.TreeNode;
|
||||
import org.dromara.sis.domain.SisAuthRecord;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@@ -15,7 +14,6 @@ import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
@@ -121,8 +119,8 @@ public class SisAuthRecordController extends BaseController {
|
||||
*
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ 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;
|
||||
|
||||
@@ -13,7 +12,7 @@ import java.io.Serial;
|
||||
* 授权记录对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-24
|
||||
* @since 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -35,7 +34,7 @@ public class SisAuthRecord extends TenantEntity {
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 对象类型:1-单位 2-人
|
||||
* 来源类型:1-单位 2-人
|
||||
*/
|
||||
private Long targetType;
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import java.io.Serial;
|
||||
* 人像信息对象 tb_person_lib_img
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-24
|
||||
* @since 2025-06-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -73,4 +73,9 @@ public class SisPersonLibImg extends TenantEntity {
|
||||
*/
|
||||
private Long remoteImgId;
|
||||
|
||||
/**
|
||||
* 入驻员工id
|
||||
*/
|
||||
private Long residentPersonId;
|
||||
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
* 授权记录业务对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-24
|
||||
* @since 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -35,7 +35,7 @@ public class SisAuthRecordBo extends BaseEntity {
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 对象类型:1-单位 2-人
|
||||
* 来源类型:1-单位 2-人
|
||||
*/
|
||||
@NotNull(message = "对象类型:1-单位 2-人不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long targetType;
|
||||
|
@@ -82,8 +82,8 @@ public class SisPersonLibImgBo extends BaseEntity {
|
||||
private Long remoteImgId;
|
||||
|
||||
/**
|
||||
* 同步E8
|
||||
* 入驻员工id
|
||||
*/
|
||||
private Boolean isSyncE8;
|
||||
private Long residentPersonId;
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,14 @@
|
||||
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;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +16,7 @@ import java.util.Date;
|
||||
* 授权记录视图对象 sis_auth_record
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-24
|
||||
* @since 2025-07-24
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@@ -43,7 +39,7 @@ public class SisAuthRecordVo implements Serializable {
|
||||
private Long targetId;
|
||||
|
||||
/**
|
||||
* 对象类型:1-单位 2-人
|
||||
* 来源类型:1-单位 2-人
|
||||
*/
|
||||
@ExcelProperty(value = "对象类型:1-单位 2-人")
|
||||
private Long targetType;
|
||||
|
@@ -90,4 +90,10 @@ public class SisPersonLibImgVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "人像库id")
|
||||
private Collection<Long> libIds;
|
||||
|
||||
/**
|
||||
* 入驻员工id
|
||||
*/
|
||||
@ExcelProperty(value = "入驻员工id")
|
||||
private Long residentPersonId;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class RemoteSisAuthImpl implements RemoteSisAuth {
|
||||
private final ISisAuthRecordService sisAuthRecordService;
|
||||
|
||||
@Override
|
||||
public Long personAuth(RemotePersonAuth personAuth) {
|
||||
public Boolean personAuth(RemotePersonAuth personAuth) {
|
||||
return sisAuthRecordService.insertByPerson(personAuth);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ 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;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -50,7 +49,7 @@ public interface ISisAuthRecordService {
|
||||
* @param bo 授权记录
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Long insertByPerson(RemotePersonAuth bo);
|
||||
Boolean insertByPerson(RemotePersonAuth bo);
|
||||
|
||||
/**
|
||||
* 修改授权记录
|
||||
@@ -89,7 +88,7 @@ public interface ISisAuthRecordService {
|
||||
*
|
||||
* @return List<TreeNode<Long>>
|
||||
*/
|
||||
// List<TreeNode<Long>> authDeviceTree();
|
||||
List<TreeNode<Long>> authDeviceTree();
|
||||
|
||||
/**
|
||||
* 根据人脸比对ID,返回授权记录
|
||||
|
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.constant.CodePrefixConstants;
|
||||
import org.dromara.common.core.domain.TreeNode;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -14,29 +15,30 @@ 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.resource.api.RemoteFileService;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||
import org.dromara.sis.domain.bo.SisPersonLibImgBo;
|
||||
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
||||
import org.dromara.sis.domain.vo.SisAuthGroupRefVo;
|
||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||
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.ISisAuthGroupRefService;
|
||||
import org.dromara.sis.service.ISisPersonLibImgService;
|
||||
import org.dromara.sis.service.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||
import org.dromara.sis.domain.vo.SisAuthRecordVo;
|
||||
import org.dromara.sis.domain.SisAuthRecord;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
@@ -53,12 +55,17 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
private final HuaWeiBoxApi huaWeiBoxApi;
|
||||
private final E8PlatformApi e8PlatformApi;
|
||||
private final SisAuthRecordMapper baseMapper;
|
||||
private final ISisElevatorInfoService elevatorInfoService;
|
||||
private final ISisAuthGroupRefService sisAuthGroupRefService;
|
||||
private final ISisPersonLibImgService sisPersonLibImgService;
|
||||
private final ISisAccessControlService sisAccessControlService;
|
||||
|
||||
|
||||
@DubboReference
|
||||
private final RemoteFileService remoteFileService;
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteFloorService remoteFloorService;
|
||||
|
||||
/**
|
||||
* 查询授权记录
|
||||
@@ -117,49 +124,35 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long insertByPerson(RemotePersonAuth bo) {
|
||||
public Boolean insertByPerson(RemotePersonAuth bo) {
|
||||
SisAuthRecord add = new SisAuthRecord();
|
||||
add.setTargetType(2L);
|
||||
add.setTargetType(1L);
|
||||
add.setTargetId(bo.getId());
|
||||
add.setGroupId(bo.getAuthGroupId());
|
||||
add.setBegDate(bo.getBegDate());
|
||||
add.setEndDate(bo.getEndDate());
|
||||
add.setBegDate(bo.getAuthBegDate());
|
||||
add.setEndDate(bo.getAuthEndDate());
|
||||
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);
|
||||
|
||||
if (flag) {
|
||||
// 写入安防人像信息
|
||||
this.syncPersonImg(bo, huaweiBoxId);
|
||||
|
||||
// 写入E8平台
|
||||
e8Id = syncE8Plat(bo, imageByte);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
this.syncPersonImg(bo);
|
||||
}
|
||||
|
||||
return e8Id;
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void syncPersonImg(RemotePersonAuth bo, Long huaweiBoxId){
|
||||
private void syncPersonImg(RemotePersonAuth bo){
|
||||
log.info("开始写入安防人像信息");
|
||||
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
||||
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
||||
personLibImg.setImgOssId(12346L);
|
||||
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);
|
||||
personLibImg.setResidentPersonId(bo.getId());
|
||||
sisPersonLibImgService.insertByBo(personLibImg);
|
||||
log.info("写入安防人像信息完成");
|
||||
}
|
||||
@@ -220,8 +213,8 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
// 初始化赋值
|
||||
CustomerAuthAddReq authReq = new CustomerAuthAddReq();
|
||||
authReq.setPersonIds(List.of(e8Id));
|
||||
authReq.setStartTime(DateUtil.format(bo.getBegDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
authReq.setEndTime(DateUtil.format(bo.getEndDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
authReq.setStartTime(DateUtil.format(bo.getAuthBegDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
authReq.setEndTime(DateUtil.format(bo.getAuthEndDate(), "yyyy-MM-dd HH:mm:ss"));
|
||||
List<CustomerAuthAddReq.AuthGroupData> list = new ArrayList<>();
|
||||
SisAccessControlVo accessControlVo;
|
||||
for(Long deviceId : deviceIds){
|
||||
@@ -276,4 +269,83 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 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<SisElevatorInfoVo> eleVoList = elevatorInfoService.queryList(new SisElevatorInfoBo());
|
||||
List<SisAccessControlVo> acVoList = sisAccessControlService.queryList(new SisAccessControlBo());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user