init:米东项目初始化
This commit is contained in:
@@ -0,0 +1,210 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.saye.hospitalgd.commons.JsonResult;
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.model.Users;
|
||||
import com.saye.hospitalgd.service.system.DepartService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class DepartController {
|
||||
|
||||
@Autowired
|
||||
private DepartService departService;
|
||||
|
||||
/**
|
||||
* @description 到部门页面
|
||||
* @author thuang
|
||||
* @created 2019年11月13日 下午5:26:53
|
||||
* @param modelMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toDepartManager")
|
||||
public String toDepartManager(ModelMap modelMap){
|
||||
|
||||
String parentId="10330001";
|
||||
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
|
||||
|
||||
modelMap.addAttribute("departInfo", resourceInfo);
|
||||
|
||||
return "system/departManager";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 新增部门
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:42:26
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addDepart")
|
||||
@ResponseBody
|
||||
public JsonResult addDepart(@RequestBody Map requestMap){
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
map.put("parentId", StringDUtil.changeNullToEmpty(requestMap.get("parentId")));
|
||||
map.put("departName", StringDUtil.changeNullToEmpty(requestMap.get("departName")));
|
||||
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
|
||||
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
map.put("modifyUserName", userName);
|
||||
map.put("modifyTrueName", userTrueName);
|
||||
|
||||
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
String createDate = DateDUtil.getCurrentDate();
|
||||
map.put("createTime", createTime);
|
||||
map.put("createDate", createDate);
|
||||
map.put("modifyTime",createTime);
|
||||
int result=0;
|
||||
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
result = departService.addDepart(map);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增部门:map:"+map.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "新增部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
|
||||
}
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("新增成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("新增失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 部门信息修改
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:45:34
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/modifyDepart")
|
||||
@ResponseBody
|
||||
public JsonResult modifyDepart(@RequestBody Map requestMap){
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
|
||||
map.put("departName", StringDUtil.changeNullToEmpty(requestMap.get("departName")));
|
||||
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
map.put("modifyUserName", userName);
|
||||
map.put("modifyTrueName", userTrueName);
|
||||
|
||||
String modifyTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
map.put("modifyTime",modifyTime);
|
||||
int result=0;
|
||||
try {
|
||||
result=departService.modifyDepart(map);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改部门:map:"+map.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "修改部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
|
||||
}
|
||||
JsonResult j=new JsonResult();
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 删除某部门及其下的所有子结点,并更新其父部门的是否叶子结点信息
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:48:04
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/removeDepart")
|
||||
@ResponseBody
|
||||
public JsonResult removeDepart(@RequestBody Map requestMap){
|
||||
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
|
||||
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
map.put("modifyUserName", userName);
|
||||
map.put("modifyTrueName", userTrueName);
|
||||
|
||||
String modifyTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
map.put("modifyTime",modifyTime);
|
||||
int result=0;
|
||||
try {
|
||||
result=departService.removeDepart(map);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除部门:map:"+map.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "删除部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
|
||||
}
|
||||
|
||||
JsonResult j=new JsonResult();
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("删除成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("删除失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据上级部门查询部门
|
||||
* @author thuang
|
||||
* @date 2021/7/8 10:10
|
||||
* @version 1.0
|
||||
*/
|
||||
@RequestMapping("/findDepartByParentId")
|
||||
@ResponseBody
|
||||
public HashMap<Object,Object> findDepartByParentId(@RequestBody HashMap<Object,Object> map){
|
||||
HashMap<Object,Object> responseMap=new HashMap<>();
|
||||
String errCode="0";
|
||||
String errMsg="";
|
||||
|
||||
try {
|
||||
String parentId=StringDUtil.changeNullToEmpty(map.get("parentId"));
|
||||
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
|
||||
|
||||
responseMap.put("resourceInfo",resourceInfo);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
responseMap.put("errCode",errCode);
|
||||
responseMap.put("errMsg",errMsg);
|
||||
|
||||
return responseMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.saye.hospitalgd.commons.JsonResult;
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.commons.page.PageUtil;
|
||||
import com.saye.hospitalgd.commons.page.TemplatePage;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.commons.uuid.UUIDGenerator;
|
||||
import com.saye.hospitalgd.model.Dicinfo;
|
||||
import com.saye.hospitalgd.model.ResourceInfo;
|
||||
import com.saye.hospitalgd.model.Users;
|
||||
import com.saye.hospitalgd.service.system.DicinfoService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class DicinfoController {
|
||||
|
||||
@Autowired
|
||||
private DicinfoService dicinfoService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 跳转到字典管理页面
|
||||
* @author qfqi
|
||||
* @created 2019年12月23日 下午1:47:21
|
||||
* @param modelMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toDicinfoManager")
|
||||
public String toDepartManager(ModelMap modelMap){
|
||||
|
||||
String parentCode="0";
|
||||
List<Dicinfo> list= dicinfoService.findDicinfoTreeNodeList(parentCode);
|
||||
ResourceInfo resource = new ResourceInfo();
|
||||
resource.setTitle("字典");
|
||||
resource.setId("0");
|
||||
for (Dicinfo dicinfo : list) {
|
||||
//生成主节点
|
||||
ResourceInfo resourceInfo = new ResourceInfo();
|
||||
resourceInfo.setTitle(dicinfo.getDicname());
|
||||
resourceInfo.setId(dicinfo.getDiccode());
|
||||
resourceInfo.setSysid(dicinfo.getParentCode());
|
||||
resource.getChildren().add(resourceInfo);
|
||||
}
|
||||
String jsonString = JSONObject.toJSONString(resource);
|
||||
modelMap.addAttribute("departInfo", jsonString);
|
||||
return "system/dicinfoManage";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 新增字典
|
||||
* @author qfqi
|
||||
* @created 2019年12月19日 下午5:20:28
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dicinfoManager/addDicinfoManager")
|
||||
@ResponseBody
|
||||
public JsonResult addDicinfoManager(String dicname,String diccode,String dicvalue,String parentCode,String sortNo){
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
JsonResult j=new JsonResult();
|
||||
map.put("dicname", dicname);
|
||||
map.put("dicvalue", dicvalue);
|
||||
map.put("parentCode", parentCode);
|
||||
map.put("sortNo", sortNo);
|
||||
|
||||
|
||||
if(diccode!=null && !"".equals(diccode)){
|
||||
//代表新增的是字典树父级 需要验证字点编码是否重复
|
||||
map.put("diccode", diccode);
|
||||
List<Dicinfo> list= dicinfoService.findDicinfoBydiccode(diccode);
|
||||
if(list.size()>0){
|
||||
//代表在相同的父类下有相同的value值,
|
||||
j.setState(false);
|
||||
j.setMessage("字典编码重复,请重新输入!");
|
||||
return j;
|
||||
}
|
||||
}else{
|
||||
//代表新增的是子类,需要查询该父类下是否存在相同的val值
|
||||
map.put("diccode", UUIDGenerator.getUUID());
|
||||
List<Dicinfo> list= dicinfoService.findDicinfoTreeByCode(map);
|
||||
if(list.size()>0){
|
||||
//代表在相同的父类下有相同的value值,
|
||||
j.setState(false);
|
||||
j.setMessage("字典值重复,请重新输入!");
|
||||
return j;
|
||||
}
|
||||
}
|
||||
int result=0;
|
||||
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
map.put("create_time",DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
|
||||
|
||||
result = dicinfoService.addDicinfo(map);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增字典:map:"+map.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "新增字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("新增成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("新增失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @description 修改字典名称
|
||||
* @author qfqi
|
||||
* @created 2019年12月19日 下午5:50:45
|
||||
* @param requestMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dicinfoManager/updateDicinfoManager")
|
||||
@ResponseBody
|
||||
public JsonResult updateDicinfoManager(String diccode,String dicname,String parentCode,String dicvalue,String sortNo){
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
JsonResult j=new JsonResult();
|
||||
map.put("dicname", dicname);
|
||||
map.put("diccode", diccode);
|
||||
map.put("modifyTime", DateDUtil.getTheCurrentTime());
|
||||
map.put("dicvalue", dicvalue);
|
||||
map.put("parentCode", parentCode);
|
||||
map.put("sortNo", sortNo);
|
||||
|
||||
|
||||
int result=0;
|
||||
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
result = dicinfoService.modifyDicinfo(map);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改字典:map:"+map.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "修改字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 删除字典
|
||||
* @author qfqi
|
||||
* @created 2019年12月19日 下午5:50:25
|
||||
* @param requestMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dicinfoManager/deleteDicinfoManager")
|
||||
@ResponseBody
|
||||
public JsonResult deleteDicinfoManager(@RequestBody Map requestMap){
|
||||
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
|
||||
int result=0;
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
result = dicinfoService.deleteDicinfo(diccode);
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除字典:diccode:"+diccode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "删除字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("删除成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("删除失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
//根据父id分页查询字典
|
||||
@RequestMapping("/dicinfoManager/selectDicinfoManager")
|
||||
@ResponseBody
|
||||
public TemplatePage selectDicinfoManager(String parentCode,Integer page,Integer limit){
|
||||
PageHelper.startPage(page, limit);
|
||||
PageInfo<Dicinfo> appsPageInfo = new PageInfo<Dicinfo>(dicinfoService.findDicinfoTreeNodeList(parentCode));
|
||||
return PageUtil.loadJsonPage(appsPageInfo);
|
||||
}
|
||||
|
||||
//根据上级编码查询所有数据
|
||||
@RequestMapping("/dicinfoManager/selectDicinfoListByCode")
|
||||
@ResponseBody
|
||||
public List<HashMap<Object, Object>> selectDicinfoListByCode(String parent_code){
|
||||
|
||||
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCode(parent_code);
|
||||
return list;
|
||||
}
|
||||
|
||||
//根据条件分页查询字典
|
||||
@RequestMapping("/dicinfoManager/selectDicinfoPageListByCondition")
|
||||
@ResponseBody
|
||||
public TemplatePage selectDicinfoPageListByCondition(String parentCode,String dicname,Integer page,Integer limit){
|
||||
|
||||
HashMap<String, String> map = new HashMap<String,String>();
|
||||
map.put("parentCode", parentCode);
|
||||
map.put("dicname", dicname);
|
||||
PageHelper.startPage(page, limit);
|
||||
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object, Object>>(dicinfoService.selectDicinfoListByCondition(map));
|
||||
return PageUtil.loadJsonPage(appsPageInfo);
|
||||
}
|
||||
|
||||
//根据条件查询所有字典
|
||||
@RequestMapping("/dicinfoManager/selectDicinfoListByCondition")
|
||||
@ResponseBody
|
||||
public List<HashMap<Object, Object>> selectDicinfoListByCondition(@RequestBody HashMap<String, String> map){
|
||||
|
||||
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCondition(map);
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @description 获取最大字典顺序
|
||||
* @author qfqi
|
||||
* @created 2021年1月13日 下午2:56:03
|
||||
* @param requestMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dicinfoManager/getMaxDicValue")
|
||||
@ResponseBody
|
||||
public JsonResult getMaxDicValue(@RequestBody Map requestMap){
|
||||
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
|
||||
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
HashMap<String, String> map = new HashMap<String,String>();
|
||||
map.put("parentCode", diccode);
|
||||
HashMap<Object, Object> result = dicinfoService.getMaxDicValue(map);
|
||||
j.setState(true);
|
||||
j.setData(result.get("MAXDICVALUE"));
|
||||
j.setMessage("成功!");
|
||||
} catch (Exception e) {
|
||||
j.setState(false);
|
||||
j.setMessage("查询字典最大值失败!");
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "查询字典最大值失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.model.Logger;
|
||||
import com.saye.hospitalgd.service.system.LoggerService;
|
||||
|
||||
@Controller
|
||||
public class LoggerController {
|
||||
|
||||
@Autowired
|
||||
private LoggerService loggerService;
|
||||
|
||||
/**
|
||||
* @description 到日志管理页面
|
||||
* @author thuang
|
||||
* @created 2019年11月13日 下午5:27:29
|
||||
* @param modelMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toLogger")
|
||||
public String toLogger(ModelMap modelMap){
|
||||
|
||||
return "system/logger";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 查询所有日志数据
|
||||
* @author thuang
|
||||
* @created 2019年11月13日 下午5:41:56
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/findLogger")
|
||||
@ResponseBody
|
||||
public HashMap<String, Object> findLogger(String loggerType,String startTime,String endTime,Integer page,Integer limit ){
|
||||
HashMap<Object, Object> map=new HashMap<Object, Object>();
|
||||
map.put("loggerType", loggerType);
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
|
||||
HashMap<String, Object> responseMap = new HashMap<String,Object>();
|
||||
try {
|
||||
PageHelper.startPage(page, limit);
|
||||
// PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(loggerService.hospitalgd(map));
|
||||
|
||||
PageInfo<Logger> appsPageInfo = new PageInfo<Logger>(loggerService.findLogger(map));
|
||||
|
||||
responseMap.put("code", 0);
|
||||
responseMap.put("msg", "");
|
||||
responseMap.put("count", appsPageInfo.getTotal());
|
||||
responseMap.put("data", appsPageInfo.getList());
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "查询所有日志数据失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
|
||||
}
|
||||
|
||||
return responseMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.model.ResourceInfo;
|
||||
import com.saye.hospitalgd.model.Users;
|
||||
import com.saye.hospitalgd.service.UnilateralService;
|
||||
import com.saye.hospitalgd.service.system.MenuService;
|
||||
import com.saye.hospitalgd.service.system.ServiceParamsService;
|
||||
import com.saye.hospitalgd.service.system.UsersService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
||||
import org.apache.shiro.authc.ExpiredCredentialsException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private ServiceParamsService serviceParamsService;
|
||||
|
||||
|
||||
/**
|
||||
* @description 去登录页面
|
||||
* @author dqzhang
|
||||
* @created 2019年11月13日 下午4:22:48
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toLogin")
|
||||
public String toLogin(ModelMap map) {
|
||||
|
||||
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
|
||||
map.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
|
||||
return "login";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 登录
|
||||
* @author dqzhang
|
||||
* @created 2019年11月13日 下午5:03:11
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/login")
|
||||
@ResponseBody
|
||||
public HashMap<Object,Object> signin(@RequestBody Map map) {
|
||||
|
||||
String key = StringDUtil.removeSpaces(map.get("key"));
|
||||
String username = StringDUtil.removeSpaces(map.get("username"));
|
||||
String password = StringDUtil.removeSpaces(map.get("password"));
|
||||
String vercode = StringDUtil.removeSpaces(map.get("vercode"));
|
||||
String initVector = StringDUtil.removeSpaces(map.get("initVector"));
|
||||
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
|
||||
try {
|
||||
String code = (String) subject.getSession().getAttribute("verify_code");
|
||||
if(!code.equalsIgnoreCase(vercode)) {
|
||||
errCode = "CodeError";
|
||||
errMsg = "验证码不正确!";
|
||||
}
|
||||
if("0".equals(errCode)) {
|
||||
UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password);
|
||||
subject.login(usernamePasswordToken);
|
||||
LogUtil.info(getClass(), "用户:"+username+"登录系统");
|
||||
}
|
||||
} catch (ExcessiveAttemptsException e) {
|
||||
errCode = "ExcessiveAttempts";
|
||||
errMsg = "账户已锁定,请稍后再试!";
|
||||
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
|
||||
} catch (ExpiredCredentialsException e) {
|
||||
errCode = "ExpiredCredentials";
|
||||
errMsg = "账号已过期!";
|
||||
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
|
||||
} catch (AuthenticationException e) {
|
||||
errCode = "Authentication";
|
||||
errMsg = "账号或密码错误!";
|
||||
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
|
||||
} catch (Exception e) {
|
||||
errCode = e.getLocalizedMessage();
|
||||
errMsg = "未知异常!";
|
||||
LogUtil.error(this.getClass(), "登录失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
|
||||
resultMap.put("errCode", errCode);
|
||||
resultMap.put("errMsg", errMsg);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 首页
|
||||
* @author dqzhang
|
||||
* @created 2019年11月13日 下午5:10:21
|
||||
* @param modelMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/index")
|
||||
public String index(ModelMap modelMap) {
|
||||
|
||||
HashMap<Object,Object> map = new HashMap<Object,Object>();
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
Users user = (Users) subject.getPrincipal();
|
||||
String user_id = user.getUserId();
|
||||
map.put("user_id", user_id);
|
||||
ResourceInfo resourceInfo=null;
|
||||
modelMap.addAttribute("expired",false);
|
||||
try {
|
||||
//上次密码修改时间
|
||||
String modifyTime = user.getModifyTime();
|
||||
String modifyDate = modifyTime.substring(0, 10);
|
||||
String today = DateDUtil.getCurrentDate("yyyy-MM-dd");
|
||||
long differDay = DateDUtil.getDaysOfTowDiffDate(modifyDate, today);
|
||||
if(differDay>90) { //密码90天过期
|
||||
modelMap.addAttribute("expired",true);
|
||||
}
|
||||
resourceInfo = this.menuService.getMenuByRole(map);
|
||||
String userTrueName = user.getTrueName();
|
||||
String userName = user.getUserName();
|
||||
modelMap.addAttribute("userTrueName",userTrueName);
|
||||
modelMap.addAttribute("userName",userName);
|
||||
modelMap.addAttribute("userId",user_id);
|
||||
|
||||
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
|
||||
modelMap.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "跳转首页失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
modelMap.addAttribute("resourceInfo", resourceInfo.getChildren());
|
||||
|
||||
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 查询菜单
|
||||
* @author thuang
|
||||
* @created 2019年11月6日 下午3:55:20
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/menu")
|
||||
@ResponseBody
|
||||
public ResourceInfo findMenu(){
|
||||
HashMap<Object,Object> map = new HashMap<Object,Object>();
|
||||
map.put("user_id", "admin");
|
||||
map.put("firstNode", "0");
|
||||
ResourceInfo resourceInfo=null;
|
||||
try {
|
||||
resourceInfo = this.menuService.getMenuByRole(map);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "查询菜单失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
return resourceInfo;
|
||||
}
|
||||
|
||||
@RequestMapping("/logout")
|
||||
public void logout(HttpServletResponse response) throws IOException {
|
||||
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
if(subject.isAuthenticated()) {
|
||||
subject.logout();
|
||||
}
|
||||
response.sendRedirect("/toLogin");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取验证码
|
||||
* @author dqzhang
|
||||
* @created 2019年11月27日 下午3:15:32
|
||||
* @param reuqest
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/getCode")
|
||||
public void verify(HttpServletRequest reuqest,HttpServletResponse response) throws Exception {
|
||||
|
||||
String name = reuqest.getParameter("name");
|
||||
|
||||
response.setContentType("image/jpeg");
|
||||
response.setHeader("Pragma", "No-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0L);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
Session session = subject.getSession();
|
||||
|
||||
try {
|
||||
int width = 73;
|
||||
int height = 27;
|
||||
BufferedImage image = new BufferedImage(width, height, 1);
|
||||
|
||||
Graphics g = image.getGraphics();
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
g.setColor(getRandColor(200, 250));
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
g.setFont(new Font("Times New Roman", 0, 24));
|
||||
|
||||
g.setColor(getRandColor(160, 200));
|
||||
for (int i = 0; i < 155; i++) {
|
||||
int x = random.nextInt(width);
|
||||
int y = random.nextInt(height);
|
||||
int xl = random.nextInt(12);
|
||||
int yl = random.nextInt(12);
|
||||
g.drawLine(x, y, x + xl, y + yl);
|
||||
}
|
||||
|
||||
String sRand = "";
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String rand = randomInt(1).toUpperCase();
|
||||
sRand = sRand + rand;
|
||||
|
||||
g.setColor(new Color(20 + random.nextInt(110), 20 + random
|
||||
.nextInt(110), 20 + random.nextInt(110)));
|
||||
g.drawString(rand, 13 * i + 6, 24);
|
||||
}
|
||||
if (StringDUtil.changeNullToEmpty(name).equals(""))
|
||||
session.setAttribute("verify_code", sRand);
|
||||
else {
|
||||
session.setAttribute(name, sRand);
|
||||
}
|
||||
|
||||
g.dispose();
|
||||
ServletOutputStream responseOutputStream = response.getOutputStream();
|
||||
|
||||
ImageIO.write(image, "JPEG", responseOutputStream);
|
||||
|
||||
responseOutputStream.flush();
|
||||
responseOutputStream.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Color getRandColor(int fc, int bc) {
|
||||
Random random = new Random();
|
||||
if (fc > 255)
|
||||
fc = 255;
|
||||
if (bc > 255)
|
||||
bc = 255;
|
||||
int r = fc + random.nextInt(bc - fc);
|
||||
int g = fc + random.nextInt(bc - fc);
|
||||
int b = fc + random.nextInt(bc - fc);
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
|
||||
public static final String randomInt(int length) {
|
||||
if (length < 1) {
|
||||
return null;
|
||||
}
|
||||
Random randGen = new Random();
|
||||
// char[] numbersAndLetters = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
|
||||
char[] numbersAndLetters = "0123456789".toCharArray();
|
||||
char[] randBuffer = new char[length];
|
||||
for (int i = 0; i < randBuffer.length; i++) {
|
||||
// randBuffer[i] = numbersAndLetters[randGen.nextInt(36)];
|
||||
randBuffer[i] = numbersAndLetters[randGen.nextInt(10)];
|
||||
}
|
||||
return new String(randBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/toNoAuthority")
|
||||
public String toNoAuthority(ModelMap modelMap) {
|
||||
|
||||
return "/noAuthority";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.saye.hospitalgd.commons.JsonResult;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.model.MenuRole;
|
||||
import com.saye.hospitalgd.model.ResourceInfo;
|
||||
import com.saye.hospitalgd.model.Role;
|
||||
import com.saye.hospitalgd.model.Users;
|
||||
import com.saye.hospitalgd.service.system.DepartService;
|
||||
import com.saye.hospitalgd.service.system.MenuService;
|
||||
import com.saye.hospitalgd.service.system.RoleService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class RoleController {
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
||||
@Autowired
|
||||
private DepartService departService;
|
||||
/**
|
||||
* @description 到角色管理页面
|
||||
* @author thuang
|
||||
* @created 2019年11月11日 上午10:50:40
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toRoleManager")
|
||||
public String toRoleManager(ModelMap modelMap){
|
||||
|
||||
HashMap<Object,Object> responseMap = new HashMap<Object,Object>();
|
||||
responseMap.put("firstNode", "0");
|
||||
ResourceInfo resourceInfo=null;
|
||||
try {
|
||||
resourceInfo = this.menuService.getMenuByRole(responseMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
modelMap.addAttribute("resourceInfo", resourceInfo);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("parent_id","10330701");
|
||||
List<HashMap<Object, Object>> departList = this.departService.findDepartByParentId(map);
|
||||
for (HashMap<Object, Object> departMap : departList) {
|
||||
departMap.put("id",departMap.get("DEPART_ID"));
|
||||
departMap.put("title",departMap.get("DEPART_NAME"));
|
||||
}
|
||||
modelMap.put("departList",departList);
|
||||
return "system/roleManager";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 查询列表
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:07:41
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/searchRole")
|
||||
@ResponseBody
|
||||
public HashMap<String, Object> searchRole(String roleName,String date,Integer page, Integer limit){
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
map.put("roleName", roleName);
|
||||
map.put("date", date);
|
||||
PageHelper.startPage(page, limit);
|
||||
PageInfo<Role> appsPageInfo = new PageInfo<Role>(roleService.searchRole(map));
|
||||
HashMap<String, Object> map1 = new HashMap<String,Object>();
|
||||
map1.put("code", 0);
|
||||
map1.put("msg", "你好");
|
||||
map1.put("count", appsPageInfo.getTotal());
|
||||
map1.put("data", appsPageInfo.getList());
|
||||
|
||||
return map1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 添加角色
|
||||
* @author thuang
|
||||
* @created 2019年11月11日 下午3:58:24
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/insertRoles")
|
||||
@ResponseBody
|
||||
public HashMap<Object, Object> insertRoles(String roleName,String menuId){
|
||||
|
||||
HashMap<String, String> map=new HashMap<String, String>();
|
||||
HashMap<Object, Object> response=new HashMap<Object, Object>();
|
||||
|
||||
String errCode="0";
|
||||
String errMsg="";
|
||||
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
map.put("roleName",roleName);
|
||||
map.put("menuId",menuId);
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
map.put("userName", userName);
|
||||
map.put("userTrueName", userTrueName);
|
||||
|
||||
//新增角色
|
||||
try {
|
||||
String status = roleService.addRole(map);
|
||||
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"添加角色:map:"+map.toString());
|
||||
if ("true".equals(status)) {
|
||||
|
||||
}else {
|
||||
errCode="998";
|
||||
errMsg=status;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errCode="999";
|
||||
errMsg=e.getMessage();
|
||||
LogUtil.error(this.getClass(), "新增角色失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
|
||||
response.put("errCode", errCode);
|
||||
response.put("errMsg", errMsg);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 删除用户角色
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:07:54
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/deleteRole")
|
||||
@ResponseBody
|
||||
public JsonResult deleteRole(String roleId){
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
int result=roleService.deleteRole(roleId);
|
||||
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"删除角色:roleId:"+roleId);
|
||||
JsonResult j=new JsonResult();
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("删除成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("删除失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据角色id获取角色权限菜单id
|
||||
* @author thuang
|
||||
* @created 2019年11月12日 上午9:51:08
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getSelectMenuId")
|
||||
@ResponseBody
|
||||
public List<String> getSelectMenuId(String roleId){
|
||||
|
||||
HashMap<Object, Object> map=new HashMap<Object, Object>();
|
||||
map.put("roleId",roleId);
|
||||
List<MenuRole> menuIdByRoleId = menuService.getMenuIdByRoleId(map);
|
||||
|
||||
List<String> menuIdList=new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < menuIdByRoleId.size(); i++) {
|
||||
MenuRole menuRole = menuIdByRoleId.get(i);
|
||||
menuIdList.add(menuRole.getMenuId());
|
||||
}
|
||||
|
||||
return menuIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 修改用户角色权限信息
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:08:05
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/modifyRoleResource")
|
||||
@ResponseBody
|
||||
public JsonResult modifyRoleResource(String roleId,String roleName,String menuId,String departId,String pointDelete) {
|
||||
|
||||
HashMap<String,String> map=new HashMap<String,String>();
|
||||
map.put("roleName", roleName);
|
||||
map.put("roleId", roleId);
|
||||
map.put("menuId", menuId);
|
||||
map.put("departId", departId);
|
||||
map.put("pointDelete", pointDelete);
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
int result=roleService.modifyRoleResource(map);
|
||||
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"修改用户角色权限信息:map:"+map.toString());
|
||||
JsonResult j=new JsonResult();
|
||||
if(result>0){
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,714 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.saye.hospitalgd.commons.JsonResult;
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.model.*;
|
||||
import com.saye.hospitalgd.service.system.DepartService;
|
||||
import com.saye.hospitalgd.service.system.RoleService;
|
||||
import com.saye.hospitalgd.service.system.UsersService;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.crypto.hash.Md5Hash;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Controller
|
||||
public class UsersController {
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private DepartService departService;
|
||||
|
||||
|
||||
/**
|
||||
* @description 到用户管理页面
|
||||
* @author thuang
|
||||
* @created 2019年11月15日 上午10:12:12
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/toUserManager")
|
||||
public String toUserManager(ModelMap modelMap){
|
||||
|
||||
//查询所有部门
|
||||
String parentId="10330001";
|
||||
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
|
||||
modelMap.addAttribute("departInfo", resourceInfo);
|
||||
|
||||
//查询所有角色
|
||||
List<Role> roleList = this.roleService.findRoleList();
|
||||
modelMap.addAttribute("roleList",roleList);
|
||||
|
||||
|
||||
//查询所有一级地市
|
||||
List<HashMap<Object, Object>> departList = departService.findDepartByParentId(new HashMap<String,Object>(){{put("parent_id","10330701");}});
|
||||
modelMap.addAttribute("departList",departList);
|
||||
return "system/userManager";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description user表分页查询
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:06:12
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/selectUser")
|
||||
@ResponseBody
|
||||
public HashMap<String, Object> searchUsers(String departId,String trueName,String isactive,String roleId,String dtRoleId,Integer page, Integer limit) {
|
||||
HashMap<Object,Object> map=new HashMap<Object,Object>();
|
||||
HashMap<String, Object> resultMap = new HashMap<String,Object>();
|
||||
try{
|
||||
|
||||
String[] departIds=null;
|
||||
if (departId !=null && !"".equals(departId)) {
|
||||
departIds = departId.split(",");
|
||||
}
|
||||
|
||||
map.put("departId", departIds);
|
||||
map.put("trueName", trueName);
|
||||
map.put("isactive", isactive);
|
||||
map.put("roleId", roleId);
|
||||
map.put("dtRoleId", dtRoleId);
|
||||
PageHelper.startPage(page, limit);
|
||||
|
||||
PageInfo<Users> appsPageInfo = new PageInfo<Users>(usersService.searchUsers(map));
|
||||
|
||||
resultMap.put("code", 0);
|
||||
resultMap.put("msg", "OK");
|
||||
resultMap.put("count", appsPageInfo.getTotal());
|
||||
resultMap.put("data", appsPageInfo.getList());
|
||||
}catch (Exception e){
|
||||
resultMap.put("code", 999);
|
||||
resultMap.put("msg", e.getMessage());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 新增用户
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:05:10
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/insertUsers")
|
||||
@ResponseBody
|
||||
public JsonResult insertUsers(@RequestBody HashMap<Object, Object> requestMap){
|
||||
|
||||
int i;
|
||||
JsonResult j=new JsonResult();
|
||||
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
|
||||
requestMap.put("userName", userName);
|
||||
requestMap.put("userTrueName", userTrueName);
|
||||
|
||||
i = usersService.insertUser(requestMap);
|
||||
if(i>0){
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增用户的方法:requestMap:"+requestMap.toString());
|
||||
j.setState(true);
|
||||
j.setMessage("新增成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("新增失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
j.setState(false);
|
||||
j.setMessage(e.getMessage());
|
||||
LogUtil.error(this.getClass(), "新增用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 修改用户
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:04:28
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/modifyUsers")
|
||||
@ResponseBody
|
||||
public JsonResult modifyUsers(@RequestBody HashMap<Object, Object> requestMap){
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
|
||||
requestMap.put("userName", userName);
|
||||
requestMap.put("userTrueName", userTrueName);
|
||||
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
String createDate = DateDUtil.getCurrentDate();
|
||||
/*requestMap.put("modifyTime", createTime);
|
||||
requestMap.put("createTime", createTime);*/
|
||||
requestMap.put("createDate", createDate);
|
||||
int result=usersService.modifyUsers(requestMap);
|
||||
|
||||
if(result>0){
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改用户的方法:requestMap:"+requestMap.toString());
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
j.setState(false);
|
||||
j.setMessage(e.getMessage());
|
||||
LogUtil.error(this.getClass(), "修改用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 密码重置
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:06:37
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/reSetPassword")
|
||||
@ResponseBody
|
||||
public JsonResult reSetPassword(@RequestBody HashMap<Object, Object> requestMap){
|
||||
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
|
||||
requestMap.put("modifyUserName", userName);
|
||||
requestMap.put("modifyTrueName", userTrueName);
|
||||
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
String createDate = DateDUtil.getCurrentDate();
|
||||
requestMap.put("createTime", createTime);
|
||||
requestMap.put("createDate", createDate);
|
||||
//产生6位长度的随机密码(由字母和数字组成)
|
||||
String password = StringDUtil.generateRandomCodeForLength(6);
|
||||
String addPasswordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
|
||||
requestMap.put("password", addPasswordMd5);
|
||||
|
||||
int result=usersService.reSetPassword(requestMap);
|
||||
|
||||
if(result>0){
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"重置用户的密码方法:requestMap:"+requestMap.toString());
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
j.setData(password);
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
j.setState(false);
|
||||
j.setMessage(e.getMessage());
|
||||
LogUtil.error(this.getClass(), "密码重置失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
return j;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @description 启用/禁用
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:06:54
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/unableUser")
|
||||
@ResponseBody
|
||||
public JsonResult unableUser(@RequestBody HashMap<Object, Object> requestMap){
|
||||
JsonResult j=new JsonResult();
|
||||
try{
|
||||
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
String userName = user.getUserName();
|
||||
String userTrueName = user.getTrueName();
|
||||
|
||||
requestMap.put("modifyUserName", userName);
|
||||
requestMap.put("modifyTrueName", userTrueName);
|
||||
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
String createDate = DateDUtil.getCurrentDate();
|
||||
requestMap.put("createTime", createTime);
|
||||
requestMap.put("createDate", createDate);
|
||||
|
||||
int result=usersService.unableUser(requestMap);
|
||||
|
||||
if(result>0){
|
||||
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"启用禁用用户的方法:requestMap:"+requestMap.toString());
|
||||
j.setState(true);
|
||||
j.setMessage("修改成功!");
|
||||
}else{
|
||||
j.setState(false);
|
||||
j.setMessage("修改失败!");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
j.setState(false);
|
||||
j.setMessage(e.getMessage());
|
||||
LogUtil.error(this.getClass(), "禁用启用失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 查询角色
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:07:09
|
||||
* @return
|
||||
*/
|
||||
// @RequestMapping("/findRoleList")
|
||||
// @ResponseBody
|
||||
// public JsonResult findRoleList(){
|
||||
// List<Role> list =roleService.findRoleList();
|
||||
// JsonResult j=new JsonResult();
|
||||
// j.setState(true);
|
||||
// j.setMessage("查询成功");
|
||||
// j.setData(list);
|
||||
// return j;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @description 新增用户名验证
|
||||
* @author qfqi
|
||||
* @created 2019年11月5日 下午3:07:22
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/searchByName")
|
||||
@ResponseBody
|
||||
public JsonResult searchByName(String userName){
|
||||
List<Users> list=usersService.searchByName(userName);
|
||||
JsonResult j=new JsonResult();
|
||||
j.setState(true);
|
||||
j.setMessage("查询成功");
|
||||
j.setData(list);
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 修改密码
|
||||
* @author thuang
|
||||
* @created 2019年11月27日 下午6:13:05
|
||||
* @param requestMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/modifyPassword")
|
||||
@ResponseBody
|
||||
public JsonResult modifyPassword(@RequestBody HashMap<Object, Object> requestMap){
|
||||
|
||||
String password = StringDUtil.changeNullToEmpty(requestMap.get("password"));
|
||||
String key = StringDUtil.removeSpaces(requestMap.get("key"));
|
||||
String initVector = StringDUtil.removeSpaces(requestMap.get("initVector"));
|
||||
JsonResult j=new JsonResult();
|
||||
try {
|
||||
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
Users user = (Users) subject.getPrincipal();
|
||||
String username = user.getUserName();
|
||||
String passwordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
|
||||
String addPasswordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
|
||||
|
||||
String modifyTime = DateDUtil.getTheCurrentTime();
|
||||
this.usersService.modifyPassword(username,passwordMd5,modifyTime);
|
||||
|
||||
user.setModifyTime(modifyTime);
|
||||
j.setState(true);
|
||||
j.setMessage("更改密码成功");
|
||||
LogUtil.debug(this.getClass(),"用户修改用户的密码方法:requestMap:"+requestMap.toString());
|
||||
} catch (Exception e) {
|
||||
j.setState(false);
|
||||
j.setMessage("更改密码失败");
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "修改密码失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 导入人员信息
|
||||
* @author thuang
|
||||
* @date 2021/5/19 9:57
|
||||
* @version 1.0
|
||||
*/
|
||||
@RequestMapping("/uploadUsers")
|
||||
@ResponseBody
|
||||
public HashMap<Object, Object> uploadUsers(@RequestParam("spareFile") MultipartFile file, HttpServletRequest request, HttpServletResponse response)throws Exception{
|
||||
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
|
||||
String errCode="0";
|
||||
String errMsg="";
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
XSSFWorkbook workbook =null;
|
||||
|
||||
//创建Excel,读取文件内容
|
||||
workbook = new XSSFWorkbook(file.getInputStream());
|
||||
|
||||
//获取第一个工作表
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
//获取sheet中第一行行号
|
||||
int firstRowNum = sheet.getFirstRowNum();
|
||||
//获取sheet中最后一行行号
|
||||
int lastRowNum = sheet.getLastRowNum();
|
||||
|
||||
try {
|
||||
//查询部门
|
||||
List<HashMap<Object,Object>> departs = departService.selectAllDeparts();
|
||||
HashMap<String,HashMap<Object,Object>> departTreeMap=new HashMap<>();
|
||||
HashMap<String,List<HashMap<Object,Object>>> parentIdMap=new HashMap<>();
|
||||
HashMap<String,HashMap<Object,Object>> departIdMap=new HashMap<>();
|
||||
//处理部门组织方便查询
|
||||
for (int i=0;i<departs.size();i++){
|
||||
HashMap<Object, Object> map = departs.get(i);
|
||||
String depart_id = StringDUtil.changeNullToEmpty(map.get("DEPART_ID"));
|
||||
String depart_name = StringDUtil.changeNullToEmpty(map.get("DEPART_NAME"));
|
||||
String parent_id = StringDUtil.changeNullToEmpty(map.get("PARENT_ID"));
|
||||
String parent_name = StringDUtil.changeNullToEmpty(map.get("PARENT_NAME"));
|
||||
|
||||
//如果上级名称为空说明没有上级部门,就是第一级 当然也有错误数据的情况,不过要出问题要满足名称相同,且上级都为空
|
||||
departIdMap.put(depart_id,map);
|
||||
if ("".equals(parent_name)){
|
||||
departTreeMap.put(depart_id,map);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<HashMap<Object, Object>> pidList = parentIdMap.get(parent_id);
|
||||
if (pidList == null){
|
||||
pidList=new ArrayList<>();
|
||||
parentIdMap.put(parent_id,pidList);
|
||||
}
|
||||
pidList.add(map);
|
||||
}
|
||||
for (String key : parentIdMap.keySet()){
|
||||
List<HashMap<Object, Object>> list = parentIdMap.get(key);
|
||||
HashMap<Object, Object> map = departIdMap.get(key);
|
||||
|
||||
map.put("childen",list);
|
||||
}
|
||||
|
||||
//时间
|
||||
String create_time = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
|
||||
String create_date = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
|
||||
|
||||
//添加人员
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
Users user = (Users) subject.getPrincipal();
|
||||
String modify_user_name = user.getUserName();
|
||||
String modify_true_name = user.getTrueName();
|
||||
|
||||
//循环插入数据
|
||||
int errNum=0;
|
||||
List<String> errNumList=new ArrayList<String>();
|
||||
List<HashMap<Object,Object>> addList=new ArrayList<>();
|
||||
for(int i=firstRowNum+2;i<=lastRowNum;i++){//因为表格中第一行为标题,第二行为列标题
|
||||
XSSFRow row = sheet.getRow(i);
|
||||
HashMap<Object, Object> addMap=new HashMap<Object, Object>();
|
||||
//用户id
|
||||
XSSFCell user_id = row.getCell(0);
|
||||
if(user_id==null){
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}else {
|
||||
user_id.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("user_id",user_id.getStringCellValue());
|
||||
addMap.put("user_name",user_id.getStringCellValue());
|
||||
}
|
||||
|
||||
//姓名
|
||||
XSSFCell true_name = row.getCell(1);
|
||||
if(true_name==null){
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}else {
|
||||
true_name.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("true_name",true_name.getStringCellValue());
|
||||
}
|
||||
|
||||
//性别
|
||||
XSSFCell sex = row.getCell(2);
|
||||
if(sex==null){
|
||||
addMap.put("sex","");
|
||||
}else {
|
||||
sex.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("sex",sex.getStringCellValue());
|
||||
}
|
||||
|
||||
//公司
|
||||
String companyId="";
|
||||
XSSFCell company = row.getCell(3);
|
||||
if(company==null){
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}else {
|
||||
company.setCellType(Cell.CELL_TYPE_STRING);
|
||||
String companyStr = company.getStringCellValue();
|
||||
|
||||
//第一层是最上一级
|
||||
boolean isHas=false;
|
||||
for(String key:departTreeMap.keySet()){
|
||||
HashMap<Object, Object> hashMap = departTreeMap.get(key);
|
||||
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
|
||||
//要循环的级别
|
||||
for (int j=0;j<departList.size();j++){
|
||||
HashMap<Object, Object> departObj = departList.get(j);
|
||||
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
|
||||
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
|
||||
if(companyStr.equals(depart_name)){
|
||||
addMap.put("company",depart_id);
|
||||
companyId=depart_id;
|
||||
isHas=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//判断对错 错的错误记录加1
|
||||
if (!isHas){
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//部门
|
||||
XSSFCell depart = row.getCell(4);
|
||||
if(depart==null){
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}else {
|
||||
depart.setCellType(Cell.CELL_TYPE_STRING);
|
||||
String departStr = depart.getStringCellValue();
|
||||
|
||||
//从部门树中找到部门
|
||||
HashMap<Object, Object> hashMap = departIdMap.get(companyId);
|
||||
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
|
||||
List<String> data=new ArrayList<>();
|
||||
getDepartIdByMapTree(data,departStr,departList);
|
||||
|
||||
if (data.size()>0){
|
||||
addMap.put("depart_id",data.get(0));
|
||||
}else{
|
||||
errNum++;
|
||||
errNumList.add(""+(i+1));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//岗位
|
||||
XSSFCell post = row.getCell(5);
|
||||
if(post==null){
|
||||
addMap.put("post","");
|
||||
}else {
|
||||
post.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("post",post.getStringCellValue());
|
||||
}
|
||||
|
||||
//政治面貌
|
||||
XSSFCell policital_status = row.getCell(6);
|
||||
if(policital_status==null){
|
||||
addMap.put("policital_status","");
|
||||
}else {
|
||||
policital_status.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("policital_status",policital_status.getStringCellValue());
|
||||
}
|
||||
|
||||
//专业技术资格
|
||||
XSSFCell positional_titles = row.getCell(7);
|
||||
if(positional_titles==null){
|
||||
addMap.put("positional_titles","");
|
||||
}else {
|
||||
positional_titles.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("positional_titles",positional_titles.getStringCellValue());
|
||||
}
|
||||
|
||||
//学历
|
||||
XSSFCell education = row.getCell(8);
|
||||
if(education==null){
|
||||
addMap.put("education","");
|
||||
}else {
|
||||
education.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("education",education.getStringCellValue());
|
||||
}
|
||||
|
||||
//职业技能名称
|
||||
XSSFCell vocational_name = row.getCell(9);
|
||||
if(vocational_name==null){
|
||||
addMap.put("vocational_name","");
|
||||
}else {
|
||||
vocational_name.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("vocational_name",vocational_name.getStringCellValue());
|
||||
}
|
||||
|
||||
//职业技术等级级别
|
||||
XSSFCell level = row.getCell(10);
|
||||
if(level==null){
|
||||
addMap.put("level","");
|
||||
}else {
|
||||
level.setCellType(Cell.CELL_TYPE_STRING);
|
||||
addMap.put("level",level.getStringCellValue());
|
||||
}
|
||||
|
||||
|
||||
//把固定的参数添加到map 默认密码先设置123
|
||||
addMap.put("password",new Md5Hash("123","hospitalgd",2).toString());
|
||||
addMap.put("isactive", "1");
|
||||
addMap.put("modify_user_name", modify_user_name);
|
||||
addMap.put("modify_true_name", modify_true_name);
|
||||
addMap.put("create_time", create_time);
|
||||
addMap.put("create_date", create_date);
|
||||
|
||||
addList.add(addMap);
|
||||
}
|
||||
|
||||
if(errNum>0){
|
||||
errCode="999";
|
||||
errMsg="导入失败,有"+errNum+"行导入错误";
|
||||
responseMap.put("errNumList", errNumList);
|
||||
}else{
|
||||
try {
|
||||
usersService.insertExcelUsers(addList);//往数据库插入数据
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errCode="999";
|
||||
errMsg="上传备件列表失败!"+e.getMessage();
|
||||
e.printStackTrace();
|
||||
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
|
||||
} finally {
|
||||
workbook.close();
|
||||
}
|
||||
}
|
||||
|
||||
responseMap.put("errCode", errCode);
|
||||
responseMap.put("errMsg", errMsg);
|
||||
|
||||
return responseMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据部门id查询相关人员
|
||||
* @author thuang
|
||||
* @date 2021/8/3 10:15
|
||||
* @version 1.0
|
||||
*/
|
||||
@RequestMapping("/findUserByDepartId")
|
||||
@ResponseBody
|
||||
public HashMap<Object,Object> findUserByDepartId(@RequestBody HashMap<Object,Object> map){
|
||||
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
|
||||
String errCode="0";
|
||||
String errMsg="";
|
||||
|
||||
try {
|
||||
String departIds = StringDUtil.changeNullToEmpty(map.get("departIds"));
|
||||
|
||||
//如果是空的就直接返回个空集合 不查询
|
||||
if ("".equals(departIds)){
|
||||
responseMap.put("userList",new ArrayList<>());
|
||||
}else {
|
||||
String[] split = departIds.split(",");
|
||||
|
||||
List<String> idList=new ArrayList<>();
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
idList.add(split[i]);
|
||||
}
|
||||
|
||||
List<HashMap<Object, Object>> userByDepartIds = usersService.findUserByDepartIds(idList);
|
||||
|
||||
//循环数据生成所要格式 list 中 {name,value}
|
||||
List<HashMap<Object, Object>> userList =new ArrayList<>();
|
||||
for (int i = 0; i < userByDepartIds.size(); i++) {
|
||||
HashMap<Object, Object> hashMap = userByDepartIds.get(i);
|
||||
HashMap<Object, Object> selectObj=new HashMap<>();
|
||||
|
||||
selectObj.put("name",hashMap.get("TRUE_NAME"));
|
||||
selectObj.put("value",hashMap.get("USER_ID"));
|
||||
userList.add(selectObj);
|
||||
}
|
||||
responseMap.put("userList",userList);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
errCode="999";
|
||||
errMsg="查询部门相关人员失败,原因:"+e.getMessage();
|
||||
}
|
||||
|
||||
responseMap.put("errCode", errCode);
|
||||
responseMap.put("errMsg", errMsg);
|
||||
|
||||
return responseMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 从上面生成的部门Map中根据部门名称获取部门id
|
||||
* @author thuang
|
||||
* @date 2021/7/14 13:45
|
||||
* @version 1.0
|
||||
* @param data
|
||||
*/
|
||||
public void getDepartIdByMapTree(List<String> data, String departStr, List<HashMap<Object, Object>> departList){
|
||||
|
||||
for (int i=0;i<departList.size();i++){
|
||||
HashMap<Object, Object> departObj = departList.get(i);
|
||||
|
||||
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
|
||||
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
|
||||
List<HashMap<Object,Object>> departChildenList = (List<HashMap<Object,Object>>)departObj.get("childen");
|
||||
|
||||
if(departStr.equals(depart_name)){
|
||||
data.add(depart_id);
|
||||
return;
|
||||
}
|
||||
if(departChildenList!=null && departChildenList.size()>0){
|
||||
getDepartIdByMapTree(data,departStr,departChildenList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.saye.hospitalgd.controller.system;
|
||||
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.model.StatusDefine;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* @author thuang
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2021/5/24 13:56
|
||||
*/
|
||||
@Controller
|
||||
public class downloadController {
|
||||
|
||||
@RequestMapping("/download")
|
||||
public void downloadFile(HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||
|
||||
try {
|
||||
String fileName = StringDUtil.changeNullToEmpty(request.getParameter("fileName"));
|
||||
String dowloadName = StringDUtil.changeNullToEmpty(request.getParameter("dowloadName"));
|
||||
//过滤相对路径../
|
||||
int lastIndex = fileName.lastIndexOf(".");
|
||||
//fileName = fileName.substring(0, lastIndex).replaceAll(".", "")+fileName.substring(lastIndex);
|
||||
String savePath = StatusDefine.filePath + fileName ;
|
||||
File file = new File(savePath);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
response.setContentType("application/force-download");
|
||||
response.addHeader("Content-disposition", "attachment;fileName=" + URLEncoder.encode(dowloadName+ DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd)+".xlsx", "UTF-8"));
|
||||
OutputStream os = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len = 0;
|
||||
while((len = fis.read(buf)) != -1) {
|
||||
os.write(buf, 0, len);
|
||||
}
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user