Merge remote-tracking branch 'origin/master'
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
2025-07-30 09:18:39 +08:00
28 changed files with 554 additions and 111 deletions

View File

@@ -8,6 +8,7 @@ import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
/**
@@ -24,19 +25,19 @@ public class ResidentPersonBo extends BaseEntity {
/**
* 主键id
*/
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
@NotNull(message = "主键id不能为空", groups = {EditGroup.class})
private Long id;
/**
* 用户名称
*/
@NotBlank(message = "用户名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "用户名称不能为空", groups = {AddGroup.class, EditGroup.class})
private String userName;
/**
* 联系电话
*/
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "联系电话不能为空", groups = {AddGroup.class, EditGroup.class})
private String phone;
/**
* 人员类型
@@ -46,13 +47,13 @@ public class ResidentPersonBo extends BaseEntity {
/**
* 性别
*/
@NotNull(message = "性别不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "性别不能为空", groups = {AddGroup.class, EditGroup.class})
private Long gender;
/**
* 证件号
*/
@NotBlank(message = "证件号不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "证件号不能为空", groups = {AddGroup.class, EditGroup.class})
private String idCard;
/**
@@ -113,7 +114,7 @@ public class ResidentPersonBo extends BaseEntity {
/**
* 状态
*/
private Long state=1L;
private Long state = 1L;
/**
* 备注

View File

@@ -1,6 +1,7 @@
package org.dromara.property.service.impl;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
@@ -28,6 +29,8 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 入驻员工Service业务层处理
@@ -159,15 +162,60 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
@Override
public Boolean updateByBo(ResidentPersonBo bo) {
ResidentPerson update = MapstructUtils.convert(bo, ResidentPerson.class);
validEntityBeforeUpdate(update);
return baseMapper.updateById(update) > 0;
assert update != null;
boolean flag;
// 人脸照片存在时,才同步修改授权
if (update.getAuthGroupId() != null && update.getAuthEndDate() != null && update.getImg() != null) {
ResidentPersonVo vo = queryById(update.getId());
Long e8Id = vo.getEEightId();
flag = baseMapper.updateById(update) > 0;
// 显式移除e8id
LambdaUpdateWrapper<ResidentPerson> lqw = new LambdaUpdateWrapper<>();
lqw.eq(ResidentPerson::getId, update.getId())
.set(ResidentPerson::getEEightId, null);
baseMapper.update(lqw);
if (flag) {
log.info("开始修改授权记录, {}", bo.getUserName());
RemotePersonAuth personAuth = new RemotePersonAuth();
personAuth.setId(update.getId());
personAuth.setName(update.getUserName());
personAuth.setSex(update.getGender().intValue());
personAuth.setPhone(update.getPhone());
personAuth.setEmail(update.getEmail());
personAuth.setIdCardNumber(update.getIdCard());
personAuth.setOssId(update.getImg());
personAuth.setCarNumber(update.getCarNumber());
personAuth.setE8Id(e8Id);
personAuth.setAuthGroupId(update.getAuthGroupId());
personAuth.setAuthBegDate(update.getAuthBegDate());
personAuth.setAuthEndDate(update.getAuthEndDate());
Boolean auth = remoteSisAuth.updatePersonAuth(personAuth);
Assert.isTrue(auth, "修改授权记录失败!");
}
} else {
flag = baseMapper.updateById(update) > 0;
}
Assert.isTrue(flag, "修改入驻员工失败!");
return flag;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeUpdate(ResidentPerson entity) {
//TODO 做一些数据校验,如唯一约束
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());
}
/**
@@ -200,9 +248,12 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
boolean hasE8 = list.stream()
.anyMatch(vo -> vo.getEEightId() != null); // 遇到第一个e8人员立即返回
Assert.isTrue(!hasE8, "当前存在人员已下发权限,请删除通行权限后再试!");
Collection<Long> e8Ids = list.stream()
.map(ResidentPersonVo::getEEightId)
.filter(Objects::nonNull)
.toList();
boolean auth = remoteSisAuth.deletePersonAuth(ids, e8Ids);
Assert.isTrue(auth, "删除授权记录失败!");
}
return baseMapper.deleteByIds(ids) > 0;
}
@@ -226,7 +277,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
* @return List<ResidentPersonVo>
*/
@Override
public List<ResidentPersonVo> queryUnAuthPerson(){
public List<ResidentPersonVo> queryUnAuthPerson() {
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
lqw.isNotNull(ResidentPerson::getImg)
.ne(ResidentPerson::getImg, "")