|
|
|
@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
@ -69,9 +71,15 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.xml.bind.JAXBException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 安溪县医院对接物资系统Client
|
|
|
|
@ -136,24 +144,25 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
*/
|
|
|
|
|
public String getMsgHeader(String methodName) {
|
|
|
|
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
|
|
|
|
"<root>" +
|
|
|
|
|
"<serverName>" + methodName + "</serverName>" +
|
|
|
|
|
"<format>" + "xml" + "</format>" +
|
|
|
|
|
"<callOperator>" + "" + "</callOperator>" +
|
|
|
|
|
"<certificate>" + "ousrgPVbTpn7ckRUZWypfBR7tGWi2EINBp4vIHOS44V/jN3U5dD+5A==" + "</certificate>" +
|
|
|
|
|
"<root>\n" +
|
|
|
|
|
"<serverName>" + methodName + "</serverName>\n" +
|
|
|
|
|
"<format>" + "xml" + "</format>\n" +
|
|
|
|
|
"<callOperator>" + "" + "</callOperator>\n" +
|
|
|
|
|
"<certificate>" + "ousrgPVbTpn7ckRUZWypfBR7tGWi2EINBp4vIHOS44V/jN3U5dD+5A==" + "</certificate>\n" +
|
|
|
|
|
"</root>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String setFilter() {
|
|
|
|
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
|
|
|
|
"<root>" +
|
|
|
|
|
// "<code>" + "" + "</code>" +
|
|
|
|
|
"<name>" + "红细胞寿命测定-呼气法" + "</name>" +
|
|
|
|
|
// "<spell>" + "" + "</spell>" +
|
|
|
|
|
// "<invalid>" + "" + "</invalid>" +
|
|
|
|
|
// "<subject>" + "" + "</subject>" +
|
|
|
|
|
"<root>\n" +
|
|
|
|
|
// "<code>" + "" + "</code>\n" +
|
|
|
|
|
"<name>" + "红细胞寿命测定-呼气法" + "</name>\n" +
|
|
|
|
|
// "<spell>" + "" + "</spell>\n" +
|
|
|
|
|
// "<invalid>" + "" + "</invalid>\n" +
|
|
|
|
|
// "<subject>" + "" + "</subject>\n" +
|
|
|
|
|
"</root>";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -947,26 +956,58 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
|
|
|
|
|
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
|
|
|
|
|
CtqyyRequest ctqyyRequest = new CtqyyRequest();
|
|
|
|
|
String getPriceDict = getMsgHeader("getPriceDict");
|
|
|
|
|
String s = setFilter();
|
|
|
|
|
log.error("DANGQIAN 请求头:::" + getPriceDict);
|
|
|
|
|
log.error("DANGQIAN 请求体:::" + s);
|
|
|
|
|
ctqyyRequest.setMsgHeader(getMsgHeader("getPriceDict"));
|
|
|
|
|
ctqyyRequest.setMsgBody(setFilter());
|
|
|
|
|
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_PROJECT), ctqyyRequest);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
List<PriceDict> priceDicts = JAXBUtil.unmarshalAndGetList(ProductVo.class, PriceDict.class, response);
|
|
|
|
|
log.error("获取到 智业返回产品信息:::::::::::::::::::::" + priceDicts);
|
|
|
|
|
String response = callInterface(getMsgHeader("getPriceDict"), setFilter());
|
|
|
|
|
System.out.println("Response: " + response);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("解析安溪县医院智业返回项目信息数据异常,返回结果:{}", response);
|
|
|
|
|
log.error("解析安溪县医院智业返回项目信息数据异常,返回结果:{}", e);
|
|
|
|
|
log.error("异常信息:{}", e);
|
|
|
|
|
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String callInterface(String msgHeader, String msgBody) throws Exception {
|
|
|
|
|
URL url = new URL("http://173.19.192.196:8882/OTHER/BtmsEntranceWs?wsdl");
|
|
|
|
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
connection.setRequestMethod("POST");
|
|
|
|
|
connection.setRequestProperty("Content-Type", "application/xml");
|
|
|
|
|
connection.setDoOutput(true);
|
|
|
|
|
|
|
|
|
|
String requestBody = "<request>\n" +
|
|
|
|
|
" <msgHeader>" + msgHeader + "</msgHeader>\n" +
|
|
|
|
|
" <msgBody>" + msgBody + "</msgBody>\n" +
|
|
|
|
|
"</request>";
|
|
|
|
|
|
|
|
|
|
try (OutputStream os = connection.getOutputStream()) {
|
|
|
|
|
byte[] input = requestBody.getBytes("utf-8");
|
|
|
|
|
os.write(input, 0, input.length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int responseCode = connection.getResponseCode();
|
|
|
|
|
|
|
|
|
|
log.error("Response Code: " + responseCode);
|
|
|
|
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
|
|
// 读取响应
|
|
|
|
|
java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream()).useDelimiter("\\A");
|
|
|
|
|
String response = scanner.hasNext() ? scanner.next() : "";
|
|
|
|
|
log.error("Response Body: " + response);
|
|
|
|
|
return scanner.hasNext() ? scanner.next() : "";
|
|
|
|
|
} else {
|
|
|
|
|
log.error("HTTP error code : " + responseCode);
|
|
|
|
|
throw new RuntimeException("HTTP error code : " + responseCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public String parserResult(String response) {
|
|
|
|
|
// if (response.contains("<root")) {
|
|
|
|
|
// try {
|
|
|
|
@ -984,4 +1025,6 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|