integrated_traffic/src/main/java/com/zcloud/controller/system/UsersController.java

2333 lines
94 KiB
Java
Raw Normal View History

2024-01-03 09:48:43 +08:00
package com.zcloud.controller.system;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.EmployeeData;
2024-01-03 09:48:43 +08:00
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.system.Dictionaries;
import com.zcloud.entity.system.Role;
import com.zcloud.logs.LogAnno;
2024-01-04 10:07:06 +08:00
import com.zcloud.service.check.CheckRecordService;
import com.zcloud.service.check.ListManagerService;
import com.zcloud.service.corp.CorpInfoService;
2024-01-03 11:04:18 +08:00
import com.zcloud.service.notice.NoticeManagementService;
2024-01-04 10:07:06 +08:00
import com.zcloud.service.statistics.ListStatisticsService;
2024-01-03 09:48:43 +08:00
import com.zcloud.service.system.*;
2024-01-03 11:04:18 +08:00
import com.zcloud.util.*;
2024-01-03 09:48:43 +08:00
import net.sf.json.JSONArray;
2024-01-03 11:04:18 +08:00
import org.apache.commons.io.FileUtils;
2024-01-03 09:48:43 +08:00
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
2024-01-03 09:48:43 +08:00
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import java.io.File;
import java.util.*;
2024-01-03 11:04:18 +08:00
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2024-01-03 09:48:43 +08:00
/**
*
* luoxiaobao
* www.qdkjchina.com
*/
@Controller
@RequestMapping("/user")
public class UsersController extends BaseController {
@Autowired
private UsersService usersService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private RoleService roleService;
@Autowired
private UeditorService ueditorService;
@Autowired
2024-01-03 11:04:18 +08:00
private NoticeManagementService noticemanagementService;
@Autowired
2024-01-03 09:48:43 +08:00
private FHlogService FHLOG;
@Autowired
private DepartmentService departmentService;
@Autowired
private PostService postService;
@Autowired
private CorpInfoService corpInfoService;
@Autowired
private ListManagerService listManagerService;
@Autowired
private ListStatisticsService listStatisticsService;
@Autowired
private CheckRecordService checkrecordService;
@Autowired
private DictionariesService dictionariesService;
@Autowired
private DictionariesCorpService dictionariesCorpService;
@Autowired
private ImgFilesService imgfilesService;
/**
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/list")
@RequiresPermissions("user:list")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "教育培训",menuServer= "签字信息管理",instructionsOperate = "签字信息管理",instructionsType = "用户列表")
2024-01-03 09:48:43 +08:00
public Object listUsers(Page page)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
/*检索条件*/
String ROLE_ID = pd.getString("ROLE_ID"); //角色ID
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
String DEPARTMENT_ID = pd.getString("DEPARTMENT_ID"); //关键词检索条件
if(Tools.notEmpty(DEPARTMENT_ID))pd.put("DEPARTMENT_ID", DEPARTMENT_ID.trim());
2024-01-03 11:04:18 +08:00
String STARTTIME = pd.getString("STARTTIME"); //开始时间
2024-01-03 09:48:43 +08:00
String ENDTIME = pd.getString("ENDTIME"); //结束时间
2024-01-03 11:04:18 +08:00
if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00");
2024-01-03 09:48:43 +08:00
if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00");
pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
page.setPd(pd);
2024-01-03 11:04:18 +08:00
pd.put("VIPLEVEL", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<PageData> userList = usersService.userlistPage(page); //列出用户列表
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
map.put("userList", userList);
map.put("roleList", roleList);
map.put("ROLE_ID", ROLE_ID);
map.put("page", page);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**(使)
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/listSelect")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "综合管理",menuServer= "特种设备",instructionsOperate = "设备管理",instructionsType = "用户列表")
2024-01-03 09:48:43 +08:00
public Object listSelect(Page page)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
/*检索条件*/
String ROLE_ID = pd.getString("ROLE_ID"); //角色ID
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
String DEPARTMENT_ID = pd.getString("DEPARTMENT_ID"); //关键词检索条件
if(Tools.notEmpty(DEPARTMENT_ID))pd.put("DEPARTMENT_ID", DEPARTMENT_ID.trim());
2024-01-03 11:04:18 +08:00
String STARTTIME = pd.getString("STARTTIME"); //开始时间
2024-01-03 09:48:43 +08:00
String ENDTIME = pd.getString("ENDTIME"); //结束时间
2024-01-03 11:04:18 +08:00
if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00");
2024-01-03 09:48:43 +08:00
if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00");
pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
page.setPd(pd);
List<PageData> userList = usersService.userSelectlistPage(page); //列出用户列表
map.put("userList", userList);
map.put("page", page);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @return
* @throws Exception
*/
@RequestMapping(value="/goAddUser")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "去新增用户页面")
2024-01-03 09:48:43 +08:00
public Object goAddUser()throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
2024-01-03 11:04:18 +08:00
pd = this.getPageData();
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
2024-01-03 11:04:18 +08:00
PageData cpd = new PageData();
cpd = this.getPageData();
cpd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
int allUser = usersService.getUserCount(cpd);
cpd=corpInfoService.findNumById(cpd);
map.put("USERS_NUM", cpd);
map.put("allUser", allUser);
2024-01-03 09:48:43 +08:00
map.put("roleList", roleList);
2024-01-03 11:04:18 +08:00
2024-01-03 09:48:43 +08:00
//获取部门下拉树
// List<PageData> zdepartmentPdList = new ArrayList<PageData>();
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
// PageData dept = new PageData();
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
// dept=this.departmentService.findById(dept);
List<PageData> zdepartmentPdList = new ArrayList<PageData>();
PageData dept = new PageData();
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
dept=this.departmentService.findByCorpId(dept);
String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID");
PageData node = new PageData();
node.put("id", dept.get("DEPARTMENT_ID"));
node.put("parentId", dept.get("PARENT_ID"));
node.put("name", dept.get("NAME"));
node.put("icon", "../../../assets/images/user.gif");
zdepartmentPdList.add(node);
JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList));
map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}"));
//获取岗位下拉
PageData post = new PageData();
post.put("DEPARTMENT_ID", ZDEPARTMENT_ID);
post.put("STATUS", 0);
List<PageData> postList = this.postService.listAll(post);
map.put("postList", postList);
map.put("result", errInfo);
return map;
}
/**()
* @return
* @throws Exception
*/
@RequestMapping(value="/goEditUser")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "教育培训",menuServer= "档案管理",instructionsOperate = "一人一档",instructionsType = "去修改用户页面(从系统用户页面修改)")
2024-01-03 09:48:43 +08:00
public Object goEditUser() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if("1".equals(pd.getString("USER_ID"))){return null;} //不能修改admin用户
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
2024-01-03 11:04:18 +08:00
pd.put("PARENT_ID", Jurisdiction.getVIPLEVEL());
pd.put("ISMAIN", "0");
List<PageData> userlist = roleService.findByPid(pd);
2024-01-03 09:48:43 +08:00
// //获取部门下拉树
// List<PageData> zdepartmentPdList = new ArrayList<PageData>();
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
// PageData dept = new PageData();
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
// dept=this.departmentService.findById(dept);
List<PageData> zdepartmentPdList = new ArrayList<PageData>();
PageData dept = new PageData();
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
dept=this.departmentService.findByCorpId(dept);
String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID");
PageData node = new PageData();
node.put("id", dept.get("DEPARTMENT_ID"));
node.put("parentId", dept.get("PARENT_ID"));
node.put("name", dept.get("NAME"));
node.put("icon", "../../../assets/images/user.gif");
zdepartmentPdList.add(node);
JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList));
map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}"));
String depname = null == dept?"请选择":dept.getString("NAME");
map.put("depname", null == depname?"请选择":depname);
pd = usersService.findById(pd); //根据ID读取
2024-01-03 11:04:18 +08:00
pd.put("ISSTUDENT", Boolean.valueOf(pd.getString("ISSTUDENT")));
2024-01-03 09:48:43 +08:00
PageData shiftDutyPeriod = new PageData();
shiftDutyPeriod.put("DURATION", pd.get("DURATION"));
shiftDutyPeriod.put("WORKSTATUS", pd.get("WORKSTATUS"));
shiftDutyPeriod.put("WORKPERIOD", pd.get("WORKPERIOD"));
String ROLE_IDS = pd.getString("ROLE_IDS"); //副职角色ID
if(Tools.notEmpty(ROLE_IDS)){
String arryROLE_ID[] = ROLE_IDS.split(",");
for(int i=0;i<roleList.size();i++){
Role role = roleList.get(i);
String roleId = role.getROLE_ID();
for(int n=0;n<arryROLE_ID.length;n++){
if(arryROLE_ID[n].equals(roleId)){
role.setRIGHTS("1"); //此时的目的是为了修改用户信息上,能看到副职角色都有哪些
break;
}
}
}
}
PageData userInfo = userInfoService.findById(pd); // 添加 用户详情 CERTIFICATE_INFORMATION 证书信息
2024-01-03 11:04:18 +08:00
List<PageData> userCerList = new ArrayList<PageData>();
2024-01-03 09:48:43 +08:00
if(null != userInfo){
PageData userCerPd = new PageData();
userCerPd.put("TYPE","18");
userCerPd.put("FOREIGN_KEY",pd.get("USER_ID"));
userCerList = imgfilesService.listAll(userCerPd);
pd.putAll(userInfo);
}
//获取岗位下拉
PageData post = new PageData();
post.put("DEPARTMENT_ID", ZDEPARTMENT_ID);
post.put("STATUS", 0);
List<PageData> postList = this.postService.listAll(post);
map.put("postList", postList);
map.put("pd", pd);
2024-01-03 11:04:18 +08:00
map.put("userList", userlist);
2024-01-03 09:48:43 +08:00
map.put("period", shiftDutyPeriod);
map.put("periodStr", shiftDutyPeriod.getString("DURATION")+','+shiftDutyPeriod.getString("WORKSTATUS")+','+shiftDutyPeriod.getString("WORKPERIOD"));
map.put("userCerList", userCerList);
map.put("roleList", roleList);
map.put("result", errInfo);
return map;
}
/**()
* @return
* @throws Exception
*/
@RequestMapping(value="/goEditMyInfo")
@ResponseBody
public Object goEditMyInfo() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
pd.put("USERNAME", Jurisdiction.getUsername());
2024-01-03 11:04:18 +08:00
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
2024-01-03 09:48:43 +08:00
pd = usersService.findByUsername(pd); //根据用户名读取
//获取部门下拉树
// List<PageData> zdepartmentPdList = new ArrayList<PageData>();
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
// PageData dept = new PageData();
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
// dept=this.departmentService.findById(dept);
//获取部门下拉树
List<PageData> zdepartmentPdList = new ArrayList<PageData>();
PageData dept = new PageData();
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
dept=this.departmentService.findByCorpId(dept);
String ZDEPARTMENT_ID = dept.getString("DEPARTMENT_ID");
PageData deptname = departmentService.findById(pd);
2024-01-03 09:48:43 +08:00
PageData node = new PageData();
node.put("id", dept.get("DEPARTMENT_ID"));
node.put("parentId", dept.get("PARENT_ID"));
node.put("name", dept.get("NAME"));
node.put("icon", "../../../assets/images/user.gif");
zdepartmentPdList.add(node);
JSONArray arr = JSONArray.fromObject(departmentService.listAllDepartmentToSelect(ZDEPARTMENT_ID,zdepartmentPdList));
map.put("zTreeNodes", (null == arr ?"":"{\"treeNodes\":" + arr.toString() + "}"));
String depname = null == dept ? "请选择" : dept.getString("NAME");
map.put("depname", null == depname ? "请选择" : depname);
2024-01-03 09:48:43 +08:00
//获取岗位下拉
PageData post = new PageData();
post.put("DEPARTMENT_ID", ZDEPARTMENT_ID);
post.put("STATUS", 0);
List<PageData> postList = this.postService.listAll(post);
map.put("postList", postList);
map.put("pd", pd);
map.put("deptname", deptname.getString("NAME"));//获取当前登录的人部门名称
2024-01-03 09:48:43 +08:00
map.put("roleList", roleList);
map.put("result", errInfo);
return map;
}
/**
*
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/getHiddenConfirm")
@ResponseBody
public Object getHiddenConfirm() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("IS_HAZARDCONFIRMER", "1");
List<PageData> userList = usersService.listAllUser(pd);
map.put("userList", userList);
map.put("result", errInfo); //返回结果
return map;
}
2024-01-03 09:48:43 +08:00
/**
* ()
*/
@RequestMapping(value="/editUser")
@RequiresPermissions("user:edit")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "修改用户(系统用户列表修改)")
2024-01-03 09:48:43 +08:00
public Object editUser() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if(pd.get("USERAVATARURL")!=null && !pd.getString("USERAVATARURL").equals("")){
2024-01-03 11:04:18 +08:00
// System.out.println("USERAVATARURL原长度"+pd.getString("USERAVATARURL").length());
2024-01-03 09:48:43 +08:00
String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL"));
2024-01-03 11:04:18 +08:00
// System.out.println("USERAVATARURL压缩长度"+USERAVATARURL64.length());
2024-01-03 09:48:43 +08:00
try{
FaceUtil.compareFace(pd.getString("USERAVATARURL"),pd.getString("USERAVATARURL"));
}catch (Exception e){
map.put("result", "fail");
map.put("msg", "人脸图像不符合要求 请重新上传!");
return map;
}
}
if ("input".equals(pd.getString("LEARNERCATEGORYSTATUS"))) {
pd.put("DICTTYPE","APPLICABLE_PERSONNEL");
PageData lc = dictionariesCorpService.saveSelf(pd);
pd.put("LEARNERCATEGORY", lc.getString("DICTIONARIES_ID"));
}
FHLOG.save(Jurisdiction.getUsername(), "从系统用户中修改"+pd.getString("USERNAME")+"的资料"); //记录日志
if(!Jurisdiction.getUsername().equals(pd.getString("USERNAME"))){ //如果当前登录用户修改用户资料提交的用户名非本人
if("admin".equals(pd.getString("USERNAME")) && !"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改admin
}else{ //如果当前登录用户修改用户资料提交的用户名是本人则不能修改本人的角色ID
PageData upd = new PageData();
upd = usersService.findByUsername(pd);
pd.put("ROLE_ID", upd.getString("ROLE_ID")); //对角色ID还原本人角色ID
pd.put("ROLE_IDS", Tools.notEmpty(upd.getString("ROLE_IDS"))?upd.get("ROLE_IDS"):""); //对角色ID还原本人副职角色ID
}
if(pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))){
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
}
usersService.editUser(pd); //执行修改
if("true".equals(pd.getString("ISSTUDENT"))){
if("select".equals(pd.getString("letDutiesType"))){
pd.put("DUTIES",pd.getString("DUTIES"));
}else{
PageData dicPd = new PageData();
dicPd.put("PARENT_ID","09e36ac01e9540f8bc84eab1c1a78754");
dicPd.put("BIANMA","zhiwu");
dicPd.put("NAME",pd.getString("DUTIESValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("DUTIES",dicPd.getString("DICTIONARIES_ID"));
}
if("select".equals(pd.getString("letTitleType"))){
pd.put("TITLE",pd.getString("TITLE"));
}else{
PageData dicPd = new PageData();
dicPd.put("PARENT_ID","945a6b10e59946078b500f0fbafa8679");
dicPd.put("BIANMA","zhicheng");
dicPd.put("NAME",pd.getString("letTitleValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TITLE",dicPd.getString("DICTIONARIES_ID"));
}
if("select".equals(pd.getString("letTypeOfWorkType"))){
pd.put("TYPE_OF_WORK",pd.getString("TYPE_OF_WORK"));
}else{
PageData dicPd = new PageData();
dicPd.put("PARENT_ID","55484e491a5e442d839c4595380713ec");
dicPd.put("BIANMA","gongzhong");
dicPd.put("NAME",pd.getString("letTypeOfWorkValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TYPE_OF_WORK",dicPd.getString("DICTIONARIES_ID"));
}
userInfoService.delete(pd);
userInfoService.save(pd);
}
// 如果修改了部门/岗位,将该用户所有清单都删除
if(pd.get("OPERATIONTYPE")!=null && pd.get("OPERATIONTYPE").toString() != null && Tools.notEmpty(pd.get("OPERATIONTYPE").toString())) {
List<PageData> listIds = listManagerService.listListByUser(pd);
if(listIds != null && listIds.size() > 0) {
for(PageData listPd:listIds) {
PageData pd1 = new PageData();
pd1.put("OPERATOR", Jurisdiction.getUsername()); //修改人
pd1.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd1.put("LISTMANAGER_ID", listPd.get("LISTMANAGER_ID"));
listManagerService.remove(pd1);
pd1 = listManagerService.findById(pd1);
if(pd1.get("TYPE") != null && Tools.notEmpty(pd1.get("TYPE").toString())) {
if("listType0005".equals(pd1.get("TYPE").toString())) {
pd1.put("LISTSTATISTICS_ID", this.get32UUID()); //主键
pd1.put("STARTTIME", pd1.get("START_DATE").toString()+" 00:00:00");
pd1.put("ENDTIME", pd1.get("END_DATE").toString()+" 23:59:59");
pd1.put("PERIOD", null);
PageData statistics = listStatisticsService.findByCondition(pd1);
if(statistics != null && statistics.get("LISTSTATISTICS_ID") != null) {
statistics.put("NOTEXAMINEDNUM", Integer.parseInt(statistics.get("NOTEXAMINEDNUM").toString())-2);
listStatisticsService.edit(statistics);
}
pd1.put("ISSTATISTICS", '0');
// 本期已检查的不计入统计
checkrecordService.editStatistics(pd1);
} else {
if(pd1.get("PERIOD") != null && Tools.notEmpty(pd1.get("PERIOD").toString())) {
String period = pd1.get("PERIOD").toString();
switch (period) {
case "checkPeriod0001"://每日
pd1.put("STARTTIME", DateUtil.getDay()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getDay()+" 23:59:59");
break;
case "checkPeriod0002"://每周
pd1.put("STARTTIME", DateUtil.getWeekStart());
pd1.put("ENDTIME", DateUtil.getWeekEnd());
break;
case "checkPeriod0003"://每旬
String year = DateUtil.getYear().toString();
String month = DateUtil.getMonth().toString();
Integer day = Integer.parseInt(DateUtil.getOnlyDay().toString());
String startTime = year + "-" + month + "-";
String endTime = year + "-" + month + "-";
if(day <= 10) {
startTime = startTime+"01 00:00:00";
endTime = endTime+"10 23:59:59";
} else if(day > 10 && day <= 20) {
startTime = startTime+"11 00:00:00";
endTime = endTime+"20 23:59:59";
} else {
startTime = startTime+"21 00:00:00";
endTime = DateUtil.getMonthEndDay()+" 23:59:59";
}
pd1.put("STARTTIME", startTime);
pd1.put("ENDTIME", endTime);
break;
case "checkPeriod0004"://每月
pd1.put("STARTTIME", DateUtil.getMonthFirstDay()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getMonthEndDay()+" 23:59:59");
break;
case "checkPeriod0005"://每季
pd1.put("STARTTIME", DateUtil.quarterStart()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.quarterEnd()+" 23:59:59");
break;
case "checkPeriod0006"://每年
pd1.put("STARTTIME", DateUtil.getCurrYearFirst()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getCurrYearLast()+" 23:59:59");
break;
case "checkPeriod0007"://半年
String byear = DateUtil.getYear().toString();
Integer bmonth = Integer.parseInt(DateUtil.getMonth().toString());
if(bmonth <= 6) {
pd1.put("STARTTIME", byear+"-01-01 00:00:00");
pd1.put("ENDTIME", byear+"-06-30 23:59:59");
} else if(bmonth > 6) {
pd1.put("STARTTIME", byear+"-07-01 00:00:00");
pd1.put("ENDTIME", byear+"-12-31 23:59:59");
}
break;
default:
break;
}
}
PageData statistics = listStatisticsService.findByCondition(pd1);
if(statistics != null && statistics.get("LISTSTATISTICS_ID") != null) {
statistics.put("NOTEXAMINEDNUM", Integer.parseInt(statistics.get("NOTEXAMINEDNUM").toString())-1);
listStatisticsService.edit(statistics);
}
pd1.put("ISSTATISTICS", '0');
// 本期已检查的不计入统计
checkrecordService.editStatistics(pd1);
}
}
}
}
}
map.put("result", errInfo);
return map;
}
/**
* ()
*/
@RequestMapping(value="/editUserFuns")
@RequiresPermissions("user:edit")
@ResponseBody
public Object editUserFuns() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
FHLOG.save(Jurisdiction.getUsername(), "从系统用户中修改"+pd.getString("USERNAME")+"的小程序菜单权限"); //记录日志
usersService.editUserFuns(pd); //执行修改
map.put("result", errInfo);
return map;
}
/**
* ()
*/
@RequestMapping(value="/editUserOwn")
@ResponseBody
public Object editUserOwn() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if(!Jurisdiction.getUsername().equals(pd.getString("USERNAME"))){ //如果当前登录用户修改用户资料提交的用户名非本人
FHLOG.save(Jurisdiction.getUsername(), "恶意修改用户资料:"+pd.getString("USERNAME"));
return null;//不能修改非本人的资料
}else{ //如果当前登录用户修改用户资料提交的用户名是本人则不能修改本人的角色ID
PageData upd = new PageData();
upd = usersService.findByUsername(pd);
pd.put("USER_ID", upd.getString("USER_ID")); //对ID还原本人ID防止串改
pd.put("ROLE_ID", upd.getString("ROLE_ID")); //对角色ID还原本人角色ID
pd.put("ROLE_IDS", Tools.notEmpty(upd.getString("ROLE_IDS"))?upd.get("ROLE_IDS"):""); //对角色ID还原本人副职角色ID
}
if(pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))){
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
}
usersService.editUser(pd); //执行修改
FHLOG.save(Jurisdiction.getUsername(), "从个人资料中修改"+pd.getString("USERNAME")+"的资料"); //记录日志
map.put("result", errInfo);
return map;
}
/**
* @return
*/
@RequestMapping(value="/hasUser")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "判断用户名是否存在")
2024-01-03 09:48:43 +08:00
public Object hasUser() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd = usersService.findByUsername(pd);
if(pd != null){
map.put("pd",pd);
}
map.put("result", errInfo); //返回结果
return map;
}
/**
* @return
*/
@RequestMapping(value="/hasEmail")
@ResponseBody
public Object hasEmail() throws Exception{
Map<String,String> map = new HashMap<String,String>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if(usersService.findByEmail(pd) != null){
errInfo = "fail";
}
map.put("result", errInfo); //返回结果
return map;
}
/**
* @return
*/
@RequestMapping(value="/hasNumber")
@ResponseBody
public Object hasNumber() throws Exception{
Map<String,String> map = new HashMap<String,String>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if(usersService.findByNumbe(pd) != null){
errInfo = "error";
}
map.put("result", errInfo); //返回结果
return map;
}
2024-01-03 11:04:18 +08:00
/**
* @return
*/
@RequestMapping(value="/validateIdentity")
@ResponseBody
public Object validateIdentity() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("ISVALIDATE",IdcardUtils.validateCard(pd.getString("IDENTITY_NUMBER")));
map.put("pd",pd);
map.put("result", errInfo); //返回结果
return map;
}
2024-01-03 09:48:43 +08:00
/**
* @return
* @throws Exception
*/
2024-01-11 18:02:48 +08:00
// @RequestMapping(value="/saveUser")
// @RequiresPermissions("user:add")
// @ResponseBody
// @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "保存用户")
// public Object saveUser() throws Exception{
// Map<String,Object> map = new HashMap<String,Object>();
// String errInfo = "success";
// PageData pd = new PageData();
// pd = this.getPageData();
// // 默认周期初始值为1
// pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
//// pd.put("DURATION", "1"); //工作状态持续时间
// pd.put("WORKSTATUS", "1"); //工作状态
// pd.put("WORKPERIOD", "1"); //当前工作周期数
// pd.put("RIGHTS", "788664966448");
//
// if(pd.get("USERAVATARURL")!=null && !pd.getString("USERAVATARURL").equals("")){
//// System.out.println("USERAVATARURL原长度"+pd.getString("USERAVATARURL").length());
// String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL"));
//// System.out.println("USERAVATARURL压缩长度"+USERAVATARURL64.length());
// try{
// FaceUtil.compareFace(pd.getString("USERAVATARURL"),pd.getString("USERAVATARURL"));
// }catch (Exception e){
// map.put("result", "fail");
// map.put("msg", "人脸图像不符合要求 请重新上传!");
// return map;
// }
// }
// if ("input".equals(pd.getString("LEARNERCATEGORYSTATUS"))) {
// pd.put("DICTTYPE","APPLICABLE_PERSONNEL");
// PageData lc = dictionariesCorpService.saveSelf(pd);
// pd.put("LEARNERCATEGORY", lc.getString("DICTIONARIES_ID"));
// }
// pd.put("USER_ID", this.get32UUID()); //ID 主键
// pd.put("LAST_LOGIN", ""); //最后登录时间
// pd.put("IP", ""); //IP
// pd.put("STATUS", "0"); //状态
// pd.put("ISMAIN", "0"); //状态
// pd.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,"); //用户默认皮肤
// pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString()); //密码加密
//
//
// if(null == usersService.findByUsername(pd)){ //判断用户名是否存在
// usersService.saveUser(pd); //执行保存
// if("true".equals(pd.getString("ISSTUDENT"))) {
// if ("select".equals(pd.getString("letDutiesType"))) {
// pd.put("DUTIES", pd.getString("DUTIES"));
// } else {
// PageData dicPd = new PageData();
// dicPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754");
// dicPd.put("BIANMA", "zhiwu");
// dicPd.put("NAME", pd.getString("DUTIESValue"));
// dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
// pd.put("DUTIES", dicPd.getString("DICTIONARIES_ID"));
// }
// if ("select".equals(pd.getString("letTitleType"))) {
// pd.put("TITLE", pd.getString("TITLE"));
// } else {
// PageData dicPd = new PageData();
// dicPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679");
// dicPd.put("BIANMA", "zhicheng");
// dicPd.put("NAME", pd.getString("letTitleValue"));
// dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
// pd.put("TITLE", dicPd.getString("DICTIONARIES_ID"));
// }
// if ("select".equals(pd.getString("letTypeOfWorkType"))) {
// pd.put("TYPE_OF_WORK", pd.getString("TYPE_OF_WORK"));
// } else {
// PageData dicPd = new PageData();
// dicPd.put("PARENT_ID", "55484e491a5e442d839c4595380713ec");
// dicPd.put("BIANMA", "gongzhong");
// dicPd.put("NAME", pd.getString("letTypeOfWorkValue"));
// dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
// pd.put("TYPE_OF_WORK", dicPd.getString("DICTIONARIES_ID"));
// }
// userInfoService.save(pd);
// }
// }else{
// map.put("result","failed");
// }
// FHLOG.save(Jurisdiction.getUsername(), "新增用户:"+pd.getString("USERNAME"));//记录日志
//
//
// map.put("result", errInfo); //返回结果
// map.put("USER_ID", pd.getString("USER_ID")); //返回结果
// return map;
// }
2024-01-03 09:48:43 +08:00
@RequestMapping(value="/saveUser")
@RequiresPermissions("user:add")
@ResponseBody
@Transactional
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "保存用户")
2024-01-03 09:48:43 +08:00
public Object saveUser() throws Exception{
Map<String, Object> map = new HashMap<>();
2024-01-03 09:48:43 +08:00
String errInfo = "success";
PageData pd = this.getPageData();
try {
usersService.saveUserNew(pd);
2024-01-11 18:02:48 +08:00
// 调用 Service 层保存用户
} catch (Exception e) {
errInfo = "error";
map.put("msg", e.getMessage());
2024-01-03 09:48:43 +08:00
}
map.put("result", errInfo);
map.put("USER_ID", pd.getString("USER_ID"));
2024-01-03 09:48:43 +08:00
return map;
}
/**
* @return
*/
@RequestMapping(value="/deleteUser")
@RequiresPermissions("user:del")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "删除用户")
2024-01-03 09:48:43 +08:00
public Object deleteUser() throws Exception{
Map<String,String> map = new HashMap<String,String>();
PageData pd = new PageData();
String errInfo = "success";
pd = this.getPageData();
FHLOG.save(Jurisdiction.getUsername(), "删除用户ID"+pd.getString("USER_ID")); //记录日志
usersService.deleteUser(pd); //删除用户
ueditorService.delete(pd); //删除副文本关联数据
2024-01-03 11:04:18 +08:00
StringBuilder sb = new StringBuilder();
sb.append(",");
sb.append(pd.getString("USER_ID"));
sb.append(",");
String userid = sb.toString();
System.out.println(userid);
StringBuilder sn = new StringBuilder();
sn.append(",");
sn.append(pd.getString("NAME"));
sn.append(",");
String name = sn.toString();
System.out.println(name);
pd.put("USER_ID",userid);
pd.put("NAME",name);
noticemanagementService.delete(pd);
2024-01-03 09:48:43 +08:00
List<PageData> listIds = listManagerService.listListByUser(pd);
if(listIds != null && listIds.size() > 0) {
for(PageData listPd:listIds) {
PageData pd1 = new PageData();
pd1.put("OPERATOR", Jurisdiction.getUsername()); //修改人
pd1.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd1.put("LISTMANAGER_ID", listPd.get("LISTMANAGER_ID"));
listManagerService.remove(pd1);
pd1 = listManagerService.findById(pd1);
if(pd1.get("TYPE") != null && Tools.notEmpty(pd1.get("TYPE").toString())) {
if("listType0005".equals(pd1.get("TYPE").toString())) {
pd1.put("LISTSTATISTICS_ID", this.get32UUID()); //主键
pd1.put("STARTTIME", pd1.get("START_DATE").toString()+" 00:00:00");
pd1.put("ENDTIME", pd1.get("END_DATE").toString()+" 23:59:59");
pd1.put("PERIOD", null);
PageData statistics = listStatisticsService.findByCondition(pd1);
if(statistics != null && statistics.get("LISTSTATISTICS_ID") != null) {
statistics.put("NOTEXAMINEDNUM", Integer.parseInt(statistics.get("NOTEXAMINEDNUM").toString())-2);
listStatisticsService.edit(statistics);
}
pd1.put("ISSTATISTICS", '0');
// 本期已检查的不计入统计
checkrecordService.editStatistics(pd1);
} else {
if(pd1.get("PERIOD") != null && Tools.notEmpty(pd1.get("PERIOD").toString())) {
String period = pd1.get("PERIOD").toString();
switch (period) {
case "checkPeriod0001"://每日
pd1.put("STARTTIME", DateUtil.getDay()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getDay()+" 23:59:59");
break;
case "checkPeriod0002"://每周
pd1.put("STARTTIME", DateUtil.getWeekStart());
pd1.put("ENDTIME", DateUtil.getWeekEnd());
break;
case "checkPeriod0003"://每旬
String year = DateUtil.getYear().toString();
String month = DateUtil.getMonth().toString();
Integer day = Integer.parseInt(DateUtil.getOnlyDay().toString());
String startTime = year + "-" + month + "-";
String endTime = year + "-" + month + "-";
if(day <= 10) {
startTime = startTime+"01 00:00:00";
endTime = endTime+"10 23:59:59";
} else if(day > 10 && day <= 20) {
startTime = startTime+"11 00:00:00";
endTime = endTime+"20 23:59:59";
} else {
startTime = startTime+"21 00:00:00";
endTime = DateUtil.getMonthEndDay()+" 23:59:59";
}
pd1.put("STARTTIME", startTime);
pd1.put("ENDTIME", endTime);
break;
case "checkPeriod0004"://每月
pd1.put("STARTTIME", DateUtil.getMonthFirstDay()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getMonthEndDay()+" 23:59:59");
break;
case "checkPeriod0005"://每季
pd1.put("STARTTIME", DateUtil.quarterStart()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.quarterEnd()+" 23:59:59");
break;
case "checkPeriod0006"://每年
pd1.put("STARTTIME", DateUtil.getCurrYearFirst()+" 00:00:00");
pd1.put("ENDTIME", DateUtil.getCurrYearLast()+" 23:59:59");
break;
case "checkPeriod0007"://半年
String byear = DateUtil.getYear().toString();
Integer bmonth = Integer.parseInt(DateUtil.getMonth().toString());
if(bmonth <= 6) {
pd1.put("STARTTIME", byear+"-01-01 00:00:00");
pd1.put("ENDTIME", byear+"-06-30 23:59:59");
} else if(bmonth > 6) {
pd1.put("STARTTIME", byear+"-07-01 00:00:00");
pd1.put("ENDTIME", byear+"-12-31 23:59:59");
}
break;
default:
break;
}
}
PageData statistics = listStatisticsService.findByCondition(pd1);
if(statistics != null && statistics.get("LISTSTATISTICS_ID") != null) {
statistics.put("NOTEXAMINEDNUM", Integer.parseInt(statistics.get("NOTEXAMINEDNUM").toString())-1);
listStatisticsService.edit(statistics);
}
pd1.put("ISSTATISTICS", '0');
// 本期已检查的不计入统计
checkrecordService.editStatistics(pd1);
}
}
}
}
map.put("result", errInfo); //返回结果
return map;
}
/**
*
* @throws Exception
*/
@RequestMapping(value="/deleteAllUser")
@RequiresPermissions("user:del")
@ResponseBody
public Object deleteAllUser() throws Exception{
PageData pd = new PageData();
Map<String,Object> map = new HashMap<String,Object>();
pd = this.getPageData();
String USER_IDS = pd.getString("USER_IDS");
String errInfo = "success";
if(Tools.notEmpty(USER_IDS)){
String ArrayUSER_IDS[] = USER_IDS.split(",");
FHLOG.save(Jurisdiction.getUsername(), "批量删除用户"); //记录日志
usersService.deleteAllUser(ArrayUSER_IDS); //删除用户
ueditorService.deleteAll(ArrayUSER_IDS); //删除副文本关联数据
errInfo = "success";
}else{
errInfo = "error";
}
map.put("result", errInfo); //返回结果
return map;
}
/**EXCEL
* @return
* @throws Exception
*/
@RequestMapping(value="/excel")
@RequiresPermissions("toExcel")
public ModelAndView exportExcel() throws Exception{
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
try{
/*检索条件*/
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
2024-01-03 11:04:18 +08:00
String STARTTIME = pd.getString("STARTTIME"); //开始时间
2024-01-03 09:48:43 +08:00
String ENDTIME = pd.getString("ENDTIME"); //结束时间
2024-01-03 11:04:18 +08:00
if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00");
2024-01-03 09:48:43 +08:00
if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00");
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("用户名"); //1
titles.add("编号"); //2
titles.add("姓名"); //3
titles.add("职位"); //4
titles.add("手机"); //5
titles.add("邮箱"); //6
titles.add("最近登录"); //7
titles.add("上次登录IP"); //8
dataMap.put("titles", titles);
List<PageData> userList = usersService.listAllUser(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<userList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", userList.get(i).getString("USERNAME")); //1
vpd.put("var2", userList.get(i).getString("NUMBER")); //2
vpd.put("var3", userList.get(i).getString("NAME")); //3
vpd.put("var4", userList.get(i).getString("ROLE_NAME")); //4
vpd.put("var5", userList.get(i).getString("PHONE")); //5
vpd.put("var6", userList.get(i).getString("EMAIL")); //6
vpd.put("var7", userList.get(i).getString("LAST_LOGIN")); //7
vpd.put("var8", userList.get(i).getString("IP")); //8
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView(); //执行excel操作
mv = new ModelAndView(erv,dataMap);
} catch(Exception e){
}
return mv;
}
/**EXCEL
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value="/readExcel")
@RequiresPermissions("fromExcel")
@SuppressWarnings("unchecked")
@ResponseBody
public Object readExcel(@RequestParam(value="excel",required=false) MultipartFile file) throws Exception{
Map<String,String> map = new HashMap<String,String>();
String errInfo = "success";
PageData pd = new PageData();
if (null != file && !file.isEmpty()) {
2024-01-03 11:04:18 +08:00
File tempFile = new File(file.getOriginalFilename()); //新建file
FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File
List<PageData> listPd = (List)ObjectExcelRead.readExcel(tempFile, 2, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始0:从第A列开始0:第0个sheet
2024-01-03 09:48:43 +08:00
pd.put("LAST_LOGIN", ""); //最后登录时间
pd.put("IP", ""); //IP
pd.put("STATUS", "0"); //状态
pd.put("SKIN", "pcoded-navbar brand-blue icon-colored brand-default,navbar pcoded-header navbar-expand-lg navbar-light header-blue,"); //默认皮肤
pd.put("ROLE_ID", "fhadminzhuche"); //默认角色注册用户
pd.put("ROLE_IDS", ""); //副职角色
/**
* var0 :
* var1 :
* var2 :
* var3 :
* var4 :
*/
for(int i=0;i<listPd.size();i++){
pd.put("USER_ID", this.get32UUID()); //ID
pd.put("NAME", listPd.get(i).getString("var1")); //姓名
String USERNAME = GetPinyin.getPingYin(listPd.get(i).getString("var1")); //根据姓名汉字生成全拼
pd.put("USERNAME", USERNAME);
if(usersService.findByUsername(pd) != null){ //判断用户名是否重复
USERNAME = GetPinyin.getPingYin(listPd.get(i).getString("var1"))+Tools.getRandomNum();
pd.put("USERNAME", USERNAME);
}
pd.put("BZ", listPd.get(i).getString("var4")); //备注
if(Tools.checkEmail(listPd.get(i).getString("var3"))){ //邮箱格式不对就跳过
pd.put("EMAIL", listPd.get(i).getString("var3"));
if(usersService.findByEmail(pd) != null){ //邮箱已存在就跳过
continue;
}
}else{
continue;
}
pd.put("NUMBER", listPd.get(i).getString("var0")); //编号已存在就跳过
pd.put("PHONE", listPd.get(i).getString("var2")); //手机号
pd.put("PASSWORD", new SimpleHash("SHA-1", USERNAME, "123").toString()); //默认密码123
if(usersService.findByNumbe(pd) != null){
continue;
}
usersService.saveUser(pd);
}
2024-01-03 11:04:18 +08:00
FileUtils.deleteQuietly(tempFile);//删除临时文件
2024-01-03 09:48:43 +08:00
}
map.put("result", errInfo); //返回结果
return map;
}
/**(线)
* @return
* @throws Exception
*/
@RequestMapping(value="/goEditUfromOnline")
@ResponseBody
public Object goEditUfromOnline() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if("admin".equals(pd.getString("USERNAME"))){return null;} //不能查看admin用户
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
map.put("fx", "user");
pd = usersService.findByUsername(pd); //根据ID读取
String ROLE_IDS = pd.getString("ROLE_IDS"); //副职角色ID
if(Tools.notEmpty(ROLE_IDS)){
String arryROLE_ID[] = ROLE_IDS.split(",");
for(int i=0;i<roleList.size();i++){
Role role = roleList.get(i);
String roleId = role.getROLE_ID();
for(int n=0;n<arryROLE_ID.length;n++){
if(arryROLE_ID[n].equals(roleId)){
role.setRIGHTS("1"); //此时的目的是为了修改用户信息上,能看到副职角色都有哪些
break;
}
}
}
}
map.put("pd", pd);
map.put("roleList", roleList);
map.put("result", errInfo);
return map;
}
/**
* @return
* @throws Exception
*/
@RequestMapping(value="/view")
@ResponseBody
public Object view() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String USERNAME = pd.getString("USERNAME");
if("admin".equals(USERNAME)){return null;} //不能查看admin用户
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
pd = usersService.findByUsername(pd); //根据ID读取
map.put("msg", "1");
if(null == pd){
PageData rpd = new PageData();
rpd.put("RNUMBER", USERNAME); //用户名查不到数据时就把数据当作角色的编码去查询角色表
rpd = roleService.getRoleByRnumber(rpd);
map.put("rpd", rpd);
map.put("msg", "2");
}
map.put("pd", pd);
map.put("roleList", roleList);
map.put("result", errInfo);
return map;
}
/**()
* @param page
* @return
* @throws Exception
*/
@RequestMapping(value="/listUsersForWindow")
@ResponseBody
public Object listUsersForWindow(Page page)throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
2024-01-03 11:04:18 +08:00
String STARTTIME = pd.getString("STARTTIME"); //开始时间
2024-01-03 09:48:43 +08:00
String ENDTIME = pd.getString("ENDTIME"); //结束时间
2024-01-03 11:04:18 +08:00
if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00");
2024-01-03 09:48:43 +08:00
if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00");
page.setPd(pd);
List<PageData> userList = usersService.listUsersBystaff(page); //列出用户列表(弹窗选择用)
2024-01-03 11:04:18 +08:00
pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL());
2024-01-03 09:48:43 +08:00
List<Role> roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色
map.put("userList", userList);
map.put("roleList", roleList);
map.put("page", page);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @param
2024-01-03 09:48:43 +08:00
* @throws Exception
*/
@RequestMapping(value="/listAll")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "隐患排查",instructionsOperate = "清单管理",instructionsType = "列表")
2024-01-03 09:48:43 +08:00
public Object listAll() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
List<PageData> userList = usersService.listAllUser(pd); //列出Post列表
map.put("userList", userList);
map.put("result", errInfo);
return map;
}
/**
* @param
2024-01-03 09:48:43 +08:00
* @throws Exception
*/
@RequestMapping(value="/listUserByDept")
@ResponseBody
public Object listUserByDept() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("ISMAIN", Jurisdiction.getIS_MAIN());
pd.put("ISSUPERVISE", Jurisdiction.getISSUPERVISE());
pd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID());
String DEPTIDS = pd.getString("DEPTIDS");
if(Tools.notEmpty(DEPTIDS)) {
String DEPT_IDS[] = DEPTIDS.split(",");
pd.put("DEPT_IDS", DEPT_IDS);
}
List<PageData> userList = usersService.listUserByDept(pd); //列出Post列表
map.put("userList", userList);
map.put("result", errInfo);
return map;
}
/**EXCEL
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value="/readExcel2")
2024-01-03 11:04:18 +08:00
// @RequiresPermissions("fromExcel")
2024-01-03 09:48:43 +08:00
@SuppressWarnings("unchecked")
@ResponseBody
@Transactional
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "从EXCEL导入到数据库")
2024-01-03 09:48:43 +08:00
public Object readExcel2(@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()) {
2024-01-03 11:04:18 +08:00
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
2024-01-03 09:48:43 +08:00
/**
* var0 :
* var1 :
* var2 :
* var3 :
* var4 :
* var5 :
*/
2024-01-03 11:04:18 +08:00
List<String> header = new ArrayList<String>();
header.add("部门");header.add("岗位");header.add("用户名");header.add("姓名");header.add("邮箱");header.add("备注");header.add("是否在线学习人员");
List<String> headerByLearningStatus = new ArrayList<String>();
headerByLearningStatus.add("身份证号");headerByLearningStatus.add("民族");headerByLearningStatus.add("性别");
headerByLearningStatus.add("政治面貌");headerByLearningStatus.add("出生年学");headerByLearningStatus.add("文化程度");
headerByLearningStatus.add("人员类型");headerByLearningStatus.add("职务");headerByLearningStatus.add("职称");
headerByLearningStatus.add("工种");headerByLearningStatus.add("入职日期");headerByLearningStatus.add("参加工种日期");
headerByLearningStatus.add("在职情况");
2024-01-03 09:48:43 +08:00
try {
if(listPd.size()>0) {
/** 获取企业下的所有部门信息*/
PageData departPd = new PageData();
departPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> departList = departmentService.listAll(departPd);
2024-01-03 11:04:18 +08:00
Map<String, Object> departMap = new HashMap<String, Object>();
2024-01-03 09:48:43 +08:00
for (PageData pageData : departList) {
departMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData);
}
2024-01-03 11:04:18 +08:00
/* Map<String,Object> departNameMap = new HashMap<>();/
2024-01-03 09:48:43 +08:00
for (PageData pageData : departList) {
String nameKey = getParentName(pageData.getString("DEPARTMENT_ID"),departMap);
departNameMap.put(nameKey,pageData.getString("DEPARTMENT_ID"));
}*/
/** 获取所有岗位信息 */
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, Object> userMap = new HashMap<>();
Map<String, Object> emailMap = new HashMap<>();
for (PageData pageData : userList) {
userMap.put(pageData.getString("USERNAME"), "");
}
for (PageData pageData : userEList) {
emailMap.put(pageData.getString("USERNAME"), "");
}
PageData rolePd = new PageData();
2024-01-03 11:04:18 +08:00
rolePd.put("ISMAIN", "0");
rolePd.put("PARENT_ID", Jurisdiction.getVIPLEVEL());
rolePd.put("ROLE_NAME","个人账号");
PageData role =roleService.findByPidAndMain(rolePd);
2024-01-03 09:48:43 +08:00
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<>();
for(PageData lpd:listPd) {
number++;
2024-01-03 11:04:18 +08:00
for(int i=0;i<7;i++) {
2024-01-03 09:48:43 +08:00
if(i>=4) {
continue;
}
if(!lpd.containsKey("var"+i)) {
errorStr.append("第"+number+"行的\""+header.get(i)+"\"无数据;\n");
continue;
}
if(Tools.isEmpty(lpd.get("var"+i))) {
errorStr.append("第"+number+"行的\""+header.get(i)+"\"无数据;\n");
continue;
}
}
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();//用户名
String name = Tools.isEmpty(lpd.get("var3"))?"":lpd.get("var3").toString();//姓名
String eMail = Tools.isEmpty(lpd.get("var4"))?"":lpd.get("var4").toString();//邮箱
String bz = Tools.isEmpty(lpd.get("var5"))?"":lpd.get("var5").toString();//备注
/*
if(Tools.isEmpty(dept) || Tools.isEmpty(postName) || Tools.isEmpty(userName) ||Tools.isEmpty(name) ) {
errInfo = "error";
errorStr.append("第"+number+"行,公司级部门,岗位,用户名,姓名为信息必填项,请重新确认数据");
break;
}
*/
/* if(!departMap.containsKey(dept)) {
errorStr.append("第"+number+"行的"+header.get(0)+"未找到名称为\""+dept+"\"的部门"+";\n");
continue;
}*/
2024-01-03 11:04:18 +08:00
Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX);
Matcher matcher = patternPhone.matcher(lpd.getString("var2"));
if(!matcher.matches()) {
errorStr.append("第"+number+"行,");
errorStr.append("手机号格式不正确,请重新确认数据;\n");
continue;
}
2024-01-03 09:48:43 +08:00
/** 部门信息 **/
String departId = "";
if(departMap.containsKey(dept)) {
PageData depart = (PageData)departMap.get(dept);
departId = depart.get("DEPARTMENT_ID").toString();
}else {
errorStr.append("第"+number+"行,部门信息错误,系统未找到该部门,请重新确认数据;\n");
continue;
}
/** 部门信息 结束**/
/** 岗位 **/
/* if(Tools.isEmpty(postName)) {
errInfo = "error";
errorStr.append("第"+number+"行,岗位信息为空,请重新确认数据");
break;
}*/
if(!postMap.containsKey(departId)) {
errorStr.append("第"+number+"行,未找到该部门的岗位信息,请重新确认数据;\n");
continue;
}
Map<String, Object> postValMap = postMap.get(departId);//这个部门下的所有岗位信息
if(!postValMap.containsKey(postName)) {
errorStr.append("第"+number+"行,在"+dept+"部门下,未找到"+postName+"岗位信息,请重新确认数据;\n");
continue;
}
PageData post = (PageData) postValMap.get(postName);
String postId = post.getString("POST_ID");
/*for (PageData pageData : postValList) {
if(postName.equals(pageData.getString("NAME"))) {
postId = pageData.getString("POST_ID");
}
}*/
/* if(Tools.isEmpty(postId)) {
errInfo = "error";
errorStr.append("第"+number+"行,");
errorStr.append("在"+keyDept+"部门下,未找到"+postName+"岗位信息,请重新确认数据");
break;
}*/
/** 岗位 结束**/
if(userMap.containsKey(userName)) {
2024-01-03 11:04:18 +08:00
System.out.println(userMap.containsKey(userName));
2024-01-03 09:48:43 +08:00
errorStr.append("第"+number+"行,");
errorStr.append("用户名“"+userName+"”已经存在,请勿重复导入;\n");
continue;
}
if(hasUserNameChongfu.containsKey(userName)) {
errorStr.append("第"+number+"行,");
errorStr.append("用户名重复,请重新确认数据;\n");
continue;
}
if(emailMap.containsKey(eMail)) {
errorStr.append("第"+number+"行,");
errorStr.append("邮箱“"+eMail+"”已经存在,请勿重复导入;\n");
continue;
}
if(emailChongfu.containsKey(eMail)) {
errorStr.append("第"+number+"行,");
errorStr.append("邮箱重复,请重新确认数据;\n");
continue;
}
/* if(hasUserNameChongfu.containsValue(name)) {
errInfo = "error";
errorStr.append("第"+number+"行,");
errorStr.append("姓名重复,请重新确认数据");
break;
}*/
hasUserNameChongfu.put(userName, name);
if(Tools.notEmpty(eMail)) {
emailChongfu.put(eMail, "");
}
PageData user = new PageData();
user.put("USER_ID", this.get32UUID());
user.put("USERNAME", userName);
user.put("PASSWORD", new SimpleHash("SHA-1", userName, "666666").toString());
user.put("NAME", name);
user.put("ROLE_ID", role.getString("ROLE_ID"));
user.put("LAST_LOGIN", "");
user.put("IP", "");
user.put("STATUS", "0");
user.put("BZ", bz);
user.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,");
user.put("EMAIL", 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", "");
2024-01-03 11:04:18 +08:00
user.put("RIGHTS", "788664966448");
2024-01-03 09:48:43 +08:00
user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
2024-01-03 11:04:18 +08:00
user.put("zxxxType", "0");// 在线学习情况
user.put("DURATION", "-1");// 工作状态持
String zxxxType = Tools.isEmpty(lpd.get("var6"))?"":lpd.get("var6").toString();//是否在线学习人员
if("是".equals(zxxxType)){ // 在线学习情况
user.put("zxxxType", "1");// 在线学习情况
for(int i=8;i<19;i++) {
if(i== 13) // 人员类型 非必填
if(!lpd.containsKey("var"+i)) {
errorStr.append("第"+number+"行的\""+headerByLearningStatus.get(i)+"\"无数据;\n");
continue;
}
if(Tools.isEmpty(lpd.get("var"+i))) {
errorStr.append("第"+number+"行的\""+headerByLearningStatus.get(i)+"\"无数据;\n");
continue;
}
}
String USER_ID_CARD = Tools.isEmpty(lpd.get("var7"))?"":lpd.get("var7").toString();//身份证号
String NATION = Tools.isEmpty(lpd.get("var8"))?"":lpd.get("var8").toString();//民族
String SEX = Tools.isEmpty(lpd.get("var9"))?"":lpd.get("var9").toString();//性别
String POLITICAL_OUTLOOK = Tools.isEmpty(lpd.get("var10"))?"":lpd.get("var10").toString();//政治面貌
String DATE_OF_BIRTH = Tools.isEmpty(lpd.get("var11"))?"":lpd.get("var11").toString();//出生年学
String DEGREE_OF_EDUCATION = Tools.isEmpty(lpd.get("var12"))?"":lpd.get("var12").toString();//文化程度
String PERSONNEL_TYPE = Tools.isEmpty(lpd.get("var13"))?"":lpd.get("var13").toString();//人员类型
String DUTIES = Tools.isEmpty(lpd.get("var14"))?"":lpd.get("var14").toString();//职务
String TITLE = Tools.isEmpty(lpd.get("var15"))?"":lpd.get("var15").toString();//职称
String TYPE_OF_WORK = Tools.isEmpty(lpd.get("var16"))?"":lpd.get("var16").toString();//工种
String ENTRY_DATE = Tools.isEmpty(lpd.get("var17"))?"":lpd.get("var17").toString();//入职日期
String WORKING_DATE = Tools.isEmpty(lpd.get("var18"))?"":lpd.get("var18").toString();//参加工作日期
String INCUMBENCY = Tools.isEmpty(lpd.get("var19"))?"":lpd.get("var19").toString();//在职情况
PageData minzu = dictionariesService.findByName(NATION,"0a0e406f27f74ee698fe9979d25f62dd");//民族
if(null == minzu ){
errorStr.append("第"+number+"行,");
errorStr.append("未找到该民族信息,请重新确认数据;\n");
continue;
}
PageData xibei = dictionariesService.findByName(SEX,"21501808bbc344d593fbf9ccfe6c4531");//性别
if(null == xibei ){
errorStr.append("第"+number+"行,");
errorStr.append("未找到该性别信息,请重新确认数据;\n");
continue;
}
PageData zhengzhimianmao = dictionariesService.findByName(POLITICAL_OUTLOOK,"6351efdd12dc4730952e5d195718e252");//政治面貌
if(null == zhengzhimianmao ){
errorStr.append("第"+number+"行,");
errorStr.append("未找到政治面貌信息,请重新确认数据;\n");
continue;
}
Pattern pattern = Pattern.compile("[0-9]*");
Date beginDate = DateUtil.fomatDate("1900-01-01"); // 1900, 0, 1
Matcher isNum = pattern.matcher(DATE_OF_BIRTH); //判断是否为数字
Date DATE_OF_BIRTH_VAL = new Date();
if( isNum.matches() ){
DATE_OF_BIRTH_VAL = DateUtil.getDateAfter(beginDate,Integer.parseInt(DATE_OF_BIRTH));
}else{
DATE_OF_BIRTH_VAL = DateUtil.fomatDateByNian(DATE_OF_BIRTH);//出生年学
}
PageData wenhuyachengdu = dictionariesService.findByName(DEGREE_OF_EDUCATION,"d7d80f08d73a4accbccf4fd3d8d1d867");//文化程度
if(null == wenhuyachengdu ){
errorStr.append("第"+number+"行,");
errorStr.append("未找到文化程度信息,请重新确认数据;\n");
continue;
}
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;
}
}
PageData zhiwu = dictionariesCorpService.findByName(DUTIES,Jurisdiction.getCORPINFO_ID(), "09e36ac01e9540f8bc84eab1c1a78754");//职务
if(null == zhiwu ){ //如果数据库没有这个职务,新增职务
zhiwu = new PageData();
zhiwu.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754");
zhiwu.put("BIANMA", "zhiwu");
zhiwu.put("NAME", DUTIES);
zhiwu = dictionariesCorpService.saveByZidongxinzeng(zhiwu);
}
PageData zhicheng = dictionariesCorpService.findByName(TITLE,Jurisdiction.getCORPINFO_ID(), "945a6b10e59946078b500f0fbafa8679");//职称
if(null == zhicheng ){ //如果数据库没有这个职称,新增职称
zhicheng = new PageData();
zhicheng.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679");
zhicheng.put("BIANMA", "zhicheng");
zhicheng.put("NAME", TITLE);
zhicheng = dictionariesCorpService.saveByZidongxinzeng(zhicheng);
}
PageData gongzhong = dictionariesCorpService.findByName(TYPE_OF_WORK,Jurisdiction.getCORPINFO_ID(), "55484e491a5e442d839c4595380713ec");//工种
if(null == gongzhong ){ //如果数据库没有这个工种,新增工种
gongzhong = new PageData();
gongzhong.put("PARENT_ID", "55484e491a5e442d839c4595380713ec");
gongzhong.put("BIANMA", "gongzhong");
gongzhong.put("NAME",TYPE_OF_WORK);
gongzhong = dictionariesCorpService.saveByZidongxinzeng(gongzhong);
}
Date ENTRY_DATE_VAL = new Date();//入职日期
Matcher isNum2 = pattern.matcher(ENTRY_DATE);
if( isNum2.matches() ){
ENTRY_DATE_VAL = DateUtil.getDateAfter(beginDate,Integer.parseInt(ENTRY_DATE));
}else{
ENTRY_DATE_VAL = DateUtil.fomatDateByNian(ENTRY_DATE);
}
Date WORKING_DATE_VAL = new Date();//参加工作日期
Matcher isNum3 = pattern.matcher(WORKING_DATE);
if( isNum3.matches() ){
WORKING_DATE_VAL = DateUtil.getDateAfter(beginDate,Integer.parseInt(WORKING_DATE));
}else{
WORKING_DATE_VAL = DateUtil.fomatDateByNian(WORKING_DATE);
}
2024-01-03 09:48:43 +08:00
2024-01-03 11:04:18 +08:00
PageData zaizhiqingkuang = dictionariesService.findByName(INCUMBENCY,"548764b5d4bf4bd7a18ef88274ef49e4");//在职情况
if(null == zaizhiqingkuang ){
errorStr.append("第"+number+"行,");
errorStr.append("未找到在职情况信息,请重新确认数据;\n");
continue;
}
user.put("USER_ID_CARD", USER_ID_CARD);
user.put("NATION", minzu.get("DICTIONARIES_ID"));
user.put("SEX", xibei.get("DICTIONARIES_ID"));
user.put("POLITICAL_OUTLOOK", zhengzhimianmao.get("DICTIONARIES_ID"));
user.put("DATE_OF_BIRTH", DATE_OF_BIRTH_VAL);
user.put("DEGREE_OF_EDUCATION", wenhuyachengdu.get("DICTIONARIES_ID"));
user.put("PERSONNEL_TYPE", renyuanleixing.get("DICTIONARIES_ID"));
user.put("DUTIES", zhiwu.get("DICTIONARIES_ID"));
user.put("TITLE", zhicheng.get("DICTIONARIES_ID"));
user.put("TYPE_OF_WORK", gongzhong.get("DICTIONARIES_ID"));
user.put("ENTRY_DATE", ENTRY_DATE_VAL);
user.put("WORKING_DATE", WORKING_DATE_VAL);
user.put("INCUMBENCY", zaizhiqingkuang.get("DICTIONARIES_ID"));
}
2024-01-03 09:48:43 +08:00
addUserList.add(user);
}
if(Tools.isEmpty(errorStr.toString())) {
for (PageData pageData : addUserList) {
usersService.saveUser(pageData);
2024-01-03 11:04:18 +08:00
if("1".equals(pageData.getString("zxxxType"))){
userInfoService.save(pageData);
}
2024-01-03 09:48:43 +08:00
}
errorStr.append("成功导入"+addUserList.size()+"条数据!");
}else {
errInfo = "error";
}
2024-01-03 11:04:18 +08:00
FileUtils.deleteQuietly(tempFile);//删除临时文件
}else {
map.put("result", "error"); //返回结果
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;
}
/**EXCEL
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value="/readExcel3")
// @RequiresPermissions("fromExcel")
@SuppressWarnings("unchecked")
@ResponseBody
@Transactional
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "从EXCEL导入到数据库")
public Object readExcel3(@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 :
* var6 :线
* var7 :
* var8 :
* var9 :
* var10 :
* var11 :
* var12 :
* var13 :
* var14 :
* var15 :
* var16 :
* var17 :
* var18 :
* var19 :
*/
List<String> header = new ArrayList<String>();
// header.add("部门");header.add("岗位");
header.add("用户名");
header.add("姓名");
// header.add("邮箱");header.add("备注");header.add("是否在线学习人员");
header.add("身份证号");header.add("民族");header.add("性别");
header.add("政治面貌");header.add("出生年月");header.add("文化程度");
header.add("人员类型");header.add("职务");header.add("职称");
header.add("工种");header.add("入职日期");header.add("参加工种日期");
header.add("在职情况");
try {
if(listPd.size()>0) {
/** 获取企业下的所有部门信息*/
PageData departPd = new PageData();
departPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
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);
}
/* Map<String,Object> departNameMap = new HashMap<>();
for (PageData pageData : departList) {
String nameKey = getParentName(pageData.getString("DEPARTMENT_ID"),departMap);
departNameMap.put(nameKey,pageData.getString("DEPARTMENT_ID"));
}*/
/** 获取所有岗位信息 */
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, Object> userMap = new HashMap<>();
// Map<String, Object> emailMap = new HashMap<>();
// for (PageData pageData : userList) {
// userMap.put(pageData.getString("USERNAME"), "");
// }
// 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<>();
for(PageData lpd:listPd) {
number++;
for (int i = 0; i < 14; i++) {
if (i >= 2) {
continue;
}
if (!lpd.containsKey("var" + i)) {
errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n");
continue;
}
if (Tools.isEmpty(lpd.get("var" + i))) {
errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n");
continue;
}
// if(Tools.checkEmail(listPd.get(i).getString("var3"))){ //邮箱格式不对就跳过
// lpd.put("EMAIL", listPd.get(i).getString("var3"));
// }else{
// continue;
// }
}
// 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("var0")) ? "" : lpd.get("var0").toString();//用户名
String name = Tools.isEmpty(lpd.get("var1")) ? "" : lpd.get("var1").toString();//姓名
// String eMail = Tools.isEmpty(lpd.get("var4")) ? "" : lpd.get("var4").toString();//邮箱
// String bz = Tools.isEmpty(lpd.get("var5")) ? "" : lpd.get("var5").toString();//备注
// String USER_ID_CARD = Tools.isEmpty(lpd.get("var6"))?"":lpd.get("var6").toString();//身份证号
// String NATION = Tools.isEmpty(lpd.get("var7"))?"":lpd.get("var7").toString();//民族
// String SEX = Tools.isEmpty(lpd.get("var8"))?"":lpd.get("var8").toString();//性别
//
// String POLITICAL_OUTLOOK = Tools.isEmpty(lpd.get("var9"))?"":lpd.get("var9").toString();//政治面貌
// String DATE_OF_BIRTH = Tools.isEmpty(lpd.get("var10"))?"":lpd.get("var10").toString();//出生年学
// String DEGREE_OF_EDUCATION = Tools.isEmpty(lpd.get("var11"))?"":lpd.get("var11").toString();//文化程度
//
// String PERSONNEL_TYPE = Tools.isEmpty(lpd.get("var12"))?"":lpd.get("var12").toString();//人员类型
// String DUTIES = Tools.isEmpty(lpd.get("var13"))?"":lpd.get("var13").toString();//职务
// String TITLE = Tools.isEmpty(lpd.get("var14"))?"":lpd.get("var14").toString();//职称
//
// String TYPE_OF_WORK = Tools.isEmpty(lpd.get("var15"))?"":lpd.get("var15").toString();//工种
// String ENTRY_DATE = Tools.isEmpty(lpd.get("var16"))?"":lpd.get("var16").toString();//入职日期
// String WORKING_DATE = Tools.isEmpty(lpd.get("var17"))?"":lpd.get("var17").toString();//参加工作日期
//
// String INCUMBENCY = Tools.isEmpty(lpd.get("var18"))?"":lpd.get("var18").toString();//在职情况
/*
if(Tools.isEmpty(dept) || Tools.isEmpty(postName) || Tools.isEmpty(userName) ||Tools.isEmpty(name) ) {
errInfo = "error";
errorStr.append("第"+number+"行,公司级部门,岗位,用户名,姓名为信息必填项,请重新确认数据");
break;
}
*/
/* if(!departMap.containsKey(dept)) {
errorStr.append("第"+number+"行的"+header.get(0)+"未找到名称为\""+dept+"\"的部门"+";\n");
continue;
}*/
Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX);
Matcher matcher = patternPhone.matcher(lpd.getString("var0"));
if (!matcher.matches()) {
errorStr.append("第" + number + "行,");
errorStr.append("手机号格式不正确,请重新确认数据;\n");
continue;
}
Pattern patternCard = Pattern.compile(RegexPatterns.USERID_CARD);
Matcher matchercard = patternCard.matcher(lpd.getString("var2"));
if(!matchercard.matches()) {
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;
// }
// /** 部门信息 结束**/
// /** 岗位 **/
/* if(Tools.isEmpty(postName)) {
errInfo = "error";
errorStr.append("第"+number+"行,岗位信息为空,请重新确认数据");
break;
}*/
// if (!postMap.containsKey(departId)) {
// errorStr.append("第" + number + "行,未找到该部门的岗位信息,请重新确认数据;\n");
// continue;
// }
// Map<String, Object> postValMap = postMap.get(departId);//这个部门下的所有岗位信息
// if (!postValMap.containsKey(postName)) {
// errorStr.append("第" + number + "行,在" + dept + "部门下,未找到" + postName + "岗位信息,请重新确认数据;\n");
// continue;
// }
// PageData post = (PageData) postValMap.get(postName);
// String postId = post.getString("POST_ID");
/*for (PageData pageData : postValList) {
if(postName.equals(pageData.getString("NAME"))) {
postId = pageData.getString("POST_ID");
}
}*/
/* if(Tools.isEmpty(postId)) {
errInfo = "error";
errorStr.append("第"+number+"行,");
errorStr.append("在"+keyDept+"部门下,未找到"+postName+"岗位信息,请重新确认数据");
break;
}*/
// /** 岗位 结束**/
// if(userMap.containsKey(userName)) {
// System.out.println(userMap.containsKey(userName));
// errorStr.append("第"+number+"行,");
// errorStr.append("用户名“"+userName+"”已经存在,请勿重复导入;\n");
// continue;
// }
// if(hasUserNameChongfu.containsKey(userName)) {
// errorStr.append("第"+number+"行,");
// errorStr.append("用户名重复,请重新确认数据;\n");
// continue;
// }
//
//
// if(emailMap.containsKey(eMail)) {
// errorStr.append("第"+number+"行,");
// errorStr.append("邮箱“"+eMail+"”已经存在,请勿重复导入;\n");
// continue;
// }
// if(emailChongfu.containsKey(eMail)) {
// errorStr.append("第"+number+"行,");
// errorStr.append("邮箱重复,请重新确认数据;\n");
// continue;
// }
// if(hasUserNameChongfu.containsValue(name)) {
// errInfo = "error";
// errorStr.append("第"+number+"行,");
// errorStr.append("姓名重复,请重新确认数据");
// break;
// }
// hasUserNameChongfu.put(userName, name);
// if(Tools.notEmpty(eMail)) {
// emailChongfu.put(eMail, "");
// }
PageData user = new PageData();
// user.put("USER_ID", this.get32UUID());
user.put("USERNAME", userName);
user.put("NAME", name);
user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
// user.put("DEPARTMENT_ID", departId);
user = usersService.findByUsername(user);
if (user != null && user.size() > 0) {
user.get("USER_ID");
}else{
errorStr.append("第"+number+"行,");
errorStr.append("未找到该学员信息或人员信息不一致,请重新检查数据\n");
continue;
}
user.put("PASSWORD", new SimpleHash("SHA-1", userName, "666666").toString());
user.put("ROLE_ID", role.getString("ROLE_ID"));
user.put("LAST_LOGIN", "");
user.put("IP", "");
user.put("STATUS", "0");
// user.put("BZ", bz);
user.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,");
// user.put("EMAIL", eMail);
user.put("NUMBER", "");
user.put("PHONE", "");
user.put("ROLE_IDS", "");
// 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", "true");// 在线学习情况
user.put("DURATION", "-1");// 工作状态持
// String zxxxType = Tools.isEmpty(lpd.get("var6")) ? "" : lpd.get("var6").toString();//是否在线学习人员
// if ("是".equals(zxxxType)) { // 在线学习情况
user.put("zxxxType", "1");// 在线学习情况
for (int i = 3; i < 14; i++) {
if (i == 8) // 人员类型 非必填
if (!lpd.containsKey("var" + i)) {
errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n");
continue;
}
if (Tools.isEmpty(lpd.get("var" + i))) {
errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n");
continue;
}
}
String USER_ID_CARD = Tools.isEmpty(lpd.get("var2")) ? "" : lpd.get("var2").toString();//身份证号
String NATION = Tools.isEmpty(lpd.get("var3")) ? "" : lpd.get("var3").toString();//民族
String SEX = Tools.isEmpty(lpd.get("var4")) ? "" : lpd.get("var4").toString();//性别
String POLITICAL_OUTLOOK = Tools.isEmpty(lpd.get("var5")) ? "" : lpd.get("var5").toString();//政治面貌
String DATE_OF_BIRTH = Tools.isEmpty(lpd.get("var6")) ? "" : lpd.get("var6").toString();//出生年学
String DEGREE_OF_EDUCATION = Tools.isEmpty(lpd.get("var7")) ? "" : lpd.get("var7").toString();//文化程度
String PERSONNEL_TYPE = Tools.isEmpty(lpd.get("var8")) ? "" : lpd.get("var8").toString();//人员类型
String DUTIES = Tools.isEmpty(lpd.get("var9")) ? "" : lpd.get("var9").toString();//职务
String TITLE = Tools.isEmpty(lpd.get("var10")) ? "" : lpd.get("var10").toString();//职称
String TYPE_OF_WORK = Tools.isEmpty(lpd.get("var11")) ? "" : lpd.get("var11").toString();//工种
String ENTRY_DATE = Tools.isEmpty(lpd.get("var12")) ? "" : lpd.get("var12").toString();//入职日期
String WORKING_DATE = Tools.isEmpty(lpd.get("var13")) ? "" : lpd.get("var13").toString();//参加工作日期
String INCUMBENCY = Tools.isEmpty(lpd.get("var14")) ? "" : lpd.get("var14").toString();//在职情况
PageData minzu = dictionariesService.findByName(NATION, "0a0e406f27f74ee698fe9979d25f62dd");//民族
if (null == minzu) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到该民族信息,请重新确认数据;\n");
continue;
}
PageData xibei = dictionariesService.findByName(SEX, "21501808bbc344d593fbf9ccfe6c4531");//性别
if (null == xibei) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到该性别信息,请重新确认数据;\n");
continue;
}
PageData zhengzhimianmao = dictionariesService.findByName(POLITICAL_OUTLOOK, "6351efdd12dc4730952e5d195718e252");//政治面貌
if (null == zhengzhimianmao) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到政治面貌信息,请重新确认数据;\n");
continue;
}
Pattern pattern = Pattern.compile("[0-9]*");
Date beginDate = DateUtil.fomatDate("1900-01-01"); // 1900, 0, 1
Matcher isNum = pattern.matcher(DATE_OF_BIRTH); //判断是否为数字
Date DATE_OF_BIRTH_VAL = new Date();
if (isNum.matches()) {
DATE_OF_BIRTH_VAL = DateUtil.getDateAfter(beginDate, Integer.parseInt(DATE_OF_BIRTH));
} else {
DATE_OF_BIRTH_VAL = DateUtil.fomatDateByNian(DATE_OF_BIRTH);//出生年月
}
PageData wenhuyachengdu = dictionariesService.findByName(DEGREE_OF_EDUCATION, "d7d80f08d73a4accbccf4fd3d8d1d867");//文化程度
if (null == wenhuyachengdu) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到文化程度信息,请重新确认数据;\n");
continue;
}
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;
}
}
PageData zhiwu = dictionariesCorpService.findByName(DUTIES,Jurisdiction.getCORPINFO_ID(), "09e36ac01e9540f8bc84eab1c1a78754");//职务
if (null == zhiwu) { //如果数据库没有这个职务,新增职务
zhiwu = new PageData();
zhiwu.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754");
zhiwu.put("BIANMA", "zhiwu");
zhiwu.put("NAME", DUTIES);
zhiwu = dictionariesCorpService.saveByZidongxinzeng(zhiwu);
}
PageData zhicheng = dictionariesCorpService.findByName(TITLE,Jurisdiction.getCORPINFO_ID(), "945a6b10e59946078b500f0fbafa8679");//职称
if (null == zhicheng) { //如果数据库没有这个职称,新增职称
zhicheng = new PageData();
zhicheng.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679");
zhicheng.put("BIANMA", "zhicheng");
zhicheng.put("NAME", TITLE);
zhicheng = dictionariesCorpService.saveByZidongxinzeng(zhicheng);
}
PageData gongzhong = dictionariesCorpService.findByName(TYPE_OF_WORK,Jurisdiction.getCORPINFO_ID(), "55484e491a5e442d839c4595380713ec");//工种
if (null == gongzhong) { //如果数据库没有这个工种,新增工种
gongzhong = new PageData();
gongzhong.put("PARENT_ID", "55484e491a5e442d839c4595380713ec");
gongzhong.put("BIANMA", "gongzhong");
gongzhong.put("NAME", TYPE_OF_WORK);
gongzhong = dictionariesCorpService.saveByZidongxinzeng(gongzhong);
}
Date ENTRY_DATE_VAL = new Date();//入职日期
Matcher isNum2 = pattern.matcher(ENTRY_DATE);
if (isNum2.matches()) {
ENTRY_DATE_VAL = DateUtil.getDateAfter(beginDate, Integer.parseInt(ENTRY_DATE));
} else {
ENTRY_DATE_VAL = DateUtil.fomatDateByNian(ENTRY_DATE);
}
Date WORKING_DATE_VAL = new Date();//参加工作日期
Matcher isNum3 = pattern.matcher(WORKING_DATE);
if (isNum3.matches()) {
WORKING_DATE_VAL = DateUtil.getDateAfter(beginDate, Integer.parseInt(WORKING_DATE));
} else {
WORKING_DATE_VAL = DateUtil.fomatDateByNian(WORKING_DATE);
}
PageData zaizhiqingkuang = dictionariesService.findByName(INCUMBENCY, "548764b5d4bf4bd7a18ef88274ef49e4");//在职情况
if (null == zaizhiqingkuang) {
errorStr.append("第" + number + "行,");
errorStr.append("未找到在职情况信息,请重新确认数据;\n");
continue;
}
user.put("USER_ID_CARD", USER_ID_CARD);
user.put("NATION", minzu.get("DICTIONARIES_ID"));
user.put("SEX", xibei.get("DICTIONARIES_ID"));
user.put("POLITICAL_OUTLOOK", zhengzhimianmao.get("DICTIONARIES_ID"));
user.put("DATE_OF_BIRTH", DATE_OF_BIRTH_VAL);
user.put("DEGREE_OF_EDUCATION", wenhuyachengdu.get("DICTIONARIES_ID"));
user.put("PERSONNEL_TYPE", renyuanleixing.get("DICTIONARIES_ID"));
user.put("DUTIES", zhiwu.get("DICTIONARIES_ID"));
user.put("TITLE", zhicheng.get("DICTIONARIES_ID"));
user.put("TYPE_OF_WORK", gongzhong.get("DICTIONARIES_ID"));
user.put("ENTRY_DATE", ENTRY_DATE_VAL);
user.put("WORKING_DATE", WORKING_DATE_VAL);
user.put("INCUMBENCY", zaizhiqingkuang.get("DICTIONARIES_ID"));
user.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
// }
addUserList.add(user);
}
if (Tools.isEmpty(errorStr.toString())) {
for (PageData pageData : addUserList) {
usersService.editUserState(pageData);
userInfoService.delete(pageData);
userInfoService.save(pageData);
}
errorStr.append("成功导入" + addUserList.size() + "条数据!");
} else {
errInfo = "error";
}
FileUtils.deleteQuietly(tempFile);//删除临时文件
2024-01-03 09:48:43 +08:00
}else {
map.put("result", "error"); //返回结果
map.put("msg", "Excel数据为空请检查数据后重新上传");
2024-01-03 11:04:18 +08:00
FileUtils.deleteQuietly(tempFile);//删除临时文件
2024-01-03 09:48:43 +08:00
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;
}
2024-01-03 11:04:18 +08:00
2024-01-03 09:48:43 +08:00
/**
*
* @param parentId id
* @param departMap
* @param valName
* @return
*/
public String getParentName (String parentId, Map<String, Object> departMap ) {
StringBuffer keyName = new StringBuffer();
for(int i=0;i<4;i++) {
PageData dept = (PageData) departMap.get(parentId);
if("0".equals(dept.getString("PARENT_ID"))) {
keyName.append(dept.getString("NAME")+"-");
break;
}else {
keyName.append(dept.getString("NAME")+"-");
parentId = dept.getString("PARENT_ID");
}
}
return keyName.toString();
}
/** ID
* @return
* @throws Exception
*/
@RequestMapping(value="/goUserId")
@ResponseBody
public Object goUserId() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
map.put("result", errInfo);
map.put("USER_ID", Jurisdiction.getUSER_ID());
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/listUserByCorp")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "高危作业管理",menuServer= "有限空间作业管理",instructionsOperate = "有限空间台账",instructionsType = "查询公司所有用户")
2024-01-03 09:48:43 +08:00
public Object listUserByCorp() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userList = usersService.listUserDepPos(pd); //列出Post列表
map.put("userList", userList);
map.put("result", errInfo);
return map;
}
/**
* listCascader
* @return
*/
@RequestMapping(value="/listCascader")
@RequiresPermissions("department:list")
@ResponseBody
public Object listCascader()throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
List<PageData> pdList = new ArrayList<PageData>();
List<Dictionaries> dictList = dictionariesService.listSubDictByParentId("532282f9c48346b8b646531909c739df"); //获取在线考试适用人员的子列表数据
PageData pd = new PageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userList = this.usersService.listCascader(pd); //获取单位下的所有人员
PageData other = new PageData();
other.put("value", "-");
other.put("label", "其他");
List<PageData> otherChildrenList = new ArrayList<PageData>();
for (Dictionaries dict : dictList ) {
PageData pd0 = new PageData();
pd0.put("value", dict.getBIANMA());
pd0.put("label", dict.getNAME());
List<PageData> childrenList = new ArrayList<PageData>();
for (PageData user : userList ) {
if (user.get("LEARNERCATEGORY") != null && dict.getBIANMA().equals(user.getString("LEARNERCATEGORY"))) {
PageData pd1 = new PageData();
pd1.put("value", user.getString("USER_ID"));
pd1.put("label", user.getString("USERNAME")+" [" + user.getString("DEPARTMENTNAME") + " ]");
childrenList.add(pd1);
}
}
if (childrenList.size() > 0) {
pd0.put("children", childrenList);
pdList.add(pd0);
}
}
//未设置人员在线学习分类的放到其他里
for (PageData user : userList ) {
if (user.get("LEARNERCATEGORY") == null) {
PageData pd1 = new PageData();
pd1.put("value", user.getString("USER_ID"));
pd1.put("label", user.getString("USERNAME")+" [" + user.getString("DEPARTMENTNAME") + " ]");
otherChildrenList.add(pd1);
}
}
if (otherChildrenList.size() > 0) {
other.put("children", otherChildrenList);
pdList.add(other);
}
JSONArray arr = JSONArray.fromObject(pdList);
String json = arr.toString();
map.put("USER_ID", Jurisdiction.getUSER_ID());
map.put("CascaderNodes", json);
map.put("result", errInfo);
return map;
}
/**
* listCascader
* @return
*/
@RequestMapping(value="/listCascaderByDeptLevel")
// @RequiresPermissions("department:list")
@ResponseBody
2024-01-03 11:04:18 +08:00
@LogAnno(menuType= "监测预警",menuServer= "安全承诺",instructionsOperate = "公司级承诺公告",instructionsType = "显示列表listCascader")
2024-01-03 09:48:43 +08:00
public Object listCascaderByDeptLevel()throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
List<PageData> pdList = new ArrayList<PageData>();
PageData pd = new PageData();
pd = this.getPageData();
pd.put("PARENT_ID", "4a661fa8aedc4d158c9cddaa9d2ec47e"); //获取部门级别数据
List<Dictionaries> dictList = dictionariesService.listSubDictByParent(pd);
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userList = this.usersService.listCascader(pd); //获取单位下的所有人员
for (Dictionaries dict : dictList ) {
PageData pd0 = new PageData();
pd0.put("value", dict.getBIANMA());
pd0.put("label", dict.getNAME());
List<PageData> childrenList = new ArrayList<PageData>();
for (PageData user : userList ) {
PageData pd1 = new PageData();
pd1.put("value", user.getString("USER_ID"));
pd1.put("label", user.getString("USERNAME") + " [" + user.getString("DEPARTMENTNAME") + " ]");
childrenList.add(pd1);
}
if (childrenList.size() > 0) {
pd0.put("children", childrenList);
pdList.add(pd0);
}
}
//未设置人员在线学习分类的放到其他里
// PageData other = new PageData();
// other.put("value", "-");
// other.put("label", "其他");
// List<PageData> otherChildrenList = new ArrayList<PageData>();
// for (PageData user : userList ) {
// if (user.get("LEARNERCATEGORY") == null) {
// PageData pd1 = new PageData();
// pd1.put("value", user.getString("USER_ID"));
// pd1.put("label", user.getString("USERNAME")+" [" + user.getString("DEPARTMENTNAME") + " ]");
// otherChildrenList.add(pd1);
// }
// }
// if (otherChildrenList.size() > 0) {
// other.put("children", otherChildrenList);
// pdList.add(other);
// }
JSONArray arr = JSONArray.fromObject(pdList);
String json = arr.toString();
map.put("USER_ID", Jurisdiction.getUSER_ID());
map.put("CascaderNodes", json);
map.put("result", errInfo);
return map;
}
2024-01-03 11:04:18 +08:00
/**
*
* @throws Exception
*/
@RequestMapping(value="/updataSignType")
@ResponseBody
@LogAnno(menuType= "教育培训",menuServer= "签字信息管理",instructionsOperate = "签字信息管理",instructionsType = "修改用户签字信息状态")
public Object updataSignType() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
String msg = "";
PageData pd = new PageData();
pd = this.getPageData();
PageData userInfo = userInfoService.findById(pd);// 获取用户的详情信息.没有的就是没有签字的
if(null == userInfo || Tools.isEmpty(userInfo.get("USER_SIGN_FILE_PATH"))){
errInfo = "error";
msg = "未找到用户签字信息请该用户先在APP中设置签字信息";
map.put("result", errInfo);
map.put("msg", msg);
return map;
}
PageData updatePd = new PageData();
updatePd.put("USER_ID",userInfo.getString("USER_ID"));
if(!Tools.isEmpty(pd.get("type"))){// IS_RECORDER IS_RECORDER
if("IS_RECORDER".equals(pd.get("type").toString())){
updatePd.put("IS_RECORDER",pd.getString("state"));
}
if("IS_CHARGE".equals(pd.get("type").toString())){
updatePd.put("IS_CHARGE",pd.getString("state"));
}
userInfoService.editUserSignType(updatePd);
}
map.put("result", errInfo);
map.put("msg", msg);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/listAllByCorp")
@ResponseBody
@LogAnno(menuType= "监测预警",menuServer= "在线监测",instructionsOperate = "智能预警",instructionsType = "列表")
public Object listAllByCorp() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
List<PageData> userList = usersService.listAllUser(pd); //列出Post列表
map.put("userList", userList);
map.put("result", errInfo);
return map;
}
2024-01-03 09:48:43 +08:00
}