南方医院接口完成

nanfang_branch
kevin 4 years ago
parent e94b5d88fe
commit 85a1e420e8

@ -75,6 +75,15 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
@ -123,6 +132,23 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.cxf</groupId>-->
<!-- <artifactId>cxf-rt-transports-http</artifactId>-->
<!-- <version>3.1.8</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.cxf</groupId>-->
<!-- <artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!-- <version>3.1.8</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>xerces</groupId>-->
<!-- <artifactId>xercesImpl</artifactId>-->
<!-- <version>2.11.0</version>-->
<!-- </dependency>-->
<!--commoms-->
<dependency>
<groupId>org.apache.commons</groupId>
@ -148,12 +174,6 @@
<artifactId>jdom2</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.5.5</version>
</dependency>
</dependencies>
<build>
<finalName>power</finalName>

@ -0,0 +1,20 @@
package com.manage.config;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component //或者继承implements ApplicationRunner 实现run()方法
public class MyHandel {
@PostConstruct
public void loadDic() {
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
}
//在spring容器关闭时释放
@PreDestroy
public void destroy() {
//系统运行结束
}
}

@ -1,37 +0,0 @@
package com.manage.config;
import com.manage.interfaces.webservice.PowerWebService;
import com.manage.interfaces.webservice.impl.PowerWebServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
@Configuration
public class WebServiceConfig {
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
@Bean
public PowerWebService powerWebService() {
return new PowerWebServiceImpl();
}
@Bean
public Endpoint endpoint(){
EndpointImpl endpoint = new EndpointImpl(springBus(),powerWebService());
endpoint.publish("PowerWebService");
return endpoint;
}
}

@ -33,6 +33,7 @@ public class WebServiceCxf implements InitializingBean, ApplicationContextAware
@Override
public void afterPropertiesSet() throws Exception {
Map<String, PowerWebService> beanMap = applicationContext.getBeansOfType(PowerWebService.class);
//遍历该接口的所有实现将其放入map中
for (PowerWebService serviceImpl : beanMap.values()) {
queryServiceImplMap.put(serviceImpl.getClass().getSimpleName(), serviceImpl);

@ -17,11 +17,14 @@ import com.manage.service.webSocket.WsPool;
import com.manage.util.DateUtils;
import com.manage.util.ExceptionPrintUtil;
import com.manage.util.Msg;
import com.manage.utils.ResultUtils;
import com.manage.utils.XmlUtils;
import com.manage.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.endpoint.Client;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -29,9 +32,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.jws.WebService;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -377,15 +378,15 @@ public class FontController {
}
public static void main(String[] args) throws UnsupportedEncodingException {
String xml="<Request><SourceSystem>*******</SourceSystem><TargetSystem>医院信息平台</TargetSystem><username>sj</username><password>1C821B22D0402F317E40D93213C66843</password></Request>";
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(xml.getBytes("UTF-8")));
String username = xmlUtils.getElement("username");
String password = xmlUtils.getElement("password");
System.out.println(username);
System.out.println(password);
System.out.println(ResultUtils.success().asXML());
}
// public static void main(String[] args) throws UnsupportedEncodingException {
// String xml="<Request><SourceSystem>*******</SourceSystem><TargetSystem>医院信息平台</TargetSystem><username>sj</username><password>1C821B22D0402F317E40D93213C66843</password></Request>";
// XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(xml.getBytes("UTF-8")));
// String username = xmlUtils.getElement("username");
// String password = xmlUtils.getElement("password");
// System.out.println(username);
// System.out.println(password);
// System.out.println(ResultUtils.success().asXML());
// }
/**
* 2.10
@ -402,7 +403,7 @@ public class FontController {
*/
@RequestMapping(value = "getTokenForHis",method = RequestMethod.POST)
@ResponseBody
public Msg getTokenForHis(String userName,String password) throws Exception{
public Msg getTokenForHis(@RequestParam("username") String userName,@RequestParam("password")String password) throws Exception{
if(StringUtils.isBlank(userName)){
@ -411,25 +412,27 @@ public class FontController {
if(StringUtils.isBlank(password)){
return Msg.fail("密码不能为空");
}
//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) {
String result = linkHisLogin(userName, password);
if(StringUtils.isBlank(result)){
return Msg.fail("调用第三方认证失败");
}
List<Power_User> userList = userMapper.checkUserName(userName);
if (CollectionUtils.isEmpty(userList)) {
//2.1不存在往用户表新增这条用户
userVo.setUserName(userName);
// userVo.setUserPwd(Base64.encode(MD5.KL("1C821B22D0402F317E40D93213C66843")));
userVo.setUserPwd(Base64.encode(MD5.KL(password)));
userVo.setUserPwd(Base64.encode(MD5.KL("123456")));
//TODO name从应答的xml解析
String name = analysis(result,"Name");
userVo.setName(name);
userVo.setRoleId(1);
userVo.setDeptId("3");
userVo.setEffective(1);
userVo.setCreater("his");
SimpleDateFormat fmt= new SimpleDateFormat();
SimpleDateFormat fmt= new SimpleDateFormat("yyyy-MM-dd");
userVo.setCreateDate(fmt.format(new Date()));
//插入00
userMapper.insert(userVo);
@ -438,31 +441,81 @@ public class FontController {
return Msg.success().add("token",token);
}
/**
* xmlMap xml"." XML
*
* @param xml
* @param map
* @return
*/
private Map<String, String> parseXml2Map(String xml, Map<String, String> map) {
try {
SAXReader reader = new SAXReader();
Document doc = reader.read(new StringReader(xml));
Element root = doc.getRootElement();
String path = "";
if (map.containsKey(root.getName().trim())) {
path = map.get(root.getName().trim());
map.remove(root.getName().trim());
}
for (Iterator i = root.elementIterator(); i.hasNext();) {
Element element = (Element) i.next();
if (element.isTextOnly()) {
if (path.length() > 0) {
map.put(path + element.getName().trim(), element.getTextTrim());
} else {
map.put(element.getName().trim(), element.getTextTrim());
}
} else {
map.put(element.getName().trim(), path+ element.getName().trim() + ".");
parseXml2Map(element.asXML(), map);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
/**
* resultxmlname
* @param result
* @param name
* @return
*/
private String analysis(String result, String name) {
String nameValue = "";
Map<String,String> map = new HashMap<>();
Map<String, String> valueMap = parseXml2Map(result, map);
nameValue = valueMap.get("Name");
return nameValue;
}
private String linkHisLogin(String userName, String password) {
private boolean linkHisLogin(String userName, String password) {
//创建连接工厂
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
//创建客户端
Object[] objects = new Object[0];
Client client = null;
Client client = dcf.createClient("http://192.168.128.170/csp/hsb/DHC.Published.PUB0025.BS.PUB0025.CLS?WSDL=1");
try {
//医院给的webservice地址
String url = "http://192.168.128.170/csp/hsb/DHC.Published.PUB0025.BS.PUB0025.CLS?WSDL=1";
client = dcf.createClient(url);
// //医院给的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);
objects = client.invoke("HIPManagerInfo","S0110", xmlStr);
//应答信息
String re = objects[0].toString();
System.out.println(re);
String result = objects[0].toString();
System.out.println(result);
//新用户存到数据库
if (re.contains("成功")) {
return true;
if (result.contains("成功")) {
return result;
}
return false;
} catch (Exception e) {
e.printStackTrace();
} finally {
@ -470,20 +523,39 @@ public class FontController {
client.destroy();
}
}
return false;
return null;
}
private String getXml(String userName, String password) {
String Request="<Request> <SourceSystem>"+"嘉时软件"+"" +
"</SourceSystem> <TargetSystem>医院信息平台</TargetSystem> " +
" <username>"+userName+"</username> <password>"+password+"" +
"</password> </Request> ";
private String getXml(String userName, String password) {
return Request;
// 1、创建document对象
Document document = DocumentHelper.createDocument();
// 2、创建根节点rss
Element requestElement = document.addElement("Request");
// Element patInfo = Requst.addElement("PatInfo");
// patInfo.addElement("VUID").setText("12412");
requestElement.addElement("SourceSystem").setText("厦门嘉时");
requestElement.addElement("TargetSystem").setText("医院信息平台");
requestElement.addElement("username").setText(userName);
requestElement.addElement("password").setText(password);
OutputFormat format = OutputFormat.createPrettyPrint();
// 设置编码格式
format.setEncoding("UTF-8");
String xml = document.asXML();
System.out.println(xml);
// String res = service.outHOSREG(xml);
// TBasicWebServiceService serviceService=new TBasicWebServiceService();
// TBasicWebService service = serviceService.getTBasicWebServicePort();
// String res = service.outHOSCAN(xml);
// System.out.println(res);
return document.asXML();
}
}
/**
* getInfosByUserId

@ -34,6 +34,8 @@
<property name="initialSize" value="10"/> <!-- 初始化连接池内的数据库连接-->
</bean>
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown"/>
<!-- ====================== 配置和MyBatis的整合 ======================== -->

@ -9,8 +9,8 @@ TOKEN_EXPIRE_TIME = 3600000
##################################################服务器ip##########################################################
#通用服务器IP与通用服务器端口
SERVER_IP = 192.168.1.3
SERVER_PORT = 8081
SERVER_IP = localhost
SERVER_PORT = 8080
#power权限系统ip
POWER_IP = ${SERVER_IP}
@ -25,7 +25,7 @@ EMRMEDICALRECORD_PORT = 8082
#病案管理系统ip
EMRRECORD_IP = ${SERVER_IP}
#病案管理系统端口
EMRRECORD_PORT = 8083
EMRRECORD_PORT = 8081
#病案复印预约ip
EMRAPPLYCOPY_IP = ${SERVER_IP}

@ -1,5 +1,5 @@
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://192.168.1.3\:3306/nanfang_hospital?useUnicode\=true&characterEncoding\=utf-8
jdbc.url=jdbc:mysql://localhost/nanfang_hospital?useUnicode\=true&characterEncoding\=utf-8
jdbc.username=root
jdbc.password=mamba1998

@ -12,7 +12,8 @@
<typeAliases>
<package name="com.manage.entity"/>
</typeAliases>
<plugins>
<!-- com.github.pagehelper为PageHelper类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageInterceptor">

@ -0,0 +1,32 @@
package com.manage.dao;
public class InvokeParam {
private String url;
private String method;
private String xml;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getXml() {
return xml;
}
public void setXml(String xml) {
this.xml = xml;
}
}

@ -0,0 +1,13 @@
package com.manage.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface WeatherServiceInter {
@WebMethod
public String getWeatherByCityname(String name);
}

@ -0,0 +1,11 @@
package com.manage.service.ipml;
import com.manage.service.WeatherServiceInter;
public class WeatherServiceInterImpl implements WeatherServiceInter {
@Override
public String getWeatherByCityname(String name) {
System.out.println(name+"");
return name+"";
}
}
Loading…
Cancel
Save