You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
912 lines
36 KiB
Java
912 lines
36 KiB
Java
package com.manage.controller;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.manage.bean.*;
|
|
import com.manage.dao.Power_NoticeMapper;
|
|
import com.manage.dao.Power_UserMapper;
|
|
import com.manage.entity.*;
|
|
import com.manage.service.*;
|
|
import com.manage.service.cache.Cache;
|
|
import com.manage.service.cache.CacheManager;
|
|
import com.manage.service.ipml.Power_NoticeServiceImpl;
|
|
import com.manage.service.webSocket.WsPool;
|
|
import com.manage.util.ActionScopeUtils;
|
|
import com.manage.util.ExceptionPrintUtil;
|
|
import com.manage.util.Msg;
|
|
import com.manage.util.MyCookieUtil;
|
|
import com.manage.vo.*;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.client.ClientProtocolException;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.entity.StringEntity;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
|
|
/**
|
|
* @ProjectName:
|
|
* @Description:
|
|
* @Param 传输参数
|
|
* @Return
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/7/9 15:07
|
|
* @UpdateUser: 曾文和
|
|
* @UpdateDate: 2019/7/9 15:07
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@Controller
|
|
@RequestMapping("font/")
|
|
public class FontController {
|
|
@Value("${STR_SPLIT}")
|
|
private String STR_SPLIT;
|
|
@Autowired
|
|
private PowerService powerService;
|
|
@Value("${sysFlag}")
|
|
private Integer sysFlag;
|
|
@Autowired
|
|
private User_Dept_MenuService userDeptMenuService;
|
|
@Autowired
|
|
private LogService logService;
|
|
@Autowired
|
|
private Power_NoticeMapper powerNoticeMapper;
|
|
@Autowired
|
|
private Power_UserMapper userMapper;
|
|
@Autowired
|
|
private Power_NoticeServiceImpl noticeService;
|
|
@Autowired
|
|
private Power_UserService userService;
|
|
@Value("${TOKEN_EXPIRE_TIME}")
|
|
private long TOKEN_EXPIRE_TIME;
|
|
@Autowired
|
|
private Power_MenuService powerMenuService;
|
|
@Value("${EMRMEDICALRECORD_IP}")
|
|
private String ip;
|
|
@Value("${EMRMEDICALRECORD_SYSFLAG}")
|
|
private String recordAddress;
|
|
@Value("${EMRMEDICALRECORD_PORT}")
|
|
private String port;
|
|
@Value("${POWER_PORT}")
|
|
private String POWER_PORT;
|
|
@Autowired
|
|
private Power_DeptService power_deptService;
|
|
@Autowired
|
|
private Power_UserService power_userService;
|
|
@Value("${EMRMEDICALRECORD_URLHEAD}")
|
|
private String EMRMEDICALRECORD_URLHEAD;
|
|
|
|
/**
|
|
* 2.1
|
|
* @ProjectName: getRolePowerTreeBySysFlag
|
|
* @Description: 获取菜单通过系统标识
|
|
* @Param 无
|
|
* @Return getMenusByUserIdAndSysFlag
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/7/9 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/7/9 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getMenusByUserIdAndSysFlag",method = RequestMethod.GET)
|
|
@ResponseBody
|
|
public Msg getMenusByUserIdAndSysFlag(String userName,String sysFlag,Integer userId,Integer roleId,Integer sysId,Integer hospitalId) throws Exception{
|
|
if(StringUtils.isNotBlank(sysFlag) && StringUtils.isBlank(userName) && userId == null && roleId == null
|
|
&& sysId == null && hospitalId == null){
|
|
return Msg.fail("查询复杂,数据大,暂不支持只带sysFlag参数查询");
|
|
}
|
|
if(StringUtils.isBlank(sysFlag) && StringUtils.isBlank(userName) && userId == null && roleId == null
|
|
&& sysId != null && hospitalId == null){
|
|
return Msg.fail("查询复杂,数据大,暂不支持只带sysId参数查询");
|
|
}
|
|
if(StringUtils.isBlank(sysFlag) && StringUtils.isBlank(userName) && userId == null && roleId == null
|
|
&& sysId == null && hospitalId != null){
|
|
return Msg.fail("查询复杂,数据大,暂不支持只带hospitalId参数查询");
|
|
}
|
|
if(StringUtils.isNotBlank(userName)){
|
|
List<Power_User> powerUsers = userMapper.checkUserName(userName);
|
|
if(null != powerUsers && !powerUsers.isEmpty()){
|
|
if(powerUsers.get(0).getRoleId().equals(0) || powerUsers.get(0).getRoleId().equals(-100)){
|
|
roleId = powerUsers.get(0).getRoleId();
|
|
}
|
|
}
|
|
}
|
|
List<User_Dept_Menu> list = userDeptMenuService.selectAll(userName, sysFlag, userId, roleId, sysId, hospitalId);
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("list",list);
|
|
}
|
|
|
|
/**
|
|
* 2.2
|
|
* @ProjectName: selectAllByUserIdOrRoleIdAndSysIdOrSysFlag
|
|
* @Description: 根据用户id或角色id和系统id或系统标识查询通知记录
|
|
* @Param 无
|
|
* @Return selectAllByUserIdOrRoleIdAndSysIdOrSysFlag
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/7/29 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/7/29 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "selectAllByUserIdOrRoleIdAndSysIdOrSysFlag")
|
|
@ResponseBody
|
|
public Msg selectAllByUserIdOrRoleIdAndSysIdOrSysFlag(Integer userId,Integer roleId,Integer sysId,String sysFlag) throws Exception{
|
|
List<Power_Notice> list = powerNoticeMapper.selectAllByUserIdOrRoleIdAndSysIdOrSysFlag(userId, roleId, sysId, sysFlag);
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("list",list);
|
|
}
|
|
|
|
/**
|
|
* 2.4
|
|
* @ProjectName: getUserPowerTreeBySysFlag
|
|
* @Description: 获取系统用户树通过系统标识
|
|
* @Param 无
|
|
* @Return PowerTree
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/7/9 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/7/9 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getUserPowerTreeBySysFlag",produces = {"text/json;charset=UTF-8"})
|
|
@ResponseBody
|
|
public String getUserPowerTreeBySysFlag(String sysFlag,Integer userId){
|
|
try {
|
|
if(null != userId){
|
|
//查询该用户
|
|
Power_UserVo user = userMapper.selectByPrimaryKey(userId);
|
|
List<PowerTree> dicts = powerService.getUserPowerTreeBySysFlag(sysFlag,user);
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String json = mapper.writeValueAsString(dicts);
|
|
CacheManager.addExcCount("noExc");
|
|
return json;
|
|
}else{
|
|
return null;
|
|
}
|
|
}catch(Exception e){
|
|
ExceptionPrintUtil.printException(e);
|
|
CacheManager.addExcCount("exc");
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 2.5
|
|
* @ProjectName: getRolePowerTreeBySysFlag
|
|
* @Description: 获取系统角色树通过系统标识
|
|
* @Param 无
|
|
* @Return PowerTree
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/7/9 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/7/9 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getRolePowerTreeBySysFlag",produces = {"text/json;charset=UTF-8"})
|
|
@ResponseBody
|
|
public String getRolePowerTreeBySysFlag(String sysFlag,Integer userId){
|
|
try {
|
|
if(null != userId){
|
|
Power_UserVo user = userMapper.selectByPrimaryKey(userId);
|
|
List<PowerTree> dicts = powerService.getRolePowerTreeBySysFlag(sysFlag,user);
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String json = mapper.writeValueAsString(dicts);
|
|
CacheManager.addExcCount("noExc");
|
|
return json;
|
|
}else{
|
|
return null;
|
|
}
|
|
}catch(Exception e){
|
|
ExceptionPrintUtil.printException(e);
|
|
CacheManager.addExcCount("exc");
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 2.6
|
|
* @ProjectName: getUserList
|
|
* @Description: 获取用户id和用户名
|
|
* @Param 无
|
|
* @Return userList
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/9/6 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/9/6 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getUserList")
|
|
@ResponseBody
|
|
public Msg getUserList(String userName) throws Exception{
|
|
List<User> list = new ArrayList<>();
|
|
if(StringUtils.isNoneBlank(userName)){
|
|
List<Power_User> users = userMapper.checkUserName(userName);
|
|
if(null != users && !users.isEmpty()){
|
|
Integer roleId = users.get(0).getRoleId();
|
|
if(roleId == 0){
|
|
list = userMapper.selectUserIdAndUserNameList(null);
|
|
}else{
|
|
list = userMapper.selectUserIdAndUserNameList(users.get(0).getUserId());
|
|
}
|
|
}
|
|
}else{
|
|
return Msg.fail("用户名不能为空");
|
|
}
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("userList",list);
|
|
}
|
|
|
|
/**
|
|
* 2.7
|
|
* @ProjectName: checkToken
|
|
* @Description: 验证token是否有效
|
|
* @Param 无
|
|
* @Return Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/9/24 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/9/24 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "checkToken",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public Msg checkToken(String token) throws Exception{
|
|
if(StringUtils.isNotBlank(token) && StringUtils.isNotBlank(token) ) {
|
|
Cache cache = CacheManager.getCacheInfo(token);
|
|
if (cache == null) {
|
|
return Msg.fail("token已过期或不存在");
|
|
}else{
|
|
Power_UserVo user = (Power_UserVo)cache.getValue();
|
|
CacheManager.putCache(token,new Cache(user,System.currentTimeMillis(),TOKEN_EXPIRE_TIME*1000));
|
|
}
|
|
}else{
|
|
return Msg.fail("token不能为空");
|
|
}
|
|
return Msg.success();
|
|
}
|
|
|
|
/**
|
|
* 2.8
|
|
* @ProjectName: getUserByToken
|
|
* @Description: 根据token获取用户
|
|
* @Param 无
|
|
* @Return getMenuListByToken
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/10/31 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/10/31 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getUserByToken",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public Msg getMenuListByToken(String token,String sysFlag) throws Exception{
|
|
if(StringUtils.isBlank(token)){
|
|
return Msg.fail("token不能为空!");
|
|
}
|
|
if(StringUtils.isBlank(sysFlag)){
|
|
return Msg.fail("sysFlag不能为空!");
|
|
}
|
|
Cache cacheInfo = CacheManager.getCacheInfo(token);
|
|
if(null != cacheInfo){
|
|
Power_UserVo user = (Power_UserVo) cacheInfo.getValue();
|
|
if(null != user) {
|
|
List<User_Dept_Menu> menuList = user.getMenuList();
|
|
List<User_Dept_Menu> list = new ArrayList<>();
|
|
Set<String> menus = new TreeSet<>();
|
|
if (null != menuList && !menuList.isEmpty()) {
|
|
for (User_Dept_Menu deptMenu : menuList) {
|
|
String menuSysFlag = deptMenu.getSysFlag();
|
|
if (StringUtils.isNotBlank(menuSysFlag) && menuSysFlag.equals(sysFlag)) {
|
|
list.add(deptMenu);
|
|
if (StringUtils.isNotBlank(deptMenu.getMethod())) {
|
|
menus.add(deptMenu.getMenuUrl());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
user.setMenuList(list);
|
|
user.setMenus(menus);
|
|
UserVo userVo = new UserVo();
|
|
BeanUtils.copyProperties(user, userVo);
|
|
//查询用户集合
|
|
List<User> userList = new ArrayList<>();
|
|
Integer roleId = userVo.getRoleId();
|
|
if (roleId == 0) {
|
|
userList = userMapper.selectUserIdAndUserNameList(null);
|
|
} else {
|
|
userList = userMapper.selectUserIdAndUserNameList(userVo.getUserId());
|
|
}
|
|
//设置用户集合
|
|
userVo.setUserList(userList);
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("user", userVo);
|
|
}
|
|
}
|
|
return Msg.fail("token已失效");
|
|
}
|
|
|
|
/**
|
|
* 2.9
|
|
* @ProjectName: getMenuByToken
|
|
* @Description: 根据token获取菜单
|
|
* @Param 无
|
|
* @Return getMenuListByToken
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/10/31 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/10/31 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getMenuByToken",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public Msg getMenuByToken(String token,String sysFlag) throws Exception {
|
|
if (StringUtils.isBlank(token)) {
|
|
return Msg.fail("token不能为空!");
|
|
}
|
|
if (StringUtils.isBlank(sysFlag)) {
|
|
return Msg.fail("sysFlag不能为空!");
|
|
}
|
|
Cache cacheInfo = CacheManager.getCacheInfo(token);
|
|
if (null != cacheInfo) {
|
|
Power_UserVo user = (Power_UserVo) cacheInfo.getValue();
|
|
List<User_Dept_Menu> menuList = user.getMenuList();
|
|
List<User_Dept_Menu> list = new ArrayList<>();
|
|
if (null != menuList && !menuList.isEmpty()) {
|
|
for (User_Dept_Menu deptMenu : menuList) {
|
|
String menuSysFlag = deptMenu.getSysFlag();
|
|
if (StringUtils.isNotBlank(menuSysFlag) && menuSysFlag.equals(sysFlag)) {
|
|
list.add(deptMenu);
|
|
}
|
|
}
|
|
}
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("list", list);
|
|
}else{
|
|
return Msg.fail("token已失效");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 2.10
|
|
* @ProjectName: getToken
|
|
* @Description: 获取token
|
|
* @Param 无
|
|
* @Return Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019/11/06 10:00
|
|
* @UpdateUser: 更新者
|
|
* @UpdateDate: 2019/11/06 10:00
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.0
|
|
*/
|
|
@RequestMapping(value = "getToken",method = RequestMethod.GET)
|
|
@ResponseBody
|
|
public Msg getToken(String userName,String password) throws Exception{
|
|
if(StringUtils.isBlank(userName)){
|
|
return Msg.fail("用户名不能为空");
|
|
}
|
|
if(StringUtils.isBlank(password)){
|
|
return Msg.fail("密码不能为空");
|
|
}
|
|
Power_UserVo user = new Power_UserVo();
|
|
user.setUserName(userName);
|
|
//归档特殊token=1462903487866169011
|
|
if("1462903487866169011".equals(password)){
|
|
password = null;
|
|
}
|
|
user.setRemark(password);
|
|
Power_UserVo userVo = userService.findPowerUserByUserNameAndRemark(user);
|
|
if(null == userVo){
|
|
return Msg.fail("用户名或密码不正确");
|
|
}
|
|
String token = UUID.randomUUID().toString();
|
|
List<Power_Menu> list = null;
|
|
List<User_Dept_Menu> menuList = new ArrayList<>();
|
|
Set<String> menus = new TreeSet<>();
|
|
if (userVo.getRoleId().equals(0) || userVo.getRoleId().equals(-100)) {
|
|
list = powerMenuService.queryAllPowerMenu(null,userVo.getRoleId());
|
|
} else {
|
|
list = powerMenuService.selectUserAndRoleMenuListPower(userVo.getUserId(),null);
|
|
}
|
|
if(null != list && !list.isEmpty()){
|
|
for (Power_Menu powerMenu : list) {
|
|
User_Dept_Menu deptMenu = new User_Dept_Menu();
|
|
String menuUrl = powerMenu.getMenuUrl();
|
|
if (StringUtils.isNotBlank(menuUrl)) {
|
|
BeanUtils.copyProperties(powerMenu, deptMenu);
|
|
deptMenu.setMethodParent(powerMenu.getParentId());
|
|
menuList.add(deptMenu);
|
|
}
|
|
if (StringUtils.isNotBlank(powerMenu.getMethod())) {
|
|
menus.add(powerMenu.getMenuUrl());
|
|
}
|
|
}
|
|
}
|
|
userVo.setMenuList(menuList);
|
|
userVo.setMenus(menus);
|
|
|
|
//设置科室
|
|
StringBuilder powerDepts = new StringBuilder();
|
|
List<Power_Dept> powerDeptsList = power_deptService.selectByPrimaryKeys(userVo.getDeptId());
|
|
for(int j=0;j<powerDeptsList.size();j++){
|
|
if(j<powerDeptsList.size()-1){
|
|
powerDepts.append(powerDeptsList.get(j).getDeptName()).append(",");
|
|
}else{
|
|
powerDepts.append(powerDeptsList.get(j).getDeptName());
|
|
}
|
|
}
|
|
userVo.setRemark(powerDepts.toString());
|
|
ActionScopeUtils.setSessionAttribute("token",token,Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME)));
|
|
ActionScopeUtils.setSessionAttribute("CURRENT_USER",userVo,Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME)));
|
|
CacheManager.putCache(token,new Cache(userVo,System.currentTimeMillis(),TOKEN_EXPIRE_TIME*1000));
|
|
return Msg.success().add("token",token);
|
|
}
|
|
|
|
/**
|
|
* 2.11
|
|
* @MethodName getUnReadCount
|
|
* @Description: 根据用户获取未读通知数量
|
|
* @Param 无
|
|
* @Returnt Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2019-10-17
|
|
* @UpdateUser: 曾文和
|
|
* @UpdateDate: 2019-10-17
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.2.2
|
|
*/
|
|
@RequestMapping("notice/getUnReadCount")
|
|
@ResponseBody
|
|
public Msg getUnReadCount(Integer userId) throws Exception{
|
|
if(null == userId){
|
|
return Msg.fail("用户id不能为空");
|
|
}
|
|
Power_UserVo userVo = userMapper.selectByPrimaryKey(userId);
|
|
if(null == userVo){
|
|
return Msg.fail("用户id不存在");
|
|
}
|
|
int unReadCount = noticeService.getUnReadCount();
|
|
CacheManager.addExcCount("noExc");
|
|
return Msg.success().add("unReadCount",unReadCount);
|
|
}
|
|
|
|
/**
|
|
* @MethodName checkUserName
|
|
* @Description: 根据用户名判断用户是否存在
|
|
* @Param 无
|
|
* @Returnt Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2020-04-22
|
|
* @UpdateUser: 曾文和
|
|
* @UpdateDate: 2020-04-22
|
|
* @UpdateRemark: 更新说明
|
|
* @Version: 1.2.2
|
|
*/
|
|
@RequestMapping("checkUserName")
|
|
@ResponseBody
|
|
public Msg checkUserName(String userName) throws Exception{
|
|
if(StringUtils.isBlank(userName)){
|
|
return Msg.fail("工号不能为空!");
|
|
}
|
|
//查询用户
|
|
List<Power_User> user = userMapper.checkUserName(userName);
|
|
if(null == user || user.isEmpty()){
|
|
return Msg.fail("该工号不存在!");
|
|
}
|
|
return Msg.success().add("user",user);
|
|
}
|
|
|
|
/**
|
|
* @MethodName sendEmrRecordApproveNotice
|
|
* @Description: 给病案管理系统发送审批通知
|
|
* @Param applyType 申请类型
|
|
* @Param count 新的待审批份数
|
|
* @Returnt Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2020-04-24
|
|
* @UpdateUser: 曾文和
|
|
* @UpdateDate: 2020-04-24
|
|
* @UpdateRemark: 更新说明
|
|
* @Version:
|
|
*/
|
|
@RequestMapping("sendEmrRecordApproveNotice")
|
|
@ResponseBody
|
|
public void sendEmrRecordApproveNotice(String applyType,Integer count){
|
|
try {
|
|
String title = "待审批通知";
|
|
String content = "您有"+count+"份"+applyType+"待审批!";
|
|
//查询有借阅审批权限的id集合
|
|
String menuUrl = "/approve/updateApprove";
|
|
List<Power_User> users = userMapper.selectUserIdsWithApprove(menuUrl);
|
|
for(Power_User user : users){
|
|
if(null != user) {
|
|
WsPool.sendMessageToAll("emr_record_" + user.getUserId(), title + STR_SPLIT + content + STR_SPLIT + "emr_record");
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
ExceptionPrintUtil.printException(e);
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @MethodName sendMessage
|
|
* @Description: 发送信息接口
|
|
* @Param applyType 申请类型
|
|
* @Param count 新的待审批份数
|
|
* @Returnt Msg
|
|
* @Author: 曾文和
|
|
* @CreateDate: 2020-04-24
|
|
* @UpdateUser: 曾文和
|
|
* @UpdateDate: 2020-04-24
|
|
* @UpdateRemark: 更新说明
|
|
* @Version:
|
|
*/
|
|
@RequestMapping("sendMessage")
|
|
@ResponseBody
|
|
public Msg sendMessage(Message message) throws Exception{
|
|
if(null == message.getUserId()){
|
|
return Msg.fail("消息用户id不能为空");
|
|
}
|
|
if(StringUtils.isBlank(message.getSysFlag())){
|
|
return Msg.fail("消息系统标识不能为空");
|
|
}
|
|
if(StringUtils.isBlank(message.getTitle())){
|
|
return Msg.fail("消息标题不能为空");
|
|
}
|
|
if(StringUtils.isBlank(message.getContent())){
|
|
return Msg.fail("消息内容不能为空");
|
|
}
|
|
WsPool.sendMessageToAll(message.getSysFlag() + "_" + message.getUserId(), message.getTitle() + STR_SPLIT + message.getContent() + STR_SPLIT + message.getTypeFlag());
|
|
return Msg.success();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取二维码
|
|
* @return
|
|
* @throws
|
|
*/
|
|
@RequestMapping(value="getQRcode")
|
|
@ResponseBody
|
|
public QrBean getQRcode(QRcode qRcode, HttpServletRequest request){
|
|
// 获得Http客户端
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
// 创建Post请求
|
|
HttpPost httpPost = new HttpPost("http://192.168.1.212:8080/cloudkeyserver/api/login/qrcode/nostatus/2CKV1");
|
|
//json格式转换
|
|
String jsonString = JSON.toJSONString(qRcode);
|
|
StringEntity entity = new StringEntity(jsonString, "UTF-8");
|
|
// post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
|
|
httpPost.setEntity(entity);
|
|
httpPost.setHeader("Content-Type", "application/json;charset=utf8");
|
|
// 响应模型
|
|
CloseableHttpResponse response = null;
|
|
HttpEntity responseEntity=null;
|
|
String s ="";
|
|
QrBean qrBean=new QrBean();
|
|
try {
|
|
// 由客户端执行(发送)Post请求
|
|
response = httpClient.execute(httpPost);
|
|
// 从响应模型中获取响应实体
|
|
responseEntity = response.getEntity();
|
|
System.out.println("响应状态为:" + response.getStatusLine());
|
|
if (responseEntity != null) {
|
|
JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(responseEntity));
|
|
String contents = jsonObject.getString("contents");
|
|
JSONObject contentsObject = JSONObject.parseObject(contents);
|
|
String qrCodeIdentity = contentsObject.getString("qrCodeIdentity");
|
|
JSONArray qrCodes = contentsObject.getJSONArray("qrCodes");
|
|
String qrCodeBase64 = qrCodes.getJSONObject(0).get("qrCodeBase64").toString();
|
|
qrBean.setQrCodeBase64(qrCodeBase64);
|
|
qrBean.setQrCodeIdentity(qrCodeIdentity);
|
|
}
|
|
} catch (ClientProtocolException e) {
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
try {
|
|
// 释放资源
|
|
if (httpClient != null) {
|
|
httpClient.close();
|
|
}
|
|
if (response != null) {
|
|
response.close();
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
return qrBean;
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取userToken
|
|
* @return
|
|
* @throws
|
|
*/
|
|
@RequestMapping(value="getScanCode")
|
|
@ResponseBody
|
|
public ScanCodeRes getQRcode(ScanCode scanCode, HttpServletRequest request){
|
|
System.out.println("scanCode123::::"+scanCode.getQrCodeIdentity());
|
|
// 获得Http客户端
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
// 创建Post请求
|
|
HttpPost httpPost = new HttpPost("http://192.168.1.212:8080/cloudkeyserver/api/qrcode/status");
|
|
//json格式转换
|
|
String jsonString = JSON.toJSONString(scanCode);
|
|
StringEntity entity = new StringEntity(jsonString, "UTF-8");
|
|
// post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
|
|
httpPost.setEntity(entity);
|
|
httpPost.setHeader("Content-Type", "application/json;charset=utf8");
|
|
// 响应模型
|
|
CloseableHttpResponse response = null;
|
|
HttpEntity responseEntity=null;
|
|
ScanCodeRes scanCodeRes=new ScanCodeRes();
|
|
try {
|
|
// 由客户端执行(发送)Post请求
|
|
response = httpClient.execute(httpPost);
|
|
// 从响应模型中获取响应实体
|
|
responseEntity = response.getEntity();
|
|
System.out.println("responseEntity::::"+responseEntity);
|
|
System.out.println("响应状态为:" + response.getStatusLine());
|
|
if (responseEntity != null) {
|
|
JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(responseEntity));
|
|
String contents = jsonObject.getString("contents");
|
|
JSONObject contentsObject = JSONObject.parseObject(contents);
|
|
String userToken = contentsObject.getString("userToken");
|
|
String verifyStatus = contentsObject.getString("verifyStatus");
|
|
scanCodeRes.setUserToken(userToken);
|
|
scanCodeRes.setVerifyStatus(verifyStatus);
|
|
|
|
}
|
|
} catch (ClientProtocolException e) {
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
try {
|
|
// 释放资源
|
|
if (httpClient != null) {
|
|
httpClient.close();
|
|
}
|
|
if (response != null) {
|
|
response.close();
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
return scanCodeRes;
|
|
|
|
}
|
|
/**
|
|
* 获取用户信息
|
|
* @return
|
|
* @throws
|
|
*/
|
|
@RequestMapping(value="getUserInfo")
|
|
@ResponseBody
|
|
public UserCodeRes getUserInfo(UserCode userCode, HttpServletRequest request){
|
|
// 获得Http客户端
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
// 创建Post请求
|
|
HttpPost httpPost = new HttpPost("http://192.168.1.212:8080/cloudkeyserver/api/oprinfo/search/all");
|
|
//json格式转换
|
|
String jsonString = JSON.toJSONString(userCode);
|
|
StringEntity entity = new StringEntity(jsonString, "UTF-8");
|
|
// post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
|
|
httpPost.setEntity(entity);
|
|
httpPost.setHeader("Content-Type", "application/json;charset=utf8");
|
|
// 响应模型
|
|
CloseableHttpResponse response = null;
|
|
HttpEntity responseEntity=null;
|
|
UserCodeRes userCodeRes =new UserCodeRes();
|
|
try {
|
|
// 由客户端执行(发送)Post请求
|
|
response = httpClient.execute(httpPost);
|
|
// 从响应模型中获取响应实体
|
|
responseEntity = response.getEntity();
|
|
System.out.println("responseEntity::::"+responseEntity);
|
|
System.out.println("响应状态为:" + response.getStatusLine());
|
|
if (responseEntity != null) {
|
|
JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(responseEntity));
|
|
String responseResult = jsonObject.getString("responseResult");
|
|
JSONObject responseResultObject = JSONObject.parseObject(responseResult);
|
|
String msg = responseResultObject.getString("msg");
|
|
String contents = jsonObject.getString("contents");
|
|
JSONObject contentsObject = JSONObject.parseObject(contents);
|
|
String uid = contentsObject.getString("uid");
|
|
userCodeRes.setMsg(msg);
|
|
userCodeRes.setUid(uid);
|
|
if (msg.equals("成功")){
|
|
userCodeRes.setMsgType(1);
|
|
}else {
|
|
userCodeRes.setMsgType(2);
|
|
}
|
|
|
|
}
|
|
} catch (ClientProtocolException e) {
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
try {
|
|
// 释放资源
|
|
if (httpClient != null) {
|
|
httpClient.close();
|
|
}
|
|
if (response != null) {
|
|
response.close();
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return userCodeRes;
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "qRCodeLogin",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public Msg qRCodeLogin(Power_User powerUser, HttpServletResponse response, HttpServletRequest request, Model model){
|
|
try {
|
|
Power_UserVo user = power_userService.findUserName(powerUser);
|
|
System.out.println("user:::::"+user);
|
|
//添加进操作日志
|
|
Power_Log log = new Power_Log();
|
|
if(user != null){
|
|
// //存session密码置空
|
|
//// //是否记住密码功能
|
|
//// MyCookieUtil.remember(request, response);
|
|
//设置token缓存
|
|
String token = UUID.randomUUID().toString();
|
|
//查询归属医院
|
|
/*long start5 = System.currentTimeMillis();
|
|
Power_User_Dict powerUserDict = powerUserDictMapper.selectDictIdByUserId(user.getUserId());
|
|
long end5 = System.currentTimeMillis();
|
|
System.out.println("查询医院时间="+(end5-start5)/1000.0+"s");
|
|
user.setDictId(powerUserDict.getDictId());*/
|
|
//设置用户登录次数缓存
|
|
//CacheManager.addloginUserCount(fmt.format(new Date()),user.getUserName());
|
|
CacheManager.addExcCount("noExc");
|
|
List<Power_Menu> list = null;
|
|
List<User_Dept_Menu> menuList = new ArrayList<>();
|
|
Set<String> menus = new LinkedHashSet<>();
|
|
if (user.getRoleId().equals(0) || user.getRoleId().equals(-100)) {
|
|
list = powerMenuService.queryAllPowerMenu(null,user.getRoleId());
|
|
} else {
|
|
list = powerMenuService.selectUserAndRoleMenuListPower(user.getUserId(),null);
|
|
}
|
|
if(null != list && !list.isEmpty()){
|
|
for (Power_Menu powerMenu : list) {
|
|
User_Dept_Menu deptMenu = new User_Dept_Menu();
|
|
String menuUrl = powerMenu.getMenuUrl();
|
|
if (StringUtils.isNotBlank(menuUrl)) {
|
|
BeanUtils.copyProperties(powerMenu, deptMenu);
|
|
deptMenu.setMethodParent(powerMenu.getParentId());
|
|
menuList.add(deptMenu);
|
|
}
|
|
if (StringUtils.isNotBlank(powerMenu.getMethod())) {
|
|
menus.add(powerMenu.getMenuUrl());
|
|
}
|
|
}
|
|
}
|
|
user.setMenuList(menuList);
|
|
user.setMenus(menus);
|
|
//设置科室
|
|
StringBuilder powerDepts = new StringBuilder();
|
|
List<Power_Dept> powerDeptsList = power_deptService.selectByPrimaryKeys(user.getDeptId());
|
|
for(int j=0;j<powerDeptsList.size();j++){
|
|
if(j<powerDeptsList.size()-1){
|
|
powerDepts.append(powerDeptsList.get(j).getDeptName()).append(",");
|
|
}else{
|
|
powerDepts.append(powerDeptsList.get(j).getDeptName());
|
|
}
|
|
}
|
|
Integer roleId = user.getRoleId();
|
|
if(null != roleId && roleId != 0 && roleId != -100){
|
|
user.setRemark(powerDepts.toString());
|
|
}
|
|
//清除用户登录错误次数缓存
|
|
CacheManager.clearOnly(powerUser.getUserName());
|
|
//设置进缓存
|
|
CacheManager.putCache(token,new Cache(user,System.currentTimeMillis(),TOKEN_EXPIRE_TIME*1000));
|
|
ActionScopeUtils.setSessionAttribute("token",token,Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME)));
|
|
ActionScopeUtils.setSessionAttribute("CURRENT_USER",user,Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME)));
|
|
//单点登录跳转
|
|
String url = "";
|
|
if(sysFlag == 2){
|
|
url = EMRMEDICALRECORD_URLHEAD+"/login?token="+token+"&userName="+user.getUserName()+"&flag=1";
|
|
}else{
|
|
url = "http://"+ip+":"+POWER_PORT+"/power/gatewayPage";
|
|
|
|
}
|
|
//request.getRequestDispatcher(url).forward(request, response);
|
|
|
|
//response.sendRedirect(url);
|
|
//return "redirect:gatewayPage";
|
|
return Msg.success().add("url",url);
|
|
}else{
|
|
//登录失败
|
|
Integer wrongNum = 1;
|
|
Cache cache = CacheManager.getCacheInfo(powerUser.getUserName());
|
|
if(cache != null){
|
|
//缓存中错误次数
|
|
Integer currentNum = (Integer)cache.getValue();
|
|
//叠加1
|
|
wrongNum += currentNum;
|
|
}
|
|
//添加缓存
|
|
CacheManager.putCache(powerUser.getUserName(),new Cache(wrongNum));
|
|
log.setCreater(powerUser.getUserName());
|
|
log.setLogTitle("登录");
|
|
log.setLogContent("用户密码错误");
|
|
log.setRemark("已错误【"+wrongNum+"】次");
|
|
logService.insert(log);
|
|
request.setAttribute("msg", "用户名或密码不正确");
|
|
}
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
CacheManager.addExcCount("exc");
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
/**
|
|
* @description: 判断弱密码跳转到修改密码页面
|
|
* @author linjj
|
|
* @date: 2023/7/10 16:43
|
|
*/
|
|
@RequestMapping(value = "updatePassword")
|
|
public String updatePassword(Model model , HttpServletRequest request){
|
|
return"/userDir/updatePassword1";
|
|
}
|
|
|
|
/**
|
|
* @description: 打印系统登录结构
|
|
* @params: powerUser
|
|
* @author linjj
|
|
* @date: 2023/7/26 10:15
|
|
*/
|
|
@RequestMapping(value = "PrintLogin", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public Msg login(Power_User powerUser, HttpServletResponse response, HttpServletRequest request, Model model) {
|
|
return Msg.failUser2();
|
|
}
|
|
}
|