|
|
|
@ -1,14 +1,11 @@
|
|
|
|
|
package com.manage.controller;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
|
|
|
|
import com.manage.config.WebServiceCxf;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
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.interfaces.webservice.PowerWebService;
|
|
|
|
|
import com.manage.interfaces.webservice.impl.PowerWebServiceImpl;
|
|
|
|
|
import com.manage.service.*;
|
|
|
|
|
import com.manage.service.cache.Cache;
|
|
|
|
|
import com.manage.service.cache.CacheManager;
|
|
|
|
@ -19,17 +16,16 @@ import com.manage.util.ExceptionPrintUtil;
|
|
|
|
|
import com.manage.util.Msg;
|
|
|
|
|
import com.manage.vo.*;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
|
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.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ProjectName:
|
|
|
|
@ -67,10 +63,6 @@ public class FontController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private Power_DeptService power_deptService;
|
|
|
|
|
|
|
|
|
|
public static Class getUserClass(Object root) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 2.1
|
|
|
|
|
* @ProjectName: getRolePowerTreeBySysFlag
|
|
|
|
@ -371,172 +363,6 @@ public class FontController {
|
|
|
|
|
return Msg.success().add("list",list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 = "getTokenForHis",method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Msg getTokenForHis(@RequestBody token token1) throws Exception{
|
|
|
|
|
if(StringUtils.isBlank(token1.getUsername())){
|
|
|
|
|
return Msg.fail("用户名不能为空");
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isBlank(token1.getPassword())){
|
|
|
|
|
return Msg.fail("密码不能为空");
|
|
|
|
|
}
|
|
|
|
|
String username = token1.getUsername();
|
|
|
|
|
String password = token1.getPassword();
|
|
|
|
|
//1.根据userName,password调用webService,校验第三方系统中是否有此账号
|
|
|
|
|
if (!linkHisLogin(username,password)) {
|
|
|
|
|
return Msg.fail("校验第三方系统失败");
|
|
|
|
|
}
|
|
|
|
|
//2.根据userName查询我们的用户表是否存在
|
|
|
|
|
Power_UserVo userVo = new Power_UserVo();
|
|
|
|
|
// 判断数据库中是否有此用户,如果没有则插入数据库
|
|
|
|
|
List<Power_UserVo> user = userMapper.selectList().stream().filter(u -> username.equals(u.getUserName())).limit(1).collect(Collectors.toList());
|
|
|
|
|
userVo = user.get(0);
|
|
|
|
|
if (user.size() == 0) {
|
|
|
|
|
//2.1不存在往用户表新增这条用户
|
|
|
|
|
userVo.setUserName(username);
|
|
|
|
|
// userVo.setUserPwd(Base64.encode(MD5.KL("1C821B22D0402F317E40D93213C66843")));
|
|
|
|
|
userVo.setUserPwd(Base64.encode(MD5.KL(password)));
|
|
|
|
|
userVo.setRoleId(1);
|
|
|
|
|
userVo.setDeptId("3");
|
|
|
|
|
userVo.setEffective(1);
|
|
|
|
|
userVo.setCreater("his");
|
|
|
|
|
SimpleDateFormat fmt= new SimpleDateFormat();
|
|
|
|
|
userVo.setCreateDate(fmt.format(new Date()));
|
|
|
|
|
//插入00
|
|
|
|
|
userMapper.insert(userVo);
|
|
|
|
|
}
|
|
|
|
|
String token = setToken(userVo);
|
|
|
|
|
return Msg.success().add("token","token");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean linkHisLogin(String userName, String password) {
|
|
|
|
|
//创建连接工厂
|
|
|
|
|
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
|
|
|
|
|
//创建客户端
|
|
|
|
|
Object[] objects = new Object[0];
|
|
|
|
|
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
//医院给的webservice地址
|
|
|
|
|
String url = "http://192.168.128.170/csp/hsb/DHC.Published.PUB0025.BS.PUB0025.CLS?WSDL=1";
|
|
|
|
|
client = dcf.createClient(url);
|
|
|
|
|
//动态调用getInfosByUserId方法
|
|
|
|
|
//获取请求参数xml字符串
|
|
|
|
|
String xmlStr = getXml(userName,password);
|
|
|
|
|
objects = client.invoke("HIPManagerInfo", "S0110",xmlStr);
|
|
|
|
|
//应答信息
|
|
|
|
|
String re = objects[0].toString();
|
|
|
|
|
System.out.println(re);
|
|
|
|
|
//新用户存到数据库
|
|
|
|
|
if (re.contains("成功")) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
if(null != client) {
|
|
|
|
|
client.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getXml(String userName, String password) {
|
|
|
|
|
|
|
|
|
|
String Request="<Request> <SourceSystem>"+"嘉时软件"+"" +
|
|
|
|
|
"</SourceSystem> <TargetSystem>医院信息平台</TargetSystem> " +
|
|
|
|
|
" <username>"+userName+"</username> <password>"+password+"" +
|
|
|
|
|
"</password> </Request> ";
|
|
|
|
|
|
|
|
|
|
return Request;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态调用getInfosByUserId方法
|
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
public class TestController{
|
|
|
|
|
@Autowired
|
|
|
|
|
private PowerWebServiceImpl powerWebService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private WebServiceCxf webServiceCxf;
|
|
|
|
|
@GetMapping("/call")
|
|
|
|
|
public String call(String id) {
|
|
|
|
|
PowerWebService queryService = WebServiceCxf.createQueryService(id);
|
|
|
|
|
System.out.println(queryService.toString());
|
|
|
|
|
// return queryService.getInfosByUserId("token","sj");
|
|
|
|
|
String token = CacheManager.getCacheByUserId(id);
|
|
|
|
|
return queryService.getInfosByUserId(token, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String setToken(Power_UserVo userVo){
|
|
|
|
|
String date = String.valueOf(DateUtils.getDate());
|
|
|
|
|
String token = Base64.encode(MD5.KL(date));
|
|
|
|
|
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> powerDeptList = power_deptService.selectByPrimaryKeys(userVo.getDeptId());
|
|
|
|
|
for(int j = 0;j < powerDeptList.size();j++){
|
|
|
|
|
if(j<powerDeptList.size()-1){
|
|
|
|
|
powerDepts.append(powerDeptList.get(j).getDeptName()).append(",");
|
|
|
|
|
}else{
|
|
|
|
|
powerDepts.append(powerDeptList.get(j).getDeptName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
userVo.setRemark(powerDepts.toString());
|
|
|
|
|
//移除缓存
|
|
|
|
|
CacheManager.removeCacheByObject(userVo);
|
|
|
|
|
CacheManager.putCache(date,new Cache(date,userVo,TOKEN_EXPIRE_TIME));
|
|
|
|
|
return token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 2.10
|
|
|
|
|
* @ProjectName: getToken
|
|
|
|
|