增加功能
This commit is contained in:
parent
f41139ea76
commit
dc83412a06
@ -153,48 +153,19 @@ public class CommonImpl implements HISInterfaceService {
|
|||||||
if(method == null || method.equals("") || method.equals("null")){
|
if(method == null || method.equals("") || method.equals("null")){
|
||||||
return new Result("-1","json格式不正确,必须包含method节点");
|
return new Result("-1","json格式不正确,必须包含method节点");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
// 1. 优先查找当前实例自身及父类(直到CommonImpl)中的方法
|
|
||||||
Method targetMethod = findMethodInHierarchy(this.getClass(), method);
|
|
||||||
if (targetMethod != null) {
|
|
||||||
// 执行当前类或父类中的方法(this为当前实例,可能是子类对象)
|
|
||||||
Object result = targetMethod.invoke(this, param);
|
|
||||||
return (Result) result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 若未找到,再查找commonExt中的方法
|
switch (method){
|
||||||
Method extMethod = commonExt.getClass().getMethod(method, String.class);
|
case "sampleaction":
|
||||||
Object extResult = extMethod.invoke(commonExt, param);
|
//危急值接口
|
||||||
return (Result) extResult;
|
return commonExt.sampleaction(param);
|
||||||
}catch (NoSuchMethodException e) {
|
case "getSamplingTime": //采样登记
|
||||||
// 方法不存在的情况
|
return commonExt.getSamplingTime(param);
|
||||||
|
case "getInspectTime": //标本送检
|
||||||
|
return commonExt.getInspectTime(param);
|
||||||
|
default:
|
||||||
return new Result("1","该接口还未实现!",method);
|
return new Result("1","该接口还未实现!",method);
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
// 方法访问权限不足(如private方法)
|
|
||||||
log.error("方法访问权限不足:",e);
|
|
||||||
return new Result("-1", "方法访问失败:" + e.getMessage());
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
// 方法执行过程中抛出异常
|
|
||||||
Throwable targetException = e.getTargetException();
|
|
||||||
log.error("方法执行异常:",e);
|
|
||||||
return new Result("-1", "方法执行异常:" + targetException.getMessage());
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
// 方法返回值不是Result类型
|
|
||||||
return new Result("-1", "方法返回值类型错误");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch (method){
|
|
||||||
// case "sampleaction":
|
|
||||||
// //危急值接口
|
|
||||||
// return commonExt.sampleaction(param);
|
|
||||||
// case "getSamplingTime": //采样登记
|
|
||||||
// return commonExt.getSamplingTime(param);
|
|
||||||
// case "getInspectTime": //标本送检
|
|
||||||
// return commonExt.getInspectTime(param);
|
|
||||||
// default:
|
|
||||||
// return new Result("-1","该接口还未实现!",method);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,13 +12,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SocketUtils {
|
public class SocketUtils {
|
||||||
|
|
||||||
|
|
||||||
public static String socketServerPort;
|
public static String socketServerPort;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动socket
|
* 启动socket
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.czlisinterface.jldermyy.service.impl;
|
package com.czlisinterface.jldermyy.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.XmlUtil;
|
import cn.hutool.core.util.XmlUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.hutool.http.webservice.SoapClient;
|
import cn.hutool.http.webservice.SoapClient;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@ -10,6 +13,7 @@ import com.czlisinterface.system.pojo.ComUsr;
|
|||||||
import com.czlisinterface.system.pojo.LabReqmain;
|
import com.czlisinterface.system.pojo.LabReqmain;
|
||||||
import com.czlisinterface.system.pojo.Result;
|
import com.czlisinterface.system.pojo.Result;
|
||||||
import com.czlisinterface.system.service.impl.CommonImpl;
|
import com.czlisinterface.system.service.impl.CommonImpl;
|
||||||
|
import com.czlisinterface.system.utils.CommonUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@ -18,7 +22,7 @@ import org.w3c.dom.Document;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,66 +38,128 @@ public class Lisinterface_jldermyy extends CommonImpl {
|
|||||||
String postURL;
|
String postURL;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
CommonMapper commonMapper;
|
CommonUtil commonUtil;
|
||||||
@Resource
|
@Resource
|
||||||
HisMapper_jldermyy hisMapperJldermyy;
|
HisMapper_jldermyy hisMapperJldermyy;
|
||||||
|
|
||||||
|
|
||||||
public Result test11(String param){
|
@Override
|
||||||
// log.error("测试一条error日志");
|
public Result invokeHttp(String param) {
|
||||||
// log.debug("debug日志是否也能被记录呢?");
|
Result result = super.invokeHttp(param);
|
||||||
// ComUsr userHISId = commonMapper.getUserHISId("00453");
|
if(!result.equals("1")) return result;
|
||||||
// return new Result("0",userHISId.toString());
|
JSONObject jsonObject = JSONUtil.parseObj(param);
|
||||||
List<LabReqmain> labreqmain = hisMapperJldermyy.getLabreqmain();
|
String method = jsonObject.getStr("method");
|
||||||
return new Result("0",labreqmain.toString());
|
switch (method){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Result("-1","没有找到接口方法!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用his的webservice接口
|
* 调用his的webservice接口
|
||||||
* @param action
|
* @param xmlData
|
||||||
* @param xmlStr
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Result xmlInvoke(String action,String xmlStr){
|
public Result invokeHttpWebService(String xmlData){
|
||||||
String result = "";
|
String ret = null;
|
||||||
try{
|
|
||||||
//String url = "http://172.29.91.236/sj_web_ss/StandardService.asmx?wsdl";
|
|
||||||
SoapClient client = SoapClient.create(postURL)
|
|
||||||
.header("SOAPAction","http://www.bkgtsoft.com/ESB.SoapService.Send")
|
|
||||||
// 设置要请求的方法,此接口方法前缀为web,传入对应的命名空间
|
|
||||||
.setMethod("bkg:Send", "http://www.bkgtsoft.com")
|
|
||||||
.setParam("action",action,true)//此处写true,会自动填写命名空间
|
|
||||||
.setParam("message","<![CDATA["+xmlStr+"]]>",true);
|
|
||||||
|
|
||||||
// log.info("接口地址:{}\n入参:{}",postURL,client.getMsgStr(false));
|
log.info("调用地址:"+postURL);
|
||||||
// 发送请求,参数true表示返回一个格式化后的XML内容
|
//log.info("调用平台接口,入参:"+json);
|
||||||
// 返回内容为XML字符串,可以配合XmlUtil解析这个响应
|
try (HttpResponse httpResponse = HttpRequest.post(postURL)
|
||||||
result = client.send(false);
|
.header("Content-Type", "text/xml;charset=utf-8")
|
||||||
//log.info("webservice返回内容:"+result);
|
.header("SOAPAction","urn:hl7-org:v3/PlatService")
|
||||||
// if(result.contains("<![CDATA[")){
|
.body(xmlData)
|
||||||
// result = result.substring(result.indexOf("<![CDATA[")+9,result.indexOf("]]>"));
|
.execute()) {
|
||||||
// }
|
int status = httpResponse.getStatus();
|
||||||
while(result.contains("<![CDATA[") || result.contains("]]>")){
|
ret = httpResponse.body();
|
||||||
result = result.replace("<![CDATA[","");
|
if(status != 200){
|
||||||
result = result.replace("]]>","");
|
log.error("调用平台接口,入参:{},出参:{}",xmlData,ret);
|
||||||
|
return new Result("-1","调用集成平台的http接口失败:"+ret);
|
||||||
}
|
}
|
||||||
result = result.substring(result.indexOf("<Response>"),result.indexOf("</Response>")+11);
|
|
||||||
// log.info("result:"+result);
|
|
||||||
}catch (Exception ex){
|
|
||||||
log.error("服务标识:{}\r\n入参:{}\r\n出参:{},{}",action,xmlStr,result,ex);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
log.info("服务标识:{}\r\n调用平台接口入参:{}\r\n出参:{}",action,xmlStr,result);
|
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("调用平台接口,入参:{},{}",xmlData,e);
|
||||||
|
return new Result("-1",e.getMessage());
|
||||||
|
}
|
||||||
|
log.info("调用集成平台接口:\r\n入参:"+xmlData+"\r\n出参:"+ret);
|
||||||
|
if(ret.contains("<PlatServiceResult>")){
|
||||||
|
ret = ret.substring(ret.indexOf("<PlatServiceResult>"),ret.indexOf("</PlatServiceResult>")+20);
|
||||||
|
}
|
||||||
//解析出参
|
//解析出参
|
||||||
String resultCode = "";
|
Document doc = XmlUtil.parseXml(ret);
|
||||||
String msg = "";
|
String resTag = String.valueOf(XmlUtil.getByXPath("//Res/MsgHead/ResTag", doc, XPathConstants.STRING));
|
||||||
Document doc = XmlUtil.parseXml(result);
|
String resMsg = String.valueOf(XmlUtil.getByXPath("//Res/MsgHead/ResMsg", doc, XPathConstants.STRING));
|
||||||
|
int resTagInt = -1;
|
||||||
|
try{
|
||||||
|
resTagInt = Integer.parseInt(resTag);
|
||||||
|
}catch (Exception e){
|
||||||
|
return new Result("-1","his返回值转换失败:"+e.getMessage());
|
||||||
|
}
|
||||||
|
if(resTagInt >= 0){
|
||||||
|
return new Result("0","调用接口成功!");
|
||||||
|
}else{
|
||||||
|
return new Result("-1","调用接口失败:"+resMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
public String toXml(String xmlStr11){
|
||||||
|
Map<String, Object> mapHead = new HashMap<>();
|
||||||
|
mapHead.put("SrvId","02004");
|
||||||
|
mapHead.put("ReqSysId","041001-4");
|
||||||
|
mapHead.put("MsgId", UUID.randomUUID());
|
||||||
|
mapHead.put("Dt",commonUtil.currentStringTime());
|
||||||
|
mapHead.put("MsgCheckCode","");
|
||||||
|
mapHead.put("OperateType","1");
|
||||||
|
mapHead.put("Remark","");
|
||||||
|
|
||||||
|
Map<String,Object> applyQryConditionMap = new HashMap<>();
|
||||||
|
applyQryConditionMap.put("UnitId","");
|
||||||
|
applyQryConditionMap.put("VisitType","");
|
||||||
|
applyQryConditionMap.put("PatientNo","");
|
||||||
|
applyQryConditionMap.put("VisitId","");
|
||||||
|
applyQryConditionMap.put("CardNo","");
|
||||||
|
applyQryConditionMap.put("ApplyNo","");
|
||||||
|
applyQryConditionMap.put("ApplyFormType","");
|
||||||
|
applyQryConditionMap.put("PerformDeptId","");
|
||||||
|
applyQryConditionMap.put("DeptId","");
|
||||||
|
applyQryConditionMap.put("WardId","");
|
||||||
|
applyQryConditionMap.put("OrderTimeBegin","");
|
||||||
|
applyQryConditionMap.put("OrderTimeEnd","");
|
||||||
|
applyQryConditionMap.put("AcceptNo","");
|
||||||
|
applyQryConditionMap.put("IncludeExtend","");
|
||||||
|
applyQryConditionMap.put("PerformStatus","");
|
||||||
|
applyQryConditionMap.put("ChargMark","");
|
||||||
|
applyQryConditionMap.put("ChargTimeBegin","");
|
||||||
|
applyQryConditionMap.put("ChargTimeEnd","");
|
||||||
|
applyQryConditionMap.put("OrderClass","001");
|
||||||
|
applyQryConditionMap.put("NurseAduitMark","");
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("MsgHead",mapHead);
|
||||||
|
map.put("ApplyQryCondition",applyQryConditionMap);
|
||||||
|
String xmlStr = XmlUtil.toStr(XmlUtil.mapToXml(map, "Req"), CharsetUtil.UTF_8, false, true);
|
||||||
|
String joinedStr = joinStr(xmlStr);
|
||||||
|
System.out.println("joinedStr:"+joinedStr);
|
||||||
|
Result result = invokeHttpWebService(joinedStr);
|
||||||
|
System.out.println(result);
|
||||||
|
return xmlStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String joinStr(String xmlStr){
|
||||||
|
StringBuffer sbStr = new StringBuffer();
|
||||||
|
sbStr.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:hl7-org:v3\">");
|
||||||
|
sbStr.append("<soapenv:Header/>");
|
||||||
|
sbStr.append("<soapenv:Body>");
|
||||||
|
sbStr.append("<urn:PlatService>");
|
||||||
|
sbStr.append("<urn:message><![CDATA["+xmlStr+"]]></urn:message>");
|
||||||
|
sbStr.append("</urn:PlatService>");
|
||||||
|
sbStr.append("</soapenv:Body>");
|
||||||
|
sbStr.append("</soapenv:Envelope>");
|
||||||
|
|
||||||
|
return sbStr.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>lisinterface_start</name>
|
<name>lisinterface_start</name>
|
||||||
<url>http://maven.apache.org</url>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -71,7 +70,9 @@
|
|||||||
</manifest>
|
</manifest>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<!--MANIFEST.MF 中 Class-Path 加入资源文件目录 -->
|
<!--MANIFEST.MF 中 Class-Path 加入资源文件目录 -->
|
||||||
<Class-Path>./config/</Class-Path>
|
<Class-Path>
|
||||||
|
./config/ liscommon-1.0.jar lisinterface_jldermyy-1.0.jar
|
||||||
|
</Class-Path>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</archive>
|
</archive>
|
||||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
@ -91,6 +92,23 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
|
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
|
||||||
|
<!-- 排除指定的自定义 jar 包(根据 artifactId 排除) -->
|
||||||
|
<excludeArtifactIds>liscommon,lisinterface_jldermyy</excludeArtifactIds>
|
||||||
|
<!-- 可选:如果需要更精确,可结合 groupId 排除(这里两个依赖的 groupId 都是 org.example) -->
|
||||||
|
<!-- <excludeGroupIds>org.example</excludeGroupIds>-->
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<!--打包自定义jar包-->
|
||||||
|
<execution>
|
||||||
|
<id>copy-custom-dependencies</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
<!-- 只包含这两个自定义 jar 包(根据 artifactId 匹配) -->
|
||||||
|
<includeArtifactIds>liscommon,lisinterface_jldermyy</includeArtifactIds>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user