dev:人员导入去除岗位必填的校验

main
SondonYong 2025-11-20 11:37:48 +08:00
parent 4bfbcdb7ab
commit 2848a33125
1 changed files with 19 additions and 11 deletions

View File

@ -203,9 +203,9 @@ public class UserE extends BaseE {
if(CollUtil.isEmpty(departmentList)){ if(CollUtil.isEmpty(departmentList)){
throw new BizException("该企业暂未存在部门信息,请添加部门后重新导入"); throw new BizException("该企业暂未存在部门信息,请添加部门后重新导入");
} }
if(CollUtil.isEmpty(postList)){ // if(CollUtil.isEmpty(postList)){
throw new BizException("该企业暂未存在岗位信息,请添加岗位后重新导入"); // throw new BizException("该企业暂未存在岗位信息,请添加岗位后重新导入");
} // }
Map<String, DepartmentE> departmentEMap = departmentList.stream().collect(Collectors.toMap(DepartmentE::getName, DepartmentE -> DepartmentE)); Map<String, DepartmentE> departmentEMap = departmentList.stream().collect(Collectors.toMap(DepartmentE::getName, DepartmentE -> DepartmentE));
@ -237,9 +237,10 @@ public class UserE extends BaseE {
} }
} }
// 岗位 // 岗位
if(StringUtils.isEmpty(entity.getPostName())){ if(StringUtils.isNotEmpty(entity.getPostName())){
errList.add("第" + (i+2) + "行所属岗位不能为空。"); if(CollUtil.isEmpty(postList)){
}else{ throw new BizException("该企业暂未存在岗位信息,请添加岗位后重新导入");
}
DepartmentE departmentE = departmentEMap.get(entity.getDepartmentName()); DepartmentE departmentE = departmentEMap.get(entity.getDepartmentName());
if(departmentE != null){ if(departmentE != null){
List<PostE> postListByDepartId = postList.stream().filter(post -> post.getDepartmentId().equals(departmentE.getId())).collect(Collectors.toList()); List<PostE> postListByDepartId = postList.stream().filter(post -> post.getDepartmentId().equals(departmentE.getId())).collect(Collectors.toList());
@ -252,8 +253,13 @@ public class UserE extends BaseE {
} }
} }
} }
} }
// if(StringUtils.isEmpty(entity.getPostName())){
// errList.add("第" + (i+2) + "行所属岗位不能为空。");
// }else{
//
//
// }
// 用户名 // 用户名
if(StringUtils.isEmpty(entity.getUsername())){ if(StringUtils.isEmpty(entity.getUsername())){
errList.add("第" + (i+2) + "行用户名不能为空。"); errList.add("第" + (i+2) + "行用户名不能为空。");
@ -297,10 +303,12 @@ public class UserE extends BaseE {
userE.setDepartmentName(entity.getDepartmentName()); userE.setDepartmentName(entity.getDepartmentName());
// 岗位 // 岗位
List<PostE> postListByDepartId = postList.stream().filter(post -> post.getDepartmentId().equals(departmentId)).collect(Collectors.toList()); if(StringUtils.isNotEmpty(entity.getPostName())){
Map<String, PostE> postEMap = postListByDepartId.stream().collect(Collectors.toMap(PostE::getPostName, PostE -> PostE)); List<PostE> postListByDepartId = postList.stream().filter(post -> post.getDepartmentId().equals(departmentId)).collect(Collectors.toList());
userE.setPostId(postEMap.get(entity.getPostName()).getId()); Map<String, PostE> postEMap = postListByDepartId.stream().collect(Collectors.toMap(PostE::getPostName, PostE -> PostE));
userE.setPostName(entity.getPostName()); userE.setPostId(postEMap.get(entity.getPostName()).getId());
userE.setPostName(entity.getPostName());
}
// 用户名 // 用户名
userE.setUsername(entity.getUsername()); userE.setUsername(entity.getUsername());