package com.zcloud.controller.system; import java.io.File; import java.text.SimpleDateFormat; import java.util.*; import javax.servlet.http.HttpServletResponse; import cn.hutool.json.JSONUtil; import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSON; import com.zcloud.dto.UpdateEnum; import com.zcloud.entity.system.Dictionaries; import com.zcloud.entity.system.User; import com.zcloud.service.bus.*; import com.zcloud.service.system.*; import com.zcloud.syncData.SyncPlatformAdvice; import com.zcloud.syncData.SyncTypeEnum; import com.zcloud.util.*; import org.apache.commons.collections.map.ListOrderedMap; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.fop.layoutmgr.PaddingElement; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.crypto.hash.SimpleHash; import org.hyperic.sigar.pager.PageList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.entity.system.Role; import net.sf.json.JSONArray; import sun.security.krb5.internal.PAData; import sun.util.logging.resources.logging; /** * 说明:系统用户处理类 * 作者:luoxiaobao * 官网:www.qdkjchina.com */ @Controller @RequestMapping("/user") public class UsersController extends BaseController { @Autowired private UsersService usersService; @Autowired private RoleService roleService; @Autowired private UeditorService ueditorService; @Autowired 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 LicenseInforService licenseInforService; @Autowired private UserInfoService userInfoService; @Autowired private ImgFilesService imgfilesService; @Autowired private DictionariesCorpService dictionariesCorpService; @Autowired private UserExamineService userExamineService; @Autowired private DictionariesService dictionariesService; @Value("${tongbu.url}") private String tongBuUrl; /** * 进入权限首页 * * @param * @return * @throws Exception */ @RequestMapping("/list1") @ResponseBody public Object list1() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if (Tools.isEmpty(pd.getString("ROLE_ID"))) { pd.put("ROLE_ID", "1"); //默认列出第一组角色(初始设计系统用户和会员组不能删除) } PageData fpd = new PageData(); fpd.put("ROLE_ID", "0"); List role1List = usersService.listAllRolesByPId(fpd); //列出组(页面横向排列的一级组) List roleList_z = usersService.listAllRolesByPId(pd); //列出此组下架角色 pd = usersService.findById(pd); //取得点击的角色组(横排的) map.put("pd", pd); map.put("role1List", role1List); map.put("roleList_z", roleList_z); map.put("result", errInfo); return map; } /** * 用户列表 * * @param page * @return * @throws Exception */ @RequestMapping("/list") @RequiresPermissions("user:list") @ResponseBody public Object listUsers(Page page) throws Exception { Map map = new HashMap(); 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"); //关键词检索条件 String USER_ID = pd.getString("USER_ID"); if (Tools.notEmpty(DEPARTMENT_ID)) pd.put("DEPARTMENT_ID", DEPARTMENT_ID.trim()); String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 String ENDTIME = pd.getString("ENDTIME"); //结束时间 if (Tools.notEmpty(STRARTTIME)) pd.put("STRARTTIME", STRARTTIME + " 00:00:00"); if (Tools.notEmpty(ENDTIME)) pd.put("ENDTIME", ENDTIME + " 00:00:00"); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); List userList = usersService.userlistPage(page); //列出用户列表 pd.put("ROLE_ID", "1"); List 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; } /** * 根据部门ID查询用户列表 * * @param page * @return * @throws Exception */ @RequestMapping("/getDepartmentId") @RequiresPermissions("user:list") @ResponseBody public Object getDepartmentId(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String[] departmentIds = pd.getString("DEPARTMENT_ID").split(","); List userList = new ArrayList<>(); if (departmentIds.length > 1) { userList = usersService.getDepartmentIds(departmentIds); //列出用户列表 } else { userList = usersService.getDepartmentId(pd.getString("DEPARTMENT_ID")); //列出用户列表 } pd.put("ROLE_ID", "1"); map.put("userList", userList); map.put("page", page); map.put("pd", pd); map.put("result", errInfo); return map; } /** * 查询本部门下除了选择过审核人、审批人之外的所有人 * * @param page * @return * @throws Exception */ @RequestMapping("/userConfirm") @RequiresPermissions("user:list") @ResponseBody public Object userConfirm(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); page.setPd(pd); List userList = usersService.userConfirmPage(page); //列出用户列表 map.put("userList", userList); map.put("page", page); map.put("result", errInfo); return map; } /** * 查询本部门下除了选择过确认人、审批人之外的所有人 * * @param page * @return * @throws Exception */ @RequestMapping("/userExamine") @RequiresPermissions("user:list") @ResponseBody public Object userExamine(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); page.setPd(pd); List userList = usersService.userExaminePage(page); //列出用户列表 map.put("userList", userList); map.put("page", page); map.put("result", errInfo); return map; } /** * 查询本部门下除了选择过确认人、审核人之外的所有人 * * @param page * @return * @throws Exception */ @RequestMapping("/userApprove") @RequiresPermissions("user:list") @ResponseBody public Object userApprove(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); page.setPd(pd); List userList = usersService.userApprovePage(page); //列出用户列表 map.put("userList", userList); map.put("page", page); map.put("result", errInfo); return map; } /** * 用户列表(多选列表使用) * * @param page * @return * @throws Exception */ @RequestMapping("/listSelect") @ResponseBody public Object listSelect(Page page) throws Exception { Map map = new HashMap(); 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()); String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 String ENDTIME = pd.getString("ENDTIME"); //结束时间 if (Tools.notEmpty(STRARTTIME)) pd.put("STRARTTIME", STRARTTIME + " 00:00:00"); if (Tools.notEmpty(ENDTIME)) pd.put("ENDTIME", ENDTIME + " 00:00:00"); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); List 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 public Object goAddUser() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); // pd.put("ROLE_ID", "63fb19a7907247899cca16905396e017"); pd.put("ROLE_ID", "1"); List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 map.put("roleList", roleList); String corpId = Jurisdiction.getCORPINFO_ID(); pd.put("CORPINFO_ID", corpId); PageData corp = corpInfoService.findById(pd); String corpName = corp.getString("ROLE_NAME"); pd.put("ROLE_ID", corpName); List roleList1 = roleService.listAllRolesByPId(pd); //获取部门下拉树 // List zdepartmentPdList = new ArrayList(); // 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 zdepartmentPdList = new ArrayList(); 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 postList = this.postService.listAll(post); map.put("postList", postList); map.put("roleList1", roleList1); map.put("result", errInfo); return map; } /** * 去修改用户页面(从系统用户页面修改) * * @return * @throws Exception */ @RequestMapping(value = "/goEditUser") @ResponseBody public Object goEditUser() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); PageData pd1 = new PageData(); pd = this.getPageData(); if ("1".equals(pd.getString("USER_ID"))) { return null; } //不能修改admin用户 pd.put("ROLE_ID", "1"); List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 pd = usersService.findById(pd); // //获取部门下拉树 // List zdepartmentPdList = new ArrayList(); // 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 zdepartmentPdList = new ArrayList(); 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读取 PageData shiftDutyPeriod = new PageData(); shiftDutyPeriod.put("DURATION", pd.get("DURATION")); shiftDutyPeriod.put("WORKSTATUS", pd.get("WORKSTATUS")); shiftDutyPeriod.put("WORKPERIOD", pd.get("WORKPERIOD")); pd1 = licenseInforService.findById(pd); 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 证书信息 List userCerList = new ArrayList<>(); 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); } List face_file = new ArrayList<>(); if (null != userInfo) { PageData userCerPd = new PageData(); userCerPd.put("TYPE", "30"); userCerPd.put("FOREIGN_KEY", pd.get("USER_ID")); face_file = imgfilesService.listAll(userCerPd); pd.putAll(userInfo); } //获取岗位下拉 PageData post = new PageData(); post.put("DEPARTMENT_ID", ZDEPARTMENT_ID); post.put("STATUS", 0); List postList = this.postService.listAll(post); map.put("postList", postList); map.put("pd", pd); map.put("period", shiftDutyPeriod); map.put("periodStr", shiftDutyPeriod.getString("DURATION") + ',' + shiftDutyPeriod.getString("WORKSTATUS") + ',' + shiftDutyPeriod.getString("WORKPERIOD")); map.put("licenseinfor", pd1); map.put("userCerList", userCerList); map.put("face_file", face_file); map.put("roleList", roleList); map.put("result", errInfo); return map; } /** * 去修改用户页面(个人资料修改) * * @return * @throws Exception */ @RequestMapping(value = "/goEditMyInfo") @ResponseBody public Object goEditMyInfo() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("ROLE_ID", "1"); List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 pd.put("USERNAME", Jurisdiction.getUsername()); pd = usersService.findByUsername(pd); //根据用户名读取 //获取部门下拉树 // List zdepartmentPdList = new ArrayList(); // 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 zdepartmentPdList = new ArrayList(); 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); 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); //获取岗位下拉 PageData post = new PageData(); post.put("DEPARTMENT_ID", ZDEPARTMENT_ID); post.put("STATUS", 0); List postList = this.postService.listAll(post); map.put("postList", postList); map.put("pd", pd); map.put("deptname", deptname.getString("NAME"));//获取当前登录的人部门名称 map.put("roleList", roleList); map.put("result", errInfo); return map; } /** * 修改用户排班信息 */ @RequestMapping(value = "/editUserScheduling") @RequiresPermissions("user:edit") @ResponseBody public Object editUserScheduling(String USER_ID) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); usersService.editUserScheduling(pd); pd = usersService.findById(pd); //根据ID读取 map.put("result", errInfo); map.put("pd", pd); return map; } /** * 修改用户(系统用户列表修改) */ @RequestMapping(value = "/editUser") @RequiresPermissions("user:edit") @ResponseBody @SyncPlatformAdvice(type = SyncTypeEnum.PERSONNEL, isUpdate = true) public Object editUser() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); 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 (!Tools.isEmpty(pd.getString("ROLE_ID"))) { if (pd.getString("ROLE_ID").contains(",")) { String roleId = pd.getString("ROLE_ID").substring(0, pd.getString("ROLE_ID").indexOf(","));//截取第一个,之前的数据 String roleIds = pd.getString("ROLE_ID").substring(roleId.length() + 1, pd.getString("ROLE_ID").length());//截取第一个,之后的数据 pd.put("ROLE_ID", roleId); pd.put("ROLE_IDS", roleIds); } else { pd.put("ROLE_ID", pd.getString("ROLE_ID")); pd.put("ROLE_IDS", ""); } } String USERNAME = usersService.findById(pd).getString("USERNAME"); if (!USERNAME.equals(pd.getString("USERNAME"))) { pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), Const.DEFAULT_PASSWORD).toString()); } if ("true".equals(pd.getString("ISSTUDENT"))) { pd.put("IS_ONLINELEARNING", '1'); } // todo // 定位卡号 规则 如果俩个人使用同一一个卡号,最后一个人会是这个卡号。保证一个卡号一个人用。(11.28) // 不同的公司,它定位卡的配置方案是不一样的,就你像九公司,九公司的卡是随机的。就他不是卡跟着人走,他就一天一变。 目前暂定这样 if (Tools.notEmpty(pd.getString("CARDNO"))) { usersService.resetCardNo(pd); } //每次人员信息更改都要将人物状态置为未推送且不可查询,需推送后在进行使用 pd.put("ISDELETE","1"); pd.put("ISPUSH","0"); usersService.editUser(pd); //执行修改 if ("true".equals(pd.getString("ISSTUDENT"))) { pd.put("IS_ONLINELEARNING", "1"); 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); } else { userInfoService.delete(pd); userInfoService.save(pd); } if (null == licenseInforService.findById(pd)) { if (pd.getString("PERSON_TYPE") != null) { if (pd.getString("PERSON_TYPE").equals("主要负责人") || pd.getString("PERSON_TYPE").equals("安全管理人员") || pd.getString("PERSON_TYPE").equals("特种作业人员")) { pd.put("INFOR_ID", this.get32UUID()); pd.put("USER_ID", pd.getString("USER_ID")); if (pd.getString("INFORPOSTValue") != null || !(pd.getString("INFORPOSTValue") == "")) { pd.put("INFORPOST", pd.getString("INFORPOSTValue")); } if (pd.getString("INFORTITLEValue") != null || !(pd.getString("INFORTITLEValue") == "")) { pd.put("INFORTITLE", pd.getString("INFORTITLEValue")); } if (pd.getString("INFORWORKValue") != null || !(pd.getString("INFORWORKValue") == "")) { pd.put("INFORWORK", pd.getString("INFORWORKValue")); } if (Tools.notEmpty(pd.getString("INFORPOSTValue"))) { if ("select".equals(pd.getString("letDutiesType"))) { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754"); dicPd.put("BIANMA", "zhiwu"); dicPd.put("NAME", pd.getString("INFORPOSTValue"));//职务的值 dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); //pd.put("DUTIES",dicPd.getString("DICTIONARIES_ID")); } } if (Tools.notEmpty(pd.getString("INFORTITLEValue"))) { if ("select".equals(pd.getString("letTitleType"))) { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679"); dicPd.put("BIANMA", "zhicheng"); dicPd.put("NAME", pd.getString("INFORTITLEValue")); dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); //pd.put("TITLE",dicPd.getString("DICTIONARIES_ID")); } } if (Tools.notEmpty(pd.getString("INFORWORKValue"))) { if ("select".equals(pd.getString("letTypeOfWorkType"))) { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "55484e491a5e442d839c4595380713ec"); dicPd.put("BIANMA", "gongzhong"); dicPd.put("NAME", pd.getString("INFORWORKValue")); dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); //pd.put("TYPE_OF_WORK",dicPd.getString("DICTIONARIES_ID")); } } licenseInforService.save(pd); //保存用户证照信息 } } } else { licenseInforService.edit(pd); } // 如果修改了部门/岗位,将该用户所有清单都删除 if (!Tools.isEmpty(pd.get("OPERATIONTYPE"))) { List 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); } } } } } System.out.println(pd.getString("isUpdateFace")); if (pd.getString("isUpdateFace").equals("1")) { //若修改了人脸图片 imgfilesService.delete(pd); //删除旧人脸图片 } map.put("result", errInfo); map.put("code","0"); map.put("syncInfo", JSONUtil.toJsonStr(usersService.findById(pd))); return map; } /** * 修改用户(系统用户列表修改) */ @RequestMapping(value = "/editUserFuns") @RequiresPermissions("user:edit") @ResponseBody @SyncPlatformAdvice(type = SyncTypeEnum.PERSONNEL, isUpdate = true) public Object editUserFuns() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); FHLOG.save(Jurisdiction.getUsername(), "从系统用户中修改" + pd.getString("USERNAME") + "的小程序菜单权限"); //记录日志 usersService.editUserFuns(pd); //执行修改 map.put("result", errInfo); map.put("code", "0"); map.put("syncInfo", JSONUtils.toJSONString(usersService.findById(pd))); return map; } /** * 修改用户(个人资料修改) */ @RequestMapping(value = "/editUserOwn") @ResponseBody @SyncPlatformAdvice(type = SyncTypeEnum.PERSONNEL, isUpdate = true) public Object editUserOwn() throws Exception { Map map = new HashMap(); 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); map.put("code", "0"); map.put("syncInfo", JSONUtils.toJSONString(usersService.findById(pd))); return map; } /** * 判断用户名是否存在 * * @return */ @RequestMapping(value = "/hasUser") @ResponseBody public Object hasUser() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = usersService.findByUsername(pd); if (pd != null) { map.put("pd", pd); errInfo = "fail"; map.put("msg", "用户名重复"); } map.put("result", errInfo); //返回结果 return map; } /** * 判断邮箱是否存在 * * @return */ @RequestMapping(value = "/hasEmail") @ResponseBody public Object hasEmail() throws Exception { Map map = new HashMap(); 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 map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if (usersService.findByNumbe(pd) != null) { errInfo = "fail"; } map.put("result", errInfo); //返回结果 return map; } /** * 保存用户 * * @return * @throws Exception */ @RequestMapping(value = "/saveUser") @RequiresPermissions("user:add") @ResponseBody @SyncPlatformAdvice(type = SyncTypeEnum.PERSONNEL, isInsert = true) public Object saveUser() throws Exception { Map map = new HashMap<>(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String ID = this.get32UUID(); pd.put("USER_ID", ID); //ID 主键 pd.put("LAST_LOGIN", ""); //最后登录时间 pd.put("IP", ""); //IP pd.put("STATUS", "0"); //状态 pd.put("ISMAIN", "0"); //状态 pd.put("ISDELETE", "1"); //是否删除,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()); //密码加密 pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pd.put("ISPUSH", "0"); Map resultMap = doCheck(pd.getString("USERNAME"), pd.getString("USER_ID_CARD"), ""); if (resultMap.get("result").equals("success")) { if (null == usersService.findByUsername(pd)) { //判断用户名是否存在 if (pd.getString("ROLE_ID").contains(",")) { String roleId = pd.getString("ROLE_ID").substring(0, pd.getString("ROLE_ID").indexOf(","));//截取第一个,之前的数据 String roleIds = pd.getString("ROLE_ID").substring(roleId.length() + 1, pd.getString("ROLE_ID").length());//截取第一个,之后的数据 pd.put("ROLE_ID", roleId); pd.put("ROLE_IDS", roleIds); } if ("true".equals(pd.getString("ISSTUDENT"))) { pd.put("IS_ONLINELEARNING", '1'); } // todo // 定位卡号 规则 如果俩个人使用同一一个卡号,最后一个人会是这个卡号。保证一个卡号一个人用。(11.28) // 不同的公司,它定位卡的配置方案是不一样的,就你像九公司,九公司的卡是随机的。就他不是卡跟着人走,他就一天一变。 目前暂定这样 if (Tools.notEmpty(pd.getString("CARDNO"))) { usersService.resetCardNo(pd); }else { pd.put("CARDNO",null); } usersService.saveUser(pd); //执行保存 if ("true".equals(pd.getString("ISSTUDENT"))) { pd.put("IS_ONLINELEARNING", '1'); 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")); } } else { userInfoService.save(pd); } String PERSON_TYPE = pd.getString("PERSONNEL_TYPE"); if (pd.getString("PERSON_TYPE").equals("主要负责人") || pd.getString("PERSON_TYPE").equals("安全管理人员") || pd.getString("PERSON_TYPE").equals("特种作业人员")) { if ("select".equals(pd.getString("inforpostType"))) { pd.put("INFORPOST", pd.getString("INFORPOST")); } else { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754"); dicPd.put("BIANMA", "zhiwu"); dicPd.put("NAME", pd.getString("INFORPOSTValue")); dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); pd.put("INFORPOST", dicPd.getString("DICTIONARIES_ID")); } if ("select".equals(pd.getString("infortitleType"))) { pd.put("INFORTITLE", pd.getString("INFORTITLE")); } else { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679"); dicPd.put("BIANMA", "zhicheng"); dicPd.put("NAME", pd.getString("INFORTITLEValue")); dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); pd.put("INFORTITLE", dicPd.getString("DICTIONARIES_ID")); } if ("select".equals(pd.getString("inforworkType"))) { pd.put("INFORWORK", pd.getString("INFORWORK")); } else { PageData dicPd = new PageData(); dicPd.put("PARENT_ID", "55484e491a5e442d839c4595380713ec"); dicPd.put("BIANMA", "gongzhong"); dicPd.put("NAME", pd.getString("INFORWORKValue")); dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd); pd.put("INFORWORK", dicPd.getString("DICTIONARIES_ID")); } pd.put("INFOR_ID", this.get32UUID()); pd.put("USER_ID", ID); licenseInforService.save(pd); //保存用户证照信息 } //封装调用参数 } else { map.put("result", "Error"); map.put("msg", "用户名重复"); return map; } FHLOG.save(Jurisdiction.getUsername(), "新增用户:" + pd.getString("USERNAME")); //记录日志 PageData userPd = new PageData(); userPd.put("USER_ID",ID); PageData userinfo = usersService.findById(userPd); userinfo.put("ISDELETE","0"); map.put("USERINFO", userinfo); map.put("USER_ID",ID); map.put("result", errInfo); //返回结果 map.put("code", "0"); map.put("syncInfo", JSONUtil.toJsonStr(userinfo)); } else { map.put("result", "您输入的身份证号和用户名二次校验失败,请确认后重新申请"); //返回结果 } return map; } /** * 删除用户 * * @return */ @RequestMapping(value = "/deleteUser") @RequiresPermissions("user:del") @ResponseBody public Object deleteUser() throws Exception { Map map = new HashMap(); PageData pd = new PageData(); String errInfo = "success"; pd = this.getPageData(); Map returnMap = null; if (pd.getString("ISPUSH").equals("1")) { // ------联通人员定位删除人员用------ // 用于获取除UID ISDELETE外的其他信息 PageData detail = usersService.findById(pd); pd.putAll(detail); // ------------------------------- pd.put("ISDELETE","1"); HashMap param = new HashMap<>(); Set set = pd.keySet(); for (Object key : set) { param.put(key.toString(),pd.getString(key.toString())); } String UserDto = JSON.toJSONString(param); String result = HttpClientUtilDoGet.sendHttpPost(tongBuUrl + "/docking/core/user/addOrUpdate", UserDto,param); returnMap = (Map) JSON.parse(result); } if (pd.getString("ISPUSH").equals("0") || returnMap.get("result").equals("success")) { FHLOG.save(Jurisdiction.getUsername(), "删除用户ID:" + pd.getString("USER_ID")); //记录日志 usersService.deleteUser(pd); //删除用户 ueditorService.delete(pd); //删除副文本关联数据 List 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); //返回结果 } else { map.put("result", "error"); //返回结果 } return map; } /** * 批量删除 * * @throws Exception */ @RequestMapping(value = "/deleteAllUser") @RequiresPermissions("user:del") @ResponseBody public Object deleteAllUser() throws Exception { PageData pd = new PageData(); Map map = new HashMap(); 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 = "fail"; } 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 { /*检索条件*/ pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); Map dataMap = new HashMap(); List titles = new ArrayList(); titles.add("部门"); //1 titles.add("岗位"); //2 titles.add("姓名"); //3 titles.add("用户名(电话)"); //4 titles.add("人员类型"); //5 titles.add("是否隐患确认人"); //6 dataMap.put("titles", titles); List userList = usersService.userlistAllToExcel(pd); //列出用户列表 List varList = new ArrayList(); for (int i = 0; i < userList.size(); i++) { PageData vpd = new PageData(); vpd.put("var1", userList.get(i).getString("deptName")); //2 vpd.put("var2", userList.get(i).getString("postName")); //3 vpd.put("var3", userList.get(i).getString("name")); //4 vpd.put("var4", userList.get(i).getString("username")); //5 vpd.put("var5", userList.get(i).getString("PERSON_TYPE")); //6 if ("1".equals(userList.get(i).getString("IS_HAZARDCONFIRMER"))) { vpd.put("var6", "是"); //7 } else { vpd.put("var6", "否"); //7 } varList.add(vpd); } dataMap.put("varList", varList); ObjectExcelView erv = new ObjectExcelView(); //执行excel操作 mv = new ModelAndView(erv, dataMap); } catch (Exception e) { } return mv; } /** * 下载模版 * * @param response * @throws Exception */ @RequestMapping(value = "/downExcel") public void downExcel(HttpServletResponse response) throws Exception { FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "Users.xls", "Users.xls"); } /** * 从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 map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); if (null != file && !file.isEmpty()) { String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1).toLowerCase(); if (!"xls".equals(suffixName)) { errInfo = "fail"; map.put("result", errInfo); map.put("msg", "文件格式不正确!"); return map; } String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + "user/"; //文件上传路径 String fileName = FileUpload.fileUp(file, filePath, "userexcel"); //执行上传 // String ffile = "user/"+DateUtil.getDays()+"/"; // String filePath = Const.FILEURL + Const.FILEPATHFILE + ffile; // String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); // Smb.sshSftp(file, fileName,Const.FILEPATHFILE + ffile); List listPd = (List) ObjectExcelRead.readExcel(filePath, fileName, 2, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet 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); } File old = new File(filePath, fileName); old.delete(); } map.put("result", errInfo); //返回结果 return map; } /** * 去修改用户页面(在线管理页面打开) * * @return * @throws Exception */ @RequestMapping(value = "/goEditUfromOnline") @ResponseBody public Object goEditUfromOnline() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if ("admin".equals(pd.getString("USERNAME"))) { return null; } //不能查看admin用户 pd.put("ROLE_ID", "1"); List 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 map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String USERNAME = pd.getString("USERNAME"); if ("admin".equals(USERNAME)) { return null; } //不能查看admin用户 pd.put("ROLE_ID", "1"); List 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 map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 String ENDTIME = pd.getString("ENDTIME"); //结束时间 if (Tools.notEmpty(STRARTTIME)) pd.put("STRARTTIME", STRARTTIME + " 00:00:00"); if (Tools.notEmpty(ENDTIME)) pd.put("ENDTIME", ENDTIME + " 00:00:00"); page.setPd(pd); List userList = usersService.listUsersBystaff(page); //列出用户列表(弹窗选择用) pd.put("ROLE_ID", "1"); List 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 * @throws Exception */ @RequestMapping(value = "/listAll") @ResponseBody public Object listAll() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = this.getPageData(); String[] departmentIds = pd.getString("DEPARTMENT_ID").split(","); if (departmentIds.length > 1) { pd.put("departmentIds", departmentIds); pd.remove("DEPARTMENT_ID"); } List userList = usersService.listAllUser(pd); //列出Post列表 map.put("userList", userList); map.put("result", errInfo); return map; } /** * 导出到excel * * @param * @throws Exception */ @RequestMapping(value = "/excelModel") @RequiresPermissions("toExcel") public void exportExcelModel(HttpServletResponse response) throws Exception { FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "userExcelTemplate2.xls", "用户导入模板.xls"); } /** * 从EXCEL导入到数据库 * * @param file * @return * @throws Exception */ @RequestMapping(value = "/readExcel2") @RequiresPermissions("fromExcel") @SuppressWarnings("unchecked") @ResponseBody @Transactional public Object readExcel2(@RequestParam(value = "FFILE", required = false) MultipartFile file) throws Exception { Map map = new HashMap(); String errInfo = "success"; StringBuffer errorStr = new StringBuffer(); if (null != file && !file.isEmpty()) { String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1).toLowerCase(); if (!"xls".equals(suffixName)) { errInfo = "fail"; map.put("result", errInfo); map.put("msg", "文件格式不正确!"); return map; } String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + "user/"; String fileName = FileUpload.fileUp(file, filePath, this.get32UUID());//执行上传 /* String fileTyle=fileName.substring(fileName.lastIndexOf("."),fileName.length()); String ffile = "riskpoint/"+DateUtil.getDays()+"/";*/ /* String filePath = Const.FILEURL + Const.FILEPATHFILE + ffile; String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); Smb.sshSftp(file, fileName,Const.FILEPATHFILE + ffile); */ List listPd = (List) ObjectExcelRead.readExcel(filePath, fileName, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet /** * var0 :部门 * var1 :岗位 * var2 :用户名 * var3 :姓名 * var4 :邮箱 * var5 :备注 */ List header = new ArrayList<>(); 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 departList = departmentService.listAll(departPd); Map departMap = new HashMap<>(); for (PageData pageData : departList) { departMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData); } /* Map 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 postList = postService.listAll(postPd); Map> postMap = new HashMap<>(); //部门id,岗位map for (PageData pageData : postList) { Map 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 userList = usersService.findUserNameAll(userPd); List userEList = usersService.findAllUser(userPd); Map userMap = new HashMap<>(); Map 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("ROLE_NAME", "企业分级账号"); PageData role = roleService.findByName(rolePd); if (Tools.isEmpty(role)) { errorStr.append("未找到默认角色信息!请联系管理员"); map.put("result", errInfo); //返回结果 map.put("msg", ""); //返回结果 return map; } /** * 判断是否填写必填 * 判断excel是有有重复数据 * 判断数据库是否有重复数据 * 导入 Page * * 企业分级账号 */ Map hasUserNameChongfu = new HashMap<>();//判断重复数据 Map emailChongfu = new HashMap<>();//判断重复数据 Integer number = 0;//行数,用于提示用户 List addUserList = new ArrayList<>(); for (PageData lpd : listPd) { number++; for (int i = 0; i < 6; i++) { 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 = "fail"; errorStr.append("第"+number+"行,公司级部门,岗位,用户名,姓名为信息必填项,请重新确认数据"); break; } */ /* if(!departMap.containsKey(dept)) { errorStr.append("第"+number+"行的"+header.get(0)+"未找到名称为\""+dept+"\"的部门"+";\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 = "fail"; errorStr.append("第"+number+"行,岗位信息为空,请重新确认数据"); break; }*/ if (!postMap.containsKey(departId)) { errorStr.append("第" + number + "行,未找到该部门的岗位信息,请重新确认数据;\n"); continue; } Map 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 = "fail"; errorStr.append("第"+number+"行,"); errorStr.append("在"+keyDept+"部门下,未找到"+postName+"岗位信息,请重新确认数据"); break; }*/ /** 岗位 结束**/ if (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 = "fail"; 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, Const.DEFAULT_PASSWORD).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", ""); user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); addUserList.add(user); } if (Tools.isEmpty(errorStr.toString())) { for (PageData pageData : addUserList) { usersService.saveUser(pageData); } errorStr.append("成功导入" + addUserList.size() + "条数据!"); } else { errInfo = "fail"; } File old = new File(filePath, fileName); old.delete(); } else { map.put("result", "error"); //返回结果 map.put("msg", "Excel数据为空,请检查数据后,重新上传!"); File old = new File(filePath, fileName); old.delete(); 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; } /** * 递归循环 找到父节点名称 * * @param parentId 部门父节点id * @param departMap 全部部门信息 * @return 从子节点开始往上循序 */ public String getParentName(String parentId, Map 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 map = new HashMap(); String errInfo = "success"; map.put("result", errInfo); map.put("USER_ID", Jurisdiction.getUSER_ID()); return map; } /** * 查询公司所有用户 * * @param * @throws Exception */ @RequestMapping(value = "/listUserByCorp") @ResponseBody public Object listUserByCorp() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List userList = usersService.listUserDepPos(pd); //列出Post列表 map.put("userList", userList); map.put("result", errInfo); return map; } /** * 查询部门审核人是谁 * * @param * @throws Exception */ @RequestMapping(value = "/userExamineList") @ResponseBody public Object UserExamineList() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if (pd.getString("type").equals("1")) { pd.put("IS_TO_EXAMINE", '1'); } else if (pd.getString("type").equals("2")) { pd.put("IS_EXAMINE_AND_APPROVE", '1'); } else { pd.put("IS_DEPT_CONFIRM", '1'); } pd.getString("DEPARTMENT_ID"); List examineList = userExamineService.userExamineList(pd); List userList = userExamineService.findDeptById(pd); map.put("examineList", examineList); map.put("userNameList", userList); map.put("result", errInfo); //返回结果 return map; } /** * 用户是否是:部门审核人、部门审批人、部门确认 * * @param * @throws Exception */ @RequestMapping(value = "/saveUserExamine") @ResponseBody public Object saveUserExamine() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if (pd.getString("IS_TO_EXAMINE").equals("1")) { userExamineService.deleteExamine(pd); } if (pd.getString("IS_EXAMINE_AND_APPROVE").equals("1")) { userExamineService.deleteApprove(pd); } if (pd.getString("IS_DEPT_CONFIRM").equals("1")) { userExamineService.deleteConfirm(pd); } if (Tools.notEmpty(pd.getString("USER_ID"))) { if (pd.getString("USER_ID").contains(",")) { String UserId[] = pd.getString("USER_ID").split(","); for (int i = 0; i < UserId.length; i++) { pd.put("USER_ID", UserId[i]); pd.put("IS_TO_EXAMINE", pd.getString("IS_TO_EXAMINE")); pd.put("IS_EXAMINE_AND_APPROVE", pd.getString("IS_EXAMINE_AND_APPROVE")); pd.put("IS_DEPT_CONFIRM", pd.getString("IS_DEPT_CONFIRM")); pd.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); userExamineService.saveUser(pd); } } else { pd.put("USER_ID", pd.getString("USER_ID")); pd.put("IS_TO_EXAMINE", pd.getString("IS_TO_EXAMINE")); pd.put("IS_EXAMINE_AND_APPROVE", pd.getString("IS_EXAMINE_AND_APPROVE")); pd.put("IS_DEPT_CONFIRM", pd.getString("IS_DEPT_CONFIRM")); pd.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); userExamineService.saveUser(pd); } } map.put("result", errInfo); //返回结果 return map; } /** * 显示列表listCascader * * @return */ @RequestMapping(value = "/listCascader") @RequiresPermissions("department:list") @ResponseBody public Object listCascader() throws Exception { Map map = new HashMap(); String errInfo = "success"; List pdList = new ArrayList(); List dictList = dictionariesService.listSubDictByParentId("532282f9c48346b8b646531909c739df"); //获取在线考试适用人员的子列表数据 PageData pd = new PageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List userList = this.usersService.listCascader(pd); //获取单位下的所有人员 PageData other = new PageData(); other.put("value", "-"); other.put("label", "其他"); List otherChildrenList = new ArrayList(); for (Dictionaries dict : dictList) { PageData pd0 = new PageData(); pd0.put("value", dict.getBIANMA()); pd0.put("label", dict.getNAME()); List childrenList = new ArrayList(); 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; } /** * 获取隐患确认人 * * @param * @throws Exception */ @RequestMapping(value = "/getHiddenConfirm") @ResponseBody public Object getHiddenConfirm() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pd.put("IS_HAZARDCONFIRMER", "1"); List userList = usersService.listAllUser(pd); map.put("userList", userList); map.put("result", errInfo); //返回结果 return map; } /** * 从EXCEL导入到数据库 * * @param file * @return * @throws Exception */ @RequestMapping(value = "/readExcel3") @RequiresPermissions("fromExcel") @SuppressWarnings("unchecked") @ResponseBody public Object readExcel3(@RequestParam(value = "FFILE", required = false) MultipartFile file) throws Exception { String errInfo = "success"; Map retMap = new HashMap<>(); PageData pd = new PageData(); StringBuffer msgString = new StringBuffer(); String type = ""; if (null != file && !file.isEmpty()) { String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1).toLowerCase(); if (!"xls".equals(suffixName)) { errInfo = "fail"; retMap.put("result", errInfo); retMap.put("msg", "文件格式不正确!"); retMap.put("type", "error"); return retMap; } String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + "user/"; //文件上传路径 String fileName = FileUpload.fileUp(file, filePath, "userexcel"); //执行上传 String corpId = Jurisdiction.getCORPINFO_ID(); pd.put("CORPINFO_ID", corpId); PageData corp = corpInfoService.findById(pd); String corpName = corp.getString("CORP_NAME"); List listAll = (List) ObjectExcelRead.readExcel(filePath, fileName, 1, 0, 0); if (null == listAll || listAll.size() <= 0) { errInfo = "fail"; retMap.put("result", errInfo); retMap.put("msg", "模版无数据"); retMap.put("type", "error"); return retMap; } PageData corpInfoIdPd = new PageData(); corpInfoIdPd.put("CORPINFO_ID", corpId); List deptAllList = departmentService.listAll(corpInfoIdPd); // order by LEVEL Map deptAllListMap = new HashMap<>(); // 部门名称 --id ; 两种数据 ,1是一级部门。2是二级部门 Map deptIDAndDeptName = new HashMap<>(); for (PageData pageData : deptAllList) { String parentId = pageData.getString("PARENT_ID"); String deptName = pageData.getString("NAME"); String depeId = pageData.getString("DEPARTMENT_ID"); if (parentId.equals(corpId) || parentId.equals("0")) { deptAllListMap.put(deptName, depeId); deptIDAndDeptName.put(depeId, deptName); } } for (PageData pageData : deptAllList) { String parentId = pageData.getString("PARENT_ID"); String deptName = pageData.getString("NAME"); String depeId = pageData.getString("DEPARTMENT_ID"); if (!parentId.equals(corpId)) { String parentName = deptIDAndDeptName.get(parentId); deptAllListMap.put(parentName + "--" + deptName, depeId); } } List postAllList = postService.listAll(corpInfoIdPd); Map postAllListMap = new HashMap<>(); for (PageData pageData : postAllList) { String postName = pageData.getString("NAME"); String postID = pageData.getString("POST_ID"); String postDeptId = pageData.getString("DEPARTMENT_ID"); postAllListMap.put(postDeptId + "--" + postName, postID); } List userAllList = usersService.listAllUser(corpInfoIdPd); Map userAllListMap = new HashMap<>(); for (PageData pageData : userAllList) { userAllListMap.put(pageData.get("USERNAME").toString(), ""); } Map zhiwuAllMap = new HashMap<>(); corpInfoIdPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754"); List zhiwuAllList = dictionariesCorpService.listSubDictByParentId(corpInfoIdPd); for (Dictionaries dic : zhiwuAllList) { zhiwuAllMap.put(dic.getNAME(), dic.getDICTIONARIES_ID()); } Map zhichengAllMap = new HashMap<>(); corpInfoIdPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679"); List zhichengAllList = dictionariesCorpService.listSubDictByParentId(corpInfoIdPd); for (Dictionaries dic : zhichengAllList) { zhichengAllMap.put(dic.getNAME(), dic.getDICTIONARIES_ID()); } Map addDeptMap = new LinkedHashMap<>(); // 需要插入的二级部门 Map addBanzuMap = new LinkedHashMap<>(); //需要添加的三级部门 Map addPostMap = new LinkedHashMap<>();// 需要添加的岗位 Map addUser = new LinkedHashMap<>(); // 需要添加的用户信息 Map addzhiwuMap = new ListOrderedMap(); // 需要添加的职务 Map addzhichengMap = new ListOrderedMap(); // 需要添加的职务 int i = 0; for (PageData pageData : listAll) { i++; if (Tools.isEmpty(pageData.getString("var0")) || Tools.isEmpty(pageData.getString("var2")) || Tools.isEmpty(pageData.getString("var3"))) { msgString.append("第" + i + "行必填数据没有填写;"); type = "warning"; continue; } // 日期格式处理 try { Calendar calendar = new GregorianCalendar(1900, 0, -1); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); if (pageData.get("var7") != null && StringUtils.isNotBlank(pageData.get("var7").toString())) { // 入职日期处理 int intDay = Integer.parseInt(pageData.get("var7").toString()); Date ENTRY_DATE_date = DateUtils.addDays(calendar.getTime(), intDay); //对日期格式化操作 simpleDateFormat.format(ENTRY_DATE_date); } if (pageData.get("var8") != null && StringUtils.isNotBlank(pageData.get("var8").toString())) { // 参加工作日期处理 int intDay = Integer.parseInt(pageData.get("var8").toString()); Date WORKING_DATE_date = DateUtils.addDays(calendar.getTime(), intDay); //对日期格式化操作 simpleDateFormat.format(WORKING_DATE_date); } } catch (Exception e) { msgString.append("第" + i + "日期格式填写错误!"); type = "warning"; continue; } String deptName = pageData.getString("var0"); String banzuName = pageData.getString("var1"); String postName = pageData.getString("var2"); String deptId = UuidUtil.get32UUID(); String banzuID = UuidUtil.get32UUID(); String postID = UuidUtil.get32UUID(); String realDept = ""; if (deptAllListMap.containsKey(deptName)) { deptId = deptAllListMap.get(deptName); } else { if (!addDeptMap.containsKey(deptName)) {//如果是重复的不要再次改写数据,保证id的唯一性 addDeptMap.put(deptName, deptId); // 需要添加的二级部门 } else { deptId = addDeptMap.get(deptName); } } realDept = deptId; if (!Tools.isEmpty(banzuName)) { String deptNameAndBanzuName = deptName + "--" + banzuName; if (deptAllListMap.containsKey(deptNameAndBanzuName)) { banzuID = deptAllListMap.get(deptNameAndBanzuName); } else { if (!addBanzuMap.containsKey(deptNameAndBanzuName)) { addBanzuMap.put(deptNameAndBanzuName, deptId + "--" + banzuID); // 需要添加的三级部门--班组级 } else { String[] banzuDepteIds = addBanzuMap.get(deptNameAndBanzuName).split("--");//如果是重复的不要再次改写数据,保证id的唯一性 banzuID = banzuDepteIds[1]; } } realDept = banzuID; } String postDeptAndName = realDept + "--" + postName; if (postAllListMap.containsKey(postDeptAndName)) { // 查看这个部门下面是否有这个岗位 postID = postAllListMap.get(postDeptAndName);// 有这个岗位,岗位id是数据库中的id } else { if (addPostMap.containsKey(postDeptAndName)) { // 这条数据数据库中没有,切本次没有重复,添加到待添加的岗位map中等待添加 String[] postDeptIdAndPostID = addPostMap.get(postDeptAndName).split("--"); postID = postDeptIdAndPostID[1]; } else {// 本次循环中有这个岗位,使用第一次出现的岗位id addPostMap.put(postDeptAndName, realDept + "--" + postID); } } String zhiwuName = pageData.getString("var5"); String zhichengName = pageData.getString("var6"); if (!Tools.isEmpty(zhiwuName)) { if (!zhiwuAllMap.containsKey(zhiwuName)) { String zhiwuID = UuidUtil.get32UUID(); zhiwuAllMap.put(zhiwuName, zhiwuID); addzhiwuMap.put(zhiwuName, zhiwuID); } } if (!Tools.isEmpty(zhichengName)) { if (!zhichengAllMap.containsKey(zhichengName)) { String zhichengID = UuidUtil.get32UUID(); zhichengAllMap.put(zhichengName, zhichengID); addzhichengMap.put(zhiwuName, zhichengID); } } if (userAllListMap.containsKey(pageData.getString("var4"))) { msgString.append("第" + i + "行用户已经存在,请勿重复添加;"); type = "warning"; continue; } if (!addUser.containsKey(pageData.getString("var4"))) { PageData userPd = new PageData(); userPd.put("NAME", pageData.getString("var3")); userPd.put("USERNAME", pageData.getString("var4")); userPd.put("POST_ID", postID); userPd.put("DUTIES", zhiwuAllMap.get(zhiwuName)); userPd.put("TITLE", zhichengAllMap.get(zhichengName)); userPd.put("ENTRY_DATE", pageData.getString("var7")); userPd.put("WORKING_DATE", pageData.getString("var8")); userPd.put("DEPARTMENT_ID", realDept); userPd.put("INCUMBENCY", pageData.getString("var9")); addUser.put(pageData.getString("var4"), userPd); } else { msgString.append("第" + i + "行用户重复;"); type = "warning"; continue; } } Integer deptOrder = deptAllListMap.size(); for (Map.Entry entry : addDeptMap.entrySet()) { //部门的循环 String deptKey = entry.getKey(); Object deptVal = entry.getValue(); PageData dept = new PageData(); dept.put("DEPARTMENT_ID", deptVal); dept.put("NAME", deptKey); dept.put("CORPINFO_ID", corpId); dept.put("LEVEL", "departmentLevel0002"); dept.put("PARENT_ID", corpId); dept.put("DEP_ORDER", deptOrder); dept.put("ISSUPERVISE", "0"); departmentService.save(dept); deptOrder++; } for (Map.Entry entry : addBanzuMap.entrySet()) { //班组 String[] deptNameAndBanzuName = entry.getKey().split("--"); String[] deptIdAndBauziId = entry.getValue().split("--"); PageData dept = new PageData(); dept.put("DEPARTMENT_ID", deptIdAndBauziId[1]); dept.put("NAME", deptNameAndBanzuName[1]); dept.put("CORPINFO_ID", corpId); dept.put("LEVEL", "departmentLevel0003"); dept.put("PARENT_ID", deptIdAndBauziId[0]); dept.put("DEP_ORDER", deptOrder); dept.put("ISSUPERVISE", "0"); departmentService.save(dept); } for (Map.Entry entry : addPostMap.entrySet()) { //岗位 String[] deptIDAndPostName = entry.getKey().split("--"); String[] detpIdAndPostId = entry.getValue().split("--"); PageData post = new PageData(); post.put("POST_ID", detpIdAndPostId[1]); post.put("DEPARTMENT_ID", detpIdAndPostId[0]); // 机构 post.put("NAME", deptIDAndPostName[1]); post.put("STATUS", "0"); // 状态 post.put("ISDELETE", "0"); post.put("CORPINFO_ID", corpId); post.put("CREATOR", Jurisdiction.getUSER_ID()); post.put("CREATTIME", DateUtil.date2Str(new Date())); post.put("OPERATOR", Jurisdiction.getUSER_ID()); post.put("OPERATTIME", DateUtil.date2Str(new Date())); postService.save(post); } for (Map.Entry entry : addUser.entrySet()) { PageData pageData = (PageData) entry.getValue(); PageData userPd = new PageData(); userPd.put("USER_ID", UuidUtil.get32UUID()); userPd.put("USERNAME", pageData.get("USERNAME")); userPd.put("NAME", pageData.get("NAME")); String pwd = new SimpleHash("SHA-1", pageData.get("USERNAME").toString(), Const.DEFAULT_PASSWORD).toString(); userPd.put("PASSWORD", pwd); userPd.put("ROLE_ID", "96036bcce5cf418baf8bc2f91271c8c6"); userPd.put("STATUS", "0"); userPd.put("DEPARTMENT_ID", pageData.get("DEPARTMENT_ID")); userPd.put("CORPINFO_ID", corpId); userPd.put("POST_ID", pageData.get("POST_ID")); userPd.put("ISMAIN", "0"); userPd.put("SORT", "0"); userPd.put("ISDELETE", "0"); // 判断是否添加在线学习人员字段信息 if ( (pageData.get("DUTIES") != null && StringUtils.isNotBlank(pageData.get("DUTIES").toString())) || (pageData.get("TITLE") != null && StringUtils.isNotBlank(pageData.get("TITLE").toString())) || (pageData.get("ENTRY_DATE") != null && StringUtils.isNotBlank(pageData.get("ENTRY_DATE").toString())) || (pageData.get("WORKING_DATE") != null && StringUtils.isNotBlank(pageData.get("WORKING_DATE").toString())) || (pageData.get("INCUMBENCY") != null && StringUtils.isNotBlank(pageData.get("INCUMBENCY").toString())) ) { userPd.put("IS_ONLINELEARNING", "1"); } usersService.saveUser(userPd); PageData userInfo = new PageData(); userInfo.put("USER_ID", userPd.get("USER_ID")); userInfo.put("DUTIES", pageData.get("DUTIES")); userInfo.put("TITLE", pageData.get("TITLE")); // 日期格式处理 Calendar calendar = new GregorianCalendar(1900, 0, -1); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); if (pageData.get("ENTRY_DATE") != null && StringUtils.isNotBlank(pageData.get("ENTRY_DATE").toString())) { // 入职日期处理 int intDay = Integer.parseInt(pageData.get("ENTRY_DATE").toString()); Date ENTRY_DATE_date = DateUtils.addDays(calendar.getTime(), intDay); //对日期格式化操作 userInfo.put("ENTRY_DATE", simpleDateFormat.format(ENTRY_DATE_date)); } if (pageData.get("WORKING_DATE") != null && StringUtils.isNotBlank(pageData.get("WORKING_DATE").toString())) { // 参加工作日期处理 int intDay = Integer.parseInt(pageData.get("WORKING_DATE").toString()); Date WORKING_DATE_date = DateUtils.addDays(calendar.getTime(), intDay); //对日期格式化操作 userInfo.put("WORKING_DATE", simpleDateFormat.format(WORKING_DATE_date)); } if (pageData.get("INCUMBENCY") != null) { PageData dictionariesPd = new PageData(); if ("在职".equals(pageData.get("INCUMBENCY"))) { dictionariesPd.put("NAME", pageData.get("INCUMBENCY")); PageData dictionaries = dictionariesService.findByName(dictionariesPd); userInfo.put("INCUMBENCY", dictionaries.get("DICTIONARIES_ID")); } if ("离职".equals(pageData.get("INCUMBENCY"))) { dictionariesPd.put("NAME", pageData.get("INCUMBENCY")); PageData dictionaries = dictionariesService.findByName(dictionariesPd); userInfo.put("INCUMBENCY", dictionaries.get("DICTIONARIES_ID")); } } userInfoService.save(userInfo); } for (Map.Entry entry : addzhiwuMap.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); PageData dicCorp = new PageData(); dicCorp.put("DICTIONARIES_ID", val); dicCorp.put("NAME", key); dicCorp.put("ORDER_BY", 0); dicCorp.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754"); dicCorp.put("CORPINFO_ID", corpId); dicCorp.put("CREATOR", Jurisdiction.getUSER_ID()); dicCorp.put("CREATTIME", DateUtil.date2Str(new Date())); dicCorp.put("OPERATOR", Jurisdiction.getUSER_ID()); dicCorp.put("OPERATTIME", DateUtil.date2Str(new Date())); dicCorp.put("ISDELETE", "0"); dictionariesCorpService.save(dicCorp); } for (Map.Entry entry : addzhichengMap.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); PageData dicCorp = new PageData(); dicCorp.put("DICTIONARIES_ID", val); dicCorp.put("NAME", key); dicCorp.put("ORDER_BY", 0); dicCorp.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679"); dicCorp.put("CORPINFO_ID", corpId); dicCorp.put("CREATOR", Jurisdiction.getUSER_ID()); dicCorp.put("CREATTIME", DateUtil.date2Str(new Date())); dicCorp.put("OPERATOR", Jurisdiction.getUSER_ID()); dicCorp.put("OPERATTIME", DateUtil.date2Str(new Date())); dicCorp.put("ISDELETE", "0"); dictionariesCorpService.save(dicCorp); } File old = new File(filePath, fileName); old.delete(); } retMap.put("msg", msgString.toString()); //返回结果 retMap.put("type", type); //返回结果 retMap.put("result", errInfo); //返回结果 return retMap; } /** * 导出到excel * * @param * @throws Exception */ @RequestMapping(value = "/excels") @RequiresPermissions("toExcel") public ModelAndView exportExcels() throws Exception { ModelAndView mv = new ModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); Map dataMap = new HashMap(); List titles = new ArrayList(); titles.add("用户名"); //1 titles.add("姓名"); //2 titles.add("部门"); //3 titles.add("岗位"); //4 titles.add("角色"); //5 titles.add("排班类型"); //6 dataMap.put("titles", titles); List varOList = usersService.userlistAll(pd); List varList = new ArrayList(); for (int i = 0; i < varOList.size(); i++) { PageData vpd = new PageData(); vpd.put("var1", varOList.get(i).getString("USERNAME")); //1 vpd.put("var2", varOList.get(i).getString("NAME")); //2 vpd.put("var3", varOList.get(i).getString("DEPARTMENT_NAME")); //3 vpd.put("var4", varOList.get(i).getString("POST_NAME")); //4 vpd.put("var5", varOList.get(i).getString("ROLE_NAME")); //5 if (Tools.notEmpty(varOList.get(i).getString("SHIFTDUTYONENAME")) && Tools.notEmpty(varOList.get(i).getString("SHIFTDUTYTWONAME"))) { vpd.put("var6", varOList.get(i).getString("SHIFTDUTYONENAME") + "-" + varOList.get(i).getString("SHIFTDUTYTWONAME")); //6 } else { vpd.put("var6", "全班"); //6 } varList.add(vpd); } dataMap.put("varList", varList); dataMap.put("filename", "用户信息"); ObjectExcelView erv = new ObjectExcelView(); mv = new ModelAndView(erv, dataMap); return mv; } /** * 用户列表(监管端用户+企业端用户) * * @param page * @throws Exception */ @RequestMapping(value = "/listAllManageAndCorp") @ResponseBody public Object listAllManageAndCorp() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); List userList = usersService.listAllManageAndCorp(pd); //列出Post列表 map.put("userList", userList); map.put("result", errInfo); return map; } /** * @param * @throws Exception */ @RequestMapping(value = "/resetPwdAll") @ResponseBody public Object resetPwd() throws Exception { Map map = new HashMap(); String errInfo = "success"; List list = usersService.listAllUser(new PageData()); for (PageData user : list) { String password = new SimpleHash("SHA-1", user.getString("USERNAME"), "666666").toString(); if (password.equals(user.getString("PASSWORD"))) { user.put("PASSWORD", new SimpleHash("SHA-1", user.getString("USERNAME"), Const.DEFAULT_PASSWORD).toString()); usersService.editPassword(user); } } map.put("result", errInfo); return map; } /** * @param * @throws Exception */ @RequestMapping(value = "/unLockUser") @ResponseBody public Object unLockUser() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("LOCK_STATUS", "0"); pd.put("ERROR_COUNT", 0); usersService.lockUser(pd); map.put("result", errInfo); return map; } /** * @param * @throws Exception */ @RequestMapping(value = "/getRegUserInfo") @ResponseBody public Object getRegUserInfo() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("LOCK_STATUS", "0"); pd.put("ERROR_COUNT", 0); map.put("list",usersService.getRegUserInfo(pd)); map.put("result", errInfo); return map; } /** * 校验 * * @param * @throws Exception */ @RequestMapping(value = "/goCheck") @ResponseBody public Object goCheck() throws Exception { Map map = new HashMap(); PageData pd = new PageData(); pd = this.getPageData(); HashMap param = new HashMap<>(); param.put("USERNAME",pd.getString("USERNAME")); param.put("CARD_NO",pd.getString("CARD_NO")); if (!Tools.isEmpty(pd.get("USER_ID"))) { param.put("USER_ID",pd.getString("USER_ID")); } else { param.put("USER_ID",""); } return doCheck(param.get("USERNAME"),param.get("CARD_NO"),param.get("USER_ID")); } public Map doCheck(String USERNAME, String CARD_NO, String USER_ID) throws Exception { String result = HttpClientUtilDoGet.sendHttpGet(tongBuUrl + "/docking/core/user/getCheck"+"?USERNAME="+USERNAME+"&CARD_NO="+CARD_NO+"&USER_ID="+USER_ID); Map returnMap = (Map) JSON.parse(result); return returnMap; } /** * 推送 * * @param * @throws Exception */ @RequestMapping(value = "/goPush") @ResponseBody public Object goPush() throws Exception { PageData pd = new PageData(); pd = this.getPageData(); pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 pd.put("CREATOR", Jurisdiction.getUSER_ID()); //创建人 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人 PageData sexPd = new PageData(); if (Tools.notEmpty(pd.getString("SEX"))) { sexPd.put("DICTIONARIES_ID",pd.getString("SEX")); PageData byId = dictionariesService.findById(sexPd); if (Tools.notEmpty(byId)) { pd.put("SEX",byId.getString("NAME")); } } StringBuilder ORG_PATH = new StringBuilder(); boolean hasPid = true; PageData department = departmentService.findById(pd); ORG_PATH.insert(0, department.getString("NAME")); String deptId = department.getString("PARENT_ID"); PageData deptPd = new PageData(); deptPd.put("DEPARTMENT_ID",deptId); if (!department.get("PARENT_ID").equals("0")) { while (hasPid) { PageData dept = departmentService.findById(deptPd); if (dept.get("PARENT_ID").equals("0")) { hasPid = false; } else { deptId = dept.getString("PARENT_ID"); deptPd.put("DEPARTMENT_ID",deptId); } ORG_PATH.insert(0, dept.getString("NAME") + "/"); } } pd.put("ORG_PATH",ORG_PATH); HashMap param = new HashMap<>(); Set set = pd.keySet(); for (Object key : set) { param.put(key.toString(),pd.getString(key.toString())); } //要推送的照片集合 List userPhotoDTOList = new ArrayList<>(); //人脸照片 PageData photoPd = new PageData(); photoPd.put("USER_PHOTO_ID",pd.getString("IMGFILES_ID")); photoPd.put("USER_ID",pd.getString("FOREIGN_KEY")); photoPd.put("PHOTO_URL",pd.getString("FILEPATH")); photoPd.put("PHOTO_TYPE","1"); photoPd.put("ISDELETE","0"); userPhotoDTOList.add(photoPd); param.put("userPhotoDTOList", userPhotoDTOList); String userResult = HttpClientUtilDoGet.sendHttpGet(tongBuUrl + "/docking/core/user/getUserInfoById"+"?USER_ID="+pd.getString("USER_ID")); Map userReturnMap = (Map) JSON.parse(userResult); if (userReturnMap.get("USERINFO") != null) { //有用户数据获取修改信息 PageData userInfoPd = JSON.parseObject(userReturnMap.get("USERINFO").toString(), PageData.class); String updateDescription = UpdateEnum.getUpdateDescription(userInfoPd, pd); param.put("REMARKS",updateDescription); } else { //没有数据则获取新增信息 String insertDescription = UpdateEnum.getInsertDescription(pd); param.put("REMARKS",insertDescription); } String UserDto = JSON.toJSONString(param); String result = HttpClientUtilDoGet.sendHttpPost(tongBuUrl + "/docking/core/user/addOrUpdate", UserDto,null); Map returnMap = (Map) JSON.parse(result); if (returnMap.get("result").equals("success")) { PageData pushPd = new PageData(); pushPd.put("ISPUSH","1"); if (!Tools.isEmpty(pd.get("operateType")) && pd.getString("operateType").equals("delete")) { pushPd.put("ISDELETE","1"); } else { pushPd.put("ISDELETE","0"); } pushPd.put("USER_ID",pd.getString("USER_ID")); usersService.editPushStatus(pushPd); } return returnMap; } static String CREATOR = null; static String OPERATOR = null; @RequestMapping(value = "/initCore") @ResponseBody public Object initCore() throws Exception { PageData p1d = new PageData(); // pd = this.getPageData(); if (CREATOR == null) { CREATOR = Jurisdiction.getUSER_ID(); OPERATOR = Jurisdiction.getUSER_ID(); } List pageData = usersService.listAllUser(p1d); for (PageData pd : pageData) { try { pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 pd.put("CREATOR", CREATOR); //创建人 pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 pd.put("OPERATOR", OPERATOR); //修改人 PageData sexPd = new PageData(); if (Tools.notEmpty(pd.getString("SEX"))) { sexPd.put("DICTIONARIES_ID", pd.getString("SEX")); PageData byId = dictionariesService.findById(sexPd); if (Tools.notEmpty(byId)) { pd.put("SEX", byId.getString("NAME")); } } StringBuilder ORG_PATH = new StringBuilder(); boolean hasPid = true; PageData department = departmentService.findById(pd); if (department != null) { ORG_PATH.insert(0, department.getString("NAME")); String deptId = department.getString("PARENT_ID"); PageData deptPd = new PageData(); deptPd.put("DEPARTMENT_ID", deptId); if (!"0".equals(department.get("PARENT_ID"))) { while (hasPid) { PageData dept = departmentService.findById(deptPd); if ("0".equals(dept.get("PARENT_ID"))) { hasPid = false; } else { deptId = dept.getString("PARENT_ID"); deptPd.put("DEPARTMENT_ID", deptId); } ORG_PATH.insert(0, dept.getString("NAME") + "/"); } } pd.put("ORG_PATH", ORG_PATH); } else { ORG_PATH.insert(0, ""); } PageData CorpName = corpInfoService.findById(pd); pd.put("CORPINFO_NAME", CorpName == null ? "" : CorpName.getString("CORP_NAME")); pd.put("USER_TYPE", "1"); HashMap param = new HashMap<>(); Set set = pd.keySet(); for (Object key : set) { param.put(key.toString(), pd.getString(key.toString())); } //要推送的照片集合 List userPhotoDTOList = new ArrayList<>(); //人脸照片 PageData photoPd = new PageData(); photoPd.put("USER_PHOTO_ID", pd.getString("IMGFILES_ID")); photoPd.put("USER_ID", pd.getString("FOREIGN_KEY")); photoPd.put("PHOTO_URL", pd.getString("FILEPATH")); photoPd.put("PHOTO_TYPE", "1"); photoPd.put("ISDELETE", "0"); userPhotoDTOList.add(photoPd); param.put("userPhotoDTOList", userPhotoDTOList); String userResult = HttpClientUtilDoGet.sendHttpGet(tongBuUrl + "/docking/core/user/getUserInfoById" + "?USER_ID=" + pd.getString("USER_ID")); Map userReturnMap = (Map) JSON.parse(userResult); if (userReturnMap.get("USERINFO") != null) { //有用户数据获取修改信息 PageData userInfoPd = JSON.parseObject(userReturnMap.get("USERINFO").toString(), PageData.class); String updateDescription = UpdateEnum.getUpdateDescription(userInfoPd, pd); param.put("REMARKS", updateDescription); } else { //没有数据则获取新增信息 String insertDescription = UpdateEnum.getInsertDescription(pd); param.put("REMARKS", insertDescription); } String UserDto = JSON.toJSONString(param); String result = HttpClientUtilDoGet.sendHttpPost(tongBuUrl + "/docking/core/user/addOrUpdate", UserDto, null); Map returnMap = (Map) JSON.parse(result); if (returnMap.get("result").equals("success")) { PageData pushPd = new PageData(); pushPd.put("ISPUSH", "1"); if (!Tools.isEmpty(pd.get("operateType")) && pd.getString("operateType").equals("delete")) { pushPd.put("ISDELETE", "1"); } else { pushPd.put("ISDELETE", "0"); } pushPd.put("USER_ID", pd.getString("USER_ID")); usersService.editPushStatus(pushPd); } }catch (Exception e){ } } return null; } }