|
|
|
@ -4,16 +4,19 @@ import cn.estsh.i3plus.core.api.iservice.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.ExcelTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.ReflexTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.FileContentTypeTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.UserDetailModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.UserExportModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.UserInfoImportModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
@ -24,18 +27,25 @@ import cn.estsh.impp.framework.boot.util.LocaleUtils;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.cglib.core.ReflectUtils;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.file.attribute.PosixFileAttributes;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -78,6 +88,15 @@ public class SysUserInfoController extends CoreBaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysRoleService sysRoleService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysOrganizeService sysOrganizeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PersonnelController personnelController;
|
|
|
|
|
|
|
|
|
|
@Resource(name = CommonConstWords.IMPP_REDIS_RES)
|
|
|
|
|
private ImppRedis redisRes;
|
|
|
|
|
|
|
|
|
@ -400,7 +419,7 @@ public class SysUserInfoController extends CoreBaseController {
|
|
|
|
|
@ApiOperation(value = "导出用户信息", notes = "导出用户信息")
|
|
|
|
|
public void exportSysUserInfo(SysUserInfo userInfo, Pager pager, HttpServletResponse response) throws Exception {
|
|
|
|
|
File file = null;
|
|
|
|
|
if(userInfo ==null ){
|
|
|
|
|
if (userInfo == null) {
|
|
|
|
|
userInfo = new SysUserInfo();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
@ -453,13 +472,326 @@ public class SysUserInfoController extends CoreBaseController {
|
|
|
|
|
i = bis.read(buffer);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error("用户日志导出异常", e);
|
|
|
|
|
LOGGER.error("用户信息导出异常", e);
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
FileUtils.deleteQuietly(file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/importTemplate")
|
|
|
|
|
@ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
|
|
|
public void getImportTemplate(HttpServletResponse response) {
|
|
|
|
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
|
|
|
|
try {
|
|
|
|
|
String filename = "userImportTemplate.xls";
|
|
|
|
|
SysPosition positionBean = new SysPosition();
|
|
|
|
|
positionBean.setOrganizeCode(AuthUtil.getOrganizeCode());
|
|
|
|
|
List<SysPosition> positionList = positionService.findAllByBaseBean(positionBean);
|
|
|
|
|
Map<String, String> positionMap = positionList.stream().collect(Collectors.toMap(position -> position.getPositionCode(), position -> position.getName(), (oldKey, newkey) -> oldKey));
|
|
|
|
|
|
|
|
|
|
Map<String, Map<String, String>> relatefildMap = new HashMap<>();
|
|
|
|
|
relatefildMap.put("岗位", positionMap);
|
|
|
|
|
byte[] templateBytes = excelTool.getImportTemplate(UserInfoImportModel.class, relatefildMap);
|
|
|
|
|
response.setContentType("application/force-download"); // 设置强制下载不打开
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment;fileName=" + filename); // 设置文件名
|
|
|
|
|
response.addHeader("Content-type", FileContentTypeTool.getContentType("xls"));
|
|
|
|
|
// 设置文件名
|
|
|
|
|
try {
|
|
|
|
|
InputStream inputStream = new ByteArrayInputStream(templateBytes);
|
|
|
|
|
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
int i = bis.read(buffer);
|
|
|
|
|
while (i != -1) {
|
|
|
|
|
os.write(buffer, 0, i);
|
|
|
|
|
i = bis.read(buffer);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error("用户信息导入模板下载异常", e);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/import")
|
|
|
|
|
@ApiOperation(value = "导用入户信息", notes = "导入用户信息")
|
|
|
|
|
public ResultBean importUserInfo(@RequestParam MultipartFile file) {
|
|
|
|
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
//1.读取数据
|
|
|
|
|
List<UserInfoImportModel> importModelList = excelTool.importDataAndConver(file.getOriginalFilename(), file.getInputStream(), UserInfoImportModel.class, UserInfoImportModel.class.getSimpleName());
|
|
|
|
|
List<ResultBean> faildList = new ArrayList<>();
|
|
|
|
|
LOGGER.debug("导入用户信息: 共读取数据{}条", importModelList.size());
|
|
|
|
|
if (ObjectUtils.isEmpty(importModelList)) {
|
|
|
|
|
return ResultBean.success();
|
|
|
|
|
}
|
|
|
|
|
//2.数据格式校验并去重
|
|
|
|
|
List<UserInfoImportModel> userInfoList = validateAndDistinc(importModelList, faildList);
|
|
|
|
|
|
|
|
|
|
//3.某些数据字段转换
|
|
|
|
|
SysPosition positionBean = new SysPosition();
|
|
|
|
|
String organizationCode = AuthUtil.getOrganizeCode();
|
|
|
|
|
positionBean.setOrganizeCode(organizationCode);
|
|
|
|
|
List<SysPosition> positionList = positionService.findAllByBaseBean(positionBean);
|
|
|
|
|
|
|
|
|
|
Map<String, String> positionMap = positionList.stream().collect(Collectors.toMap(position -> position.getPositionCode(), position -> String.valueOf(position.getId()), (oldKey, newkey) -> oldKey));
|
|
|
|
|
|
|
|
|
|
SysDepartment departmentBean = new SysDepartment();
|
|
|
|
|
departmentBean.setOrganizeCode(organizationCode);
|
|
|
|
|
List<SysDepartment> departmentList = departmentService.findAllByBaseBean(departmentBean);
|
|
|
|
|
//部门树
|
|
|
|
|
List<SysDepartment> departmentTree = new ArrayList<>();
|
|
|
|
|
//部门id的映射
|
|
|
|
|
Map<Long, SysDepartment> parentMap = departmentList.stream().collect(Collectors.toMap(el -> el.getId(), Function.identity()));
|
|
|
|
|
//构造全部部门的部门树
|
|
|
|
|
departmentList.forEach(el -> {
|
|
|
|
|
if (!ObjectUtils.isEmpty(el.getParentId())) {
|
|
|
|
|
if (CommonEnumUtil.PARENT.DEFAULT.getValue().longValue() == el.getParentId().longValue()) {
|
|
|
|
|
departmentTree.add(el);
|
|
|
|
|
} else {
|
|
|
|
|
SysDepartment parentSys = parentMap.get(el.getParentId());
|
|
|
|
|
if (!ObjectUtils.isEmpty(parentSys)) {
|
|
|
|
|
if (null == parentSys.getChildList()) {
|
|
|
|
|
parentSys.setChildList(new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
parentSys.getChildList().add(el);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// SysRole roleBean = new SysRole();
|
|
|
|
|
// roleBean.setOrganizeCode(organizationCode);
|
|
|
|
|
List<SysRole> roleList = sysRoleService.findAll();
|
|
|
|
|
Map<String, String> roleMap = roleList.stream().collect(Collectors.toMap(sysRole -> sysRole.getName(), sysRole -> String.valueOf(sysRole.getId()), (oldKey, newkey) -> oldKey));
|
|
|
|
|
|
|
|
|
|
List<ResultBean> successList = new ArrayList<>();
|
|
|
|
|
//4.插入数据
|
|
|
|
|
for (int i = 0; i < userInfoList.size(); i++) {
|
|
|
|
|
UserInfoImportModel el = userInfoList.get(i);
|
|
|
|
|
ResultBean<UserDetailModel> resultBean = converImportData(el, departmentTree, positionMap, roleMap);
|
|
|
|
|
if (ObjectUtils.isEmpty(resultBean) || !resultBean.success) {
|
|
|
|
|
faildList.add(resultBean);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
resultBean = personnelController.insertUserDetailModel(resultBean.getResultObject());
|
|
|
|
|
if (ObjectUtils.isEmpty(resultBean) || !resultBean.success) {
|
|
|
|
|
faildList.add(resultBean);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
successList.add(resultBean);
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("total", userInfoList.size());
|
|
|
|
|
resultMap.put("success", successList.size());
|
|
|
|
|
resultMap.put("fail", faildList.size());
|
|
|
|
|
resultMap.put("successList", successList);
|
|
|
|
|
resultMap.put("failList", faildList);
|
|
|
|
|
return new ResultBean().setSuccess(true).setResultMap(resultMap).build();
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param userInfoList 导入的全部数据
|
|
|
|
|
* @param faildList 数据重复的
|
|
|
|
|
* @return 不重复的数据
|
|
|
|
|
*/
|
|
|
|
|
private List<UserInfoImportModel> validateAndDistinc(List<UserInfoImportModel> userInfoList, List<ResultBean> faildList) {
|
|
|
|
|
//登录名
|
|
|
|
|
Set<String> loginNameSet = new HashSet<>();
|
|
|
|
|
//工号
|
|
|
|
|
Set<String> empNoSet = new HashSet<>();
|
|
|
|
|
List<UserInfoImportModel> successList = new ArrayList<>();
|
|
|
|
|
for (UserInfoImportModel el : userInfoList) {
|
|
|
|
|
if (loginNameSet.contains(el.getUserLoginName())) {
|
|
|
|
|
faildList.add(ResultBean.fail().setErrorMsg("登录名重复").setResultObject(el).build());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (empNoSet.contains(el.getInfoEmpNo())) {
|
|
|
|
|
faildList.add(ResultBean.fail().setErrorMsg("工号重复").setResultObject(el).build());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
loginNameSet.add(el.getUserLoginName());
|
|
|
|
|
empNoSet.add(el.getInfoEmpNo());
|
|
|
|
|
successList.add(el);
|
|
|
|
|
}
|
|
|
|
|
return successList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将导入的数据转换UserDetailModel
|
|
|
|
|
*
|
|
|
|
|
* @param userInfoImportModel 用户导入数据的model
|
|
|
|
|
* @param root 部门树
|
|
|
|
|
* @param positionMap 职位映射map
|
|
|
|
|
* @param roleMap 角色映射map
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ResultBean<UserDetailModel> converImportData(UserInfoImportModel userInfoImportModel, List<SysDepartment> root, Map<String, String> positionMap, Map<String, String> roleMap) {
|
|
|
|
|
|
|
|
|
|
UserDetailModel userDetailModel = new UserDetailModel();
|
|
|
|
|
userDetailModel.setInfoCardType(userInfoImportModel.getInfoCardType());
|
|
|
|
|
userDetailModel.setInfoCardNumber(userInfoImportModel.getInfoCardNumber());
|
|
|
|
|
userDetailModel.setInfoEmployeeType(userInfoImportModel.getInfoEmployeeType());
|
|
|
|
|
userDetailModel.setInfoBornDate(userInfoImportModel.getInfoBornDate());
|
|
|
|
|
userDetailModel.setInfoEmergencyPhone(userInfoImportModel.getInfoEmergencyPhone());
|
|
|
|
|
userDetailModel.setInfoEmergencyContact(userInfoImportModel.getInfoEmergencyContact());
|
|
|
|
|
userDetailModel.setInfoBirthplace(userInfoImportModel.getInfoBirthplace());
|
|
|
|
|
userDetailModel.setInfoEmpNo(userInfoImportModel.getInfoEmpNo());
|
|
|
|
|
userDetailModel.setInfoFamilyAddress(userInfoImportModel.getInfoFamilyAddress());
|
|
|
|
|
userDetailModel.setInfoGrade(userInfoImportModel.getInfoGrade());
|
|
|
|
|
userDetailModel.setInfoHobby(userInfoImportModel.getInfoHobby());
|
|
|
|
|
userDetailModel.setInfoJoinDate(userInfoImportModel.getInfoJoinDate());
|
|
|
|
|
userDetailModel.setInfoRace(userInfoImportModel.getInfoRace());
|
|
|
|
|
userDetailModel.setInfoName(userInfoImportModel.getInfoName());
|
|
|
|
|
userDetailModel.setInfoMarriage(userInfoImportModel.getInfoMarriage());
|
|
|
|
|
userDetailModel.setInfoSchool(userInfoImportModel.getInfoSchool());
|
|
|
|
|
userDetailModel.setInfoSex(userInfoImportModel.getInfoSex());
|
|
|
|
|
userDetailModel.setInfoSchoolEducation(userInfoImportModel.getInfoSchoolEducation());
|
|
|
|
|
|
|
|
|
|
userDetailModel.setUserEmail(userInfoImportModel.getUserEmail());
|
|
|
|
|
userDetailModel.setUserLoginName(userInfoImportModel.getUserLoginName());
|
|
|
|
|
userDetailModel.setUserLanguageCode(userInfoImportModel.getLanguageCode());
|
|
|
|
|
userDetailModel.setUserPhone(userInfoImportModel.getUserPhone());
|
|
|
|
|
|
|
|
|
|
//设置密码为默认值
|
|
|
|
|
userDetailModel.setUserLoginPassword(CommonConstWords.CONFIG_PWD_DEFAULT_PASSWORD);
|
|
|
|
|
SysOrganize sysOrganize = new SysOrganize();
|
|
|
|
|
sysOrganize.setOrganizeCode(AuthUtil.getOrganizeCode());
|
|
|
|
|
// SysOrganize result = sysOrganizeService.get(sysOrganize);
|
|
|
|
|
// if (ObjectUtils.isEmpty(result)) {
|
|
|
|
|
//
|
|
|
|
|
// return ResultBean.fail().setErrorMsg("组织不存在").setResultObject(userInfoImportModel).build();
|
|
|
|
|
// }
|
|
|
|
|
//转换部门id
|
|
|
|
|
//todo 可能有多个组织,导入时需要用“ , ”分割
|
|
|
|
|
// String[] infoDeparments = userInfoImportModel.getUserDepartmentNameRdds().trim().split(",");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (!StringUtils.hasText(userInfoImportModel.getInfoDepartmentNameRdds())) {
|
|
|
|
|
|
|
|
|
|
return ResultBean.fail().setErrorMsg("部门不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
String[] infoDeparments = userInfoImportModel.getInfoDepartmentNameRdds().trim().split("/");
|
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(infoDeparments)) {
|
|
|
|
|
|
|
|
|
|
return ResultBean.fail().setErrorMsg("部门不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
int mainDepartmentIndex = -1;
|
|
|
|
|
for (int i = 0; i < infoDeparments.length; i++) {
|
|
|
|
|
infoDeparments[i] = infoDeparments[i].trim();
|
|
|
|
|
if (infoDeparments[i].equals(userInfoImportModel.getInfoDepartmentNameRdd())) {
|
|
|
|
|
mainDepartmentIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mainDepartmentIndex == -1) {
|
|
|
|
|
|
|
|
|
|
return ResultBean.fail().setErrorMsg("主部门不在部门列表中").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
Long[] infoDeparmentIds = findDeparmentIds(root, infoDeparments);
|
|
|
|
|
if (ObjectUtils.isEmpty(infoDeparmentIds) || infoDeparmentIds.length != infoDeparments.length) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("部门格式错误").setResultObject(userInfoImportModel).build();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
userDetailModel.setInfoDepartmentId(String.valueOf(infoDeparmentIds[mainDepartmentIndex]));
|
|
|
|
|
userDetailModel.setInfoDepartmentIdList(Arrays.stream(infoDeparmentIds).map(el -> String.valueOf(el)).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(userInfoImportModel.getUserDepartmentNameRdds())) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("操作部门列表不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
//转换操作部门id
|
|
|
|
|
String[] userDeparments = userInfoImportModel.getUserDepartmentNameRdds().trim().split("/");
|
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(userDeparments)) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("操作部门不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
//主部门索引
|
|
|
|
|
mainDepartmentIndex = -1;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < userDeparments.length; i++) {
|
|
|
|
|
userDeparments[i] = userDeparments[i].trim();
|
|
|
|
|
if (userDeparments[i].equals(userInfoImportModel.getUserDepartmentNameRdd())) {
|
|
|
|
|
mainDepartmentIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mainDepartmentIndex == -1) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("主部门不在部门列表中").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
Long[] userDeparmentIds = findDeparmentIds(root, userDeparments);
|
|
|
|
|
if (ObjectUtils.isEmpty(userDeparmentIds) || userDeparmentIds.length != userDeparments.length) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("部门格式错误").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
userDetailModel.setUserDepartmentId(String.valueOf(userDeparmentIds[mainDepartmentIndex]));
|
|
|
|
|
userDetailModel.setUserDepartmentIdList(Arrays.stream(userDeparmentIds).map(el -> String.valueOf(el)).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
//转换角色id
|
|
|
|
|
if (!StringUtils.hasText(userInfoImportModel.getRoleNameRdds())) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("角色不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
String[] roles = userInfoImportModel.getRoleNameRdds().trim().split("/");
|
|
|
|
|
if (!ObjectUtils.isEmpty(roles)) {
|
|
|
|
|
userDetailModel.setUserRoleIdList(
|
|
|
|
|
Arrays.stream(roles).map(el -> roleMap.get(el.trim())).collect(Collectors.toList())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
//转换职位id
|
|
|
|
|
if (!StringUtils.hasText(userInfoImportModel.getPositionNameRdds())) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("职位不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
String[] positions = userInfoImportModel.getPositionNameRdds().trim().split("/");
|
|
|
|
|
if (!ObjectUtils.isEmpty(positions)) {
|
|
|
|
|
userDetailModel.setInfoPositionIdList(
|
|
|
|
|
Arrays.stream(positions).map(el -> positionMap.get(el.trim())).collect(Collectors.toList())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.hasText(userInfoImportModel.getPositionNameRdd())) {
|
|
|
|
|
return ResultBean.fail().setErrorMsg("主职位不能为空").setResultObject(userInfoImportModel).build();
|
|
|
|
|
}
|
|
|
|
|
userDetailModel.setInfoPositionId(positionMap.get(userInfoImportModel.getPositionNameRdd()));
|
|
|
|
|
|
|
|
|
|
return ResultBean.success().setResultObject(userDetailModel).build();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error("导入人员数据转换出错", e);
|
|
|
|
|
return ResultBean.fail(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据部门树查询部门id,返回部门数组
|
|
|
|
|
*
|
|
|
|
|
* @param root 部门树
|
|
|
|
|
* @param departmentNames 部门名称组成的数组
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private Long[] findDeparmentIds(List<SysDepartment> root, String[] departmentNames) {
|
|
|
|
|
if (ObjectUtils.isEmpty(root) || ObjectUtils.isEmpty(departmentNames)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
Long[] deparmentIds = new Long[departmentNames.length];
|
|
|
|
|
for (int i = 0; i < departmentNames.length; i++) {
|
|
|
|
|
int finalI = i;
|
|
|
|
|
SysDepartment sysDepartment = root.stream().filter(el -> departmentNames[finalI].equals(el.getName())).findFirst().orElse(null);
|
|
|
|
|
if (ObjectUtils.isEmpty(sysDepartment)) {
|
|
|
|
|
return deparmentIds;
|
|
|
|
|
}
|
|
|
|
|
deparmentIds[i] = sysDepartment.getId();
|
|
|
|
|
root = sysDepartment.getChildList();
|
|
|
|
|
if (ObjectUtils.isEmpty(root)) {
|
|
|
|
|
return deparmentIds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return deparmentIds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<Long> packUserInfo(SysUserInfo userInfo) {
|
|
|
|
|
ArrayList<Long> idList = new ArrayList<>();
|
|
|
|
|
if (userInfo.getOrganizeId() == null || userInfo.getOrganizeId() <= 0) {
|
|
|
|
@ -494,4 +826,5 @@ public class SysUserInfoController extends CoreBaseController {
|
|
|
|
|
return idList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|