相关人员名单导入--忽略大小写

This commit is contained in:
zhn
2022-10-12 10:32:05 +08:00
parent d7aaf663f8
commit c40f5f1b7f
@@ -14,9 +14,11 @@ import com.jero.common.util.RedisUtil;
import com.jero.common.util.TokenUtils; import com.jero.common.util.TokenUtils;
import com.jero.modules.dummy.service.impl.DummyInventoryInfoEOServiceImpl; import com.jero.modules.dummy.service.impl.DummyInventoryInfoEOServiceImpl;
import com.jero.modules.enums.DictCodeEnum; import com.jero.modules.enums.DictCodeEnum;
import com.jero.modules.ocr.entity.User;
import com.jero.modules.project.entity.ProjectLibraryBase; import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectRelatedPersonnel; import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.enums.ProjectInventoryFieldEnum; import com.jero.modules.project.enums.ProjectInventoryFieldEnum;
import com.jero.modules.project.enums.ProjectRoleEnum;
import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper; import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper;
import com.jero.modules.project.service.IProjectRelatedPersonnelService; import com.jero.modules.project.service.IProjectRelatedPersonnelService;
import com.jero.modules.system.entity.SysDictItem; import com.jero.modules.system.entity.SysDictItem;
@@ -967,6 +969,11 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
*/ */
@Override @Override
public Result<?> oppositeDisposeData(List<ProjectRelatedPersonnel> records, String projectId, String cut) { public Result<?> oppositeDisposeData(List<ProjectRelatedPersonnel> records, String projectId, String cut) {
//查询所有的用户
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
wrapper.select(SysUser::getUsername,SysUser::getId);
List<SysUser> userList = sysUserService.list(wrapper);
Result<?> result = new Result<>(); Result<?> result = new Result<>();
int row=3; int row=3;
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
@@ -1021,15 +1028,18 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
List<String> lawEngineerNameList = Arrays.asList(projectRelatedPersonnel.getLawEngineerName().split(",")); List<String> lawEngineerNameList = Arrays.asList(projectRelatedPersonnel.getLawEngineerName().split(","));
if (CollectionUtils.isNotEmpty(lawEngineerNameList) && StringUtils.isNotBlank(lawEngineerNameList.get(0))) { if (CollectionUtils.isNotEmpty(lawEngineerNameList) && StringUtils.isNotBlank(lawEngineerNameList.get(0))) {
lawEngineerNameList = lawEngineerNameList.stream().distinct().collect(Collectors.toList()); lawEngineerNameList = lawEngineerNameList.stream().distinct().collect(Collectors.toList());
lawEngineerUsers=sysUserService.queryUserIdListByNameList(lawEngineerNameList); //验证导入的相关人员
if(lawEngineerUsers.size()!=lawEngineerNameList.size()){ lawEngineerUsers = personnelMatch(userList, lawEngineerNameList, message, ProjectRoleEnum.REGULATI_ENGINEER.getValue(), cut, row);
//中英切换提示语
if(CutEnum.CN.getValue().equals(cut)) { // lawEngineerUsers=sysUserService.queryUserIdListByNameList(lawEngineerNameList);
message.append("导入的法规工程师姓名有误,请检查第" + row + ""); // if(lawEngineerUsers.size()!=lawEngineerNameList.size()){
}else{ // //中英切换提示语
message.append("The imported law engineer is wrong.Please check line " + row ); // if(CutEnum.CN.getValue().equals(cut)) {
} // message.append("导入的法规工程师姓名有误,请检查第" + row + "行");
} // }else{
// message.append("The imported law engineer is wrong.Please check line " + row );
// }
// }
} }
if(CollectionUtils.isNotEmpty(lawEngineerUsers)) { if(CollectionUtils.isNotEmpty(lawEngineerUsers)) {
@@ -1055,15 +1065,18 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
List<String> engineeringInterfacePersonNameList = Arrays.asList(projectRelatedPersonnel.getEngineeringInterfacePersonName().split(",")); List<String> engineeringInterfacePersonNameList = Arrays.asList(projectRelatedPersonnel.getEngineeringInterfacePersonName().split(","));
if (CollectionUtils.isNotEmpty(engineeringInterfacePersonNameList) && StringUtils.isNotBlank(engineeringInterfacePersonNameList.get(0))) { if (CollectionUtils.isNotEmpty(engineeringInterfacePersonNameList) && StringUtils.isNotBlank(engineeringInterfacePersonNameList.get(0))) {
engineeringInterfacePersonNameList = engineeringInterfacePersonNameList.stream().distinct().collect(Collectors.toList()); engineeringInterfacePersonNameList = engineeringInterfacePersonNameList.stream().distinct().collect(Collectors.toList());
engineeringInterfacePersonUsers=sysUserService.queryUserIdListByNameList(engineeringInterfacePersonNameList); //验证导入的相关人员
if(engineeringInterfacePersonUsers.size()!=engineeringInterfacePersonNameList.size()){ engineeringInterfacePersonUsers = personnelMatch(userList, engineeringInterfacePersonNameList, message, ProjectRoleEnum.ENGINEERING_INTERFACE_PERSON.getValue(), cut, row);
//中英切换提示语
if(CutEnum.CN.getValue().equals(cut)) { // engineeringInterfacePersonUsers=sysUserService.queryUserIdListByNameList(engineeringInterfacePersonNameList);
message.append("导入的工程接口人姓名有误,请检查第" + row + ""); // if(engineeringInterfacePersonUsers.size()!=engineeringInterfacePersonNameList.size()){
}else{ // //中英切换提示语
message.append("The imported engineering interface person is wrong.Please check line " + row ); // if(CutEnum.CN.getValue().equals(cut)) {
} // message.append("导入的工程接口人姓名有误,请检查第" + row + "行");
} // }else{
// message.append("The imported engineering interface person is wrong.Please check line " + row );
// }
// }
} }
if(CollectionUtils.isNotEmpty(engineeringInterfacePersonUsers)) { if(CollectionUtils.isNotEmpty(engineeringInterfacePersonUsers)) {
@@ -1090,8 +1103,13 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
//校验是否为项目基础表设定的认证工程师 //校验是否为项目基础表设定的认证工程师
List<ProjectRelatedPersonnel> baseCertificationEngineerList = queryCertificationEngineer(projectId); List<ProjectRelatedPersonnel> baseCertificationEngineerList = queryCertificationEngineer(projectId);
List<String> baseCertificationEngineerNameList = baseCertificationEngineerList.stream().map(e -> e.getCertificationEngineerName()).collect(Collectors.toList()); List<String> baseCertificationEngineerNameList = baseCertificationEngineerList.stream().map(e -> e.getCertificationEngineerName()).collect(Collectors.toList());
//转为小写后在判断
List<String> baseCertificationEngineerNameListTemp = new ArrayList<>();
for (String s : baseCertificationEngineerNameList) {
baseCertificationEngineerNameListTemp.add(s.toLowerCase());
}
for(String certificationEngineerName : certificationEngineerNameList){ for(String certificationEngineerName : certificationEngineerNameList){
if(!baseCertificationEngineerNameList.contains(certificationEngineerName)){ if(!baseCertificationEngineerNameListTemp.contains(certificationEngineerName.toLowerCase())){
//中英切换提示语 //中英切换提示语
if(CutEnum.CN.getValue().equals(cut)) { if(CutEnum.CN.getValue().equals(cut)) {
message.append("导入的认证工程师姓名不属于该项目,请检查第" + row + ""); message.append("导入的认证工程师姓名不属于该项目,请检查第" + row + "");
@@ -1101,18 +1119,32 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
break; break;
} }
} }
// for(String certificationEngineerName : certificationEngineerNameList){
// if(!baseCertificationEngineerNameList.contains(certificationEngineerName.toLowerCase())){
// //中英切换提示语
// if(CutEnum.CN.getValue().equals(cut)) {
// message.append("导入的认证工程师姓名不属于该项目,请检查第" + row + "行");
// }else {
// message.append("The imported certified engineer name does not belong to this project..Please check line " + row );
// }
// break;
// }
// }
if (CollectionUtils.isNotEmpty(certificationEngineerNameList) && StringUtils.isNotBlank(certificationEngineerNameList.get(0))) { if (CollectionUtils.isNotEmpty(certificationEngineerNameList) && StringUtils.isNotBlank(certificationEngineerNameList.get(0))) {
certificationEngineerNameList = certificationEngineerNameList.stream().distinct().collect(Collectors.toList()); certificationEngineerNameList = certificationEngineerNameList.stream().distinct().collect(Collectors.toList());
certificationEngineerUsers=sysUserService.queryUserIdListByNameList(certificationEngineerNameList); //验证导入的相关人员
if(certificationEngineerUsers.size()!=certificationEngineerNameList.size()){ certificationEngineerUsers = personnelMatch(userList, certificationEngineerNameList, message, ProjectRoleEnum.ENGINEERING_INTERFACE_PERSON.getValue(), cut, row);
//中英切换提示语
if(CutEnum.CN.getValue().equals(cut)) { // certificationEngineerUsers=sysUserService.queryUserIdListByNameList(certificationEngineerNameList);
message.append("导入的认证工程师姓名有误,请检查第" + row + ""); // if(certificationEngineerUsers.size()!=certificationEngineerNameList.size()){
}else { // //中英切换提示语
message.append("The imported certification engineer is wrong.Please check line " + row ); // if(CutEnum.CN.getValue().equals(cut)) {
} // message.append("导入的认证工程师姓名有误,请检查第" + row + "行");
} // }else {
// message.append("The imported certification engineer is wrong.Please check line " + row );
// }
// }
} }
if(CollectionUtils.isNotEmpty(certificationEngineerUsers)) { if(CollectionUtils.isNotEmpty(certificationEngineerUsers)) {
@@ -1156,6 +1188,66 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
return result; return result;
} }
/**
* 验证导入的相关人员
* @param userList 所有的用户
* @param personnelList 相关人员(法规工程师,认证工程师,工程接口人)
* @param message 异常信息拼接
* @param personnelType 人员类型
* @param cut 中英文切换
* @param row 行数
*/
public List<SysUser> personnelMatch(List<SysUser> userList,
List<String> personnelList,
StringBuilder message,
String personnelType,
String cut,
int row){
int count = 0;
//全部转为小写来匹配
List<SysUser> sysUserList = new ArrayList<>();
for (String personnel : personnelList) {
String personnelLower = personnel.toLowerCase();
for (SysUser sysUser : userList) {
String username = sysUser.getUsername();
String usernameLower = username.toLowerCase();
if(personnelLower.equals(usernameLower)){
sysUserList.add(sysUser);
count ++;
}
}
}
if(personnelList.size() != count){
//法规工程师异常提示语
if(ProjectRoleEnum.REGULATI_ENGINEER.getValue().equals(personnelType)){
if(CutEnum.CN.getValue().equals(cut)) {
message.append("导入的工程接口人姓名有误,请检查第" + row + "");
}else{
message.append("The imported engineering interface person is wrong.Please check line " + row );
}
}
//认证工程师异常提示语
if(ProjectRoleEnum.HOMOLOGATION_ENGINEER.getValue().equals(personnelType)){
if(CutEnum.CN.getValue().equals(cut)) {
message.append("导入的认证工程师姓名有误,请检查第" + row + "");
}else {
message.append("The imported certification engineer is wrong.Please check line " + row );
}
}
//工程接口人异常提示语
if(ProjectRoleEnum.ENGINEERING_INTERFACE_PERSON.getValue().equals(personnelType)){
if(CutEnum.CN.getValue().equals(cut)) {
message.append("导入的工程接口人姓名有误,请检查第" + row + "");
}else{
message.append("The imported engineering interface person is wrong.Please check line " + row );
}
}
}else{
return sysUserList;
}
return new ArrayList<>();
}
@Override @Override
public ProjectRelatedPersonnel queryByProjectIdAndDutyTerritory(String projectId, String dutyTerritory) { public ProjectRelatedPersonnel queryByProjectIdAndDutyTerritory(String projectId, String dutyTerritory) {
LambdaQueryWrapper<ProjectRelatedPersonnel> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProjectRelatedPersonnel> queryWrapper = new LambdaQueryWrapper<>();