|
|
|
@ -16,6 +16,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
|
|
import com.glxp.mipsdl.client.CommonHttpClient;
|
|
|
|
|
import com.glxp.mipsdl.config.ThirdSysConfig;
|
|
|
|
|
import com.glxp.mipsdl.constant.ConstantType;
|
|
|
|
@ -30,6 +33,7 @@ import com.glxp.mipsdl.dao.inout.IoOrderDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
|
|
|
|
|
import com.glxp.mipsdl.dao.thrsys.*;
|
|
|
|
|
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.axxyy.PriceDict;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
|
|
|
|
@ -42,7 +46,6 @@ import com.glxp.mipsdl.entity.thrsys.*;
|
|
|
|
|
import com.glxp.mipsdl.http.HttpClient;
|
|
|
|
|
import com.glxp.mipsdl.req.base.*;
|
|
|
|
|
import com.glxp.mipsdl.req.base.forthird.*;
|
|
|
|
|
import com.glxp.mipsdl.req.ctqyy.CtqyyRequest;
|
|
|
|
|
import com.glxp.mipsdl.req.ctqyy.DlThirdProjectRequest;
|
|
|
|
|
import com.glxp.mipsdl.req.ctqyy.GetSickRequest;
|
|
|
|
|
import com.glxp.mipsdl.req.njxyy.PostThrProductRequest;
|
|
|
|
@ -61,21 +64,20 @@ import com.glxp.mipsdl.thirddao.njxyy.ThrCorpMapper;
|
|
|
|
|
import com.glxp.mipsdl.thirddao.njxyy.ThrProductsMapper;
|
|
|
|
|
import com.glxp.mipsdl.thirddao.njxyy.ThrSickerMapper;
|
|
|
|
|
import com.glxp.mipsdl.util.*;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import okhttp3.*;
|
|
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
import org.xml.sax.InputSource;
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
|
|
import javax.xml.bind.JAXBException;
|
|
|
|
|
import javax.xml.bind.Unmarshaller;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
@ -88,11 +90,7 @@ import javax.xml.transform.stream.StreamResult;
|
|
|
|
|
;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -151,7 +149,6 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
ThrSickerMapper thrSickerMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拼接xml请求头
|
|
|
|
|
*
|
|
|
|
@ -173,7 +170,7 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
|
|
|
|
"<root>\n" +
|
|
|
|
|
"<code>" + "" + "</code>\n" +
|
|
|
|
|
"<name>红细胞寿命测定-呼气法</name>\n" +
|
|
|
|
|
"<name>红细胞</name>\n" +
|
|
|
|
|
"<spell>" + "" + "</spell>\n" +
|
|
|
|
|
"<invalid>" + "" + "</invalid>\n" +
|
|
|
|
|
"<subject>" + "" + "</subject>\n" +
|
|
|
|
@ -184,40 +181,17 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
|
|
|
|
|
private static String buildSoapRequest(String msgHeader, String msgBody) {
|
|
|
|
|
// 构建 SOAP 请求消息
|
|
|
|
|
// String soapRequestTemplate =
|
|
|
|
|
// "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:zys=\"http://www.zysoft.com.cn/\">\n" +
|
|
|
|
|
// "<soapenv:Header/>\n" +
|
|
|
|
|
// " <soapenv:Body>\n" +
|
|
|
|
|
// " <zys:CallInterface>\n" +
|
|
|
|
|
// " <zys:msgHeader><![CDATA[%s]]></zys:msgHeader>\n" +
|
|
|
|
|
// " <zys:msgBody><![CDATA[%s]]></zys:msgBody>\n" +
|
|
|
|
|
// " </zys:CallInterface>\n" +
|
|
|
|
|
// " </soapenv:Body>\n" +
|
|
|
|
|
// "</soapenv:Envelope>";
|
|
|
|
|
String soapRequestTemplate = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:zys=\"http://www.zysoft.com.cn/\">\n" +
|
|
|
|
|
String soapRequestTemplate =
|
|
|
|
|
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:zys=\"http://www.zysoft.com.cn/\">\n" +
|
|
|
|
|
"<soapenv:Header/>\n" +
|
|
|
|
|
" <soapenv:Body>\n" +
|
|
|
|
|
" <zys:CallInterface>\n" +
|
|
|
|
|
" <zys:msgHeader><![CDATA[<root>\n" +
|
|
|
|
|
" <serverName>getPriceDict</serverName>\n" +
|
|
|
|
|
" <format>xml</format>\n" +
|
|
|
|
|
" <callOperator></callOperator>\n" +
|
|
|
|
|
" <certificate>ousrgPVbTpn7ckRUZWypfBR7tGWi2EINBp4vIHOS44V/jN3U5dD+5A==</certificate>\n" +
|
|
|
|
|
" </root>]]>\n" +
|
|
|
|
|
"</zys:msgHeader>\n" +
|
|
|
|
|
"<zys:msgBody><![CDATA[\t\n" +
|
|
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
|
|
|
|
"<root>\n" +
|
|
|
|
|
"<name>红细胞寿命测定-呼气法</name>\n" +
|
|
|
|
|
"</root>]]>\n" +
|
|
|
|
|
"</zys:msgBody>\n" +
|
|
|
|
|
" <zys:msgHeader><![CDATA[%s]]></zys:msgHeader>\n" +
|
|
|
|
|
" <zys:msgBody><![CDATA[%s]]></zys:msgBody>\n" +
|
|
|
|
|
" </zys:CallInterface>\n" +
|
|
|
|
|
" </soapenv:Body>\n" +
|
|
|
|
|
"</soapenv:Envelope>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return String.format(soapRequestTemplate, msgHeader, msgBody);
|
|
|
|
|
return soapRequestTemplate;
|
|
|
|
|
return String.format(soapRequestTemplate, msgHeader, msgBody);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1014,9 +988,17 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
|
|
|
|
|
try {
|
|
|
|
|
// 发送请求
|
|
|
|
|
BaseResponse response = callInterface(getMsgHeader("getPriceDict"), setFilter());
|
|
|
|
|
// 记录日志
|
|
|
|
|
log.error("获取智业收费项目222: " + response);
|
|
|
|
|
String response = callInterface(getMsgHeader("getPriceDict"), setFilter());
|
|
|
|
|
String xml = getXml(response);
|
|
|
|
|
if (xml == null){
|
|
|
|
|
return ResultVOUtils.error(500,"获取项目字典错误");
|
|
|
|
|
}
|
|
|
|
|
DataVo dataVo = getDataVo(xml);
|
|
|
|
|
if (dataVo.getCode() != 0){
|
|
|
|
|
return ResultVOUtils.error(500,"获取项目字典错误");
|
|
|
|
|
}
|
|
|
|
|
List<PriceDict> list = dataVo.getList(PriceDict.class);
|
|
|
|
|
log.error("最终获取的收费项目: " + list);
|
|
|
|
|
// log.error("获取智业收费项目:::::: " + response);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("获取智业收费项目失败" );
|
|
|
|
@ -1026,21 +1008,19 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final String WSDL_URL = "http://173.19.192.196:8882/OTHER/BtmsEntranceWs?wsdl";
|
|
|
|
|
|
|
|
|
|
public BaseResponse callInterface(String msgHeader, String msgBody) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
private static final String WSDL_URL = "http://173.19.192.196:8882/OTHER/BtmsEntranceWs?wsdl";
|
|
|
|
|
|
|
|
|
|
public String callInterface(String msgHeader, String msgBody) {
|
|
|
|
|
try {
|
|
|
|
|
// 构建请求头
|
|
|
|
|
Map<String, String> headers = Map.of(
|
|
|
|
|
"Content-Type", "text/xml;charset=utf-8",
|
|
|
|
|
"SOAPAction","http://www.zysoft.com.cn/CallInterface"
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
// 注意:这里我们实际上是在构建一个表单体,而不是直接发送XML或JSON
|
|
|
|
|
// 因此,我们需要对msgHeader和msgBody进行URL编码,并将它们作为表单字段发送
|
|
|
|
|
String postData = buildSoapRequest(null,null);
|
|
|
|
|
String postData = buildSoapRequest(msgHeader,msgBody);
|
|
|
|
|
|
|
|
|
|
HttpRequest request = HttpRequest.post(WSDL_URL)
|
|
|
|
|
.addHeaders(headers)
|
|
|
|
@ -1050,18 +1030,14 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
String xml = xmlResponse.body();
|
|
|
|
|
// 假设 XML 解析到的 JSON 字符串部分
|
|
|
|
|
log.error("获取智业收费项目999:" + xml);
|
|
|
|
|
return ResultVOUtils.error(500, xml);
|
|
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("获取智业收费项目失败===" + e.getMessage());
|
|
|
|
|
return ResultVOUtils.error(500, "获取智业收费项目失败===" + e.getMessage());
|
|
|
|
|
throw new RuntimeException("获取智业收费项目失败===" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String soapXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><zys:CallInterfaceResponse xmlns:zys=\"http://www.zysoft.com.cn/\">" +
|
|
|
|
|
" <zys:payload><?xml version=\"1.0\" encoding=\"utf-8\"?><root><code>0</code><data><lists><code>023050000701</code><name>红细胞寿命测定-呼气法</name><unit>次</unit><price>245</price><spell>HXBSMCDHQF</spell><valid>Y</valid><sequence></sequence><std_code>23050000701</std_code><subject>D</subject><subjectname>化验</subjectname><dispreceipt>FJ15</dispreceipt><dispreceiptname>化验费</dispreceiptname><resireceipt>FJ15</resireceipt><resireceiptname>化验费</resireceiptname><starttime>20190412000000</starttime><stoptime></stoptime><modifytime>20190505170000</modifytime><modifyoperator>SYSTEM3</modifyoperator><item_connotation>红细胞寿命测定-呼气法</item_connotation><except_content></except_content><country_code>002305000070000-23050000701</country_code><org_stdcode></org_stdcode></lists></data></root></zys:payload>" +
|
|
|
|
|
"</zys:CallInterfaceResponse></soapenv:Body></soapenv:Envelope>";
|
|
|
|
|
public String getXml(String soapXml) {
|
|
|
|
|
try {
|
|
|
|
|
// 提取 <zys:payload> 中的内容
|
|
|
|
|
int payloadStart = soapXml.indexOf("<zys:payload>") + "<zys:payload>".length();
|
|
|
|
@ -1088,33 +1064,31 @@ public class AxxyyClient extends CommonHttpClient {
|
|
|
|
|
transformer.transform(new DOMSource(doc), new StreamResult(writer));
|
|
|
|
|
String standardXml = writer.toString();
|
|
|
|
|
|
|
|
|
|
// 处理空标签,将 <tag/> 替换为 <tag></tag>
|
|
|
|
|
Pattern pattern = Pattern.compile("<([^/][^>]*)\\s*/>");
|
|
|
|
|
Matcher matcher = pattern.matcher(standardXml);
|
|
|
|
|
String resultXml = matcher.replaceAll("<$1></$1>");
|
|
|
|
|
|
|
|
|
|
// 输出标准 XML
|
|
|
|
|
System.out.println(resultXml);
|
|
|
|
|
|
|
|
|
|
log.error("解析后的数据" + resultXml);
|
|
|
|
|
return resultXml;
|
|
|
|
|
} catch (ParserConfigurationException | SAXException | TransformerException | IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
private static String formatXML(Document doc) throws TransformerException {
|
|
|
|
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
|
|
|
|
Transformer transformer = transformerFactory.newTransformer();
|
|
|
|
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
|
|
|
|
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
|
|
|
|
|
|
|
|
|
DOMSource source = new DOMSource(doc);
|
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
|
StreamResult result = new StreamResult(writer);
|
|
|
|
|
|
|
|
|
|
transformer.transform(source, result);
|
|
|
|
|
|
|
|
|
|
return writer.toString();
|
|
|
|
|
public DataVo getDataVo(String xml){
|
|
|
|
|
try {
|
|
|
|
|
XmlMapper xmlMapper = new XmlMapper();
|
|
|
|
|
JsonNode xmlNode = xmlMapper.readTree(xml.getBytes());
|
|
|
|
|
// 创建 JSON 映射器
|
|
|
|
|
ObjectMapper jsonMapper = new ObjectMapper();
|
|
|
|
|
String json = jsonMapper.writeValueAsString(xmlNode);
|
|
|
|
|
DataVo dataVo = JSONUtil.toBean(json,DataVo.class);
|
|
|
|
|
return dataVo;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|