fix(sis): 优化人脸照片同步和授权记录更新逻辑
This commit is contained in:
@@ -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;
|
||||
@@ -159,15 +160,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, "");
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +272,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, "")
|
||||
|
Reference in New Issue
Block a user