fix:人员导入增加excel手机号、姓名重复验证、人脸取消必填

This commit is contained in:
dzc committed 2025-03-31 17:28:02 +08:00
1 parent ae79956dcf
commit 8e7b2fab04
5 files changed
+70 -16

No files matched your search

@@ -65,6 +65,7 @@ import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.flow.task.dto.TaskDto;
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
@@ -541,6 +542,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String walletAutoCreate = ParamResolver.getStr("WALLET_AUTO_CREATE");
String userDefaultRole = ParamResolver.getStr("USER_DEFAULT_ROLE");
List<Long> roleIds = roleList.stream().filter(v -> ObjectUtil.equals(v.getRoleCode(), walletAutoCreate) || ObjectUtil.equals(v.getRoleCode(), userDefaultRole)).map(SysRole::getRoleId).toList();
// 用户手机号重复判断
List<String> userPoneList = excelList.stream().map(UserExcelFaceVo::getMobile).toList();
// 用户名重复判断
List<String> usernameList = excelList.stream().map(UserExcelFaceVo::getUsername).toList();
// 读取图片
Map<String, PictureData> images = ExcelTool.getPictureFromExcel(file, 1);
for (UserExcelFaceVo v : excelList) {
@@ -576,9 +581,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String key = String.valueOf(v.getLineNum() - 1);
face = images.getOrDefault(key, null);
}
if (ObjectUtil.isEmpty(face)) {
errorMsg.add("人脸照片为空");
// if (ObjectUtil.isEmpty(face)) {
// errorMsg.add("人脸照片为空");
// }
long userPhone = userPoneList.stream().filter(i -> ObjectUtil.equals(i, v.getMobile())).count();
if (userPhone > 1) {
errorMsg.add("用手机号 <" + v.getMobile() + "> 重复");
}
long repetitionUsername = usernameList.stream().filter(i -> ObjectUtil.equals(i, v.getUsername())).count();
if (repetitionUsername > 1) {
errorMsg.add("用户名 <" + v.getUsername() + "> 重复");
}
if (CollUtil.isEmpty(errorMsg)) {
insertExcelUser(v, deptId, roleIds, face);
} else {
@@ -638,7 +654,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 插入用户
Long usrId = this.saveUser(userDTO);
userDTO.setUserId(usrId);
insertExcelFace(userDTO, face);
// 更新人脸
if (ObjectUtil.isNotEmpty(face)) {
insertExcelFace(userDTO, face);
}
}
public void insertExcelFace(UserDTO user, PictureData face) {
@@ -1,5 +1,6 @@
package com.bsd.pjcloud.wallet.api.vo.rule;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -11,7 +12,7 @@ import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WalletRuleJoinVo extends WalletRuleJoinEntity {
public class WalletRuleJoinVo extends WalletRuleJoinEntity implements BaseDeptInterface {
/**
* 源钱包类型
@@ -30,4 +31,11 @@ public class WalletRuleJoinVo extends WalletRuleJoinEntity {
private String targetUniqueCode;
private String targetIcon;
/**
* 部门
*/
private Long deptId;
private String deptName;
}
@@ -70,7 +70,8 @@ public class WalletRuleJoinController {
@PostMapping
// @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_add')")
public R save(@RequestBody WalletRuleJoinDto dto) {
return R.ok(walletRuleJoinService.create(dto));
walletRuleJoinService.create(dto);
return R.ok();
}
@Operation(summary = "修改钱包规则配置", description = "修改钱包规则配置")
@@ -21,7 +21,7 @@ public interface WalletRuleJoinService extends IService<WalletRuleJoinEntity> {
/**
* 新增
*/
Long create(WalletRuleJoinEntity dto);
void create(WalletRuleJoinDto dto);
/**
* 修改
@@ -4,10 +4,16 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleJoinDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinVo;
import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleJoinMapper;
import com.bsd.pjcloud.wallet.service.WalletRuleJoinService;
@@ -18,6 +24,8 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 钱包规则配置
@@ -30,31 +38,39 @@ public class WalletRuleJoinServiceImpl extends ServiceImpl<WalletRuleJoinMapper,
private final WalletTypeService walletTypeService;
private final RemoteDeptService remoteDeptService;
/**
* 权限分页查询
*/
@Override
public Page<WalletRuleJoinVo> scopeJoinPage(Page page, WalletRuleJoinDto dto, DataScope dataScope) {
return baseMapper.scopeJoinPage(page, dto, dataScope);
Page<WalletRuleJoinVo> pageList = baseMapper.scopeJoinPage(page, dto, dataScope);
disposeList(pageList.getRecords(), dto);
return pageList;
}
/**
* 新增
*/
@Override
public Long create(WalletRuleJoinEntity dto) {
if (existWalletRuleJoin(dto)) {
throw new RuntimeException("绑定类型不能重复");
}
public void create(WalletRuleJoinDto dto) {
if (areWalletIdsDistinct(dto)) {
throw new RuntimeException("源钱包类型与目标钱包类型不能重复");
}
WalletTypeEntity targetMch = walletTypeService.getById(dto.getTargetWalletTypeId());
if (ObjectUtil.isEmpty(targetMch)) {
throw new RuntimeException("目标钱包类型不存在");
List<WalletRuleJoinEntity> saveList = new ArrayList<>();
for (Long v : dto.getTargetDeptIdList()) {
if (ObjectUtil.isEmpty(v)) continue;
WalletRuleJoinEntity item = BeanUtils.toBean(dto, WalletRuleJoinEntity.class);
item.setTargetDeptId(v);
if (existWalletRuleJoin(dto)) {
// 查询部门
SysDept sysDept = remoteDeptService.getDeptByDeptId(v).getData();
throw new RuntimeException(sysDept.getName() + "部门绑定类型不能重复");
}
saveList.add(item);
}
baseMapper.insert(dto);
return dto.getId();
baseMapper.insert(saveList);
}
/**
@@ -118,4 +134,14 @@ public class WalletRuleJoinServiceImpl extends ServiceImpl<WalletRuleJoinMapper,
}
return ObjectUtil.equals(dto.getSourceWalletTypeId(), dto.getTargetWalletTypeId());
}
private void disposeList(List<WalletRuleJoinVo> list, WalletRuleJoinDto dto) {
if (ObjectUtil.isEmpty(list)) return;
// 部门
List<Long> deptIds = list.stream().map(WalletRuleJoinVo::getTargetDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(list, deptList.getData());
}
}
}