diff --git a/src/main/java/com/zcloud/controller/risk/IdentificationPartsController.java b/src/main/java/com/zcloud/controller/risk/IdentificationPartsController.java index 6f93a40..8699c6b 100644 --- a/src/main/java/com/zcloud/controller/risk/IdentificationPartsController.java +++ b/src/main/java/com/zcloud/controller/risk/IdentificationPartsController.java @@ -1,5 +1,6 @@ package com.zcloud.controller.risk; +import com.alibaba.fastjson.JSONObject; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; @@ -13,11 +14,16 @@ import com.zcloud.util.*; import org.apache.commons.io.FileUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; 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.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; @@ -34,498 +40,554 @@ import java.util.*; @RequestMapping("/identificationparts") public class IdentificationPartsController extends BaseController { - @Autowired - private CorpInfoService corpInfoService; - @Autowired - private IdentificationPartsService identificationpartsService; - @Autowired - private RiskUnitService riskunitService; - @Autowired - private RiskPointService riskpointService; - @Autowired - private DepartmentService departmentService; - @Autowired - private IdeRepositoryService ideRepositoryService; + @Autowired + private CorpInfoService corpInfoService; + @Autowired + private IdentificationPartsService identificationpartsService; + @Autowired + private RiskUnitService riskunitService; + @Autowired + private RiskPointService riskpointService; + @Autowired + private DepartmentService departmentService; + @Autowired + private IdeRepositoryService ideRepositoryService; @Autowired private RiskPointTemporaryService riskPointTemporaryService; - @Autowired - private RiskCheckItemService riskcheckitemService; - @Autowired - private ResourceCorpService resourceCorpService; - @Autowired - private ImgFilesService imgFilesService; - @Autowired - private Smb smb; - @Autowired - private UsersService usersService; - /**新增 - * @param - * @throws Exception - */ - @RequestMapping(value="/add") - @RequiresPermissions("identificationparts:add") - @ResponseBody - @Transactional - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "新增") - public Object add(@RequestParam(value="FFILE",required=false) MultipartFile[] files) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); + @Autowired + private RiskCheckItemService riskcheckitemService; + @Autowired + private ResourceCorpService resourceCorpService; + @Autowired + private ImgFilesService imgFilesService; + @Autowired + private Smb smb; + @Autowired + private UsersService usersService; - pd.put("CHECK_NAME", pd.getString("PARTSNAME")); - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pd.put("RISK_UNIT_ID", pd.getString("RISK_UNIT_ID")); - List list = identificationpartsService.listAll(pd); - if(list!=null&&list.size()>0) { - map.put("result", "failed"); - map.put("exception", "辨识部位已存在,请修改后重试"); - return map; - } - pd.put("IDENTIFICATIONPARTS_ID", this.get32UUID()); //主键 + @Autowired + private RestTemplate restTemplate; + /** + * 新增 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/add") + @RequiresPermissions("identificationparts:add") + @ResponseBody + @Transactional + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "新增") + public Object add(@RequestParam(value = "FFILE", required = false) MultipartFile[] files) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); - pd.put("CREATOR", Jurisdiction.getUsername()); //添加人 - pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 - pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pd.put("ISDELETE", "0"); //是否删除 1-是 0-否 - pd.put("ISMATCHING", "0"); - identificationpartsService.save(pd); + pd.put("CHECK_NAME", pd.getString("PARTSNAME")); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + pd.put("RISK_UNIT_ID", pd.getString("RISK_UNIT_ID")); + List list = identificationpartsService.listAll(pd); + if (list != null && list.size() > 0) { + map.put("result", "failed"); + map.put("exception", "辨识部位已存在,请修改后重试"); + return map; + } + pd.put("IDENTIFICATIONPARTS_ID", this.get32UUID()); //主键 - if (files != null && files.length > 0) { - for (int i = 0; i < files.length; i++) { - MultipartFile file = files[i]; + pd.put("CREATOR", Jurisdiction.getUsername()); //添加人 + pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间 + pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + pd.put("ISDELETE", "0"); //是否删除 1-是 0-否 + pd.put("ISMATCHING", "0"); + identificationpartsService.save(pd); + + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + MultipartFile file = files[i]; // 保存文件 - String ffile = DateUtil.getDays(); - String fileName = ""; //执0行上传 + String ffile = DateUtil.getDays(); + String fileName = ""; //执0行上传 - if (null != file && !file.isEmpty()) { - fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - byte[] bytes = file.getBytes(); - smb.sshSftp(file, fileName,Const.FILEPATHYHTP + ffile); - } - pd.put("IMGFILES_ID", this.get32UUID()); - pd.put("FILEPATH", Const.FILEPATHYHTP + ffile+"/"+fileName); - pd.put("TYPE", 17); - pd.put("FOREIGN_KEY", pd.get("IDENTIFICATIONPARTS_ID")); - imgFilesService.save(pd); - } - } - map.put("result", errInfo); - return map; - } + if (null != file && !file.isEmpty()) { + fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + byte[] bytes = file.getBytes(); + smb.sshSftp(file, fileName, Const.FILEPATHYHTP + ffile); + } + pd.put("IMGFILES_ID", this.get32UUID()); + pd.put("FILEPATH", Const.FILEPATHYHTP + ffile + "/" + fileName); + pd.put("TYPE", 17); + pd.put("FOREIGN_KEY", pd.get("IDENTIFICATIONPARTS_ID")); + imgFilesService.save(pd); + } + } + map.put("result", errInfo); + return map; + } - /**获取风险点下拉框选项 - * @param page - * @throws Exception - */ - @RequestMapping(value="/getSelect") - @ResponseBody - @LogAnno(menuType= "双重预控",menuServer= "风险提示",instructionsOperate = "风险告知卡",instructionsType = "获取风险点下拉框选项") - public Object getPointSelect() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); + /** + * 获取风险点下拉框选项 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/getSelect") + @ResponseBody + @LogAnno(menuType = "双重预控", menuServer = "风险提示", instructionsOperate = "风险告知卡", instructionsType = "获取风险点下拉框选项") + public Object getPointSelect() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 - List unitList = riskunitService.listAll(pd); - map.put("unitList", unitList); - map.put("result", errInfo); - return map; - } + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + List unitList = riskunitService.listAll(pd); + map.put("unitList", unitList); + map.put("result", errInfo); + return map; + } - /**删除 - * @param out - * @throws Exception - */ - @RequestMapping(value="/delete") - @RequiresPermissions("identificationparts:del") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "删除") - public Object delete() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - pd.put("CHECK_IDENTIFICATION_ID", pd.get("IDENTIFICATIONPARTS_ID")); - List list = riskpointService.listAll(pd); - if(list!=null && list.size()>0) { + /** + * 删除 + * + * @param out + * @throws Exception + */ + @RequestMapping(value = "/delete") + @RequiresPermissions("identificationparts:del") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "删除") + public Object delete() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("CHECK_IDENTIFICATION_ID", pd.get("IDENTIFICATIONPARTS_ID")); + List list = riskpointService.listAll(pd); + if (list != null && list.size() > 0) { // map.put("result", "failed"); //返回结果 - map.put("msg", "该辨识部位有风险管控台账,请删除所有的风险管控台账后再删除"); - return map; - } - pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - identificationpartsService.delete(pd); - map.put("result", errInfo); //返回结果 - return map; - } + map.put("msg", "该辨识部位有风险管控台账,请删除所有的风险管控台账后再删除"); + return map; + } + pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + identificationpartsService.delete(pd); + map.put("result", errInfo); //返回结果 + return map; + } - /**修改 - * @param - * @throws Exception - */ - @RequestMapping(value="/edit") - @RequiresPermissions("identificationparts:edit") - @ResponseBody - @Transactional - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "修改") - public Object edit(@RequestParam(value="FFILE",required=false) MultipartFile[] files) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - identificationpartsService.edit(pd); + /** + * 修改 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/edit") + @RequiresPermissions("identificationparts:edit") + @ResponseBody + @Transactional + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "修改") + public Object edit(@RequestParam(value = "FFILE", required = false) MultipartFile[] files) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + identificationpartsService.edit(pd); - if (files != null && files.length > 0) { - for (int i = 0; i < files.length; i++) { - MultipartFile file = files[i]; + if (files != null && files.length > 0) { + for (int i = 0; i < files.length; i++) { + MultipartFile file = files[i]; // 保存文件 - String ffile = DateUtil.getDays(); - String fileName = ""; //执0行上传 + String ffile = DateUtil.getDays(); + String fileName = ""; //执0行上传 - if (null != file && !file.isEmpty()) { - fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); - byte[] bytes = file.getBytes(); - smb.sshSftp(file, fileName,Const.FILEPATHYHTP + ffile); - } - pd.put("IMGFILES_ID", this.get32UUID()); - pd.put("FILEPATH", Const.FILEPATHYHTP + ffile+"/"+fileName); - pd.put("TYPE", 17); - pd.put("FOREIGN_KEY", pd.get("IDENTIFICATIONPARTS_ID")); - imgFilesService.save(pd); - } - } - map.put("result", errInfo); - return map; - } + if (null != file && !file.isEmpty()) { + fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + byte[] bytes = file.getBytes(); + smb.sshSftp(file, fileName, Const.FILEPATHYHTP + ffile); + } + pd.put("IMGFILES_ID", this.get32UUID()); + pd.put("FILEPATH", Const.FILEPATHYHTP + ffile + "/" + fileName); + pd.put("TYPE", 17); + pd.put("FOREIGN_KEY", pd.get("IDENTIFICATIONPARTS_ID")); + imgFilesService.save(pd); + } + } + map.put("result", errInfo); + return map; + } - /**列表 - * @param page - * @throws Exception - */ - @RequestMapping(value="/list") - @RequiresPermissions("identificationparts:list") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "列表") - public Object list(Page page) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - PageData npd = new PageData(); - pd = this.getPageData(); - String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 - if(Tools.notEmpty(KEYWORDS))npd.put("KEYWORDS", KEYWORDS.trim()); - npd.put("ISMAIN", Jurisdiction.getIS_MAIN()); - npd.put("ISSUPERVISE", Jurisdiction.getISSUPERVISE()); - npd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); - npd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pd.put("USER_ID",Jurisdiction.getUSER_ID()); - PageData cpd = new PageData(); - cpd = usersService.findById(pd); - npd.put("ISLEADER", cpd.getString("ISLEADER")); - if(cpd.getString("ISLEADER") != null && cpd.getString("ISLEADER").equals("1")){ - String DEPARTMENT_ID = npd.getString("DEPARTMENT_ID"); - String ids = departmentService.getDEPARTMENT_IDS(DEPARTMENT_ID); - ids=npd.getString("DEPARTMENT_ID")+","+ids; //把自己部门插入进去 - if(ids!=null && Tools.notEmpty(ids)&& ids.lastIndexOf(",")>-1) { - ids = ids.substring(0,ids.lastIndexOf(",")); - npd.put("DEPARTMENT_IDS", ids.split(",")); - }else { - npd.put("DEPARTMENT_IDS", DEPARTMENT_ID); - } - } - page.setPd(npd); +// /region/region/list - List varList = identificationpartsService.list(page); //列出IdentificationParts列表 - int hasJur = resourceCorpService.countByCorpId(pd); - if(varList != null && varList.size() > 0) { - for(PageData var : varList) { - PageData pd2 = new PageData(); - pd2.put("FOREIGN_KEY", var.getString("IDENTIFICATIONPARTS_ID")); - List imgs = imgFilesService.listAll(pd2); - var.put("imgs", imgs); - } - } - map.put("varList", varList); - map.put("hasJur", hasJur>0?"1":"0"); - map.put("page", page); - map.put("result", errInfo); - return map; - } + /** + * @Description: 电子围栏 来自人员定位系统 + * @Author: dearLin + * @Date: 2024/1/25/025 9:02 + * @Param: [com.zcloud.entity.Page] [page] + * @Return: java.lang.Object + */ + @RequestMapping(value = "/ryRegionList") + @ResponseBody + public Object ryRegionList(Page page) throws Exception { + ReturnMap returnMap = new ReturnMap(); + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", PLSUtil.getToken()); + HttpEntity httpEntity = new HttpEntity<>(headers); + PageData pageData = this.getPageData(); + String KEYWORDS = (String) pageData.getOrDefault("KEYWORDS",""); + ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/region/region/list?pageNum=" + + Integer.parseInt(pageData.getString("currentPage")) + + "&pageSize=" + Integer.parseInt(pageData.getString("showCount")) + + "&str=" + KEYWORDS + "&type=0", HttpMethod.GET, httpEntity, JSONObject.class); + JSONObject body = exchange.getBody(); + if (body != null) { + List list = body.getJSONArray("rows").toJavaList(JSONObject.class); + returnMap.put("varList",list); + page.setTotalPage(body.getIntValue("total")); + returnMap.put("page",page); + return returnMap; + } + return ReturnMap.error("查询失败"); + } - /**列表 - * @param page - * @throws Exception - */ - @RequestMapping(value="/listAll") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "隐患排查",instructionsOperate = "清单管理",instructionsType = "列表") - public Object listAll(Page page) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); + /** + * 列表 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/list") + @RequiresPermissions("identificationparts:list") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "列表") + public Object list(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + PageData npd = new PageData(); + pd = this.getPageData(); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if (Tools.notEmpty(KEYWORDS)) npd.put("KEYWORDS", KEYWORDS.trim()); + npd.put("ISMAIN", Jurisdiction.getIS_MAIN()); + npd.put("ISSUPERVISE", Jurisdiction.getISSUPERVISE()); + npd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID()); + npd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + pd.put("USER_ID", Jurisdiction.getUSER_ID()); + PageData cpd = new PageData(); + cpd = usersService.findById(pd); + npd.put("ISLEADER", cpd.getString("ISLEADER")); + if (cpd.getString("ISLEADER") != null && cpd.getString("ISLEADER").equals("1")) { + String DEPARTMENT_ID = npd.getString("DEPARTMENT_ID"); + String ids = departmentService.getDEPARTMENT_IDS(DEPARTMENT_ID); + ids = npd.getString("DEPARTMENT_ID") + "," + ids; //把自己部门插入进去 + if (ids != null && Tools.notEmpty(ids) && ids.lastIndexOf(",") > -1) { + ids = ids.substring(0, ids.lastIndexOf(",")); + npd.put("DEPARTMENT_IDS", ids.split(",")); + } else { + npd.put("DEPARTMENT_IDS", DEPARTMENT_ID); + } + } + page.setPd(npd); - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 - List partsList = identificationpartsService.listAll(pd); - map.put("partsList", partsList); - map.put("result", errInfo); - return map; - } + List varList = identificationpartsService.list(page); //列出IdentificationParts列表 + int hasJur = resourceCorpService.countByCorpId(pd); + if (varList != null && varList.size() > 0) { + for (PageData var : varList) { + PageData pd2 = new PageData(); + pd2.put("FOREIGN_KEY", var.getString("IDENTIFICATIONPARTS_ID")); + List imgs = imgFilesService.listAll(pd2); + var.put("imgs", imgs); + } + } + map.put("varList", varList); + map.put("hasJur", hasJur > 0 ? "1" : "0"); + map.put("page", page); + map.put("result", errInfo); + return map; + } - /**列表 - * @param page - * @throws Exception - */ - @RequestMapping(value="/listAllByIdens") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "隐患排查",instructionsOperate = "清单管理",instructionsType = "列表") - public Object listAllByIdens(Page page) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - String DATA_IDS = pd.getString("IDS"); - if(Tools.notEmpty(DATA_IDS)){ - String ArrayDATA_IDS[] = DATA_IDS.split(","); - pd.put("ArrayDATA_IDS", ArrayDATA_IDS); - List varList = identificationpartsService.listAllByIdens(pd); - errInfo = "success"; - map.put("varList", varList); - }else{ - errInfo = "error"; - } - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 - List partsList = identificationpartsService.listAll(pd); - map.put("partsList", partsList); - map.put("result", errInfo); - return map; - } + /** + * 列表 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/listAll") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "隐患排查", instructionsOperate = "清单管理", instructionsType = "列表") + public Object listAll(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); - /**去修改页面获取数据 - * @param - * @throws Exception - */ - @RequestMapping(value="/goEdit") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "去修改页面获取数据") - public Object goEdit() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - pd = identificationpartsService.findById(pd); //根据ID读取 + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + List partsList = identificationpartsService.listAll(pd); + map.put("partsList", partsList); + map.put("result", errInfo); + return map; + } - PageData pd2 = new PageData(); - pd2.put("FOREIGN_KEY", pd.getString("IDENTIFICATIONPARTS_ID")); - pd2.put("TYPE",pd.get("TYPE")); - List imgs = imgFilesService.listAll(pd2);//营业执照图片 + /** + * 列表 + * + * @param page + * @throws Exception + */ + @RequestMapping(value = "/listAllByIdens") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "隐患排查", instructionsOperate = "清单管理", instructionsType = "列表") + public Object listAllByIdens(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String DATA_IDS = pd.getString("IDS"); + if (Tools.notEmpty(DATA_IDS)) { + String ArrayDATA_IDS[] = DATA_IDS.split(","); + pd.put("ArrayDATA_IDS", ArrayDATA_IDS); + List varList = identificationpartsService.listAllByIdens(pd); + errInfo = "success"; + map.put("varList", varList); + } else { + errInfo = "error"; + } + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + List partsList = identificationpartsService.listAll(pd); + map.put("partsList", partsList); + map.put("result", errInfo); + return map; + } - map.put("pd", pd); - map.put("imgs", imgs); - map.put("result", errInfo); - return map; - } + /** + * 去修改页面获取数据 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/goEdit") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "去修改页面获取数据") + public Object goEdit() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd = identificationpartsService.findById(pd); //根据ID读取 - /**批量删除 - * @param - * @throws Exception - */ - @RequestMapping(value="/deleteAll") - @RequiresPermissions("identificationparts:del") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "批量删除") - public Object deleteAll() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - String DATA_IDS = pd.getString("DATA_IDS"); - if(Tools.notEmpty(DATA_IDS)){ - String ArrayDATA_IDS[] = DATA_IDS.split(","); - for (String id : ArrayDATA_IDS) { - PageData iden = new PageData(); - iden.put("CHECK_IDENTIFICATION_ID", id); - List list = riskpointService.listAll(iden); - if(list!=null && list.size()>0) { + PageData pd2 = new PageData(); + pd2.put("FOREIGN_KEY", pd.getString("IDENTIFICATIONPARTS_ID")); + pd2.put("TYPE", pd.get("TYPE")); + List imgs = imgFilesService.listAll(pd2);//营业执照图片 + + map.put("pd", pd); + map.put("imgs", imgs); + map.put("result", errInfo); + return map; + } + + /** + * 批量删除 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/deleteAll") + @RequiresPermissions("identificationparts:del") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "批量删除") + public Object deleteAll() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String DATA_IDS = pd.getString("DATA_IDS"); + if (Tools.notEmpty(DATA_IDS)) { + String ArrayDATA_IDS[] = DATA_IDS.split(","); + for (String id : ArrayDATA_IDS) { + PageData iden = new PageData(); + iden.put("CHECK_IDENTIFICATION_ID", id); + List list = riskpointService.listAll(iden); + if (list != null && list.size() > 0) { // map.put("result", "failed"); //返回结果 - map.put("msg", "该辨识部位下还有风险管控台账,请先删除风险管控台账"); - return map; - } - pd.put("IDENTIFICATIONPARTS_ID", id); - pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - identificationpartsService.delete(pd); - } + map.put("msg", "该辨识部位下还有风险管控台账,请先删除风险管控台账"); + return map; + } + pd.put("IDENTIFICATIONPARTS_ID", id); + pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + identificationpartsService.delete(pd); + } // identificationpartsService.deleteAll(ArrayDATA_IDS); - errInfo = "success"; - }else{ - errInfo = "error"; - } - map.put("result", errInfo); //返回结果 - return map; - } + errInfo = "success"; + } else { + errInfo = "error"; + } + map.put("result", errInfo); //返回结果 + return map; + } - @RequestMapping(value="/resourceConfig") - @ResponseBody - public Object resourceConfig() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - try { - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 - String DATA_IDS = pd.getString("DATA_IDS");// 勾选的资源库ID集合 - List idList = new ArrayList(); - if(Tools.notEmpty(DATA_IDS)){ - String ArrayDATA_IDS[] = DATA_IDS.split(","); - for(String id : ArrayDATA_IDS) { - idList.add(id); - } - } - List allRisk = riskPointTemporaryService.listAllByIdeAndTime(pd); + @RequestMapping(value = "/resourceConfig") + @ResponseBody + public Object resourceConfig() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + try { + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + String DATA_IDS = pd.getString("DATA_IDS");// 勾选的资源库ID集合 + List idList = new ArrayList(); + if (Tools.notEmpty(DATA_IDS)) { + String ArrayDATA_IDS[] = DATA_IDS.split(","); + for (String id : ArrayDATA_IDS) { + idList.add(id); + } + } + List allRisk = riskPointTemporaryService.listAllByIdeAndTime(pd); - String riskPointCountString = riskpointService.countByCorpInfo(pd); - Integer count = Integer.parseInt(riskPointCountString); - if(allRisk != null && allRisk.size() > 0) { - List deleteIds = new ArrayList(); + String riskPointCountString = riskpointService.countByCorpInfo(pd); + Integer count = Integer.parseInt(riskPointCountString); + if (allRisk != null && allRisk.size() > 0) { + List deleteIds = new ArrayList(); - for(PageData risk : allRisk) { - deleteIds.add(risk.get("RISKPOINTTEMPORARY_ID").toString()); - if("1".equals(risk.get("TYPE").toString())) { // 原有风险因素修改 - risk.put("RISKPOINT_ID", risk.get("RES_ID")); - riskpointService.edit(risk); - // 修改冗余字段检查内容 - PageData pd2 = new PageData(); - pd2.put("CHECK_CONTENT", risk.get("MEASURES")); - pd2.put("RISKPOINT_ID", risk.get("RISKPOINT_ID")); - riskcheckitemService.editByPoint(pd2); - } else {// 新增风险因素 - risk.put("RISKPOINT_ID", this.get32UUID()); //主键 - count ++; - risk.put("SORT", count); - for(int i = 0; i < idList.size(); i++) { - if(idList.get(i).equals(risk.get("RES_ID").toString())) { - idList.remove(i); - break; - } - } - riskpointService.save(risk); - PageData item = new PageData(); - item.put("RISKCHECKITEM_ID", this.get32UUID()); //主键 - item.put("RISKPOINT_ID", risk.get("RISKPOINT_ID")); //风险点主键 - item.put("ISDELETE", "0"); //是否删除 - item.put("CREATOR", Jurisdiction.getUsername()); //添加人 - item.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - item.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - item.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - item.put("CHECK_CONTENT", risk.get("MEASURES")); //检查内容 - riskcheckitemService.save(item); - } - } - } - if(idList != null && idList.size() > 0) { - //查询资源库信息 - List resList = ideRepositoryService.listAllByIds(idList.toArray(new String[idList.size()])); - if(resList != null && resList.size() > 0) { - for(PageData res : resList) { - res.put("RISKPOINT_ID", this.get32UUID()); //主键 - res.put("RES_ID", res.get("IDEREPOSITORY_ID")); - res.put("RISK_UNIT_ID", pd.get("RISK_UNIT_ID")); - res.put("IDENTIFICATION_ID", pd.get("IDENTIFICATION_ID")); - res.put("CORPINFO_ID", pd.get("CORPINFO_ID")); - res.put("USER_ID", pd.get("USER_ID")); - res.put("DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); - res.put("CREATOR", Jurisdiction.getUsername()); //添加人 - res.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - res.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - res.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - res.put("RES_ISDELETE", "0"); - count ++; - res.put("SORT", count); - riskpointService.save(res); - PageData item = new PageData(); - item.put("RISKCHECKITEM_ID", this.get32UUID()); //主键 - item.put("RISKPOINT_ID", res.get("RISKPOINT_ID")); //风险点主键 - item.put("ISDELETE", "0"); //是否删除 - item.put("CREATOR", Jurisdiction.getUsername()); //添加人 - item.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - item.put("OPERATOR", Jurisdiction.getUsername()); //修改人 - item.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 - item.put("CHECK_CONTENT", res.get("MEASURES")); //检查内容 - riskcheckitemService.save(item); - } - } - } - // 若未配置过资源库,修改辨识部位状态 - if(pd.get("ISMATCHING") != null && Tools.notEmpty(pd.get("ISMATCHING").toString()) && !"1".equals(pd.get("ISMATCHING").toString())) { //修改匹配资源库状态 - pd.put("ISMATCHING", "1"); - pd.put("IDENTIFICATIONPARTS_ID", pd.get("IDENTIFICATION_ID")); - identificationpartsService.editMatching(pd); - } - //删除风险因素临时表中已经使用过的数据 - riskPointTemporaryService.deleteAbandoned(pd); - } catch (Exception e) { - e.printStackTrace(); - errInfo = "error"; - map.put("result", errInfo); - } + for (PageData risk : allRisk) { + deleteIds.add(risk.get("RISKPOINTTEMPORARY_ID").toString()); + if ("1".equals(risk.get("TYPE").toString())) { // 原有风险因素修改 + risk.put("RISKPOINT_ID", risk.get("RES_ID")); + riskpointService.edit(risk); + // 修改冗余字段检查内容 + PageData pd2 = new PageData(); + pd2.put("CHECK_CONTENT", risk.get("MEASURES")); + pd2.put("RISKPOINT_ID", risk.get("RISKPOINT_ID")); + riskcheckitemService.editByPoint(pd2); + } else {// 新增风险因素 + risk.put("RISKPOINT_ID", this.get32UUID()); //主键 + count++; + risk.put("SORT", count); + for (int i = 0; i < idList.size(); i++) { + if (idList.get(i).equals(risk.get("RES_ID").toString())) { + idList.remove(i); + break; + } + } + riskpointService.save(risk); + PageData item = new PageData(); + item.put("RISKCHECKITEM_ID", this.get32UUID()); //主键 + item.put("RISKPOINT_ID", risk.get("RISKPOINT_ID")); //风险点主键 + item.put("ISDELETE", "0"); //是否删除 + item.put("CREATOR", Jurisdiction.getUsername()); //添加人 + item.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 + item.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + item.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + item.put("CHECK_CONTENT", risk.get("MEASURES")); //检查内容 + riskcheckitemService.save(item); + } + } + } + if (idList != null && idList.size() > 0) { + //查询资源库信息 + List resList = ideRepositoryService.listAllByIds(idList.toArray(new String[idList.size()])); + if (resList != null && resList.size() > 0) { + for (PageData res : resList) { + res.put("RISKPOINT_ID", this.get32UUID()); //主键 + res.put("RES_ID", res.get("IDEREPOSITORY_ID")); + res.put("RISK_UNIT_ID", pd.get("RISK_UNIT_ID")); + res.put("IDENTIFICATION_ID", pd.get("IDENTIFICATION_ID")); + res.put("CORPINFO_ID", pd.get("CORPINFO_ID")); + res.put("USER_ID", pd.get("USER_ID")); + res.put("DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); + res.put("CREATOR", Jurisdiction.getUsername()); //添加人 + res.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 + res.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + res.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + res.put("RES_ISDELETE", "0"); + count++; + res.put("SORT", count); + riskpointService.save(res); + PageData item = new PageData(); + item.put("RISKCHECKITEM_ID", this.get32UUID()); //主键 + item.put("RISKPOINT_ID", res.get("RISKPOINT_ID")); //风险点主键 + item.put("ISDELETE", "0"); //是否删除 + item.put("CREATOR", Jurisdiction.getUsername()); //添加人 + item.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 + item.put("OPERATOR", Jurisdiction.getUsername()); //修改人 + item.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间 + item.put("CHECK_CONTENT", res.get("MEASURES")); //检查内容 + riskcheckitemService.save(item); + } + } + } + // 若未配置过资源库,修改辨识部位状态 + if (pd.get("ISMATCHING") != null && Tools.notEmpty(pd.get("ISMATCHING").toString()) && !"1".equals(pd.get("ISMATCHING").toString())) { //修改匹配资源库状态 + pd.put("ISMATCHING", "1"); + pd.put("IDENTIFICATIONPARTS_ID", pd.get("IDENTIFICATION_ID")); + identificationpartsService.editMatching(pd); + } + //删除风险因素临时表中已经使用过的数据 + riskPointTemporaryService.deleteAbandoned(pd); + } catch (Exception e) { + e.printStackTrace(); + errInfo = "error"; + map.put("result", errInfo); + } - map.put("pd", pd); - map.put("result", errInfo); - return map; - } + map.put("pd", pd); + map.put("result", errInfo); + return map; + } - /**导出到excel - * @param - * @throws Exception - */ - @RequestMapping(value="/excel") + /** + * 导出到excel + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/excel") // @RequiresPermissions("toExcel") - public ModelAndView exportExcel() throws Exception{ - ModelAndView mv = new ModelAndView(); - PageData pd = new PageData(); - pd = this.getPageData(); - String DATA_IDS = pd.getString("DATA_IDS"); - if(Tools.notEmpty(DATA_IDS)){ - String[] ArrayDATA_IDS = DATA_IDS.split(","); - pd.put("ArrayDATA_IDS",ArrayDATA_IDS); - } - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - Map dataMap = new HashMap(); - List titles = new ArrayList(); - titles.add("所属企业"); //2 - titles.add("风险点(单元)"); //2 - titles.add("辨识部位"); //1 - dataMap.put("titles", titles); - List varOList = identificationpartsService.listOut(pd); - List varList = new ArrayList(); - for(int i=0;i dataMap = new HashMap(); + List titles = new ArrayList(); + titles.add("所属企业"); //2 + titles.add("风险点(单元)"); //2 + titles.add("辨识部位"); //1 + dataMap.put("titles", titles); + List varOList = identificationpartsService.listOut(pd); + List varList = new ArrayList(); + for (int i = 0; i < varOList.size(); i++) { + PageData vpd = new PageData(); + vpd.put("var1", varOList.get(i).getString("CORP_NAME")); //1 + vpd.put("var2", varOList.get(i).getString("RISKUNITNAME")); //2 + vpd.put("var3", varOList.get(i).getString("PARTSNAME")); //6 + varList.add(vpd); + } + dataMap.put("varList", varList); + ObjectExcelView erv = new ObjectExcelView(); + mv = new ModelAndView(erv, dataMap); + return mv; + } - /**导出到excel - * @param - * @throws Exception - */ + /**导出到excel + * @param + * @throws Exception + */ // @RequestMapping(value="/excelModel") //// @RequiresPermissions("toExcel") // public void exportExcelModel(HttpServletResponse response) throws Exception{ @@ -533,297 +595,304 @@ public class IdentificationPartsController extends BaseController { // FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "identificationpartsExcelTemplate.xls", "identificationpartsExcelTemplate.xls"); // } - /**从EXCEL导入到数据库 - * @param file - * @return - * @throws Exception - */ - @RequestMapping(value="/readExcel") - @SuppressWarnings("unchecked") - @ResponseBody - @Transactional - public Object readExcel(@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()) { - File tempFile = new File(file.getOriginalFilename()); //新建file - FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File - List listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet - /** - * - * 所属部门 风险点(单元) 辨识部位 - */ + /** + * 从EXCEL导入到数据库 + * + * @param file + * @return + * @throws Exception + */ + @RequestMapping(value = "/readExcel") + @SuppressWarnings("unchecked") + @ResponseBody + @Transactional + public Object readExcel(@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()) { + File tempFile = new File(file.getOriginalFilename()); //新建file + FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File + List listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet + /** + * + * 所属部门 风险点(单元) 辨识部位 + */ - List saveList = new ArrayList<>(); - try { - if(listPd.size()>0) { - List header = new ArrayList<>(); - header.add("所属部门");header.add("风险点(单元)");header.add("辨识部位"); - PageData pdCorpId = new PageData(); - pdCorpId.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pdCorpId.put("ISDELETE", "0"); - List departAll =departmentService.listAll(pdCorpId); - Map departMapAll = new HashMap<>(); - for (PageData pageData : departAll) { - departMapAll.put(Tools.excelHandle(pageData.getString("NAME")), pageData); - } - List riskunitListAll =riskunitService.listAll(pdCorpId); - Map riskunitMapAll = new HashMap<>(); - for (PageData pageData : riskunitListAll) { - riskunitMapAll.put(pageData.getString("DEPARTMENT_ID")+ Tools.excelHandle(pageData.getString("RISKUNITNAME")), pageData); - } + List saveList = new ArrayList<>(); + try { + if (listPd.size() > 0) { + List header = new ArrayList<>(); + header.add("所属部门"); + header.add("风险点(单元)"); + header.add("辨识部位"); + PageData pdCorpId = new PageData(); + pdCorpId.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + pdCorpId.put("ISDELETE", "0"); + List departAll = departmentService.listAll(pdCorpId); + Map departMapAll = new HashMap<>(); + for (PageData pageData : departAll) { + departMapAll.put(Tools.excelHandle(pageData.getString("NAME")), pageData); + } + List riskunitListAll = riskunitService.listAll(pdCorpId); + Map riskunitMapAll = new HashMap<>(); + for (PageData pageData : riskunitListAll) { + riskunitMapAll.put(pageData.getString("DEPARTMENT_ID") + Tools.excelHandle(pageData.getString("RISKUNITNAME")), pageData); + } - List identiListAll =identificationpartsService.listAll(pdCorpId); - Map identiMapAll = new HashMap<>(); - for (PageData pageData : identiListAll) { - identiMapAll.put(pageData.getString("RISK_UNIT_ID")+ Tools.excelHandle(pageData.getString("PARTSNAME")), pageData); - } - Map hasAgain = new HashMap<>(); - int succeeNum = 1; - for(PageData lpd:listPd) { - succeeNum++; + List identiListAll = identificationpartsService.listAll(pdCorpId); + Map identiMapAll = new HashMap<>(); + for (PageData pageData : identiListAll) { + identiMapAll.put(pageData.getString("RISK_UNIT_ID") + Tools.excelHandle(pageData.getString("PARTSNAME")), pageData); + } + Map hasAgain = new HashMap<>(); + int succeeNum = 1; + for (PageData lpd : listPd) { + succeeNum++; - for(int i=0;i第"+succeeNum+"行的\""+header.get(i)+"\"无数据

"); - continue; - } - if(Tools.isEmpty(lpd.get("var"+i))) { - errorStr.append("

第"+succeeNum+"行的\""+header.get(i)+"\"无数据

"); - continue; - } - } + for (int i = 0; i < header.size(); i++) { + if (!lpd.containsKey("var" + i)) { + errorStr.append("

第" + succeeNum + "行的\"" + header.get(i) + "\"无数据

"); + continue; + } + if (Tools.isEmpty(lpd.get("var" + i))) { + errorStr.append("

第" + succeeNum + "行的\"" + header.get(i) + "\"无数据

"); + continue; + } + } - String departVar = Tools.isEmpty(lpd.get("var0"))?"": Tools.excelHandle(lpd.get("var0")); - String riskNameVar = Tools.isEmpty(lpd.get("var1"))?"": Tools.excelHandle(lpd.get("var1")); - String checkNameVar = Tools.isEmpty(lpd.get("var2"))?"": Tools.excelHandle(lpd.get("var2")); - if(hasAgain.containsKey(departVar+riskNameVar+checkNameVar)) { - errorStr.append("

第"+succeeNum+"行的"+"数据重复

"); - continue; - } - hasAgain.put(departVar+riskNameVar+checkNameVar, "1"); - if(!departMapAll.containsKey(departVar)) { - errorStr.append("

第"+succeeNum+"行:"+"未找到名称为\""+departVar+"\"的"+header.get(0)+"

"); - continue; - } - PageData depart = (PageData) departMapAll.get(departVar); - if(!riskunitMapAll.containsKey(depart.getString("DEPARTMENT_ID")+riskNameVar)) { - errorStr.append("

第"+succeeNum+"行:"+"在"+departVar+"部门下未找到名称为\""+riskNameVar+"\"的"+header.get(1)+"

"); - continue; - } - PageData risk = (PageData) riskunitMapAll.get(depart.getString("DEPARTMENT_ID")+riskNameVar); - if(identiMapAll.containsKey(risk.get("RISKUNIT_ID")+checkNameVar)) { - errorStr.append("

第"+succeeNum+"行:"+"发现已经存在\""+riskNameVar+"-"+checkNameVar+"\"的"+header.get(2)+"

"); - continue; - } + String departVar = Tools.isEmpty(lpd.get("var0")) ? "" : Tools.excelHandle(lpd.get("var0")); + String riskNameVar = Tools.isEmpty(lpd.get("var1")) ? "" : Tools.excelHandle(lpd.get("var1")); + String checkNameVar = Tools.isEmpty(lpd.get("var2")) ? "" : Tools.excelHandle(lpd.get("var2")); + if (hasAgain.containsKey(departVar + riskNameVar + checkNameVar)) { + errorStr.append("

第" + succeeNum + "行的" + "数据重复

"); + continue; + } + hasAgain.put(departVar + riskNameVar + checkNameVar, "1"); + if (!departMapAll.containsKey(departVar)) { + errorStr.append("

第" + succeeNum + "行:" + "未找到名称为\"" + departVar + "\"的" + header.get(0) + "

"); + continue; + } + PageData depart = (PageData) departMapAll.get(departVar); + if (!riskunitMapAll.containsKey(depart.getString("DEPARTMENT_ID") + riskNameVar)) { + errorStr.append("

第" + succeeNum + "行:" + "在" + departVar + "部门下未找到名称为\"" + riskNameVar + "\"的" + header.get(1) + "

"); + continue; + } + PageData risk = (PageData) riskunitMapAll.get(depart.getString("DEPARTMENT_ID") + riskNameVar); + if (identiMapAll.containsKey(risk.get("RISKUNIT_ID") + checkNameVar)) { + errorStr.append("

第" + succeeNum + "行:" + "发现已经存在\"" + riskNameVar + "-" + checkNameVar + "\"的" + header.get(2) + "

"); + continue; + } // else { // System.out.println(succeeNum); // } - PageData identificationparts = new PageData(); - identificationparts.put("RISK_UNIT_ID", risk.get("RISKUNIT_ID")); - identificationparts.put("PARTSNAME", lpd.get("var2")); - identificationparts.put("IDENTIFICATIONPARTS_ID", this.get32UUID()); - identificationparts.put("ISDELETE", "0"); - identificationparts.put("ISMATCHING", "0"); - identificationparts.put("CREATOR", Jurisdiction.getUsername()); - identificationparts.put("CREATTIME", DateUtil.date2Str(new Date())); - identificationparts.put("OPERATOR", Jurisdiction.getUsername()); - identificationparts.put("OPERATTIME", DateUtil.date2Str(new Date())); - identificationparts.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - saveList.add(identificationparts); + PageData identificationparts = new PageData(); + identificationparts.put("RISK_UNIT_ID", risk.get("RISKUNIT_ID")); + identificationparts.put("PARTSNAME", lpd.get("var2")); + identificationparts.put("IDENTIFICATIONPARTS_ID", this.get32UUID()); + identificationparts.put("ISDELETE", "0"); + identificationparts.put("ISMATCHING", "0"); + identificationparts.put("CREATOR", Jurisdiction.getUsername()); + identificationparts.put("CREATTIME", DateUtil.date2Str(new Date())); + identificationparts.put("OPERATOR", Jurisdiction.getUsername()); + identificationparts.put("OPERATTIME", DateUtil.date2Str(new Date())); + identificationparts.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + saveList.add(identificationparts); - } - if(Tools.isEmpty(errorStr.toString())) { - for (PageData pageData : saveList) { - identificationpartsService.save(pageData); - } - errorStr.append("成功导入"+saveList.size()+"条数据!"); - }else { - errInfo = "error"; - } - FileUtils.deleteQuietly(tempFile);//删除临时文件 - }else { - map.put("result", "error"); //返回结果 - map.put("resultStr", "Excel数据未空,请检查数据后,重新上传!"); - FileUtils.deleteQuietly(tempFile);//删除临时文件 - return map; - } - }catch (Exception e) { - map.put("result", "error"); //返回结果 - map.put("resultStr", e.toString()); - FileUtils.deleteQuietly(tempFile);//删除临时文件 - return map; - } - } - map.put("result", "success"); //返回结果 - map.put("resultType", errInfo); //返回message类型 - map.put("isExcel","1"); //返回类型 - map.put("resultStr", errorStr.toString()); - return map; - } + } + if (Tools.isEmpty(errorStr.toString())) { + for (PageData pageData : saveList) { + identificationpartsService.save(pageData); + } + errorStr.append("成功导入" + saveList.size() + "条数据!"); + } else { + errInfo = "error"; + } + FileUtils.deleteQuietly(tempFile);//删除临时文件 + } else { + map.put("result", "error"); //返回结果 + map.put("resultStr", "Excel数据未空,请检查数据后,重新上传!"); + FileUtils.deleteQuietly(tempFile);//删除临时文件 + return map; + } + } catch (Exception e) { + map.put("result", "error"); //返回结果 + map.put("resultStr", e.toString()); + FileUtils.deleteQuietly(tempFile);//删除临时文件 + return map; + } + } + map.put("result", "success"); //返回结果 + map.put("resultType", errInfo); //返回message类型 + map.put("isExcel", "1"); //返回类型 + map.put("resultStr", errorStr.toString()); + return map; + } - /**判断同一个风险点辨识部位名称是否重复 - * @param - * @throws Exception - */ - @RequestMapping(value="/hasName") - @ResponseBody - public Object hasName() throws Exception{ - Map map = new HashMap<>(); - PageData pd = new PageData(); - pd = this.getPageData(); - String errInfo = "success"; - PageData identificationparts = new PageData(); + /** + * 判断同一个风险点辨识部位名称是否重复 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/hasName") + @ResponseBody + public Object hasName() throws Exception { + Map map = new HashMap<>(); + PageData pd = new PageData(); + pd = this.getPageData(); + String errInfo = "success"; + PageData identificationparts = new PageData(); - identificationparts.put("RISKUNIT_ID", pd.getString("RISK_UNIT_ID")); - identificationparts.put("CHECK_NAME",pd.getString("name")); - List list = identificationpartsService.listAll(identificationparts); - if(list.size()>0) { - errInfo = "error"; - } - map.put("result", errInfo); //返回结果 - map.put("count", list.size()); - return map; - } + identificationparts.put("RISKUNIT_ID", pd.getString("RISK_UNIT_ID")); + identificationparts.put("CHECK_NAME", pd.getString("name")); + List list = identificationpartsService.listAll(identificationparts); + if (list.size() > 0) { + errInfo = "error"; + } + map.put("result", errInfo); //返回结果 + map.put("count", list.size()); + return map; + } - /** - * 去修改页面获取数据 - * - * 风险管控->辨识部位->匹配资源存在风险 - * @param - * @throws Exception - */ - @RequestMapping(value="/goEditRes") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "辨识部位",instructionsType = "获取匹配资源存在风险数据") - public Object goEditRes() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - Set accidentSet = new HashSet(); - String levelId = new String(); + /** + * 去修改页面获取数据 + *

+ * 风险管控->辨识部位->匹配资源存在风险 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/goEditRes") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "风险管控", instructionsOperate = "辨识部位", instructionsType = "获取匹配资源存在风险数据") + public Object goEditRes() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + Set accidentSet = new HashSet(); + String levelId = new String(); - List rptIdList = new ArrayList();// 编辑已存在风险因素后,生成的临时风险因素ID集合 - List rptResIdList = new ArrayList();// 编辑资源库后,生成的临时风险因素ID集合 - // 新添加临时风险因素列表 - List rpTimeList = riskPointTemporaryService.listAllByTime(pd); - if(rpTimeList != null & rpTimeList.size() > 0) { - for(PageData pData : rpTimeList) { - if(pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { - String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); - Set accSet = new HashSet(Arrays.asList(split)); - accidentSet.addAll(accSet); - } - if(pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { - if(levelId.compareTo(pData.get("LEVELID").toString()) < 0) {// 取最高级 - levelId = pData.get("LEVELID").toString(); - } - } - if(pData.get("TYPE") != null && Tools.notEmpty(pData.get("TYPE").toString())) { - if("1".equals(pData.get("TYPE").toString())) {// 原数据是已存在风险因素 - rptIdList.add(pData.get("RES_ID").toString()); - } else if("2".equals(pData.get("TYPE").toString())) { // 原数据是资源库 - rptResIdList.add(pData.get("RES_ID").toString()); - } - } - } - } - if(rptIdList != null && rptIdList.size() > 0) { - pd.put("rptIds", rptIdList.toArray()); - } + List rptIdList = new ArrayList();// 编辑已存在风险因素后,生成的临时风险因素ID集合 + List rptResIdList = new ArrayList();// 编辑资源库后,生成的临时风险因素ID集合 + // 新添加临时风险因素列表 + List rpTimeList = riskPointTemporaryService.listAllByTime(pd); + if (rpTimeList != null & rpTimeList.size() > 0) { + for (PageData pData : rpTimeList) { + if (pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { + String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); + Set accSet = new HashSet(Arrays.asList(split)); + accidentSet.addAll(accSet); + } + if (pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { + if (levelId.compareTo(pData.get("LEVELID").toString()) < 0) {// 取最高级 + levelId = pData.get("LEVELID").toString(); + } + } + if (pData.get("TYPE") != null && Tools.notEmpty(pData.get("TYPE").toString())) { + if ("1".equals(pData.get("TYPE").toString())) {// 原数据是已存在风险因素 + rptIdList.add(pData.get("RES_ID").toString()); + } else if ("2".equals(pData.get("TYPE").toString())) { // 原数据是资源库 + rptResIdList.add(pData.get("RES_ID").toString()); + } + } + } + } + if (rptIdList != null && rptIdList.size() > 0) { + pd.put("rptIds", rptIdList.toArray()); + } - // 自定义风险因素列表 - pd.put("CHECK_IDENTIFICATION_ID", pd.get("IDENTIFICATIONPARTS_ID")); - List riskPointList = riskpointService.listAllToRes(pd); + // 自定义风险因素列表 + pd.put("CHECK_IDENTIFICATION_ID", pd.get("IDENTIFICATIONPARTS_ID")); + List riskPointList = riskpointService.listAllToRes(pd); - if(riskPointList != null & riskPointList.size() > 0) { - for(PageData pData : riskPointList) { - if(pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { - String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); - Set accSet = new HashSet(Arrays.asList(split)); - accidentSet.addAll(accSet); - } - if(pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { - if(levelId.compareTo(pData.get("LEVELID").toString()) < 0) {// 取最高级 - levelId = pData.get("LEVELID").toString(); - } - } - // 将已经保存的资源库数据排除 - if(pData.get("RES_ID") != null && Tools.notEmpty(pData.get("RES_ID").toString())) { - rptResIdList.add(pData.get("RES_ID").toString()); - } - } - } + if (riskPointList != null & riskPointList.size() > 0) { + for (PageData pData : riskPointList) { + if (pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { + String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); + Set accSet = new HashSet(Arrays.asList(split)); + accidentSet.addAll(accSet); + } + if (pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { + if (levelId.compareTo(pData.get("LEVELID").toString()) < 0) {// 取最高级 + levelId = pData.get("LEVELID").toString(); + } + } + // 将已经保存的资源库数据排除 + if (pData.get("RES_ID") != null && Tools.notEmpty(pData.get("RES_ID").toString())) { + rptResIdList.add(pData.get("RES_ID").toString()); + } + } + } - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 - PageData corp = corpInfoService.findById(pd); - // 资源库列表 - pd.put("CORP_TYPE", corp.get("CORP_TYPE")); - pd.put("CORP_TYPE2", corp.get("CORP_TYPE2")); - pd.put("CORP_TYPE3", corp.get("CORP_TYPE3")); - pd.put("CORP_TYPE4", corp.get("CORP_TYPE4")); - //查询资源库使用状态是否为启用 - int count = resourceCorpService.countByCorpId(pd); - if(count != 0){ - // 将查询条件单拿出来 - // change by liu jun description:梦姐提的新需求:[只匹配辨识部位名称,不需匹配风险点(单元)](禅道编号:8290) - PageData condition = new PageData(); - // 公司的行业类型 - condition.put("CORP_TYPE",pd.get("CORP_TYPE")); - condition.put("CORP_TYPE2",pd.get("CORP_TYPE2")); - condition.put("CORP_TYPE3",pd.get("CORP_TYPE3")); - condition.put("CORP_TYPE4",pd.get("CORP_TYPE4")); - // 辨识部位 - condition.put("IDENTIFICATION",pd.get("IDENTIFICATION")); - List ideResList = ideRepositoryService.listAll(condition); - // add by liu jun description:根据公司的行业类型一级一级的匹配。从第四级开始匹配,如果第四级没有数据,就匹配第三级以此类推 - if (ideResList == null || ideResList.size() == 0) { - condition.put("CORP_TYPE4", ""); - ideResList = ideRepositoryService.listAll(condition); - if (ideResList == null || ideResList.size() == 0) { - condition.put("CORP_TYPE3", ""); - ideResList = ideRepositoryService.listAll(condition); - if (ideResList == null || ideResList.size() == 0) { - condition.put("CORP_TYPE2", ""); - ideResList = ideRepositoryService.listAll(condition); - if (ideResList == null || ideResList.size() == 0) { - condition.put("CORP_TYPE", ""); - ideResList = ideRepositoryService.listAll(condition); - } - } - } - } - // 行业类型 - if(ideResList != null & ideResList.size() > 0) { - for(PageData pData : ideResList) { - if(pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { - String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); - Set accSet = new HashSet(Arrays.asList(split)); - accidentSet.addAll(accSet); - } - if(pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { - if(levelId.compareTo(pData.get("LEVELID").toString()) > 0) {// 取最高级 - levelId = pData.get("LEVELID").toString(); - } - } - } - } - map.put("ideResList", ideResList); - } - String accidents_name = String.join(",", accidentSet); - pd = identificationpartsService.findById(pd); //根据ID读取 - pd.put("ACCIDENTS_NAME", accidents_name); - pd.put("LEVELID", levelId); - map.put("pd", pd); - map.put("riskPointList", riskPointList); - map.put("rpTimeList", rpTimeList); - map.put("result", errInfo); - return map; - } + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 + PageData corp = corpInfoService.findById(pd); + // 资源库列表 + pd.put("CORP_TYPE", corp.get("CORP_TYPE")); + pd.put("CORP_TYPE2", corp.get("CORP_TYPE2")); + pd.put("CORP_TYPE3", corp.get("CORP_TYPE3")); + pd.put("CORP_TYPE4", corp.get("CORP_TYPE4")); + //查询资源库使用状态是否为启用 + int count = resourceCorpService.countByCorpId(pd); + if (count != 0) { + // 将查询条件单拿出来 + // change by liu jun description:梦姐提的新需求:[只匹配辨识部位名称,不需匹配风险点(单元)](禅道编号:8290) + PageData condition = new PageData(); + // 公司的行业类型 + condition.put("CORP_TYPE", pd.get("CORP_TYPE")); + condition.put("CORP_TYPE2", pd.get("CORP_TYPE2")); + condition.put("CORP_TYPE3", pd.get("CORP_TYPE3")); + condition.put("CORP_TYPE4", pd.get("CORP_TYPE4")); + // 辨识部位 + condition.put("IDENTIFICATION", pd.get("IDENTIFICATION")); + List ideResList = ideRepositoryService.listAll(condition); + // add by liu jun description:根据公司的行业类型一级一级的匹配。从第四级开始匹配,如果第四级没有数据,就匹配第三级以此类推 + if (ideResList == null || ideResList.size() == 0) { + condition.put("CORP_TYPE4", ""); + ideResList = ideRepositoryService.listAll(condition); + if (ideResList == null || ideResList.size() == 0) { + condition.put("CORP_TYPE3", ""); + ideResList = ideRepositoryService.listAll(condition); + if (ideResList == null || ideResList.size() == 0) { + condition.put("CORP_TYPE2", ""); + ideResList = ideRepositoryService.listAll(condition); + if (ideResList == null || ideResList.size() == 0) { + condition.put("CORP_TYPE", ""); + ideResList = ideRepositoryService.listAll(condition); + } + } + } + } + // 行业类型 + if (ideResList != null & ideResList.size() > 0) { + for (PageData pData : ideResList) { + if (pData.get("ACCIDENTS_NAME") != null && Tools.notEmpty(pData.get("ACCIDENTS_NAME").toString())) { + String[] split = pData.get("ACCIDENTS_NAME").toString().split(","); + Set accSet = new HashSet(Arrays.asList(split)); + accidentSet.addAll(accSet); + } + if (pData.get("LEVELID") != null && Tools.notEmpty(pData.get("LEVELID").toString())) { + if (levelId.compareTo(pData.get("LEVELID").toString()) > 0) {// 取最高级 + levelId = pData.get("LEVELID").toString(); + } + } + } + } + map.put("ideResList", ideResList); + } + String accidents_name = String.join(",", accidentSet); + pd = identificationpartsService.findById(pd); //根据ID读取 + pd.put("ACCIDENTS_NAME", accidents_name); + pd.put("LEVELID", levelId); + map.put("pd", pd); + map.put("riskPointList", riskPointList); + map.put("rpTimeList", rpTimeList); + map.put("result", errInfo); + return map; + } } diff --git a/src/main/java/com/zcloud/controller/system/UsersController.java b/src/main/java/com/zcloud/controller/system/UsersController.java index 4d1e29b..480999b 100644 --- a/src/main/java/com/zcloud/controller/system/UsersController.java +++ b/src/main/java/com/zcloud/controller/system/UsersController.java @@ -1,5 +1,6 @@ package com.zcloud.controller.system; +import com.alibaba.fastjson.JSON; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.EmployeeData; import com.zcloud.entity.Page; @@ -18,6 +19,7 @@ import net.sf.json.JSONArray; import org.apache.commons.io.FileUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.crypto.hash.SimpleHash; +import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; @@ -39,139 +41,146 @@ import java.util.regex.Pattern; @RequestMapping("/user") public class UsersController extends BaseController { - @Autowired + @Autowired private UsersService usersService; - @Autowired - private UserInfoService userInfoService; - @Autowired + @Autowired + private UserInfoService userInfoService; + @Autowired private RoleService roleService; - @Autowired - private UeditorService ueditorService; - @Autowired - private NoticeManagementService noticemanagementService; - @Autowired + @Autowired + private UeditorService ueditorService; + @Autowired + private NoticeManagementService noticemanagementService; + @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 DictionariesService dictionariesService; - @Autowired - private DictionariesCorpService dictionariesCorpService; - @Autowired - private ImgFilesService imgfilesService; - /**用户列表 - * @param page - * @return - * @throws Exception - */ - @RequestMapping("/list") - @RequiresPermissions("user:list") - @ResponseBody - @LogAnno(menuType= "教育培训",menuServer= "签字信息管理",instructionsOperate = "签字信息管理",instructionsType = "用户列表") - public Object listUsers(Page page)throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); + @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; - /*检索条件*/ - 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 - String ENDTIME = pd.getString("ENDTIME"); //结束时间 - if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00"); - if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00"); - pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID()); - page.setPd(pd); - pd.put("VIPLEVEL", Jurisdiction.getVIPLEVEL()); - List userList = usersService.userlistPage(page); //列出用户列表 - pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); - List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + /** + * 用户列表 + * + * @param page + * @return + * @throws Exception + */ + @RequestMapping("/list") + @RequiresPermissions("user:list") + @ResponseBody + @LogAnno(menuType = "教育培训", menuServer = "签字信息管理", instructionsOperate = "签字信息管理", instructionsType = "用户列表") + public Object listUsers(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); - map.put("userList", userList); - map.put("roleList", roleList); - map.put("ROLE_ID", ROLE_ID); - map.put("page", page); - map.put("pd", pd); + /*检索条件*/ + 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if (Tools.notEmpty(STARTTIME)) pd.put("STARTTIME", STARTTIME + " 00:00:00"); + if (Tools.notEmpty(ENDTIME)) pd.put("ENDTIME", ENDTIME + " 00:00:00"); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + page.setPd(pd); + pd.put("VIPLEVEL", Jurisdiction.getVIPLEVEL()); + List userList = usersService.userlistPage(page); //列出用户列表 + pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 - map.put("result", errInfo); - return map; - } + map.put("userList", userList); + map.put("roleList", roleList); + map.put("ROLE_ID", ROLE_ID); + map.put("page", page); + map.put("pd", pd); - /**用户列表(多选列表使用) - * @param page - * @return - * @throws Exception - */ - @RequestMapping("/listSelect") - @ResponseBody - @LogAnno(menuType= "综合管理",menuServer= "特种设备",instructionsOperate = "设备管理",instructionsType = "用户列表") - public Object listSelect(Page page)throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); + map.put("result", errInfo); + return map; + } - /*检索条件*/ - 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 - String ENDTIME = pd.getString("ENDTIME"); //结束时间 - if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 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); + /** + * 用户列表(多选列表使用) + * + * @param page + * @return + * @throws Exception + */ + @RequestMapping("/listSelect") + @ResponseBody + @LogAnno(menuType = "综合管理", menuServer = "特种设备", instructionsOperate = "设备管理", instructionsType = "用户列表") + public Object listSelect(Page page) throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); - map.put("result", errInfo); - return map; - } + /*检索条件*/ + 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if (Tools.notEmpty(STARTTIME)) pd.put("STARTTIME", STARTTIME + " 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 - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "去新增用户页面") - public Object goAddUser()throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); - List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 - 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); - map.put("roleList", roleList); + /** + * 去新增用户页面 + * + * @return + * @throws Exception + */ + @RequestMapping(value = "/goAddUser") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "去新增用户页面") + public Object goAddUser() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + 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); + map.put("roleList", roleList); - //获取部门下拉树 + //获取部门下拉树 // List zdepartmentPdList = new ArrayList(); // String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID(); // ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID; @@ -180,49 +189,53 @@ public class UsersController extends BaseController { // 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"); + 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 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("result", errInfo); - return map; - } + //获取岗位下拉 + 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("result", errInfo); + return map; + } - /**去修改用户页面(从系统用户页面修改) - * @return - * @throws Exception - */ - @RequestMapping(value="/goEditUser") - @ResponseBody - @LogAnno(menuType= "教育培训",menuServer= "档案管理",instructionsOperate = "一人一档",instructionsType = "去修改用户页面(从系统用户页面修改)") - public Object goEditUser() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - if("1".equals(pd.getString("USER_ID"))){return null;} //不能修改admin用户 - pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); - List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 - pd.put("PARENT_ID", Jurisdiction.getVIPLEVEL()); - pd.put("ISMAIN", "0"); - List userlist = roleService.findByPid(pd); + /** + * 去修改用户页面(从系统用户页面修改) + * + * @return + * @throws Exception + */ + @RequestMapping(value = "/goEditUser") + @ResponseBody + @LogAnno(menuType = "教育培训", menuServer = "档案管理", instructionsOperate = "一人一档", instructionsType = "去修改用户页面(从系统用户页面修改)") + public Object goEditUser() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if ("1".equals(pd.getString("USER_ID"))) { + return null; + } //不能修改admin用户 + pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + pd.put("PARENT_ID", Jurisdiction.getVIPLEVEL()); + pd.put("ISMAIN", "0"); + List userlist = roleService.findByPid(pd); // //获取部门下拉树 // List zdepartmentPdList = new ArrayList(); // String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID(); @@ -230,450 +243,473 @@ public class UsersController extends BaseController { // 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"); + 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读取 - pd.put("ISSTUDENT", Boolean.valueOf(pd.getString("ISSTUDENT"))); - PageData shiftDutyPeriod = new PageData(); - shiftDutyPeriod.put("DURATION", pd.get("DURATION")); - shiftDutyPeriod.put("WORKSTATUS", pd.get("WORKSTATUS")); - shiftDutyPeriod.put("WORKPERIOD", pd.get("WORKPERIOD")); + 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读取 + pd.put("ISSTUDENT", Boolean.valueOf(pd.getString("ISSTUDENT"))); + 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 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); - } - //获取岗位下拉 - 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("userList", userlist); - 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; - } + 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); + } + //获取岗位下拉 + 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("userList", userlist); + 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 map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - pd.put("ROLE_ID", Jurisdiction.getVIPLEVEL()); - List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 - pd.put("USERNAME", Jurisdiction.getUsername()); - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pd = usersService.findByUsername(pd); //根据用户名读取 - //获取部门下拉树 + /** + * 去修改用户页面(个人资料修改) + * + * @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", Jurisdiction.getVIPLEVEL()); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + pd.put("USERNAME", Jurisdiction.getUsername()); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + 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"); + //获取部门下拉树 + 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() + "}")); + 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); + 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; - } + //获取岗位下拉 + 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; + } - /** - * 获取隐患确认人 - * - * @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; - } + /** + * 获取隐患确认人 + * + * @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; + } - /** - * 修改用户(系统用户列表修改) - */ - @RequestMapping(value="/editUser") - @RequiresPermissions("user:edit") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "修改用户(系统用户列表修改)") - public Object editUser() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - if(pd.get("USERAVATARURL")!=null && !pd.getString("USERAVATARURL").equals("")){ + /** + * 修改用户(系统用户列表修改) + */ + @RequestMapping(value = "/editUser") + @RequiresPermissions("user:edit") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "修改用户(系统用户列表修改)") + public Object editUser() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + + + if (pd.get("USERAVATARURL") != null && !pd.getString("USERAVATARURL").equals("")) { // System.out.println("USERAVATARURL原长度:"+pd.getString("USERAVATARURL").length()); - String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL")); + 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; - } - } + 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 ("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 = 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()); + } + String msg = usersService.changeOrUpdUserCardNo(pd); + if (msg.equals(Const.CAN_CHENG_USER)) { + if (PLSUtil.editUser(pd)) { + 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 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; - // 如果修改了部门/岗位,将该用户所有清单都删除 - if(pd.get("OPERATIONTYPE")!=null && pd.get("OPERATIONTYPE").toString() != null && Tools.notEmpty(pd.get("OPERATIONTYPE").toString())) { - 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 "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 "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 "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 "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 "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; - 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); + } - 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", "errInfo"); + map.put("msg", "人员定位系统修改失败"); + } + return map; + } + map.put("result", "errInfo"); + map.put("msg", msg); + return map; + } - pd1.put("ISSTATISTICS", '0'); - // 本期已检查的不计入统计 - checkrecordService.editStatistics(pd1); - } - } - } - } - } + /** + * 修改用户(系统用户列表修改) + */ + @RequestMapping(value = "/editUserFuns") + @RequiresPermissions("user:edit") + @ResponseBody + 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); + return map; + } - map.put("result", errInfo); - return map; - } + /** + * 修改用户(个人资料修改) + */ + @RequestMapping(value = "/editUserOwn") + @ResponseBody + 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); + return map; + } - /** - * 修改用户(系统用户列表修改) - */ - @RequestMapping(value="/editUserFuns") - @RequiresPermissions("user:edit") - @ResponseBody - 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); - return map; - } + /** + * 判断用户名是否存在 + * + * @return + */ + @RequestMapping(value = "/hasUser") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "判断用户名是否存在") + 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); + } + map.put("result", errInfo); //返回结果 + return map; + } - /** - * 修改用户(个人资料修改) - */ - @RequestMapping(value="/editUserOwn") - @ResponseBody - 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); - 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="/hasUser") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "判断用户名是否存在") - 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); - } - 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 = "error"; + } + 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 = "/validateIdentity") + @ResponseBody + public Object validateIdentity() throws Exception { + Map map = new HashMap(); + 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; + } - /**判断编码是否存在 - * @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 = "error"; - } - map.put("result", errInfo); //返回结果 - return map; - } - - /**检验身份证号是否有效 - * @return - */ - @RequestMapping(value="/validateIdentity") - @ResponseBody - public Object validateIdentity() throws Exception{ - Map map = new HashMap(); - 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; - } - - /**保存用户 - * @return - * @throws Exception - */ + /** + * 保存用户 + * + * @return + * @throws Exception + */ // @RequestMapping(value="/saveUser") // @RequiresPermissions("user:add") // @ResponseBody @@ -761,957 +797,1024 @@ public class UsersController extends BaseController { // map.put("USER_ID", pd.getString("USER_ID")); //返回结果 // return map; // } + @RequestMapping(value = "/saveUser") + @RequiresPermissions("user:add") + @ResponseBody + @Transactional + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "保存用户") + public Object saveUser() throws Exception { + Map map = new HashMap<>(); + String errInfo = "success"; + PageData pd = this.getPageData(); + try { + usersService.saveUserNew(pd); + // 调用 Service 层保存用户 + } catch (Exception e) { + errInfo = "error"; + map.put("msg", e.getMessage()); + throw e; + } + map.put("result", errInfo); + map.put("USER_ID", pd.getString("USER_ID")); + return map; + } - @RequestMapping(value="/saveUser") - @RequiresPermissions("user:add") - @ResponseBody - @Transactional - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "保存用户") - public Object saveUser() throws Exception{ - Map map = new HashMap<>(); - String errInfo = "success"; - PageData pd = this.getPageData(); - try { - usersService.saveUserNew(pd); - // 调用 Service 层保存用户 - } catch (Exception e) { - errInfo = "error"; - map.put("msg", e.getMessage()); - } - map.put("result", errInfo); - map.put("USER_ID", pd.getString("USER_ID")); - return map; - } + /** + * 删除用户 + * + * @return + */ + @RequestMapping(value = "/deleteUser") + @RequiresPermissions("user:del") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "删除用户") + public Object deleteUser() throws Exception { + Map map = new HashMap(); + PageData pd = new PageData(); + String errInfo = "success"; + pd = this.getPageData(); + FHLOG.save(Jurisdiction.getUsername(), "删除用户ID:" + pd.getString("USER_ID")); //记录日志 + if (!PLSUtil.removeUser(pd)) { + map.put("result", "errInfo"); //返回结果 + map.put("msg", "删除失败,请联系管理员"); //返回结果 + return map; + } + usersService.deleteUser(pd); //删除用户 + ueditorService.delete(pd); //删除副文本关联数据 - /**删除用户 - * @return - */ - @RequestMapping(value="/deleteUser") - @RequiresPermissions("user:del") - @ResponseBody - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "删除用户") - public Object deleteUser() throws Exception{ - Map map = new HashMap(); - 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); //删除副文本关联数据 + 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); - 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); + 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; - 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 "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 "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 "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 "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 "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; - 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); + } - 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); + } + } + } + } - pd1.put("ISSTATISTICS", '0'); - // 本期已检查的不计入统计 - checkrecordService.editStatistics(pd1); - } - } - } - } + map.put("result", errInfo); //返回结果 + return map; + } - 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 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 = "error"; + } + 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 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 = "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 { - /**导出用户信息到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()); + String STARTTIME = pd.getString("STARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if (Tools.notEmpty(STARTTIME)) pd.put("STARTTIME", STARTTIME + " 00:00:00"); + if (Tools.notEmpty(ENDTIME)) pd.put("ENDTIME", ENDTIME + " 00:00:00"); - /*检索条件*/ - String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 - if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); - String STARTTIME = pd.getString("STARTTIME"); //开始时间 - String ENDTIME = pd.getString("ENDTIME"); //结束时间 - if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 00:00:00"); - if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00"); - - 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 - titles.add("最近登录"); //7 - titles.add("上次登录IP"); //8 - dataMap.put("titles", titles); - List userList = usersService.listAllUser(pd); - List varList = new ArrayList(); - for(int i=0;i 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 + titles.add("最近登录"); //7 + titles.add("上次登录IP"); //8 + dataMap.put("titles", titles); + List userList = usersService.listAllUser(pd); + List varList = new ArrayList(); + 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 map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - if (null != file && !file.isEmpty()) { - File tempFile = new File(file.getOriginalFilename()); //新建file - FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File - List listPd = (List)ObjectExcelRead.readExcel(tempFile, 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 map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + if (null != file && !file.isEmpty()) { + File tempFile = new File(file.getOriginalFilename()); //新建file + FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File + List listPd = (List) ObjectExcelRead.readExcel(tempFile, 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); - } + pd.put("PASSWORD", new SimpleHash("SHA-1", USERNAME, "123").toString()); //默认密码123 + if (usersService.findByNumbe(pd) != null) { + continue; + } + usersService.saveUser(pd); + } - FileUtils.deleteQuietly(tempFile);//删除临时文件 - } - map.put("result", errInfo); //返回结果 - return map; - } + FileUtils.deleteQuietly(tempFile);//删除临时文件 + } + 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", Jurisdiction.getVIPLEVEL()); - 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 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", Jurisdiction.getVIPLEVEL()); + 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", Jurisdiction.getVIPLEVEL()); - 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; - } + /** + * 查看用户 + * + * @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", Jurisdiction.getVIPLEVEL()); + 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 - String ENDTIME = pd.getString("ENDTIME"); //结束时间 - if(Tools.notEmpty(STARTTIME))pd.put("STARTTIME", STARTTIME+" 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", Jurisdiction.getVIPLEVEL()); - 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 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 STARTTIME = pd.getString("STARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if (Tools.notEmpty(STARTTIME)) pd.put("STARTTIME", STARTTIME + " 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", Jurisdiction.getVIPLEVEL()); + 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 - @LogAnno(menuType= "双重预防",menuServer= "隐患排查",instructionsOperate = "清单管理",instructionsType = "列表") - public Object listAll() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - List userList = usersService.listAllUser(pd); //列出Post列表 - map.put("userList", userList); - map.put("result", errInfo); - return map; - } + /** + * 列表 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/listAll") + @ResponseBody + @LogAnno(menuType = "双重预防", menuServer = "隐患排查", instructionsOperate = "清单管理", instructionsType = "列表") + public Object listAll() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + List userList = usersService.listAllUser(pd); //列出Post列表 + map.put("userList", userList); + map.put("result", errInfo); + return map; + } - /**列表 - * @param - * @throws Exception - */ - @RequestMapping(value="/listUserByDept") - @ResponseBody - public Object listUserByDept() throws Exception{ - Map map = new HashMap(); - 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 userList = usersService.listUserByDept(pd); //列出Post列表 - map.put("userList", userList); - map.put("result", errInfo); - return map; - } + /** + * 列表 + * + * @param + * @throws Exception + */ + @RequestMapping(value = "/listUserByDept") + @ResponseBody + public Object listUserByDept() throws Exception { + Map map = new HashMap(); + 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 userList = usersService.listUserByDept(pd); //列出Post列表 + map.put("userList", userList); + map.put("result", errInfo); + return map; + } - /**从EXCEL导入到数据库 - * @param file - * @return - * @throws Exception - */ - @RequestMapping(value="/readExcel2") + /** + * 从EXCEL导入到数据库 + * + * @param file + * @return + * @throws Exception + */ + @RequestMapping(value = "/readExcel2") // @RequiresPermissions("fromExcel") - @SuppressWarnings("unchecked") - @ResponseBody - @Transactional - @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "从EXCEL导入到数据库") - public Object readExcel2(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - StringBuffer errorStr = new StringBuffer(); + @SuppressWarnings("unchecked") + @ResponseBody + @Transactional + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "从EXCEL导入到数据库") + 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()) { - File tempFile = new File(file.getOriginalFilename()); //新建file - FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File - List listPd = (List)ObjectExcelRead.readExcel(tempFile, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet - /** - * var0 :部门 - * var1 :岗位 - * var2 :用户名 - * var3 :姓名 - * var4 :邮箱 - * var5 :备注 - */ + if (null != file && !file.isEmpty()) { + File tempFile = new File(file.getOriginalFilename()); //新建file + FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File + List listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet + /** + * var0 :部门 + * var1 :岗位 + * var2 :用户名 + * var3 :姓名 + * var4 :邮箱 + * var5 :人员定位卡号(4位纯数字) + * var6 :备注 + */ - List header = new ArrayList(); - header.add("部门");header.add("岗位");header.add("用户名");header.add("姓名");header.add("邮箱");header.add("备注");header.add("是否在线学习人员"); - List headerByLearningStatus = new ArrayList(); - 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("在职情况"); - try { + List header = new ArrayList(); + header.add("部门"); + header.add("岗位"); + header.add("用户名"); + header.add("姓名"); + header.add("邮箱"); + header.add("人员定位卡号"); + header.add("备注"); +// header.add("是否在线学习人员"); +// List headerByLearningStatus = new ArrayList(); +// 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("在职情况"); + 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")); - }*/ + if (listPd.size() > 0) { + Set cardNoMap = new HashSet(); - /** 获取所有岗位信息 */ - 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 departPd = new PageData(); + departPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + List userInfoMap = usersService.getUserCardNoAll(departPd); + HashMap userInfos = new HashMap<>(); - /** 获取所有用户信息 用于判断姓名是否重复 */ - 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("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 hasUserNameChongfu = new HashMap<>();//判断重复数据 + for (PageData pageData : userInfoMap) { + userInfos.put(pageData.getString("CARDNO"), pageData.getString("USERNAME")); + } + List departList = departmentService.listAll(departPd); + Map departMap = new HashMap(); + for (PageData pageData : departList) { + departMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData); + } + /** 获取所有岗位信息 */ + 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); + } + /** 获取所有岗位信息结束 */ - Map emailChongfu = new HashMap<>();//判断重复数据 - Integer number =0;//行数,用于提示用户 - List addUserList = new ArrayList<>(); - for(PageData lpd:listPd) { - number++; - for(int i=0;i<7;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; - } - } + /** 获取所有用户信息 用于判断姓名是否重复 */ + 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"), JSON.toJSONString(pageData)); + } + for (PageData pageData : userEList) { + emailMap.put(pageData.getString("USERNAME"), ""); + } + PageData rolePd = new PageData(); + rolePd.put("ISMAIN", "0"); + rolePd.put("PARENT_ID", Jurisdiction.getVIPLEVEL()); + rolePd.put("ROLE_NAME", "个人账号"); + PageData role = roleService.findByPidAndMain(rolePd); + if (Tools.isEmpty(role)) { + errorStr.append("未找到默认角色信息!请联系管理员"); + map.put("result", errInfo); //返回结果 + map.put("msg", ""); //返回结果 + return map; + } + /** + * 判断是否填写必填 + * 判断excel是有有重复数据 + * 判断数据库是否有重复数据 + * 导入 Page + * + * 企业分级账号 + */ + Map hasUserNameChongfu = new HashMap<>();//判断重复数据 - 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; - }*/ - Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX); - Matcher matcher = patternPhone.matcher(lpd.getString("var2")); - if(!matcher.matches()) { - errorStr.append("第"+number+"行,"); - errorStr.append("手机号格式不正确,请重新确认数据;\n"); - continue; - } - /** 部门信息 **/ - String departId = ""; - if(departMap.containsKey(dept)) { - PageData depart = (PageData)departMap.get(dept); - departId = depart.get("DEPARTMENT_ID").toString(); - }else { - errorStr.append("第"+number+"行,部门信息错误,系统未找到该部门,请重新确认数据;\n"); - continue; - } - /** 部门信息 结束**/ - /** 岗位 **/ + Map emailChongfu = new HashMap<>();//判断重复数据 + Integer number = 0;//行数,用于提示用户 + List addUserList = new ArrayList<>(); + List editUserList = new ArrayList<>(); + for (PageData lpd : listPd) { + number++; + for (int i = 0; i < 7; i++) { + if (i == 1 || i == 6) { + continue; + } + if (Tools.isEmpty(lpd.get("var" + i))) { + errorStr.append("第" + number + "行的\"" + header.get(i) + "\"无数据;\n"); + } + } -/* if(Tools.isEmpty(postName)) { - errInfo = "error"; - 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 = "error"; - errorStr.append("第"+number+"行,"); - errorStr.append("在"+keyDept+"部门下,未找到"+postName+"岗位信息,请重新确认数据"); - break; - }*/ + 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 CardNo = Tools.isEmpty(lpd.get("var5")) ? "" : lpd.get("var5").toString();//人员定位卡号 + String bz = Tools.isEmpty(lpd.get("var6")) ? "" : lpd.get("var6").toString();//备注 + Pattern patternPhone = Pattern.compile(RegexPatterns.PHONE_REGEX); + Pattern patternRardNo = Pattern.compile(RegexPatterns.VERIFY_CARDNO_REGEX); + Matcher matcher = patternPhone.matcher(lpd.getString("var2")); + Matcher matcherRardNo = patternRardNo.matcher(lpd.getString("var5")); + if (!matcherRardNo.matches()) { + errorStr.append("第" + number + "行,"); + errorStr.append("定位卡号" + CardNo + "格式不正确,请重新确认数据;\n"); + } + if (!matcher.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; + } + /** 部门信息 结束**/ + /** 岗位 **/ + Map postValMap = postMap.get(departId);//这个部门下的所有岗位信息 + String postId = ""; + if (postValMap != null) { + PageData o = (PageData) postValMap.get(postName); + postId = o.getString("POST_ID"); + } + /** 岗位 结束**/ - /** 岗位 结束**/ - 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 (hasUserNameChongfu.containsKey(userName)) { + errorStr.append("第" + number + "行,"); + errorStr.append("用户名重复,请重新确认数据;\n"); + continue; + } + if (!cardNoMap.add(CardNo)) { + errorStr.append("第" + number + "行,"); + errorStr.append("定位卡号" + CardNo + "excel中重复,请重新确认数据;\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 (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, ""); + 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("CARDNO", CardNo); + 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("RIGHTS", "788664966448"); + user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + user.put("ISSTUDENT", "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); +// } +// +// PageData zaizhiqingkuang = dictionariesService.findByName(INCUMBENCY, "548764b5d4bf4bd7a18ef88274ef49e4");//在职情况 +// if (null == zaizhiqingkuang) { +// errorStr.append("第" + number + "行,"); +// errorStr.append("未找到在职情况信息,请重新确认数据;\n"); +// continue; +// } +// String cardNo = userInfos.get(user.getString("CARDNO")); +// if (cardNo != null) { +// errorStr.append("第" + number + "行,"); +// errorStr.append("该定位卡号" + cardNo + "系统中已存在,使用人为:" + userInfos.get("CARDNO") + "请重新确认数据;\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")); +// +// } + if (userMap.containsKey(userName)) { + PageData useredit = JSON.parseObject(userMap.get(userName), PageData.class); + useredit.put("NAME", name); + useredit.put("CARDNO", CardNo); + useredit.put("ROLE_ID", role.getString("ROLE_ID")); + useredit.put("LAST_LOGIN", ""); + useredit.put("IP", ""); + useredit.put("STATUS", "0"); + useredit.put("BZ", bz); + useredit.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,"); + useredit.put("EMAIL", eMail); + useredit.put("NUMBER", ""); + useredit.put("PHONE", ""); + useredit.put("ROLE_IDS", ""); + useredit.put("DEPARTMENT_ID", departId); + useredit.put("POST_ID", postId); + useredit.put("ISMAIN", "0"); + useredit.put("FUN_IDS", ""); + useredit.put("RIGHTS", "788664966448"); + useredit.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + useredit.put("ISSTUDENT", "0");// 在线学习情况 + useredit.put("DURATION", "-1");// 工作状态持 + editUserList.add(useredit); + } else { + addUserList.add(user); + } + } + // 进行定位卡号同步校验 + for (PageData pageData : editUserList) { + String msg = usersService.changeOrUpdUserCardNo(pageData); + if (!msg.equals(Const.CAN_CHENG_USER)) { + errorStr.append("第" + number + "行,"); + errorStr.append(msg+"\n"); + } + } + for (PageData pageData : addUserList) { + if (PLSUtil.saveUser(pageData)) { + PageData cardNumberPeople = PLSUtil.getCardNumberPeople(pageData); + pageData.put("PLS_ID", cardNumberPeople.getString("psnId")); + }else { + errorStr.append("第" + number + "行,"); + errorStr.append("人员定位系统用户添加失败,请联系管理员。"+"\n"); } - 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", ""); - user.put("RIGHTS", "788664966448"); - user.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - 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; - } + } + if (Tools.isEmpty(errorStr.toString())) { + for (PageData pageData : addUserList) { + usersService.saveUser(pageData); + } + for (PageData pageData : editUserList) { + if (PLSUtil.editUser(pageData)) { + usersService.editUser(pageData); } - 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();//性别 + } + errorStr.append("成功导入" + addUserList.size() + "条数据!"); + errorStr.append("成功修改" + editUserList.size() + "条数据!"); + } else { + errInfo = "error"; + } + 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; + } - 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();//文化程度 + } + map.put("result", errInfo); //返回结果 + map.put("msg", errorStr.toString()); //返回结果 + map.put("isExcel", "1"); //返回类型 + map.put("resultStr", errorStr.toString()); + return map; + } - 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); - } - - 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")); - - } - addUserList.add(user); - } - if(Tools.isEmpty(errorStr.toString())) { - for (PageData pageData : addUserList) { - usersService.saveUser(pageData); - if("1".equals(pageData.getString("zxxxType"))){ - userInfoService.save(pageData); - } - } - - errorStr.append("成功导入"+addUserList.size()+"条数据!"); - }else { - errInfo = "error"; - } - 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") + /** + * 从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 map = new HashMap(); - String errInfo = "success"; - StringBuffer errorStr = new StringBuffer(); + @SuppressWarnings("unchecked") + @ResponseBody + @Transactional + @LogAnno(menuType = "双重预防", menuServer = "企业管理", instructionsOperate = "用户管理", instructionsType = "从EXCEL导入到数据库") + public Object readExcel3(@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()) { - File tempFile = new File(file.getOriginalFilename()); //新建file - FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File - List 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 :在职情况 - */ + if (null != file && !file.isEmpty()) { + File tempFile = new File(file.getOriginalFilename()); //新建file + FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File + List 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 header = new ArrayList(); + List header = new ArrayList(); // 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("入职日期");header.add("参加工种日期"); - header.add("在职情况"); - try { + 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 departList = departmentService.listAll(departPd); - Map departMap = new HashMap(); - for (PageData pageData : departList) { - departMap.put(Tools.excelHandle(pageData.getString("NAME")), pageData); - } + 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 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()); + /** 获取所有用户信息 用于判断姓名是否重复 */ + 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<>(); @@ -1722,55 +1825,55 @@ public class UsersController extends BaseController { // 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 - * - * 企业分级账号 - */ + 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 hasUserNameChongfu = new HashMap<>();//判断重复数据 // Map emailChongfu = new HashMap<>();//判断重复数据 - Integer number =0;//行数,用于提示用户 - List 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; - } + Integer number = 0;//行数,用于提示用户 + List 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 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();//身份证号 @@ -1801,20 +1904,20 @@ public class UsersController extends BaseController { 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; - } + 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)) { @@ -1889,366 +1992,374 @@ public class UsersController extends BaseController { // if(Tools.notEmpty(eMail)) { // emailChongfu.put(eMail, ""); // } - PageData user = new PageData(); + 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("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 = 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("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("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");// 工作状态持 + 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();//性别 + 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 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 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 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();//在职情况 + 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 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); - } + } + 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 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); - } + 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; - } + 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()); + 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); - } + 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);//删除临时文件 - }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; - } + errorStr.append("成功导入" + addUserList.size() + "条数据!"); + } else { + errInfo = "error"; + } + 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; - } + } + 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 全部部门信息 - * @param valName 部门名称 - * @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 parentId 部门父节点id + * @param departMap 全部部门信息 + * @param valName 部门名称 + * @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 page - * @throws Exception - */ - @RequestMapping(value="/listUserByCorp") - @ResponseBody - @LogAnno(menuType= "高危作业管理",menuServer= "有限空间作业管理",instructionsOperate = "有限空间台账",instructionsType = "查询公司所有用户") - 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 page + * @throws Exception + */ + @RequestMapping(value = "/listUserByCorp") + @ResponseBody + @LogAnno(menuType = "高危作业管理", menuServer = "有限空间作业管理", instructionsOperate = "有限空间台账", instructionsType = "查询公司所有用户") + 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; + } - /** - * 显示列表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); //获取单位下的所有人员 + /** + * 显示列表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); - } + 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; - } + 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") + /** + * 显示列表listCascader + * + * @return + */ + @RequestMapping(value = "/listCascaderByDeptLevel") // @RequiresPermissions("department:list") - @ResponseBody - @LogAnno(menuType= "监测预警",menuServer= "安全承诺",instructionsOperate = "公司级承诺公告",instructionsType = "显示列表listCascader") - public Object listCascaderByDeptLevel()throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - List pdList = new ArrayList(); - PageData pd = new PageData(); - pd = this.getPageData(); - pd.put("PARENT_ID", "4a661fa8aedc4d158c9cddaa9d2ec47e"); //获取部门级别数据 - List dictList = dictionariesService.listSubDictByParent(pd); - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - List userList = this.usersService.listCascader(pd); //获取单位下的所有人员 + @ResponseBody + @LogAnno(menuType = "监测预警", menuServer = "安全承诺", instructionsOperate = "公司级承诺公告", instructionsType = "显示列表listCascader") + public Object listCascaderByDeptLevel() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + List pdList = new ArrayList(); + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("PARENT_ID", "4a661fa8aedc4d158c9cddaa9d2ec47e"); //获取部门级别数据 + List dictList = dictionariesService.listSubDictByParent(pd); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + List userList = this.usersService.listCascader(pd); //获取单位下的所有人员 - 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 ) { - 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 (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) { + 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", "其他"); @@ -2266,67 +2377,73 @@ public class UsersController extends BaseController { // 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; - } - /**修改用户签字信息状态 - * 安全生产机构负责人 和 记录人员 - * @throws Exception - */ - @RequestMapping(value="/updataSignType") - @ResponseBody - @LogAnno(menuType= "教育培训",menuServer= "签字信息管理",instructionsOperate = "签字信息管理",instructionsType = "修改用户签字信息状态") - public Object updataSignType() throws Exception{ - Map map = new HashMap(); - String errInfo = "success"; - String msg = ""; - PageData pd = new PageData(); - pd = this.getPageData(); + 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; + } - 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 = "列表") + /** + * 修改用户签字信息状态 + * 安全生产机构负责人 和 记录人员 + * + * @throws Exception + */ + @RequestMapping(value = "/updataSignType") + @ResponseBody + @LogAnno(menuType = "教育培训", menuServer = "签字信息管理", instructionsOperate = "签字信息管理", instructionsType = "修改用户签字信息状态") + public Object updataSignType() throws Exception { + Map map = new HashMap(); + String errInfo = "success"; + String msg = ""; + PageData pd = new PageData(); + pd = this.getPageData(); - public Object listAllByCorp() 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.listAllUser(pd); //列出Post列表 - map.put("userList", userList); - map.put("result", errInfo); - return map; - } + 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 map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + List userList = usersService.listAllUser(pd); //列出Post列表 + map.put("userList", userList); + map.put("result", errInfo); + return map; + } } diff --git a/src/main/java/com/zcloud/entity/PageData.java b/src/main/java/com/zcloud/entity/PageData.java index 2fee103..0003190 100644 --- a/src/main/java/com/zcloud/entity/PageData.java +++ b/src/main/java/com/zcloud/entity/PageData.java @@ -66,7 +66,10 @@ public class PageData extends HashMap implements Map getUserCardNoAll(PageData departPd); } diff --git a/src/main/java/com/zcloud/service/system/UsersService.java b/src/main/java/com/zcloud/service/system/UsersService.java index cfe3754..2885800 100644 --- a/src/main/java/com/zcloud/service/system/UsersService.java +++ b/src/main/java/com/zcloud/service/system/UsersService.java @@ -281,4 +281,14 @@ public interface UsersService { */ public PageData findByIdForEmis(PageData pd)throws Exception; + /** + * @Description: 修改人员定位卡号 + * @Author: dearLin + * @Date: 2024/1/24/024 14:12 + * @Param: [com.zcloud.entity.PageData] [pd] + * @Return: boolean + */ + String changeOrUpdUserCardNo(PageData pd) throws Exception; + + List getUserCardNoAll(PageData departPd); } diff --git a/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java b/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java index 704a719..99384ee 100644 --- a/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java +++ b/src/main/java/com/zcloud/service/system/impl/UsersServiceImpl.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; + /** * 说明:用户服务接口实现类 * 作者:luoxiaobao @@ -25,474 +26,579 @@ import java.util.List; @Transactional //开启事物 public class UsersServiceImpl implements UsersService { - @Autowired - private UsersMapper usersMapper; - @Autowired - private DepartmentService departmentService; - @Autowired - private UserInfoService userInfoService; - @Autowired - private DictionariesCorpService dictionariesCorpService; - @Autowired - private FHlogService FHLOG; + @Autowired + private UsersMapper usersMapper; + @Autowired + private DepartmentService departmentService; + @Autowired + private UserInfoService userInfoService; + @Autowired + private DictionariesCorpService dictionariesCorpService; + @Autowired + private FHlogService FHLOG; - /**通过用户名获取用户信息 - * @param pd - * @return - * @throws Exception - */ - public PageData findByUsername(PageData pd) throws Exception { - return usersMapper.findByUsername(pd); - } - public PageData findByName(PageData pd) throws Exception { - return usersMapper.findByName(pd); - } + /** + * 通过用户名获取用户信息 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findByUsername(PageData pd) throws Exception { + return usersMapper.findByUsername(pd); + } - /**通过用户ID获取用户信息 - * @param pd - * @return - * @throws Exception - */ - public PageData findById(PageData pd)throws Exception{ - return usersMapper.findById(pd); - } + public PageData findByName(PageData pd) throws Exception { + return usersMapper.findByName(pd); + } - /**通 - * @param pd - * @return - * @throws Exception - */ - public List listUserAndDept (PageData pd) throws Exception{ - return usersMapper.listUserAndDept(pd); - } + /** + * 通过用户ID获取用户信息 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findById(PageData pd) throws Exception { + return usersMapper.findById(pd); + } - /** 获取获取部门账号 - * @param pd - * @return - * @throws Exception - */ - public List listUserbyDep(PageData pd)throws Exception{ - return usersMapper.listUserbyDep(pd); - } + /** + * 通 + * + * @param pd + * @return + * @throws Exception + */ + public List listUserAndDept(PageData pd) throws Exception { + return usersMapper.listUserAndDept(pd); + } - /**用户列表 - * @param page - * @return - * @throws Exception - */ - public List userlistPage(Page page) throws Exception { - return usersMapper.userlistPage(page); - } - public List listAll(PageData pd)throws Exception{ - return usersMapper.listAll(pd); - } - /**用户列表 - * @param page - * @return - * @throws Exception - */ - public List userSelectlistPage(Page page) throws Exception { - return usersMapper.userSelectlistPage(page); - } + /** + * 获取获取部门账号 + * + * @param pd + * @return + * @throws Exception + */ + public List listUserbyDep(PageData pd) throws Exception { + return usersMapper.listUserbyDep(pd); + } - /**通过用户ID获取用户信息和角色信息 - * @param USER_ID - * @return - * @throws Exception - */ - public User getUserAndRoleById(String USER_ID) throws Exception { - return usersMapper.getUserAndRoleById(USER_ID); - } + /** + * 用户列表 + * + * @param page + * @return + * @throws Exception + */ + public List userlistPage(Page page) throws Exception { + return usersMapper.userlistPage(page); + } - /**保存用户IP - * @param pd - * @throws Exception - */ - public void saveIP(PageData pd) throws Exception { - usersMapper.saveIP(pd); - } + public List listAll(PageData pd) throws Exception { + return usersMapper.listAll(pd); + } - /**通过邮箱获取数据 - * @param pd - * @return - * @throws Exception - */ - public PageData findByEmail(PageData pd) throws Exception { - return usersMapper.findByEmail(pd); - } + /** + * 用户列表 + * + * @param page + * @return + * @throws Exception + */ + public List userSelectlistPage(Page page) throws Exception { + return usersMapper.userSelectlistPage(page); + } - /**通过编码获取数据 - * @param pd - * @return - * @throws Exception - */ - public PageData findByNumbe(PageData pd) throws Exception { - return usersMapper.findByNumbe(pd); - } + /** + * 通过用户ID获取用户信息和角色信息 + * + * @param USER_ID + * @return + * @throws Exception + */ + public User getUserAndRoleById(String USER_ID) throws Exception { + return usersMapper.getUserAndRoleById(USER_ID); + } - /**列出某角色下的所有用户 - * @param pd - * @return - * @throws Exception - */ - public List listAllUserByRoldId(PageData pd) throws Exception{ - return usersMapper.listAllUserByRoldId(pd); - } + /** + * 保存用户IP + * + * @param pd + * @throws Exception + */ + public void saveIP(PageData pd) throws Exception { + usersMapper.saveIP(pd); + } - /**用户列表(全部) - * @param pd - * @return - * @throws Exception - */ - public List listAllUser(PageData pd)throws Exception{ - return usersMapper.listAllUser(pd); - } + /** + * 通过邮箱获取数据 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findByEmail(PageData pd) throws Exception { + return usersMapper.findByEmail(pd); + } - /**查询部门下用户 - * @param pd - * @return - * @throws Exception - */ - public List listUserByDept(PageData pd)throws Exception{ - return usersMapper.listUserByDept(pd); - } + /** + * 通过编码获取数据 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findByNumbe(PageData pd) throws Exception { + return usersMapper.findByNumbe(pd); + } - /**用户列表(弹窗选择用) - * @param page - * @return - * @throws Exception - */ - public List listUsersBystaff(Page page)throws Exception{ - return usersMapper.userBystafflistPage(page); - } + /** + * 列出某角色下的所有用户 + * + * @param pd + * @return + * @throws Exception + */ + public List listAllUserByRoldId(PageData pd) throws Exception { + return usersMapper.listAllUserByRoldId(pd); + } - /**保存用户 - * @param pd - * @throws Exception - */ - public void saveUser(PageData pd)throws Exception { - usersMapper.saveUser(pd); - } + /** + * 用户列表(全部) + * + * @param pd + * @return + * @throws Exception + */ + public List listAllUser(PageData pd) throws Exception { + return usersMapper.listAllUser(pd); + } - /**保存用户系统皮肤 - * @param pd - * @throws Exception - */ - public void saveSkin(PageData pd)throws Exception{ - usersMapper.saveSkin(pd); - } + /** + * 查询部门下用户 + * + * @param pd + * @return + * @throws Exception + */ + public List listUserByDept(PageData pd) throws Exception { + return usersMapper.listUserByDept(pd); + } - /**修改用户 - * @param pd - * @throws Exception - */ - public void editUser(PageData pd)throws Exception{ - usersMapper.editUser(pd); - } - public void editUserState(PageData pd)throws Exception{ - usersMapper.editUserState(pd); - } + /** + * 用户列表(弹窗选择用) + * + * @param page + * @return + * @throws Exception + */ + public List listUsersBystaff(Page page) throws Exception { + return usersMapper.userBystafflistPage(page); + } - /**通过USERID查监管端用户 - * @param pd - * @throws Exception - */ - @Override - public PageData findByRegulatoryId(PageData pd) throws Exception { - return usersMapper.findByRegulatoryId(pd); - } + /** + * 保存用户 + * + * @param pd + * @throws Exception + */ + public void saveUser(PageData pd) throws Exception { + usersMapper.saveUser(pd); + } - public PageData findByIdForEmis(PageData pd) throws Exception { - return usersMapper.findByIdForEmis(pd); - } - @Override - public void saveUserNew(PageData pd) throws Exception { - pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); - pd.put("WORKSTATUS", "1"); - pd.put("WORKPERIOD", "1"); - pd.put("RIGHTS", "788664966448"); + /** + * 保存用户系统皮肤 + * + * @param pd + * @throws Exception + */ + public void saveSkin(PageData pd) throws Exception { + usersMapper.saveSkin(pd); + } - if (pd.get("USERAVATARURL") != null && !pd.getString("USERAVATARURL").equals("")) { - String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL")); - try { - FaceUtil.compareFace(pd.getString("USERAVATARURL"), pd.getString("USERAVATARURL")); - } catch (Exception e) { - throw new Exception("人脸图像不符合要求,请重新上传"); - } - } + /** + * 修改用户 + * + * @param pd + * @throws Exception + */ + public void editUser(PageData pd) throws Exception { + usersMapper.editUser(pd); + } - if ("input".equals(pd.getString("LEARNERCATEGORYSTATUS"))) { - pd.put("DICTTYPE", "APPLICABLE_PERSONNEL"); - PageData lc = dictionariesCorpService.saveSelf(pd); - pd.put("LEARNERCATEGORY", lc.getString("DICTIONARIES_ID")); - } + public void editUserState(PageData pd) throws Exception { + usersMapper.editUserState(pd); + } - pd.put("USER_ID", Warden.get32UUID()); - pd.put("LAST_LOGIN", ""); - pd.put("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()); + /** + * 通过USERID查监管端用户 + * + * @param pd + * @throws Exception + */ + @Override + public PageData findByRegulatoryId(PageData pd) throws Exception { + return usersMapper.findByRegulatoryId(pd); + } - if (usersMapper.findByUsername(pd) == null) { - 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); - } + public PageData findByIdForEmis(PageData pd) throws Exception { + return usersMapper.findByIdForEmis(pd); + } - usersMapper.saveUser(pd); - FHLOG.save(Jurisdiction.getUsername(), "新增用户:" + pd.getString("USERNAME")); + @Override + public String changeOrUpdUserCardNo(PageData nowuser) throws Exception { + PageData oldUser = usersMapper.findById(nowuser); + // 先判断人员新的定位卡号是否有变化,没变化直接可以修改 + if (oldUser.getString("CARDNO").equals(nowuser.getString("CARDNO"))) { + return Const.CAN_CHENG_USER; + } + // 有变化看库里是否有人在用这个新卡号 + PageData getCordNo = new PageData(); + getCordNo.putAll(nowuser); + getCordNo.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID()); + PageData usedCardNo = usersMapper.findByCardNo(getCordNo); + // 卡号被本系统中他人使用了 + if (usedCardNo != null) { + return Const.CARD_ALREADY_BEEN_USED+usedCardNo.getString("NAME"); + } + PageData cardNumberPeople = PLSUtil.getCardNumberPeople(nowuser); + // 这个新卡号其他系统中绑定人了 + if (cardNumberPeople != null) { + return "人员定位系统中"+Const.CARD_ALREADY_BEEN_USED+cardNumberPeople.getString("name"); + } + return Const.CAN_CHENG_USER; + } - if (PLSUtil.getToken(pd)) { - PLSUtil.saveUser(pd); - } else { - throw new Exception("无法获取有效的Token"); - } - } else { - throw new Exception("用户名已存在"); - } - } + @Override + public List getUserCardNoAll(PageData departPd) { + return usersMapper.getUserCardNoAll(departPd); + } + + @Override + public void saveUserNew(PageData pd) throws Exception { + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); + pd.put("WORKSTATUS", "1"); + pd.put("WORKPERIOD", "1"); + pd.put("RIGHTS", "788664966448"); + // 先判断这个人定位卡号与姓名是否对的上 + if (!PLSUtil.hasCardNumber(pd)) { + throw new Exception(pd.getString("CARDNO") + "定位卡已经存在"); + } + + if (pd.get("USERAVATARURL") != null && !pd.getString("USERAVATARURL").equals("")) { + String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL")); + try { + FaceUtil.compareFace(pd.getString("USERAVATARURL"), pd.getString("USERAVATARURL")); + } catch (Exception e) { + throw new Exception("人脸图像不符合要求,请重新上传"); + } + } + + 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", Warden.get32UUID()); + pd.put("LAST_LOGIN", ""); + pd.put("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 (usersMapper.findByUsername(pd) == null && PLSUtil.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); + } + PageData cardNumberPeople = PLSUtil.getCardNumberPeople(pd); + pd.put("PLS_ID", cardNumberPeople.getString("psnId")); + usersMapper.saveUser(pd); + FHLOG.save(Jurisdiction.getUsername(), "新增用户:" + pd.getString("USERNAME")); + } else { + throw new Exception("请检查定位卡号与用户名是否重复"); + } + } - public void editPassword(PageData pd)throws Exception{ - usersMapper.editPassword(pd); - } + public void editPassword(PageData pd) throws Exception { + usersMapper.editPassword(pd); + } - /**删除用户 - * @param pd - * @throws Exception - */ - public void deleteUser(PageData pd)throws Exception{ - usersMapper.deleteUser(pd); - } + /** + * 删除用户 + * + * @param pd + * @throws Exception + */ + public void deleteUser(PageData pd) throws Exception { + usersMapper.deleteUser(pd); + } - /**批量删除用户 - * @param pd - * @throws Exception - */ - public void deleteAllUser(String[] USER_IDS)throws Exception{ - usersMapper.deleteAllUser(USER_IDS); - } - public List listUserBYids(String[] USER_IDS)throws Exception{ - return usersMapper.listUserBYids(USER_IDS); - } + /** + * 批量删除用户 + * + * @param pd + * @throws Exception + */ + public void deleteAllUser(String[] USER_IDS) throws Exception { + usersMapper.deleteAllUser(USER_IDS); + } - /**修改用户小程序权限 - * @param pd - * @throws Exception - */ - public void editUserFuns(PageData pd) { - usersMapper.editUserFuns(pd); - } + public List listUserBYids(String[] USER_IDS) throws Exception { + return usersMapper.listUserBYids(USER_IDS); + } - /**查询小程序用户 - * @param pd - * @return - * @throws Exception - */ - public PageData findAppUserById(PageData pd) throws Exception { - return usersMapper.findAppUserById(pd); - } + /** + * 修改用户小程序权限 + * + * @param pd + * @throws Exception + */ + public void editUserFuns(PageData pd) { + usersMapper.editUserFuns(pd); + } - /**用户同意协议 - * @param pd - * @throws Exception - */ - public void agreeProtocol(PageData pd) throws Exception { - usersMapper.agreeProtocol(pd); - } - /** - * 获取该企业下所有用户,用户判断是否重复 - * @param pd - * @return - * @throws Exception - */ - public List findUserNameAll(PageData pd) throws Exception { - // TODO Auto-generated method stub - return usersMapper.findUserNameAll(pd); - } - /** - * - * @param pd - * @return - * @throws Exception - */ - public List findAllUser(PageData pd) throws Exception { - // TODO Auto-generated method stub - return usersMapper.findAllUser(pd); - } + /** + * 查询小程序用户 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findAppUserById(PageData pd) throws Exception { + return usersMapper.findAppUserById(pd); + } - /** - * 获取账号及部门岗位 - * @param pd - * @return - * @throws Exception - */ - @Override - public List listUserDepPos(PageData pd) throws Exception { - return usersMapper.listUserDepPos(pd); - } + /** + * 用户同意协议 + * + * @param pd + * @throws Exception + */ + public void agreeProtocol(PageData pd) throws Exception { + usersMapper.agreeProtocol(pd); + } - /** - * 查询公司员工总数 - * @param pd - * @return - */ - public int getUserCount(PageData pd) throws Exception{ - return usersMapper.getUserCount(pd); - } + /** + * 获取该企业下所有用户,用户判断是否重复 + * + * @param pd + * @return + * @throws Exception + */ + public List findUserNameAll(PageData pd) throws Exception { + // TODO Auto-generated method stub + return usersMapper.findUserNameAll(pd); + } - /** - * 查询公司检查过清单的员工总数 - * @param pd - * @return - */ - public int getWorkedUserCount(PageData pd) throws Exception{ - return usersMapper.getWorkedUserCount(pd); - } + /** + * @param pd + * @return + * @throws Exception + */ + public List findAllUser(PageData pd) throws Exception { + // TODO Auto-generated method stub + return usersMapper.findAllUser(pd); + } - /** - * 查询用户倒班周期数据 - * @param pd - * @return - * @throws Exception - */ - public List getUserWork(PageData pd) throws Exception { - return usersMapper.getUserWork(pd); - } + /** + * 获取账号及部门岗位 + * + * @param pd + * @return + * @throws Exception + */ + @Override + public List listUserDepPos(PageData pd) throws Exception { + return usersMapper.listUserDepPos(pd); + } - /**修改用户倒班周期 - * @param pd - * @throws Exception - */ - public void editShiftWork(PageData pd) { - usersMapper.editShiftWork(pd); - } + /** + * 查询公司员工总数 + * + * @param pd + * @return + */ + public int getUserCount(PageData pd) throws Exception { + return usersMapper.getUserCount(pd); + } - /**获取人员Cascader数据(人员ID,姓名,部门ID,部门级别) - * @param pd - * @return - * @throws Exception - */ - @Override - public List listCascader(PageData pd) throws Exception { - return usersMapper.listCascader(pd); - } + /** + * 查询公司检查过清单的员工总数 + * + * @param pd + * @return + */ + public int getWorkedUserCount(PageData pd) throws Exception { + return usersMapper.getWorkedUserCount(pd); + } - /**清除在线学习人员分类 - * @param pd - * @return - * @throws Exception - */ - @Override - public void clearLearnerCategory(PageData pd) throws Exception { - usersMapper.clearLearnerCategory(pd); - } + /** + * 查询用户倒班周期数据 + * + * @param pd + * @return + * @throws Exception + */ + public List getUserWork(PageData pd) throws Exception { + return usersMapper.getUserWork(pd); + } - /** - * 获取账号及部门岗位 - * @param pd - * @return - * @throws Exception - */ - @Override - public List listUserDepPoslistPage(Page page) throws Exception { - return usersMapper.listUserDepPoslistPage(page); - } - /** - *更新用户pushcid - * @param pd - * @throws Exception - */ - public void updatePushCid(PageData pd)throws Exception{ - usersMapper.updatePushCid(pd); - } - /**修改公司名称时同步修改企业账号 - * @param pd - * @throws Exception - */ - public void updateCornUser(PageData pd)throws Exception{ - usersMapper.updateCornUser(pd); - } - /**查询用户名称及部门名称 - * @param pd - * @return - * @throws Exception - */ - public PageData findUserDept(PageData pd)throws Exception{ - return usersMapper.findUserDept(pd); - } + /** + * 修改用户倒班周期 + * + * @param pd + * @throws Exception + */ + public void editShiftWork(PageData pd) { + usersMapper.editShiftWork(pd); + } - /**用户列表(本部门及所有上级部门领导负责人) - * @param pd - * @return - * @throws Exception - */ - public List listUserLeader(PageData pd)throws Exception{ - List deptArr = new ArrayList<>(); - PageData dept = departmentService.findById(pd); - deptArr.add(dept.getString("DEPARTMENT_ID")); - findParentDept(deptArr, dept); - pd.put("DEPT_IDS", deptArr); - List userList = usersMapper.listUserLeader(pd); - for (int i = 0; i < userList.size(); i++) { //申请人为部门负责人 移除 - if (pd.getString("USER_ID").equals(userList.get(i).getString("USER_ID"))) { - userList.remove(i); - } - } - return userList; - } + /** + * 获取人员Cascader数据(人员ID,姓名,部门ID,部门级别) + * + * @param pd + * @return + * @throws Exception + */ + @Override + public List listCascader(PageData pd) throws Exception { + return usersMapper.listCascader(pd); + } - private void findParentDept(List deptArr, PageData dept) throws Exception { - if (!"0".equals(dept.getString("PARENT_ID"))) { - PageData p = new PageData(); - p.put("DEPARTMENT_ID", dept.getString("PARENT_ID")); - PageData parent = departmentService.findById(p); - deptArr.add(parent.getString("DEPARTMENT_ID")); - if (!"0".equals(parent.getString("PARENT_ID"))) { - findParentDept(deptArr, parent); + /** + * 清除在线学习人员分类 + * + * @param pd + * @return + * @throws Exception + */ + @Override + public void clearLearnerCategory(PageData pd) throws Exception { + usersMapper.clearLearnerCategory(pd); + } - } - } - } + /** + * 获取账号及部门岗位 + * + * @param pd + * @return + * @throws Exception + */ + @Override + public List listUserDepPoslistPage(Page page) throws Exception { + return usersMapper.listUserDepPoslistPage(page); + } - /**获取账号及部门岗位 - * @param page - * @return - * @throws Exception - */ - public List listUserlistPage(Page page)throws Exception{ - return usersMapper.listUserlistPage(page); - } + /** + * 更新用户pushcid + * + * @param pd + * @throws Exception + */ + public void updatePushCid(PageData pd) throws Exception { + usersMapper.updatePushCid(pd); + } + + /** + * 修改公司名称时同步修改企业账号 + * + * @param pd + * @throws Exception + */ + public void updateCornUser(PageData pd) throws Exception { + usersMapper.updateCornUser(pd); + } + + /** + * 查询用户名称及部门名称 + * + * @param pd + * @return + * @throws Exception + */ + public PageData findUserDept(PageData pd) throws Exception { + return usersMapper.findUserDept(pd); + } + + /** + * 用户列表(本部门及所有上级部门领导负责人) + * + * @param pd + * @return + * @throws Exception + */ + public List listUserLeader(PageData pd) throws Exception { + List deptArr = new ArrayList<>(); + PageData dept = departmentService.findById(pd); + deptArr.add(dept.getString("DEPARTMENT_ID")); + findParentDept(deptArr, dept); + pd.put("DEPT_IDS", deptArr); + List userList = usersMapper.listUserLeader(pd); + for (int i = 0; i < userList.size(); i++) { //申请人为部门负责人 移除 + if (pd.getString("USER_ID").equals(userList.get(i).getString("USER_ID"))) { + userList.remove(i); + } + } + return userList; + } + + private void findParentDept(List deptArr, PageData dept) throws Exception { + if (!"0".equals(dept.getString("PARENT_ID"))) { + PageData p = new PageData(); + p.put("DEPARTMENT_ID", dept.getString("PARENT_ID")); + PageData parent = departmentService.findById(p); + deptArr.add(parent.getString("DEPARTMENT_ID")); + if (!"0".equals(parent.getString("PARENT_ID"))) { + findParentDept(deptArr, parent); + + } + } + } + + /** + * 获取账号及部门岗位 + * + * @param page + * @return + * @throws Exception + */ + public List listUserlistPage(Page page) throws Exception { + return usersMapper.listUserlistPage(page); + } } diff --git a/src/main/java/com/zcloud/util/Const.java b/src/main/java/com/zcloud/util/Const.java index 7696629..6ac3c54 100644 --- a/src/main/java/com/zcloud/util/Const.java +++ b/src/main/java/com/zcloud/util/Const.java @@ -68,4 +68,8 @@ public class Const { public static final String ENDPOINT = "vod.cn-beijing.aliyuncs.com";// 访问的域名 public static final String TOPIC_EIGHTWORK="eightWork_whb_chen"; + + // 修改用户相关 + public static final String CAN_CHENG_USER="SUCCEEDS"; + public static final String CARD_ALREADY_BEEN_USED="当前卡号已经被使用。使用人:"; } diff --git a/src/main/java/com/zcloud/util/DateUtil.java b/src/main/java/com/zcloud/util/DateUtil.java index 32cd30e..f0d3321 100644 --- a/src/main/java/com/zcloud/util/DateUtil.java +++ b/src/main/java/com/zcloud/util/DateUtil.java @@ -193,6 +193,21 @@ public class DateUtil { return dateStr; } + /** + * 当前时间加n小时之后的时间 + * @param days + * @return + */ + public static String getAfterHourDate(String hours) { + int hoursInt = Integer.parseInt(hours); + Calendar canlendar = Calendar.getInstance(); // java.util包 + canlendar.add(Calendar.HOUR, hoursInt); // 日期减 如果不够减会将月变动 + Date date = canlendar.getTime(); + SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dateStr = sdfd.format(date); + return dateStr; + } + /** * 得到n天之后是周几 * @param days @@ -759,7 +774,8 @@ public class DateUtil { } public static void main(String[] args) { - System.out.println(getHalfYearMonth(true)); + String afterHourDate = DateUtil.getAfterHourDate("12"); + System.out.println(afterHourDate); } diff --git a/src/main/java/com/zcloud/util/PLSUtil.java b/src/main/java/com/zcloud/util/PLSUtil.java index 352277b..d79746c 100644 --- a/src/main/java/com/zcloud/util/PLSUtil.java +++ b/src/main/java/com/zcloud/util/PLSUtil.java @@ -1,5 +1,6 @@ package com.zcloud.util; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.zcloud.entity.Camera; import com.zcloud.entity.Card; @@ -8,325 +9,209 @@ import com.zcloud.entity.PageData; import com.zcloud.service.corp.CorpPlsInfoService; import com.zcloud.service.system.UsersService; import okhttp3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.nio.charset.StandardCharsets; +import java.util.*; +@Component public class PLSUtil { + private static final Logger logger = LoggerFactory.getLogger(PLSUtil.class); + + private static CorpPlsInfoService corpplsinfoService; + private static UsersService usersService; + // 后台地址 + public static HashMap BAKEADDR = new HashMap<>(); + @Autowired - public static CorpPlsInfoService corpplsinfoService; - @Autowired - public static UsersService usersService; + public void setCorpplsinfoService(CorpPlsInfoService corpplsinfoServicebean, UsersService usersServicebean) { + corpplsinfoService = corpplsinfoServicebean; + usersService = usersServicebean; + } + + @PostConstruct + private void initBakeAddr() throws Exception { + List dataList = corpplsinfoService.listAll(new PageData()); + dataList.forEach(item -> { + BAKEADDR.put(item.getString("CORPINFO_ID"), item.getString("POST_URL")); + }); + } /** - * 验证登录 - * @param pd - * @return - * @throws Exception + * @Description: 获取token + * @Author: dearLin + * @Date: 2024/1/24/024 9:59 + * @Param: [] [] + * @Return: java.lang.String */ - public static boolean getToken(PageData pd) throws Exception { - boolean tokenUpdated = false; + public static String getToken() throws Exception { + PageData pd = new PageData(); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pd = corpplsinfoService.findById(pd); String token = pd.getString("TOKEN"); + String backAddr = pd.getString("POST_URL"); String expireTime = pd.getString("EXPIRE_TIME"); String userName = pd.getString("ACCOUNT"); String passWord = pd.getString("PASSWORD"); String loginUrl = pd.getString("POST_URL") + "/auth/login"; - if (token == null || expireTime == null || expireTime.trim().isEmpty() || DateUtil.compareDate(DateUtil.getTime(), expireTime)) { JSONObject loginPayload = new JSONObject(); loginPayload.put("username", userName); loginPayload.put("password", passWord); loginPayload.put("isPresentationMode", "2"); - - Response response = sendPostHttpRequest(loginPayload.toJSONString(), loginUrl,null); - if (response.isSuccessful()) { - String responseBody = response.body().string(); - JSONObject responseJSON = new JSONObject(responseBody.isEmpty()); - JSONObject data = responseJSON.getJSONObject("data"); - token = data.getString("access_token"); - String newExpireTime = DateUtil.getAfterDayDate("1"); + PageData response = sendPostHttpRequest(loginUrl, loginPayload.toJSONString(), null); + if (response != null) { + PageData valueData = JSONObject.parseObject(response.getString("data"), PageData.class); + token = valueData.getString("access_token"); + String newExpireTime = DateUtil.getAfterHourDate("12"); pd.put("TOKEN", token); pd.put("EXPIRE_TIME", newExpireTime); corpplsinfoService.edit(pd); - tokenUpdated = true; + return token; } else { - System.out.println("登录失败" + response.code()); + System.out.println("登录失败"); } - } else { - tokenUpdated = true; - } - return tokenUpdated; - } - - /** - * 新增员工信息 - * @param pd - * @throws Exception - */ - public static void saveUser(PageData pd) throws Exception { - if (getToken(pd)) { - PageData user = usersService.findByUsername(pd); - EmployeeData employeeData = new EmployeeData(); - - if (user == null) { - employeeData.setName(user.getString("NAME")); - employeeData.setAvatar(user.getString("USERAVATARPREFIX") + user.getString("USERAVATARURL")); - employeeData.setCardNo(user.getString("CARDNO")); - employeeData.setSex(user.getString("SEX")); - employeeData.setPhone(user.getString("PHONE")); - } - - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String url = pd.getString("POST_URL") + "/deploy/psnmgmt/insertPsnInfo"; - Response response = sendPostHttpRequest(url,employeeData.toString(),token); - if (!response.isSuccessful()) { - throw new IOException("请求失败:" + response); - } - } else { - throw new Exception("无法获取有效的Token"); - } - } - - /** - * 修改人员卡 - * @param pd - * @throws Exception - */ - public static void updateUserCardInfo(PageData pd) throws Exception { - Card card = new Card(); - if (getToken(pd)){ - card.setCardNo(pd.getString("CARDNO")); - card.setPsnId(pd.getString("PsnId")); - card.setCardType(pd.getString("CARDTYPE")); - card.setCardStatus(pd.getString("CARDSTATUS")); - card.setRemark(pd.getString("REMARK")); - - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String url = pd.getString("POST_URL") + "/deploy/card"; - - Response response = sendPutHttpRequest(url, card.toString(), token); - if (!response.isSuccessful()) { - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); - } - } - - /** - * 根据人员卡卡号获取人员信息 - * @param pd - * @return - * @throws Exception - */ - public static JSONObject cardIdGetUserInfo(PageData pd) throws Exception { - JSONObject result = null; - if (getToken(pd)){ - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String cardId = pd.getString("CARDNO"); - String url = pd.getString("POST_URL") + "/deploy/psnmgt/feign-client/getPsnInfoByCardId/" + cardId; - - Response response = sendGetHttpRequest(url, null, token); - if (response.isSuccessful()){ - String responseBody = response.body().string(); - result = new JSONObject(responseBody.isEmpty()); - }else { - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); - } - - return result; - } - - /** - * 添加摄像头 - * @param pd - * @throws Exception - */ - public static void saveCamera(PageData pd) throws Exception { - Camera camera = new Camera(); - if (getToken(pd)) { - camera.setCamName(pd.getString("CAMNAME")); - camera.setCamNo(pd.getString("CAMNO")); - camera.setCamIp(pd.getString("CAMIP")); - camera.setPort(pd.getString("PORT")); - camera.setType(pd.getString("TYPE")); - camera.setCamUserName(pd.getString("CAMUSERNAME")); - camera.setCamPassword(pd.getString("CAMPASSWORD")); - camera.setLon(pd.getString("LON")); - camera.setAlt(pd.getString("ALT")); - camera.setChannel(pd.getString("CHANNEL")); - camera.setIndexcode(pd.getString("INDEXCODE")); - - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String url = pd.getString("POST_URL") + "/device/camera"; - - Response response = sendPostHttpRequest(url, String.valueOf(camera), token); - if (!response.isSuccessful()){ - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); - } - } - - /** - * 修改摄像头基本信息 - * @param pd - * @throws Exception - */ - public static void updateCamera(PageData pd) throws Exception { - Camera camera = new Camera(); - if (getToken(pd)){ - camera.setCamName(pd.getString("CAMNAME")); - camera.setCamNo(pd.getString("CAMNO")); - camera.setCamIp(pd.getString("CAMIP")); - camera.setPort(pd.getString("PORT")); - camera.setType(pd.getString("TYPE")); - camera.setCamUserName(pd.getString("CAMUSERNAME")); - camera.setCamPassword(pd.getString("CAMPASSWORD")); - camera.setLon(pd.getString("LON")); - camera.setAlt(pd.getString("ALT")); - camera.setChannel(pd.getString("CHANNEL")); - camera.setIndexcode(pd.getString("INDEXCODE")); - - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String url = pd.getString("POST_URL") + "/device/camera"; - Response response = sendPutHttpRequest(url, String.valueOf(camera), token); - if (!response.isSuccessful()){ - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); - } - } - - /** - * 获取电子围栏列表 - * @param pd - * @return - * @throws Exception - */ - public static JSONObject getAListOfElectronicFences(PageData pd) throws Exception { - if (getToken(pd)) { - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - String url = pd.getString("POST_URL") + "/region/api/electronicFence/getAListOfElectronicFences"; - - Response response = sendGetHttpRequest(url, null, token); - if (response.isSuccessful()){ - String responseBody = response.body().string(); - return new JSONObject(responseBody.isEmpty()); - }else { - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); - } - } - - /** - * 告警统计 - * @param pd - * @return - * @throws Exception - */ - public static JSONObject getAlarmStatistics(PageData pd) throws Exception { - JSONObject result = null; - if (getToken(pd)){ - pd = corpplsinfoService.findById(pd); - String token = pd.getString("TOKEN"); - Map queryParams = new HashMap<>(); - queryParams.put("type",pd.getString("week")); - String url = pd.getString("POST_URL") + "/region/alarm/alarmStatistics"; - - Response response = sendGetHttpRequest(url, queryParams, token); - if (response.isSuccessful()){ - String responseBody = response.body().string(); - return new JSONObject(responseBody.isEmpty()); - }else { - throw new IOException("请求失败:" + response); - } - }else { - throw new Exception("无法获取有效的Token"); } + return token; } /** - * 发送post类型请求 - * @param url - * @param jsonPayload - * @param token - * @return - * @throws IOException + * @Description: 查询这个人的定位卡号是否存在 + * @Author: dearLin + * @Date: 2024/1/24/024 10:00 + * @Param: [com.zcloud.entity.PageData] [user] + * @Return: void */ - private static Response sendPostHttpRequest(String url, String jsonPayload, String token) throws IOException { - OkHttpClient client = new OkHttpClient(); - MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - RequestBody body = RequestBody.create(JSON, jsonPayload); - Request.Builder builder = new Request.Builder() // 构建一个新的Request对象。 - .url(url)// 设置请求的URL。 - .post(body);// 设置请求的方法为POST,并设置请求体。 - - //构建请求头 - if (token != null && !token.isEmpty()) {// 检查token是否存在且不为空。 - builder.addHeader("Authorization", "Bearer " + token); + public static boolean hasCardNumber(PageData user) throws Exception { + // 根据 定位卡号获取对应的人 + String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); + PageData response = sendGetHttpRequest(url, null, getToken()); + if (response != null) { + if (!"200".equals(response.getString("code"))) { + return false; + } + List dataList = JSONObject.parseArray(response.getString("data"), PageData.class); + return dataList.isEmpty(); } - - // 构建请求 - Request request = builder.build(); - //发起请求并响应数据 - return client.newCall(request).execute(); + return false; } /** - * 发送PUT类型请求 - * @param url - * @param jsonPayload - * @param token - * @return - * @throws IOException + * @Description: 查询这个人的定位卡号是否存在 + * @Author: dearLin + * @Date: 2024/1/24/024 10:00 + * @Param: [com.zcloud.entity.PageData] [user] + * @Return: void */ - private static Response sendPutHttpRequest(String url, String jsonPayload, String token)throws IOException{ - OkHttpClient client = new OkHttpClient(); - MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - RequestBody body = RequestBody.create(JSON, jsonPayload); - Request.Builder builder = new Request.Builder() - .url(url) - .put(body); - if (token != null && !token.isEmpty()) { - builder.addHeader("Authorization", "Bearer " + token); + public static PageData getCardNumberPeople(PageData user) throws Exception { + // 根据 定位卡号获取对应的人 + String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); + PageData response = sendGetHttpRequest(url, null, getToken()); + if (response != null) { + if (!"200".equals(response.getString("code"))) { + return null; + } + List dataList = JSONObject.parseArray(response.getString("data"), PageData.class); + return dataList.size() > 0 ? dataList.get(0) : null; } - Request request = builder.build(); + return null; + } - return client.newCall(request).execute(); + /** + * @Description: 把人新增到 人员定位系统 + * @Author: dearLin + * @Date: 2024/1/24/024 10:00 + * @Param: [com.zcloud.entity.PageData] [user] + * @Return: void + */ + public static boolean saveUser(PageData user) throws Exception { + String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/insertPsnIfon"; + JSONObject loginPayload = new JSONObject(); + loginPayload.put("name", user.getString("NAME")); + loginPayload.put("cardNo", user.getString("CARDNO")); + loginPayload.put("empNo", ""); + loginPayload.put("sex", ""); + loginPayload.put("certType", ""); + loginPayload.put("certNo", ""); + loginPayload.put("office", ""); + loginPayload.put("staffType", ""); + loginPayload.put("phone", ""); + loginPayload.put("empId", ""); + loginPayload.put("age", ""); + loginPayload.put("addr", ""); + loginPayload.put("remark", ""); + loginPayload.put("enterpriseName", ""); + loginPayload.put("officeName", ""); + loginPayload.put("jobsName", ""); + loginPayload.put("deptName", ""); + loginPayload.put("deptId", ""); + loginPayload.put("avatar", ""); + PageData response = sendPostHttpRequest(url, loginPayload.toJSONString(), getToken()); + return "200".equals(response.getString("code")); + } + + /** + * @Description: 把人新增到 人员定位系统 + * @Author: dearLin + * @Date: 2024/1/24/024 10:00 + * @Param: [com.zcloud.entity.PageData] [user] + * @Return: void + */ + public static boolean editUser(PageData user) throws Exception { + String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/updPsnInfoById"; + JSONObject loginPayload = new JSONObject(); + loginPayload.put("name", user.getString("NAME")); + loginPayload.put("psnId", user.getString("PLS_ID")); + loginPayload.put("cardNo", user.getString("CARDNO")); + loginPayload.put("empNo", ""); + loginPayload.put("sex", ""); + loginPayload.put("certType", ""); + loginPayload.put("certNo", ""); + loginPayload.put("office", ""); + loginPayload.put("staffType", ""); + loginPayload.put("phone", ""); + loginPayload.put("empId", ""); + loginPayload.put("age", ""); + loginPayload.put("addr", ""); + loginPayload.put("remark", ""); + loginPayload.put("enterpriseName", ""); + loginPayload.put("officeName", ""); + loginPayload.put("jobsName", ""); + loginPayload.put("deptName", ""); + loginPayload.put("deptId", ""); + loginPayload.put("avatar", ""); + PageData response = sendPostHttpRequest(url, loginPayload.toJSONString(), getToken()); + return "200".equals(response.getString("code")); + } + public static boolean removeUser(PageData user) throws Exception { + String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt"; + PageData removeUser = usersService.findById(user); + PageData response = sendDeleteHttpRequest(url, Long.parseLong(removeUser.getString("PLS_ID")), getToken()); + return "200".equals(response.getString("code")); } /** * 发送get类型请求 + * * @param url * @param queryParams * @param token - * @return + * @return PageData * @throws IOException */ - private static Response sendGetHttpRequest(String url, Map queryParams, String token) throws IOException { + + private static PageData sendGetHttpRequest(String url, Map queryParams, String token) throws IOException { OkHttpClient client = new OkHttpClient(); - HttpUrl.Builder httpBuilder = HttpUrl.parse(url).newBuilder(); + HttpUrl.Builder httpBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); //封装请求参数 if (queryParams != null) { for (Map.Entry param : queryParams.entrySet()) { @@ -342,24 +227,90 @@ public class PLSUtil { } Request request = requestBuilder.build(); + Response execute = client.newCall(request).execute(); + if (execute.code() != 200) { + logger.error("get请求失败,返回状态码:{},url:{}", execute.code(), url); + throw new RuntimeException("get请求失败"); + } + return JSONObject.parseObject(execute.body().string(), PageData.class); //发送请求并返回响应数据 + } + + + /** + * 发送post类型请求 + * + * @param url + * @param jsonPayload + * @param token + * @return + * @throws IOException + */ + private static PageData sendPostHttpRequest(String url, String jsonPayload, String token) throws IOException { + OkHttpClient client = new OkHttpClient(); + MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + RequestBody body = RequestBody.create(JSON, jsonPayload); + Request.Builder builder = new Request.Builder() // 构建一个新的Request对象。 + .url(url)// 设置请求的URL。 + .post(body);// 设置请求的方法为POST,并设置请求体。 + //构建请求头 + if (token != null && !token.isEmpty()) {// 检查token是否存在且不为空。 + builder.addHeader("Authorization", "Bearer " + token); + } + + // 构建请求 + Request request = builder.build(); + Response execute = client.newCall(request).execute(); + if (execute.code() != 200) { + logger.error("post请求失败,返回状态码:{},url:{}", execute.code(), url); + throw new RuntimeException("get请求失败"); + } + PageData pageData = JSONObject.parseObject(execute.body().string(), PageData.class); + if (!"200".equals(pageData.getString("code"))) { + logger.error("post请求失败,返回值:{},url:{}", pageData.getString("msg"), url); + } + return pageData; + //发起请求并响应数据 + } + + /** + * 发送PUT类型请求 + * + * @param url + * @param jsonPayload + * @param token + * @return + * @throws IOException + */ + private static Response sendPutHttpRequest(String url, String jsonPayload, String token) throws IOException { + OkHttpClient client = new OkHttpClient(); + MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + RequestBody body = RequestBody.create(JSON, jsonPayload); + Request.Builder builder = new Request.Builder() + .url(url) + .put(body); + if (token != null && !token.isEmpty()) { + builder.addHeader("Authorization", "Bearer " + token); + } + Request request = builder.build(); + return client.newCall(request).execute(); } /** * 发送delete类型请求 + * * @param url * @param camIds * @param token * @return * @throws IOException */ - private static Response sendDeleteHttpRequest(String url, List camIds, String token) throws IOException { + private static PageData sendDeleteHttpRequest(String url,Long camIds, String token) throws IOException { OkHttpClient client = new OkHttpClient(); //将要删除的Id列表转换为逗号分隔的字符串 - String joinedIds = String.join(",", camIds); //构建完整的url - url = url + "/" + joinedIds; + url = url + "/" + camIds; Request.Builder builderBuilder = new Request.Builder() .url(url) @@ -370,7 +321,15 @@ public class PLSUtil { } Request request = builderBuilder.build(); - - return client.newCall(request).execute(); + Response execute = client.newCall(request).execute(); + if (execute.code() != 200) { + logger.error("post请求失败,返回状态码:{},url:{}", execute.code(), url); + throw new RuntimeException("get请求失败"); + } + PageData pageData = JSONObject.parseObject(execute.body().string(), PageData.class); + if (!"200".equals(pageData.getString("code"))) { + logger.error("post请求失败,返回值:{},url:{}", pageData.getString("msg"), url); + } + return pageData; } } diff --git a/src/main/java/com/zcloud/util/RegexPatterns.java b/src/main/java/com/zcloud/util/RegexPatterns.java index c70db49..ba5be80 100644 --- a/src/main/java/com/zcloud/util/RegexPatterns.java +++ b/src/main/java/com/zcloud/util/RegexPatterns.java @@ -23,6 +23,7 @@ public class RegexPatterns { * 验证码正则, 6位数字或字母 */ public static final String VERIFY_CODE_REGEX = "^[a-zA-Z\\d]{6}$"; + public static final String VERIFY_CARDNO_REGEX = "^[0-9]{4}$"; /** * 身份证号正则, 15位或者18位,最后一位可以为字母 */ diff --git a/src/main/java/com/zcloud/util/ReturnMap.java b/src/main/java/com/zcloud/util/ReturnMap.java new file mode 100644 index 0000000..ab82ecf --- /dev/null +++ b/src/main/java/com/zcloud/util/ReturnMap.java @@ -0,0 +1,146 @@ +package com.zcloud.util; + +/** + * 说明:TODO + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ + +import com.zcloud.util.examUntil.CodeMessageEnum; +import org.apache.http.HttpStatus; + +import java.util.HashMap; +import java.util.Map; + +/** + * @description: R类 + **/ +public class ReturnMap extends HashMap { + /** + * 序列ID + */ + private static final long serialVersionUID = 1L; + + /** + * R的无参构造, 初始化信息 + */ + public ReturnMap() { + put("code", 0); + put("msg", "success"); + put("result", "success"); + } + + /** + * error1: 返回默认error + * + * @return 返回默认error + */ + public static ReturnMap error() { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常, 请联系管理员"); + } + + /** + * error2 + * + * @param msg 错误信息 + * @return 返回自定义信息的error + */ + public static ReturnMap error(String msg) { + return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); + } + + public static ReturnMap error(CodeMessageEnum codeMessageEnum, String uri) { + return error(codeMessageEnum.getCode(), codeMessageEnum.getMessage(), uri); + } + + /** + * 原先R的code和msg被覆盖 + * + * @param code 错误码 + * @param msg 错误信息 + * @return 自定义的错误码和错误信息 + */ + public static ReturnMap error(int code, String msg) { + ReturnMap r = new ReturnMap(); + r.put("code", code); + r.put("result", "error"); + r.put("msg", msg); + return r; + } + + public static ReturnMap error(String code, String msg) { + ReturnMap r = new ReturnMap(); + r.put("code", code); + r.put("result", "error"); + r.put("msg", msg); + return r; + } + + public static ReturnMap error(String code, String msg, String uri) { + ReturnMap r = new ReturnMap(); + r.put("code", code); + r.put("result", "error"); + r.put("msg", msg); + r.put("uri", uri); + return r; + } + + /** + * ok1 + * 加入了msg + * + * @param msg + * @return + */ + public static ReturnMap ok(String msg) { + ReturnMap r = new ReturnMap(); + r.put("msg", msg); + return r; + } + + /** + * ok2: 加入了map + * + * @param map + * @return + */ + public static ReturnMap ok(Map map) { + ReturnMap r = new ReturnMap(); + r.putAll(map); + return r; + } + + /** + * ok3: 直接返回"0", "success" + * + * @return + */ + public static ReturnMap ok() { + return new ReturnMap(); + } + + /** + * 放入自定义的key和value, 然后返回 + * + * @param key + * @param value + * @return + */ + @Override + public ReturnMap put(String key, Object value) { + super.put(key, value); + return this; + } + + /** + * 得到这个对象的code + * + * @return + */ + public Integer getCode() { + return (Integer) this.get("code"); + } +} + + + diff --git a/src/main/java/com/zcloud/util/examUntil/BaseResultInterface.java b/src/main/java/com/zcloud/util/examUntil/BaseResultInterface.java new file mode 100644 index 0000000..5b28ac6 --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/BaseResultInterface.java @@ -0,0 +1,18 @@ +package com.zcloud.util.examUntil; + +/** + * 说明:TODO + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +/** + * @desc 对象返回到前端以及异常抛出的接口类 + */ +public interface BaseResultInterface { + + + String getCode(); + + + String getMessage(); +} diff --git a/src/main/java/com/zcloud/util/examUntil/BizException.java b/src/main/java/com/zcloud/util/examUntil/BizException.java new file mode 100644 index 0000000..795390b --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/BizException.java @@ -0,0 +1,84 @@ +package com.zcloud.util.examUntil; + +/** + * 说明:TODO + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ + +public class BizException extends RuntimeException implements BaseResultInterface { + + private static final long serialVersionUID = 1L; + + + /** + * 错误码 + */ + private String code; + + /** + * 错误信息 + */ + private String message; + + public BizException() { + super(); + } + + public BizException(CodeMessageEnum codeMessageEnum) { + super(codeMessageEnum.getCode(),new Throwable()); + this.code = codeMessageEnum.getCode(); + this.message = codeMessageEnum.getMessage(); + } + + public BizException(CodeMessageEnum codeMessageEnum, Throwable cause) { + super(codeMessageEnum.getCode(), cause); + this.code = codeMessageEnum.getCode(); + this.message = codeMessageEnum.getMessage(); + } + public BizException (CodeMessageEnum codeMessageEnum, Throwable cause,String details) { + super(codeMessageEnum.getCode(), cause); + this.code = codeMessageEnum.getCode(); + this.message = codeMessageEnum.getMessage() + details; + } + public BizException(CodeMessageEnum codeMessageEnum, String message, Throwable cause) { + super(codeMessageEnum.getCode(), cause); + this.code = codeMessageEnum.getCode(); + this.message = message; + } + + public BizException(String message) { + super(message); + this.message = message; + } + + public BizException(String code, String message) { + super(code); + this.code = code; + this.message = message; + } + + public BizException(String code, String message, Throwable cause) { + super(code, cause); + this.code = code; + this.message = message; + } + + @Override + public Throwable fillInStackTrace() { + return this; + } + + + @Override + public String getCode() { + return this.code; + } + + @Override + public String getMessage() { + return this.message; + } +} + + diff --git a/src/main/java/com/zcloud/util/examUntil/CodeMessageEnum.java b/src/main/java/com/zcloud/util/examUntil/CodeMessageEnum.java new file mode 100644 index 0000000..2ac51a5 --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/CodeMessageEnum.java @@ -0,0 +1,197 @@ +package com.zcloud.util.examUntil; + +/** + * 说明:TODO + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +public enum CodeMessageEnum implements BaseResultInterface { + + /** ********* 0000成功 *************** */ + SUCCESS("0000", "成功!"), + SUCCESS_LOGIN("0001", "用户登录成功"), + SUCCESS_LOGOUT("0002", "用户退出成功"), + + /* 默认失败 */ + COMMON_FAIL("999", "失败"), + + /** ********* 1xxx系统错误 *************** */ + SERVER_BUSY("1001", "服务器正忙,请稍后再试!"), + INTERNAL_SERVER_ERROR("1002", "服务器内部错误"), + NOT_FOUND("1003", "未找到该资源!"), + REQUEST_METHOD_ERROR("1004", "接口请求方法异常"), + SQL_SYNTAX_ERROR_EXCEPTION("1005", "SQL语法错误异常"), + NULL_POINT_ERROR_EXCEPTION("1006", "空指针异常信息"), + INNER_FRAME_EXCEPTION("1007", "内部框架执行异常"), + PARSE_TOKEN_EXCEPTION("1008", "解析token异常"), + TOKEN_NOT_EXIST("1009", "token不存在"), + TOKEN_SIGNATURE_EXCEPTION("1010", "token签名异常"), + TOKEN_EXPIRE("1011", "token过期,请重新登录"), + IMG_TYPE_NOT_CONFIG("1012", "请配置图片类型"), + NOT_CONFIG_FILE_DIR("1013", "请配置文件路径"), + UPLOAD_FILE_ERROR("1014", "文件上传失败"), + FILE_NOT_EXIST("1015", "文件不存在"), + FILE_HAS_DELETED("1016", "文件已被删除"), + DRIVER_CLASS_NOT_FOUND("1017", "数据库的连接驱动正在加载中..."), + TRY_CONNECT_DATABASE_ERROR("1018", "尝试连接数据库失败"), + CLOSE_CONNECT_DATABASE_ERROR("1019", "关闭数据库连接失败"), + DATABASE_NAME_NOT_EXIST("1020", "数据库名称不存在"), + CLOSE_DATASOURCE_ERROR("1021", "释放数据库资源异常"), + DRUID_DATASOURCE_ERROR("1022", "数据源创建中..."), + CREATE_DATABASE_ERROR("1023", "创建数据库失败"), + CREATE_TABLE_ERROR("1024", "创建表失败"), + UPDATE_TABLE_FIELD_ERROR("1025", "更新表字段失败"), + DELETE_TABLE_FIELD_ERROR("1026", "删除表字段失败"), + QUERY_ROLE_ERROR("1027", "查询角色失败"), + UPDATE_GROUP_ERROR("1028", "更新接口组失败"), + DELETE_GROUP_ERROR("1029", "删除接口组失败"), + SAVE_INTERFACE_ERROR("1030", "保存接口信息失败"), + + /** + * ******2xxx参数错误 ********************* + */ + BODY_NOT_MATCH("2001", "请求的数据格式不符"), + SIGNATURE_NOT_MATCH("2002", "请求的数字签名不匹配!"), + REQUEST_PATH_NOT_MATCH("2003", "当前请求路径没有权限!"), + NOT_UPLOAD_FILE_NAME_ERROR("2004", "上传的文件名不存在,请重新上传"), + NOT_SUPPORT_IMG_TYPE("2005", "图片格式不正确,请重新上传"), + NOT_SUPPORT_USERNAME_TYPE("2006", "excel用户名不能为空"), + NOT_SUPPORT_ROLE_TYPE("2007", "角色不存在"), + NOT_SUPPORT_DEPT_TYPE("2008", "部门不存在"), + SQL_INJECT_NOT_ALLOWED("2009", "参数中存在数据库关键字,请修改"), + TABLE_FIELD_NOT_EXIST("2010", "表字段不存在"), + FILE_PICTURE_IS_NULL("2011", "附件不存在"), + FILE_PICTURE_DELETE("2012", "删除附件失败"), + DIC_BIANMA_REPEAT("2013", "字典编码重复"), + + + + + + /** *********** 3xxx用户错误 ******************* */ + USER_NOT_LOGIN("3001", "用户未登录"), + USER_ACCOUNT_EXPIRED("3002", "账号已过期"), + USER_CREDENTIALS_ERROR("3003", "用户名或密码错误"), + USER_CREDENTIALS_EXPIRED("3004", "密码过期"), + USER_ACCOUNT_NOT_BIND_ENTERPRISE("3005", "当前账号未绑定企业"), + USER_ACCOUNT_LOCKED("3006", "账号被锁定"), + USER_ACCOUNT_NOT_EXIST("3007", "账号不存在"), + USER_ACCOUNT_ALREADY_EXIST("3008", "账号已存在"), + USER_ACCOUNT_USE_BY_OTHERS("3009", "账号下线"), + USER_NO_PERMISSION("3010", "当前账号没有此权限"), + USERNAME_NOT_BLANK("3011", "用户不能为空"), + USER_LOGIN_ERROR("3012", "用户登录失败"), + USER_LOGOUT_ERROR("3013", "用户退出失败"), + USER_ACCOUNT_USE_BY_OTHERS_ERROR("3014", "账号下线异常"), + USER_ACCESS_DENIED("3015", "权限认证失败"), + USERNAME_EXIST_ERROR("3016", "用户名重名"), + + ROLE_NAME_ALREADY_EXIST("3101", "角色已存在"), + + /** ********** 4xxx业务错误 *********************** */ + ENTERPRISE_NOT_EXIST("4001", "当前企业不存在"), + APP_KEY_EXIST("4002", "应用key已存在"), + APP_NOT_EXIST("4003", "应用不存在"), + APP_PAGE_NAME_EXIST("4004", "当前页面名称已存在"), + APP_PAGE_KEY_EXIST("4005", "当前页面key已存在"), + APP_PAGE_NOT_EXIST("4006", "当前页面不存在,或已删除"), + APP_PAGE_TYPE_ERROR("4007", "页面类型有误"), + APP_PAGE_HOME_IS_NOT_EXIST("4008", "请设置首页"), + CAN_NOT_DELETE_HOME_PAGE("4009", "请勿删除首页"), + DELETE_PAGE_ERROR("4010", "删除页面失败"), + CONFIG_CUSTOM_ERROR("4011", "配置自定义页面失败"), + APP_PAGE_PARENT_NOT_EXIST("4012", "当前页面的父级页面不存在,或已删除"), + DATASOURCE_NAME_EXIST("4013", "当前数据源名称已经存在,请修改后重试"), + DATASOURCE_NOT_EXIST("4014", "当前数据源不存在"), + DATASOURCE_HAS_DELETED("4015", "当前数据源已删除"), + MODEL_NOT_EXIST("4016", "当前模型不存在"), + MODEL_HAS_DELETED("4017", "当前模型已删除"), + MODEL_NAME_HAS_EXIST("4018", "当前模型名称已存在"), + DATASOURCE_NOT_CONFIG("4019", "数据源配置为空,请联系管理员"), + DATASOURCE_NOT_CONFIG_DIALECT("4020", "未配置数据源的类型"), + DATASOURCE_NOT_CONFIG_DRIVER_CLASS_NAME("4021", "未配置数据源的驱动"), + DEPT_USER_EXIST("4022", "部门下存在用户"), + NOT_CONFIG_PAGE_BUTTON_TYPE("4023", "未配置按钮雷星"), + MODEL_PAGE_RELATION_MODEL("4024", "已关联当前模型页面"), + MODEL_PAGE_NOT_EXIST("4025", "模型页面不存在或已被删除"), + MODEL_HAS_RELATION_MODEL_PAGE("4026", "当前模型已关联模型页面,不允许删除"), + FORM_NOT_EXIST("4027", "模型表单不存在"), + READ_FILE_ERROR("4028", "读取模型页面的模板文件失败"), + MODEL_PAGE_CONTENT_NULL("4029", "未配置模型页面的模板文件"), + NOT_CONFIG_QUERY_SQL("4030", "未配置查询语句"), + APP_PAGE_BUTTON_OPTION_VALUE_ERROR("4031", "未配置接口"), + DELETE_COLUMN_ERROR("4032", "删除当前失败"), + INSERT_DATA_ERROR("4033", "新建数据失败"), + EDIT_DATA_ERROR("4034", "编辑数据失败"), + DATASOURCE_HAS_MODELS("4035", "当前数据源存在模型,不允许删除"), + NOT_CONFIG_FORM_API("4036", "未配置模型表单页的接口信息"), + PLEASE_WRITE_AT_LEAST_DATA("4037", "请至少填写一行数据"), + AMIS_PAGE_ERROR("4038", "分页参数异常"), + QUERY_APP_PAGE_QUERY_FIELD_ERROR("4039", "查询搜素参数异常"), + REQUEST_PARAM_NOT_IN_APP_PAGE_QUERY_FIELD("4040", "请求参数不在查询数据表中"), + STYLE_LANGUAGE_ON_CSS("4041", "自定义css中的样式语言不能为空"), + APP_CONFIG_TYPE_NOT_EXIST("4042", "不支持当前应用设置的类型"), + APP_CONFIG_NOT_EXIST_OR_DELETED("4043", "当前设置不存在或已被删除"), + APP_HAS_CONFIG_ON_THIS_TYPE("4044", "当前应用设置的类型已存在,请更新"), + NOT_SUPPORT_COMPONENT_FRAME("4045", "不支持当前组件框架"), + NOT_SUPPORT_COMPONENT_TYPE("4046", "不支持当前组件类型"), + CURRENT_APP_KEY_EXIST("4047", "当前应用的组件key已存在"), + CREATE_CUSTOM_COMPONENT_ERROR("4048", "新增自定义组件失败"), + APP_CUSTOM_COMPONENT_NOT_EXIST("4049", "当前组件不存在或已被删除"), + UPDATE_CUSTOM_COMPONENT_ERROR("4050", "更新自定义组件失败"), + DELETED_CUSTOM_COMPONENT_ERROR("4051", "删除自定义组件失败"), + INSERT_COMPONENT_DEPENDENCE_ERROR("4052", "新增自定义组件依赖项失败"), + DELETE_COMPONENT_DEPENDENCE_ERROR("4053", "删除自定义组件依赖项失败"), + CURRENT_COMPONENT_DEPENDENCE_NOT_EXIST("4054", "当前自定义组件依赖项不存在或已被删除"), + CURRENT_APP_NAME_EXIST("4055", "当前应用的组件名称已存在"), + NOT_SUPPORT_DATASOURCE_FROM("4056", "不支持当前的数据库来源"), + JDBC_CONFIG_ERROR("4057", "平台内置的数据源配置有误"), + NOT_SUPPORT_MODEL_TYPE("4058", "不支持当前的页面模板"), + NOT_SUPPORT_CUSTOM_PAGE("4059", "暂不支持自定义页面"), + FORM_PAGE_ON_DEVELOPING("4060", "自定义页面的该功能正在开发中..."), + APP_PAGE_QUERY_FIELD_NOT_EXIST("4061", "当前查询条件不存在,或已被删除"), + APP_PAGE_BUTTON_NOT_EXIST("4062", "当前页面按钮不存在,或已被删除"), + TABLE_KEY_MORE_THEN_ONE("4063", "主键超过一个"), + TABLE_KEY_LESS_THEN_ONE("4064", "主键必须存在"), + TABLE_KEY_MUST_BE_INT("4065", "主键必须为整数类型"), + TABLE_FIELD_MUST_EXIST("4066", "必须存在表字段"), + CURRENT_MODEL_PAGE_HAS_CONVERSION_CUSTOM_PAGE("4067", "当前模型页面已转成自定义页面"), + NOT_SUPPORT_RELEASE_STATUS("4068", "发布版本状态有误"), + APP_FORM_BUTTON_NOT_EXIST("4067", "当前表单按钮不存在,或已被删除"), + DATASOURCE_KEY_EXIST_ERROR("4068","数据源key已存在") + ; + + CodeMessageEnum(String code, String message) { + this.code = code; + this.message = message; + } + + /** 返回到前端的code值 */ + private String code; + + /** 返回到前端的code对应的message值 */ + private String message; + + @Override + public String getCode() { + return this.code; + } + + @Override + public String getMessage() { + return this.message; + } + +// public static CodeVo getJsonObjectByCode(String code) { +// CodeVo codeVo = new CodeVo(); +// if (Tools.isEmpty(code)) { +// return codeVo; +// } +// for (CodeMessageEnum enumObj : CodeMessageEnum.values()) { +// if (enumObj.getCode().equals(code)) { +// return new CodeVo(code, enumObj.message); +// } +// } +// return codeVo; +// } +} diff --git a/src/main/java/com/zcloud/util/examUntil/ErrorOperation.java b/src/main/java/com/zcloud/util/examUntil/ErrorOperation.java new file mode 100644 index 0000000..6489d78 --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/ErrorOperation.java @@ -0,0 +1,14 @@ +package com.zcloud.util.examUntil; + +import java.lang.annotation.*; + +/** + * @Description: 异常拦截接口 + * @Author: dearLin + * @Date: 2023/3/8 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ErrorOperation { +} diff --git a/src/main/java/com/zcloud/util/examUntil/GlobalExceptionHandler.java b/src/main/java/com/zcloud/util/examUntil/GlobalExceptionHandler.java new file mode 100644 index 0000000..138f443 --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/GlobalExceptionHandler.java @@ -0,0 +1,94 @@ +package com.zcloud.util.examUntil; + +/** + * 说明:TODO + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ + + +import com.zcloud.util.ReturnMap; +import org.mybatis.spring.MyBatisSystemException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import javax.servlet.http.HttpServletRequest; + +import static com.zcloud.util.examUntil.CodeMessageEnum.SERVER_BUSY; + + +/** + * 全局异常 + */ +@RestControllerAdvice(annotations = {ErrorOperation.class}) +//@Slf4j +public class GlobalExceptionHandler { + + /** + * 业务异常类 + * + */ + @ExceptionHandler(value = BizException.class) + @ResponseBody + public ReturnMap bizExceptionHandler(HttpServletRequest req, BizException e) { + e.printStackTrace(); +// log.error("发生业务异常: {}, 请求接口: {}", e.getMessage(), req.getRequestURI()); + return ReturnMap.error("2001" ,e.getMessage(), req.getRequestURI()); + } + + + /** + * 空指针异常 + * + * @param e 异常信息 + * @param req 请求 + */ + @ExceptionHandler(value = NullPointerException.class) + @ResponseBody + public ReturnMap exceptionHandler(HttpServletRequest req, NullPointerException e) { + e.printStackTrace(); +// log.error("空指针异常信息: {}, 请求接口: {}", e, req.getRequestURI()); + return ReturnMap.error(SERVER_BUSY, req.getRequestURI()); + } + + /** + * 接口请求方法异常 + * + */ + @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) + @ResponseBody + public ReturnMap methodNotSupportedExceptionHandler(HttpServletRequest req, Exception e) { + e.printStackTrace(); +// log.error("请求方法异常信息: {},请求接口: {}", e, req.getRequestURI()); + return ReturnMap.error(SERVER_BUSY, req.getRequestURI()); + } + + /** + * SQL 语法错误异常 + */ + @ExceptionHandler(value = MyBatisSystemException.class) + @ResponseBody + public ReturnMap sqlSyntaxErrorExceptionHandler(HttpServletRequest req, Exception e) { + e.printStackTrace(); +// log.error("MyBatis系统异常信息: {},请求接口: {}", e, req.getRequestURI()); + return ReturnMap.error(SERVER_BUSY, req.getRequestURI()); + } + + + + /** + * 其他异常信息 + * + * @param req + * @param e + */ + @ExceptionHandler(value = Exception.class) + @ResponseBody + public ReturnMap exceptionHandler(HttpServletRequest req, Exception e) { + e.printStackTrace(); +// log.error("未知异常: {}, 请求接口: {}", e, req.getRequestURI()); + return ReturnMap.error(SERVER_BUSY, req.getRequestURI()); + } +} diff --git a/src/main/java/com/zcloud/util/examUntil/HttpContextUtils.java b/src/main/java/com/zcloud/util/examUntil/HttpContextUtils.java new file mode 100644 index 0000000..fcae61e --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/HttpContextUtils.java @@ -0,0 +1,54 @@ +package com.zcloud.util.examUntil; + +import org.apache.commons.lang.StringUtils; +import org.springframework.http.HttpHeaders; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * 说明:获取请求参数工具类 + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +public class HttpContextUtils { + public static HttpServletRequest getHttpServletRequest() { + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if(requestAttributes == null){ + return null; + } + + return ((ServletRequestAttributes) requestAttributes).getRequest(); + } + + public static Map getParameterMap(HttpServletRequest request) { + Enumeration parameters = request.getParameterNames(); + + Map params = new HashMap<>(); + while (parameters.hasMoreElements()) { + String parameter = parameters.nextElement(); + String value = request.getParameter(parameter); + if (StringUtils.isNotBlank(value)) { + params.put(parameter, value); + } + } + + return params; + } + + public static String getDomain(){ + HttpServletRequest request = getHttpServletRequest(); + StringBuffer url = request.getRequestURL(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); + } + + public static String getOrigin(){ + HttpServletRequest request = getHttpServletRequest(); + return request.getHeader(HttpHeaders.ORIGIN); + } +} diff --git a/src/main/java/com/zcloud/util/examUntil/RestTemplateConfig.java b/src/main/java/com/zcloud/util/examUntil/RestTemplateConfig.java new file mode 100644 index 0000000..972acbb --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/RestTemplateConfig.java @@ -0,0 +1,19 @@ +package com.zcloud.util.examUntil; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + //启动时需要实例化该类的一个实例 + @Autowired + private RestTemplateBuilder builder; + //使用RestTemplateBuilder来实例化RestTemplate对象,Spring已经默认注入了RestTemplateBuilder实例 + @Bean + public RestTemplate restTemplate(){ + return builder.build(); + } +} diff --git a/src/main/java/com/zcloud/util/examUntil/UserChangeRecordConfig.java b/src/main/java/com/zcloud/util/examUntil/UserChangeRecordConfig.java new file mode 100644 index 0000000..a4091bc --- /dev/null +++ b/src/main/java/com/zcloud/util/examUntil/UserChangeRecordConfig.java @@ -0,0 +1,99 @@ +package com.zcloud.util.examUntil; + +import com.alibaba.fastjson.JSON; +import com.zcloud.entity.PageData; +import com.zcloud.util.DateUtil; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.UuidUtil; + +import java.util.Date; +import java.util.List; + +/** + * @Description: TODO + * @Author: dearLin + * @Date: 2023/8/17/017 15:10 + * @Param: + * @Return: + */ +public class UserChangeRecordConfig { + + public static final String PC = "pc端"; + public static final String APP = "app端"; + public static final String APP_EDIT_BASE_INFO = "app端修改用户基础信息"; + public static final String APP_EDIT_CORP_BASE_INFO = "app端修改用户就职信息"; + public static final String PC_EDIT_BASE_INFO = "pc端修改用户基础信息"; + public static final String PC_IMPROT_USER_BASE_INFO = "pc端导入用户信息"; + public static final String PC_EDIT_CORP_BASE_INFO = "pc端修改用户就职信息"; + public static final String PC_DEL_CORP_BASE_INFO = "pc端解除用户服务信息"; + + + public static final String PC_IMPROT_USER_BASE_img = "img端导入用户信息"; + /** + * @Description: 修改信息 + * @Author: dearLin + * @Date: 2023/8/17/017 15:47 + * @Param: [java.util.List, com.zcloud.entity.PageData] [logUserList, user] + * @Return: java.util.List + */ + public static List editUserLogPc(List logUserList, PageData user) { + user.put("CREATTIME", DateUtil.date2Str(new Date())); + user.put("CHANGE_RECORD_ID", UuidUtil.get32UUID()); + user.put("CHANGE_DATA", JSON.toJSONString(user)); + user.put("CREATOR", Jurisdiction.getUSER_ID()); + user.put("CREATOR_NAME", Jurisdiction.getUsername()); + logUserList.add(user); + return logUserList; + } + + /** + * @Description: 导入用户信息 + * @Author: dearLin + * @Date: 2023/8/17/017 15:47 + * @Param: [java.util.List, com.zcloud.entity.PageData] [logUserList, user] + * @Return: java.util.List + */ + public static void importUserLogPc(PageData user) { + user.put("CREATTIME", DateUtil.date2Str(new Date())); + user.put("CHANGE_RECORD_ID", UuidUtil.get32UUID()); + user.put("CHANGE_DATA", JSON.toJSONString(user)); + user.put("CREATOR", Jurisdiction.getUSER_ID()); + user.put("CREATOR_NAME", Jurisdiction.getUsername()); + user.put("REAMKE", "人员被" + Jurisdiction.getUsername() + "导入,就职于:" + user.getString("CORPINFO_NAME") + "。部门:" + user.getString("DEPARTMENT_NAME")); + } + + /** + * @Description: 导入修改用户信息 + * @Author: dearLin + * @Date: 2023/8/17/017 15:47 + * @Param: [java.util.List, com.zcloud.entity.PageData] [logUserList, user] + * @Return: java.util.List + */ + public static void importEditUserLogPc(PageData user) { + user.put("CREATTIME", DateUtil.date2Str(new Date())); + user.put("CHANGE_RECORD_ID", UuidUtil.get32UUID()); + user.put("CHANGE_DATA", JSON.toJSONString(user)); + user.put("CREATOR", Jurisdiction.getUSER_ID()); + user.put("CREATOR_NAME", Jurisdiction.getUsername()); + user.put("REAMKE", "人员被" + Jurisdiction.getUsername() + "导入更新,就职于:" + user.getString("CORPINFO_NAME") + "。部门:" + user.getString("DEPARTMENT_NAME")); + + } + + /** + * @Description: 解除服务关系 + * @Author: dearLin + * @Date: 2023/8/17/017 15:47 + * @Param: [java.util.List, com.zcloud.entity.PageData] [logUserList, user] + * @Return: java.util.List + */ + public static List clearRelation(List logUserList, PageData user) { + user.put("CREATTIME", DateUtil.date2Str(new Date())); + user.put("CHANGE_RECORD_ID", UuidUtil.get32UUID()); + user.put("CHANGE_DATA", JSON.toJSONString(user)); + user.put("CREATOR", Jurisdiction.getUSER_ID()); + user.put("CREATOR_NAME", Jurisdiction.getUsername()); + user.put("REAMKE", "人员被" + Jurisdiction.getUsername() + "解除服务关系,曾就职于:" + user.getString("CORPINFO_NAME") + "。部门:" + user.getString("DEPARTMENT_NAME")); + logUserList.add(user); + return logUserList; + } +} diff --git a/src/main/resources/mybatis/datasource/risk/IdentificationPartsMapper.xml b/src/main/resources/mybatis/datasource/risk/IdentificationPartsMapper.xml index 065cf64..473befa 100644 --- a/src/main/resources/mybatis/datasource/risk/IdentificationPartsMapper.xml +++ b/src/main/resources/mybatis/datasource/risk/IdentificationPartsMapper.xml @@ -2,19 +2,22 @@ - - - BUS_IDENTIFICATIONPARTS - + + + BUS_IDENTIFICATIONPARTS + - - - SYS_DICTIONARIES - + + + SYS_DICTIONARIES + - - - f.PARTSNAME, + + + f + . + PARTSNAME + , f.CORPINFO_ID, f.CREATOR, f.CREATTIME, @@ -23,14 +26,17 @@ f.ISDELETE, f.LONGITUDE, f.LATITUDE, + f.ELECTRONIC_FENCE_ID, + f.ELECTRONIC_FENCE, f.IDENTIFICATIONPARTS_ID, f.RISK_UNIT_ID, f.ISMATCHING - + - - - PARTSNAME, + + + PARTSNAME + , CORPINFO_ID, CREATOR, CREATTIME, @@ -39,419 +45,434 @@ ISDELETE, LONGITUDE, LATITUDE, + ELECTRONIC_FENCE_ID, + ELECTRONIC_FENCE, IDENTIFICATIONPARTS_ID, RISK_UNIT_ID, ISMATCHING - + - - - #{PARTSNAME}, - #{CORPINFO_ID}, - #{CREATOR}, - #{CREATTIME}, - #{OPERATOR}, - #{OPERATTIME}, - #{ISDELETE}, - #{LONGITUDE}, - #{LATITUDE}, - #{IDENTIFICATIONPARTS_ID}, - #{RISK_UNIT_ID}, - #{ISMATCHING} - + + + #{PARTSNAME}, + #{CORPINFO_ID}, + #{CREATOR}, + #{CREATTIME}, + #{OPERATOR}, + #{OPERATTIME}, + #{ISDELETE}, + #{LONGITUDE}, + #{LATITUDE}, + #{ELECTRONIC_FENCE_ID}, + #{ELECTRONIC_FENCE}, + #{IDENTIFICATIONPARTS_ID}, + #{RISK_UNIT_ID}, + #{ISMATCHING} + - - - insert into - - ( - - ) values ( - - ) - + + + insert into + + ( + + ) values ( + + ) + - - - update - - set - ISDELETE = '1', - OPERATOR = #{OPERATOR}, - OPERATTIME = #{OPERATTIME} - where - IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} - + + + update + + set + ISDELETE = '1', + OPERATOR = #{OPERATOR}, + OPERATTIME = #{OPERATTIME} + where + IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} + - - - update - - set - PARTSNAME = #{PARTSNAME}, - OPERATOR = #{OPERATOR}, - OPERATTIME = #{OPERATTIME}, - LONGITUDE = #{LONGITUDE}, - LATITUDE = #{LATITUDE}, - RISK_UNIT_ID=#{RISK_UNIT_ID}, - IDENTIFICATIONPARTS_ID = IDENTIFICATIONPARTS_ID - where - IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} - - - - update - - set - ISMATCHING = #{ISMATCHING} - where - IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} - + + + update + + set + PARTSNAME = #{PARTSNAME}, + OPERATOR = #{OPERATOR}, + OPERATTIME = #{OPERATTIME}, + LONGITUDE = #{LONGITUDE}, + LATITUDE = #{LATITUDE}, + ELECTRONIC_FENCE_ID = #{ELECTRONIC_FENCE_ID}, + ELECTRONIC_FENCE = #{ELECTRONIC_FENCE}, + RISK_UNIT_ID=#{RISK_UNIT_ID}, + IDENTIFICATIONPARTS_ID = IDENTIFICATIONPARTS_ID + where + IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} + + + + update + + set + ISMATCHING = #{ISMATCHING} + where + IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} + - - - - + select + , + un.RISKUNITNAME, + d.NAME DEPTNAME, + d.DEPARTMENT_ID + from + + f + left join bus_riskunit un on un.RISKUNIT_ID = f.RISK_UNIT_ID + left join oa_department d on d.DEPARTMENT_ID = un.DEPARTMENT_ID + where + f.IDENTIFICATIONPARTS_ID = #{IDENTIFICATIONPARTS_ID} + + + + + and f.CORPINFO_ID = #{CORPINFO_ID} + + + AND + f.PARTSNAME = #{PARTSNAME} + + + AND + f.RISK_UNIT_ID = #{RISK_UNIT_ID} + + - - + select + , + un.RISKUNITNAME, + de.NAME as DEPT_NAME, + min(r.LEVELID) LEVELID + from + + f + left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID + left join bus_riskunit un on un.RISKUNIT_ID = f.RISK_UNIT_ID + left join OA_DEPARTMENT de on de.DEPARTMENT_ID = un.DEPARTMENT_ID + LEFT JOIN bus_riskpoint r ON r.IDENTIFICATION_ID = f.IDENTIFICATIONPARTS_ID + where f.ISDELETE = '0' + + and f.CORPINFO_ID = #{pd.CORPINFO_ID} + + + and f.RISK_UNIT_ID = #{pd.RISK_UNIT_ID} + + + + + + + + and + un.DEPARTMENT_ID in + + '${item}' + + + + + + + + + + + and + un.DEPARTMENT_ID in + + '${item}' + + + + and + ((un.DEPARTMENT_ID in ( + select + SUB_DEPARTMENT_ID + from + oa_supervision_department osd + where + osd.SUP_DEPARTMENT_ID = #{pd.DEPARTMENT_ID} + and osd.ISDELETE = '0' + and osd.CORPINFO_ID = #{pd.CORPINFO_ID} + )) or ( + un.DEPARTMENT_ID in + + '${item}' + + )) + + + + + and + un.DEPARTMENT_ID in + + '${item}' + + + + and + (un.DEPARTMENT_ID in ( + select + SUB_DEPARTMENT_ID + from + oa_supervision_department osd + where + osd.SUP_DEPARTMENT_ID = #{pd.DEPARTMENT_ID} + and osd.ISDELETE = '0' + and osd.CORPINFO_ID = #{pd.CORPINFO_ID}) + or un.DEPARTMENT_ID = #{pd.DEPARTMENT_ID}) + + + - - - - and - un.DEPARTMENT_ID in - - '${item}' - - - - and - un.DEPARTMENT_ID in - - '${item}' - - - - - - and un.DEPARTMENT_ID=#{pd.DEPARTMENT_ID} - - - - - - - - and r.LEVELID = #{pd.LEVELID} - - - and - ( - f.PARTSNAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') - or - f.RISK_UNIT_ID in ( select RISKUNIT_ID from BUS_RISKUNIT where RISKUNITNAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') ) - ) - - - and r.LEVELID IS NOT NULL - - GROUP BY f.IDENTIFICATIONPARTS_ID - order by f.OPERATTIME desc - + + + + and + un.DEPARTMENT_ID in + + '${item}' + + + + and + un.DEPARTMENT_ID in + + '${item}' + + + + + + and un.DEPARTMENT_ID=#{pd.DEPARTMENT_ID} + + + + + + + + and r.LEVELID = #{pd.LEVELID} + + + and + ( + f.PARTSNAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%') + or + f.RISK_UNIT_ID in ( select RISKUNIT_ID from BUS_RISKUNIT where RISKUNITNAME LIKE CONCAT(CONCAT('%', + #{pd.KEYWORDS}),'%') ) + ) + + + and r.LEVELID IS NOT NULL + + GROUP BY f.IDENTIFICATIONPARTS_ID + order by f.OPERATTIME desc + - - - + select + , + c.CORP_NAME, + un.RISKUNITNAME + from + + f + left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID + left join bus_riskunit un on un.RISKUNIT_ID = f.RISK_UNIT_ID + where f.ISDELETE = '0' + + and f.CORPINFO_ID = #{CORPINFO_ID} + + + and f.RISK_UNIT_ID = #{RISK_UNIT_ID} + + + and f.RISK_UNIT_ID = #{RISKUNIT_ID} + + + and f.PARTSNAME = #{CHECK_NAME} + + + and un.RISKUNITNAME = #{unRISKUNITNAME} + + order by f.OPERATTIME desc + + + - - + + - - + + - - - update - - set - ISDELETE = '1' - where - IDENTIFICATIONPARTS_ID in - - #{item} - - + + + update + + set + ISDELETE = '1' + where + IDENTIFICATIONPARTS_ID in + + #{item} + + - - + + - + diff --git a/src/main/resources/mybatis/datasource/system/UsersMapper.xml b/src/main/resources/mybatis/datasource/system/UsersMapper.xml index d1e3f4d..4255f56 100644 --- a/src/main/resources/mybatis/datasource/system/UsersMapper.xml +++ b/src/main/resources/mybatis/datasource/system/UsersMapper.xml @@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" BZ, SKIN, EMAIL, + SEX, NUMBER, PHONE, ROLE_IDS, @@ -84,6 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" IS_SAFETY, ISDELETE, ISHEAD, + CARDNO, + PLS_ID, ISLEADER @@ -103,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{SKIN}, #{EMAIL}, #{NUMBER}, + #{SEX}, #{PHONE}, #{ROLE_IDS}, #{DEPARTMENT_ID}, @@ -124,6 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{IS_SAFETY}, 0, #{ISHEAD}, + #{CARDNO}, + #{PLS_ID}, #{ISLEADER} @@ -141,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" f.SKIN, f.EMAIL, f.NUMBER, + f.SEX, f.PHONE, f.ROLE_IDS, f.DEPARTMENT_ID, @@ -160,6 +167,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" f.IS_SAFETY, f.CORPINFO_ID, f.ISHEAD, + f.CARDNO, + f.PLS_ID, f.ISLEADER @@ -266,9 +275,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ROLE_ID = #{ROLE_ID}, ROLE_IDS = #{ROLE_IDS}, BZ = #{BZ}, + SEX = #{SEX}, EMAIL = #{EMAIL}, NUMBER = #{NUMBER}, SORT = #{SORT}, + CARDNO = #{CARDNO}, PHONE = #{PHONE} ,LEARNERCATEGORY = #{LEARNERCATEGORY} @@ -913,7 +924,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + +