|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
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.encrypt.Base64;
|
|
|
|
|
import com.manage.encrypt.MD5;
|
|
|
|
|
import com.manage.entity.*;
|
|
|
|
|
import com.manage.service.*;
|
|
|
|
|
import com.manage.service.cache.Cache;
|
|
|
|
@ -12,19 +14,32 @@ 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.DateUtils;
|
|
|
|
|
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.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -46,9 +61,13 @@ public class FontController {
|
|
|
|
|
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;
|
|
|
|
@ -60,8 +79,20 @@ public class FontController {
|
|
|
|
|
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
|
|
|
|
@ -557,4 +588,313 @@ public class FontController {
|
|
|
|
|
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");
|
|
|
|
|
// qRcode.setLoginTypeBitValue(16);
|
|
|
|
|
// qRcode.setType(3);
|
|
|
|
|
// qRcode.setProjectUid("cloudkey-fstth");
|
|
|
|
|
// qRcode.setApplicationId("fstth-wzh");
|
|
|
|
|
System.out.println("qRcode:::::"+qRcode.getApplicationId());
|
|
|
|
|
//json格式转换
|
|
|
|
|
String jsonString = JSON.toJSONString(qRcode);
|
|
|
|
|
System.out.println("jsonString1::::"+jsonString);
|
|
|
|
|
StringEntity entity = new StringEntity(jsonString, "UTF-8");
|
|
|
|
|
System.out.println("jsonString::::"+jsonString);
|
|
|
|
|
// 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("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 qrCodeIdentity = contentsObject.getString("qrCodeIdentity");
|
|
|
|
|
JSONArray qrCodes = contentsObject.getJSONArray("qrCodes");
|
|
|
|
|
String qrCodeBase64 = qrCodes.getJSONObject(0).get("qrCodeBase64").toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qrBean.setQrCodeBase64(qrCodeBase64);
|
|
|
|
|
qrBean.setQrCodeIdentity(qrCodeIdentity);
|
|
|
|
|
System.out.println("qrBean::::"+qrBean.getQrCodeIdentity());
|
|
|
|
|
}
|
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|