|
@ -5,19 +5,15 @@ import com.coreframework.remoting.reflect.InvokeRequest;
|
|
|
import com.coreframework.remoting.reflect.Rpc;
|
|
|
import com.yihu.hos.config.Config;
|
|
|
import com.yihu.hos.gateway.control.rpc.IResourceRpc;
|
|
|
import com.yihu.hos.gateway.exception.EHRException;
|
|
|
import com.yihu.hos.gateway.model.RsResourceRpcGateway;
|
|
|
import com.yihu.hos.gateway.model.rpc.RPCRequestResult;
|
|
|
import com.yihu.hos.gateway.model.rpc.RPCResponseResult;
|
|
|
import com.yihu.hos.gateway.util.Constant;
|
|
|
import net.sf.json.JSON;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import net.sf.json.xml.XMLSerializer;
|
|
|
import org.dom4j.Document;
|
|
|
import org.dom4j.Element;
|
|
|
import org.dom4j.io.SAXReader;
|
|
|
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
import javax.xml.bind.Unmarshaller;
|
|
|
import java.io.StringReader;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
@ -117,6 +113,15 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
|
if ("10000".equals(root.element("RespCode"))) {
|
|
|
//xml轉json
|
|
|
JSONObject obj = new JSONObject();
|
|
|
//得到Data节点
|
|
|
Element dataXml= root.element("Data");
|
|
|
//判断data节点是否有从表
|
|
|
List elements=root.elements("Data_1");
|
|
|
if(elements!=null&&elements.size()>0){
|
|
|
for(Object obj1:elements){
|
|
|
Element data1XML=(Element) obj1;
|
|
|
}
|
|
|
}
|
|
|
obj.put(root.getName(), iterateElement(root));
|
|
|
String jsonString = obj.toString();
|
|
|
//調用接口存入mongo
|
|
@ -125,6 +130,11 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* xml轉map
|
|
|
* @param element
|
|
|
* @return
|
|
|
*/
|
|
|
private static Map iterateElement(Element element) {
|
|
|
List jiedian = element.elements();
|
|
|
Element et = null;
|
|
@ -151,4 +161,15 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* xml轉json
|
|
|
* @param xml
|
|
|
* @return
|
|
|
*/
|
|
|
private static String XML2Json(String xml){
|
|
|
XMLSerializer xmlSerializer = new XMLSerializer();
|
|
|
JSON json = xmlSerializer.read(xml);
|
|
|
return json.toString();
|
|
|
}
|
|
|
}
|