Compare commits
2 Commits
99336196e0
...
d070a52487
Author | SHA1 | Date | |
---|---|---|---|
d070a52487 | |||
3b7635bf1d |
@ -0,0 +1,16 @@
|
||||
package org.dromara.property.api;
|
||||
|
||||
import org.dromara.property.api.domain.vo.RemoteResidentPersonVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteResidentPersonService
|
||||
* @since 2025/7/26
|
||||
*/
|
||||
public interface RemoteResidentPersonService {
|
||||
|
||||
// 查询已上传图片,未授权人员
|
||||
List<RemoteResidentPersonVo> queryUnAuthPerson();
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.dromara.property.api.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteResidentPersonVo
|
||||
* @since 2025/7/26
|
||||
*/
|
||||
@Data
|
||||
public class RemoteResidentPersonVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String ossId;
|
||||
|
||||
private Long eEightId;
|
||||
|
||||
private Long authGroupId;
|
||||
}
|
@ -9,5 +9,5 @@ import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
*/
|
||||
public interface RemoteSisAuth {
|
||||
|
||||
Long personAuth(RemotePersonAuth personAuth);
|
||||
Boolean personAuth(RemotePersonAuth personAuth);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ public class RemotePersonAuth implements Serializable {
|
||||
|
||||
private Long authGroupId;
|
||||
|
||||
private Date begDate;
|
||||
private Date authBegDate;
|
||||
|
||||
private Date endDate;
|
||||
private Date authEndDate;
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,16 @@ public class ResidentUnit extends TenantEntity {
|
||||
*/
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date authBegDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date authEndDate;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
|
@ -45,27 +45,26 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
@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 Long authGroupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date begDate;
|
||||
private Date authBegDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endDate;
|
||||
private Date authEndDate;
|
||||
|
||||
/**
|
||||
* e8平台id
|
||||
|
@ -69,6 +69,21 @@ public class ResidentUnitBo extends BaseEntity {
|
||||
@NotNull(message = "入驻时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date authBegDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date authEndDate;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@ -81,12 +96,6 @@ public class ResidentUnitBo extends BaseEntity {
|
||||
// @NotNull(message = "员工人数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long number=0L;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -113,5 +113,10 @@ public class ResidentPersonVo implements Serializable {
|
||||
@ExcelProperty(value = "权限组id")
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* e8平台id
|
||||
*/
|
||||
private Long eEightId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -109,4 +109,16 @@ public class ResidentUnitVo implements Serializable {
|
||||
@ExcelProperty(value = "权限组id")
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ExcelProperty(value = "开始时间")
|
||||
private Date authBegDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@ExcelProperty(value = "结束时间")
|
||||
private Date authEndDate;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package org.dromara.property.dubbo;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.property.api.RemoteResidentPersonService;
|
||||
import org.dromara.property.api.domain.vo.RemoteResidentPersonVo;
|
||||
import org.dromara.property.domain.vo.ResidentPersonVo;
|
||||
import org.dromara.property.service.IResidentPersonService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteResidentPersonServiceImpl
|
||||
* @since 2025/7/26
|
||||
*/
|
||||
@Slf4j
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class RemoteResidentPersonServiceImpl implements RemoteResidentPersonService {
|
||||
|
||||
private final IResidentPersonService residentPersonService;
|
||||
|
||||
// 查询已上传图片,未授权人员
|
||||
@Override
|
||||
// 查询已上传图片,未授权人员
|
||||
public List<RemoteResidentPersonVo> queryUnAuthPerson(){
|
||||
List<ResidentPersonVo> listVo = residentPersonService.queryUnAuthPerson();
|
||||
|
||||
return listVo.stream().map(vo -> {
|
||||
RemoteResidentPersonVo remoteResidentPersonVo = new RemoteResidentPersonVo();
|
||||
remoteResidentPersonVo.setId(vo.getId());
|
||||
remoteResidentPersonVo.setOssId(vo.getImg());
|
||||
remoteResidentPersonVo.setEEightId(vo.getEEightId());
|
||||
remoteResidentPersonVo.setAuthGroupId(vo.getAuthGroupId());
|
||||
return remoteResidentPersonVo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package org.dromara.property.service;
|
||||
|
||||
import org.dromara.property.domain.ResidentPerson;
|
||||
import org.dromara.property.domain.vo.ResidentPersonVo;
|
||||
import org.dromara.property.domain.bo.ResidentPersonBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -13,7 +12,7 @@ import java.util.List;
|
||||
* 入驻员工Service接口
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-19
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
public interface IResidentPersonService {
|
||||
|
||||
@ -69,8 +68,15 @@ public interface IResidentPersonService {
|
||||
|
||||
/**
|
||||
* 获取单位人员数量
|
||||
* @param unitId
|
||||
* @return
|
||||
* @param unitId 单元id
|
||||
* @return Long
|
||||
*/
|
||||
Long queryPersonCount(Long unitId);
|
||||
|
||||
/**
|
||||
* 查询已上传图片,未授权人员
|
||||
*
|
||||
* @return List<ResidentPersonVo>
|
||||
*/
|
||||
List<ResidentPersonVo> queryUnAuthPerson();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -10,10 +9,13 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.domain.vo.ResidentUnitVo;
|
||||
import org.dromara.property.service.IResidentUnitService;
|
||||
import org.dromara.sis.api.RemoteSisAuth;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.ResidentPersonBo;
|
||||
import org.dromara.property.domain.vo.ResidentPersonVo;
|
||||
@ -22,6 +24,7 @@ import org.dromara.property.mapper.ResidentPersonMapper;
|
||||
import org.dromara.property.service.IResidentPersonService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@ -30,14 +33,18 @@ import java.util.Collection;
|
||||
* 入驻员工Service业务层处理
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-19
|
||||
* @since 2025-06-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
|
||||
private final ResidentPersonMapper baseMapper;
|
||||
@Resource
|
||||
private ResidentPersonMapper baseMapper;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IResidentUnitService residentUnitService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteSisAuth remoteSisAuth;
|
||||
@ -108,7 +115,13 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
ResidentPerson add = MapstructUtils.convert(bo, ResidentPerson.class);
|
||||
Assert.notNull(add, "数据处理失败");
|
||||
// 唯一性校验
|
||||
assert add != null;
|
||||
validEntityBeforeSave(add);
|
||||
|
||||
// 首次入驻新用户权限组默认使用公司权限
|
||||
ResidentUnitVo ruVo = residentUnitService.queryById(bo.getUnitId());
|
||||
add.setAuthGroupId(ruVo.getAuthGroupId());
|
||||
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "员工入驻失败!");
|
||||
if (flag) {
|
||||
@ -116,21 +129,20 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||
personAuth.setId(add.getId());
|
||||
personAuth.setName(bo.getUserName());
|
||||
personAuth.setSex(bo.getGender() != 1L ? 0 : 1);
|
||||
personAuth.setSex(bo.getGender().intValue());
|
||||
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, "新增授权记录失败");
|
||||
bo.setId(add.getId());
|
||||
bo.setEEightId(personId);
|
||||
this.updateByBo(bo);
|
||||
// 使用公司权限组
|
||||
personAuth.setAuthBegDate(ruVo.getAuthBegDate());
|
||||
personAuth.setAuthEndDate(ruVo.getAuthEndDate());
|
||||
personAuth.setAuthGroupId(ruVo.getAuthGroupId());
|
||||
|
||||
Boolean auth = remoteSisAuth.personAuth(personAuth);
|
||||
Assert.isTrue(auth, "新增授权记录失败");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@ -177,7 +189,17 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(ResidentPerson::getId, ids);
|
||||
List<ResidentPersonVo> list = baseMapper.selectVoList(lqw);
|
||||
|
||||
boolean hasEnabled = list.stream()
|
||||
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
|
||||
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
|
||||
|
||||
boolean hasE8 = list.stream()
|
||||
.anyMatch(vo -> vo.getEEightId() != null); // 遇到第一个e8人员立即返回
|
||||
Assert.isTrue(!hasE8, "当前存在人员已下发权限,请删除通行权限后再试!");
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
@ -185,8 +207,8 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
/**
|
||||
* 获取单位人员数量
|
||||
*
|
||||
* @param unitId
|
||||
* @return
|
||||
* @param unitId 单位id
|
||||
* @return Long
|
||||
*/
|
||||
@Override
|
||||
public Long queryPersonCount(Long unitId) {
|
||||
@ -194,4 +216,17 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
lqw.eq(unitId != null, ResidentPerson::getUnitId, unitId);
|
||||
return baseMapper.selectCount(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已上传图片,未授权人员
|
||||
*
|
||||
* @return List<ResidentPersonVo>
|
||||
*/
|
||||
public List<ResidentPersonVo> queryUnAuthPerson(){
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.isNotNull(ResidentPerson::getImg)
|
||||
.ne(ResidentPerson::getImg, "")
|
||||
.isNull(ResidentPerson::getEEightId);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user