用户管理导入修改、从业人员 人员类型支持多选

dev
277151821@qq.com 2024-04-29 08:35:26 +08:00
parent 8a5e062d2c
commit 58fc5c5043
7 changed files with 338 additions and 5 deletions

View File

@ -2778,6 +2778,17 @@ public class UsersController extends BaseController {
pd.put("AUTHENTICATION", "0"); pd.put("AUTHENTICATION", "0");
userInfoService.delete(pd); userInfoService.delete(pd);
userInfoService.save(pd); userInfoService.save(pd);
PageData pdd = new PageData();
pdd.put("USER_ID", pd.getString("USER_ID"));
userInfoService.delUserInfoPersonnelType(pdd);
String[] PERSONNEL_TYPES = pd.getString("PERSONNEL_TYPE").split(",");
for (String str : PERSONNEL_TYPES) {
pdd.put("ID", Warden.get32UUID());
pdd.put("PERSONNEL_TYPE", str);
userInfoService.addUserInfoPersonnelType(pdd);
}
// 如果修改了部门/岗位,将该用户所有清单都删除 // 如果修改了部门/岗位,将该用户所有清单都删除
if (pd.get("OPERATIONTYPE") != null && pd.get("OPERATIONTYPE").toString() != null && Tools.notEmpty(pd.get("OPERATIONTYPE").toString())) { if (pd.get("OPERATIONTYPE") != null && pd.get("OPERATIONTYPE").toString() != null && Tools.notEmpty(pd.get("OPERATIONTYPE").toString())) {
List<PageData> listIds = listManagerService.listListByUser(pd); List<PageData> listIds = listManagerService.listListByUser(pd);
@ -3038,4 +3049,281 @@ public class UsersController extends BaseController {
map.put("result", errInfo); map.put("result", errInfo);
return map; return map;
} }
/**
* EXCEL
*
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value = "/readExcel4")
// // @RequiresPermissions("fromExcel")
@SuppressWarnings("unchecked")
@ResponseBody
@Transactional
@LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "从EXCEL导入到数据库")
public Object readExcel4(@RequestParam(value = "FFILE", required = false) MultipartFile file) throws Exception {
Map<String, String> map = new HashMap<String, String>();
String errInfo = "success";
StringBuffer errorStr = new StringBuffer();
if (null != file && !file.isEmpty()) {
File tempFile = new File(file.getOriginalFilename()); //新建file
FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File
List<PageData> listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始0:从第A列开始0:第0个sheet
/**
* var0 :
* var1 :
* var2 :
* var3 :
* var4 :
* var5 :
*/
List<String> header = new ArrayList<String>();
header.add("部门");
header.add("岗位");
header.add("手机号");
header.add("姓名");
header.add("身份证号");
header.add("人员类型");
try {
if (listPd.size() > 0 && listPd.size() <= 1000) {
/** 获取企业下的所有部门信息*/
PageData departPd = new PageData();
departPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userInfoMap = usersService.getUserCardNoAll(departPd);
HashMap<String, String> userInfos = new HashMap<>();
for (PageData pageData : userInfoMap) {
userInfos.put(pageData.getString("CARDNO"), pageData.getString("USERNAME"));
}
List<PageData> departList = departmentService.listAll(departPd);
Map<String, Object> departMap = new HashMap<String, Object>();
for (PageData pageData : departList) {
departMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData);
}
/** 获取所有岗位信息 */
PageData postPd = new PageData();
postPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> postList = postService.listAll(postPd);
Map<String, Map<String, Object>> postMap = new HashMap<>(); //部门id岗位map
for (PageData pageData : postList) {
Map<String, Object> postValMap = new HashMap<>();
String postDept = pageData.getString("DEPARTMENT_ID");
if (postMap.containsKey(postDept)) {
postValMap = postMap.get(postDept);
}
postValMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData);
postMap.put(postDept, postValMap);
}
/** 获取所有岗位信息结束 */
/** 获取所有用户信息 用于判断姓名是否重复 */
PageData userPd = new PageData();
userPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userList = usersService.findUserNameAll(userPd);
List<PageData> userEList = usersService.findAllUser(userPd);
Map<String, String> userMap = new HashMap<>();
Map<String, Object> emailMap = new HashMap<>();
for (PageData pageData : userList) {
userMap.put(pageData.getString("USERNAME"), JSON.toJSONString(pageData));
}
for (PageData pageData : userEList) {
emailMap.put(pageData.getString("USERNAME"), "");
}
PageData rolePd = new PageData();
rolePd.put("ISMAIN", "0");
rolePd.put("PARENT_ID", Jurisdiction.getVIPLEVEL());
rolePd.put("ROLE_NAME", "个人账号");
PageData role = roleService.findByPidAndMain(rolePd);
if (Tools.isEmpty(role)) {
errorStr.append("未找到默认角色信息!请联系管理员");
map.put("result", errInfo); //返回结果
map.put("msg", ""); //返回结果
return map;
}
/**
*
* excel
*
* Page
*
*
*/
Map<String, Object> hasUserNameChongfu = new HashMap<>();//判断重复数据
Map<String, Object> emailChongfu = new HashMap<>();//判断重复数据
Integer number = 0;//行数,用于提示用户
List<PageData> addUserList = new ArrayList<>();
List<PageData> editUserList = new ArrayList<>();
for (PageData lpd : listPd) {
number++;
for (int i = 0; i < 6; i++) {
if (Tools.isEmpty(lpd.get("var" + i))) {
errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n");
}
}
String dept = Tools.isEmpty(lpd.get("var0")) ? "" : Tools.excelHandle(lpd.get("var0"));//部门
String postName = Tools.isEmpty(lpd.get("var1")) ? "" : lpd.get("var1").toString();//岗位
String userName = Tools.isEmpty(lpd.get("var2")) ? "" : lpd.get("var2").toString();//手机号
Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX);
Matcher matcher = patternPhone.matcher(lpd.getString("var2"));
if (!matcher.matches()) {
errorStr.append("第" + number + "行,");
errorStr.append("手机号格式不正确,请重新确认数据;\n");
continue;
}
String name = Tools.isEmpty(lpd.get("var3")) ? "" : lpd.get("var3").toString();//姓名
String IDNumber = Tools.isEmpty(lpd.get("var4")) ? "" : lpd.get("var4").toString();//身份证号
Pattern patternCard = Pattern.compile(RegexPatterns.USERID_CARD);
Matcher matchercard = patternCard.matcher(lpd.getString("var4"));
if (!matchercard.matches()) {
errorStr.append("第" + number + "行,");
errorStr.append("身份证号格式不正确,请重新确认数据;\n");
continue;
}
String PERSONNEL_TYPE = Tools.isEmpty(lpd.get("var5")) ? "" : lpd.get("var5").toString();//人员类型
PageData renyuanleixing = new PageData();
if (!Tools.isEmpty(PERSONNEL_TYPE)) {//人员类型
renyuanleixing = dictionariesService.findByName(PERSONNEL_TYPE, "0b62f92b0b624aab8e89a77304a64d5e");//人员类型
if (null == renyuanleixing) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到人员类型信息,请重新确认数据;\n");
continue;
}
}
/** 部门信息 **/
String departId = "";
if (departMap.containsKey(dept)) {
PageData depart = (PageData) departMap.get(dept);
departId = depart.get("DEPARTMENT_ID").toString();
} else {
errorStr.append("第" + number + "行,部门信息错误,系统未找到该部门,请重新确认数据;\n");
continue;
}
/** 部门信息 结束**/
/** 岗位 **/
Map<String, Object> postValMap = postMap.get(departId);//这个部门下的所有岗位信息
String postId = "";
if (postValMap != null) {
PageData o = (PageData) postValMap.get(postName);
if (o != null) {
postId = o.getString("POST_ID");
}
}
/** 岗位 结束**/
if (hasUserNameChongfu.containsKey(userName)) {
errorStr.append("第" + number + "行,");
errorStr.append("手机号重复,请重新确认数据;\n");
continue;
}
hasUserNameChongfu.put(userName, name);
PageData user = new PageData();
user.put("USER_ID", this.get32UUID());
user.put("USERNAME", userName);
user.put("USER_ID_CARD", IDNumber);
user.put("PERSONNEL_TYPE", renyuanleixing.get("DICTIONARIES_ID"));
user.put("PASSWORD", new SimpleHash("SHA-1", userName, "Aa@123456").toString());
user.put("NAME", name);
user.put("CARDNO", "");
user.put("ROLE_ID", role.getString("ROLE_ID"));
user.put("LAST_LOGIN", "");
user.put("IP", "");
user.put("STATUS", "0");
user.put("BZ", "");
user.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,");
user.put("EMAIL", "");
user.put("NUMBER", "");
user.put("PHONE", "");
user.put("ROLE_IDS", "");
user.put("DEPARTMENT_ID", departId);
user.put("POST_ID", postId);
user.put("ISMAIN", "0");
user.put("FUN_IDS", "");
user.put("RIGHTS", "788664966448");
user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
user.put("ISSTUDENT", "0");// 在线学习情况
user.put("DURATION", "-1");// 工作状态持
if (userMap.containsKey(userName)) {
PageData useredit = JSON.parseObject(userMap.get(userName), PageData.class);
useredit.put("NAME", name);
useredit.put("CARDNO", "");
useredit.put("USER_ID_CARD", IDNumber);
useredit.put("PERSONNEL_TYPE", renyuanleixing.get("DICTIONARIES_ID"));
useredit.put("ROLE_ID", role.getString("ROLE_ID"));
useredit.put("LAST_LOGIN", "");
useredit.put("IP", "");
useredit.put("STATUS", "0");
useredit.put("BZ", "");
useredit.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,");
useredit.put("EMAIL", "");
useredit.put("NUMBER", "");
useredit.put("PHONE", "");
useredit.put("ROLE_IDS", "");
useredit.put("DEPARTMENT_ID", departId);
useredit.put("POST_ID", postId);
useredit.put("ISMAIN", "0");
useredit.put("FUN_IDS", "");
useredit.put("RIGHTS", "788664966448");
useredit.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
useredit.put("ISSTUDENT", "0");// 在线学习情况
useredit.put("DURATION", "-1");// 工作状态持
editUserList.add(useredit);
} else {
addUserList.add(user);
}
}
if (Tools.isEmpty(errorStr.toString())) {
for (PageData pageData : addUserList) {
usersService.saveUser(pageData);
}
for (PageData pageData : editUserList) {
// if (PLSUtil.editUser(pageData)) {
usersService.editUser(pageData);
// }
}
errorStr.append("成功导入" + addUserList.size() + "条数据!");
errorStr.append("成功修改" + editUserList.size() + "条数据!");
} else {
errInfo = "error";
}
FileUtils.deleteQuietly(tempFile);//删除临时文件
} else {
map.put("result", "error"); //返回结果
if(listPd.size() > 1000){
map.put("msg", "Excel数据大于1000条不支持上传请检查数据后重新上传");
} else {
map.put("msg", "Excel数据为空请检查数据后重新上传");
}
FileUtils.deleteQuietly(tempFile);//删除临时文件
return map;
}
} catch (Exception e) {
map.put("result", "fail"); //返回结果
map.put("msg", e.toString());
e.printStackTrace();
return map;
}
}
map.put("result", errInfo); //返回结果
map.put("msg", errorStr.toString()); //返回结果
map.put("isExcel", "1"); //返回类型
map.put("resultStr", errorStr.toString());
return map;
}
} }

View File

@ -94,5 +94,8 @@ public interface UserInfoMapper{
* @throws Exception * @throws Exception
*/ */
void editUserInfo(PageData pd); void editUserInfo(PageData pd);
void delUserInfoPersonnelType(PageData pd);
void addUserInfoPersonnelType(PageData pd);
} }

View File

@ -83,6 +83,10 @@ public interface UserInfoService{
void editAuthentication(PageData pd) throws Exception; void editAuthentication(PageData pd) throws Exception;
void editUserInfo(PageData user) throws Exception; void editUserInfo(PageData user) throws Exception;
public void delUserInfoPersonnelType(PageData pd)throws Exception;
public void addUserInfoPersonnelType(PageData pd)throws Exception;
} }

View File

@ -149,5 +149,13 @@ public class UserInfoServiceImpl implements UserInfoService {
public void editUserInfo(PageData pd) throws Exception { public void editUserInfo(PageData pd) throws Exception {
userinfoMapper.editUserInfo(pd); userinfoMapper.editUserInfo(pd);
} }
public void delUserInfoPersonnelType(PageData pd)throws Exception{
userinfoMapper.delUserInfoPersonnelType(pd);
}
public void addUserInfoPersonnelType(PageData pd)throws Exception{
userinfoMapper.addUserInfoPersonnelType(pd);
}
} }

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.zcloud.entity.Page; import com.zcloud.entity.Page;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.entity.system.User; import com.zcloud.entity.system.User;
import com.zcloud.mapper.datasource.system.UserInfoMapper;
import com.zcloud.mapper.datasource.system.UsersMapper; import com.zcloud.mapper.datasource.system.UsersMapper;
import com.zcloud.service.corp.CorpInfoService; import com.zcloud.service.corp.CorpInfoService;
import com.zcloud.service.system.*; import com.zcloud.service.system.*;
@ -1315,6 +1316,14 @@ public class UsersServiceImpl implements UsersService {
pd.put("WORKSTATUS", ""); // pd.put("WORKSTATUS", ""); //
pd.put("WORKPERIOD", ""); // pd.put("WORKPERIOD", ""); //
usersMapper.saveUser(pd); usersMapper.saveUser(pd);
String[] PERSONNEL_TYPES = pd.getString("PERSONNEL_TYPE").split(",");
for (String str : PERSONNEL_TYPES) {
PageData pdd = new PageData();
pdd.put("ID", Warden.get32UUID());
pdd.put("USER_ID", pd.getString("USER_ID"));
pdd.put("PERSONNEL_TYPE", str);
userInfoService.addUserInfoPersonnelType(pdd);
}
return ReturnMap.ok(); return ReturnMap.ok();
} }
return ReturnMap.error("保存失败"); return ReturnMap.error("保存失败");

View File

@ -166,8 +166,11 @@
du.NAME AS DUTIES_NAME, du.NAME AS DUTIES_NAME,
ti.NAME AS TITLE_NAME, ti.NAME AS TITLE_NAME,
w.NAME AS TYPE_OF_WORK_NAME, w.NAME AS TYPE_OF_WORK_NAME,
pt.NAME AS PERSONNEL_TYPE_NAME <!-- pt.NAME AS PERSONNEL_TYPE_NAME -->
(SELECT GROUP_CONCAT(dic.NAME SEPARATOR ',') from SYS_DICTIONARIES dic
where dic.PARENT_ID = '0b62f92b0b624aab8e89a77304a64d5e'
and dic.BIANMA like '%TRAFFIC_EMPLOYMENT_DRIVE%'
and FIND_IN_SET(dic.DICTIONARIES_ID,f.PERSONNEL_TYPE)) as PERSONNEL_TYPE_NAME
from from
<include refid="tableName"></include> f <include refid="tableName"></include> f
left join SYS_DICTIONARIES s on s.DICTIONARIES_ID = f.SEX left join SYS_DICTIONARIES s on s.DICTIONARIES_ID = f.SEX
@ -176,7 +179,7 @@
left join SYS_DICTIONARIES d on d.DICTIONARIES_ID = f.DEGREE_OF_EDUCATION left join SYS_DICTIONARIES d on d.DICTIONARIES_ID = f.DEGREE_OF_EDUCATION
left join SYS_DICTIONARIES_CORP du on du.DICTIONARIES_ID = f.DUTIES left join SYS_DICTIONARIES_CORP du on du.DICTIONARIES_ID = f.DUTIES
left join SYS_DICTIONARIES_CORP w on w.DICTIONARIES_ID = f.TYPE_OF_WORK left join SYS_DICTIONARIES_CORP w on w.DICTIONARIES_ID = f.TYPE_OF_WORK
left join SYS_DICTIONARIES pt on pt.DICTIONARIES_ID = f.PERSONNEL_TYPE <!-- left join SYS_DICTIONARIES pt on pt.DICTIONARIES_ID = f.PERSONNEL_TYPE -->
left join SYS_DICTIONARIES_CORP ti on ti.DICTIONARIES_ID = f.TITLE left join SYS_DICTIONARIES_CORP ti on ti.DICTIONARIES_ID = f.TITLE
where where
f.USER_ID = #{USER_ID} f.USER_ID = #{USER_ID}
@ -366,4 +369,18 @@
where where
USER_ID = #{USER_ID} USER_ID = #{USER_ID}
</update> </update>
<insert id="addUserInfoPersonnelType" parameterType="pd">
insert into sys_userinfo_personnel_type
(
ID,USER_ID,PERSONNEL_TYPE
) values (
#{ID},#{USER_ID},#{PERSONNEL_TYPE}
)
</insert>
<delete id="delUserInfoPersonnelType" parameterType="pd">
delete from sys_userinfo_personnel_type where USER_ID = #{USER_ID}
</delete>
</mapper> </mapper>

View File

@ -1690,7 +1690,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
,info.DUTIES ,info.DUTIES
,info.TITLE ,info.TITLE
,info.ENTRY_DATE ,info.ENTRY_DATE
,dic.`NAME` as PERSONNEL_TYPE_NAME <!-- ,dic.`NAME` as PERSONNEL_TYPE_NAME -->
,(SELECT GROUP_CONCAT(dic.NAME SEPARATOR ',') from SYS_DICTIONARIES dic
where dic.PARENT_ID = '0b62f92b0b624aab8e89a77304a64d5e'
and dic.BIANMA like '%TRAFFIC_EMPLOYMENT_DRIVE%'
and FIND_IN_SET(dic.DICTIONARIES_ID,info.PERSONNEL_TYPE)) as PERSONNEL_TYPE_NAME
,uc.USER_CORP_ID ,uc.USER_CORP_ID
,uc.APPLY_TYPE ,uc.APPLY_TYPE
,uc.APPLY_STATUS ,uc.APPLY_STATUS
@ -1701,7 +1705,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join BUS_SHIFTWORKRULES sw on sw.SHIFTWORKRULES_ID = u.SHIFTDUTYONE left join BUS_SHIFTWORKRULES sw on sw.SHIFTWORKRULES_ID = u.SHIFTDUTYONE
left join BUS_SHIFTWORKRULES swr on swr.SHIFTWORKRULES_ID = u.SHIFTDUTYTWO left join BUS_SHIFTWORKRULES swr on swr.SHIFTWORKRULES_ID = u.SHIFTDUTYTWO
left join SYS_USERINFO info on info.USER_ID = u.USER_ID left join SYS_USERINFO info on info.USER_ID = u.USER_ID
left join SYS_DICTIONARIES dic on dic.DICTIONARIES_ID = info.PERSONNEL_TYPE <!-- left join SYS_DICTIONARIES dic on dic.DICTIONARIES_ID = info.PERSONNEL_TYPE -->
left join ( left join (
SELECT t1.USER_CORP_ID, t1.CORPINFO_ID, t1.USER_ID, t1.APPLY_TYPE, t1.APPLY_STATUS, t1.ISDELETE SELECT t1.USER_CORP_ID, t1.CORPINFO_ID, t1.USER_ID, t1.APPLY_TYPE, t1.APPLY_STATUS, t1.ISDELETE
FROM SYS_USER_CORP t1 FROM SYS_USER_CORP t1