|  | @ -8,6 +8,8 @@ import com.yihu.hos.config.Config;
 | 
	
		
			
				|  |  | import com.yihu.hos.gateway.control.rpc.IResourceRpc;
 | 
	
		
			
				|  |  | import com.yihu.hos.gateway.model.rpc.RPCResponseResult;
 | 
	
		
			
				|  |  | import com.yihu.hos.gateway.util.Constant;
 | 
	
		
			
				|  |  | import com.yihu.hos.gateway.util.RPCUtil;
 | 
	
		
			
				|  |  | import com.yihu.hos.resource.util.httpclient.HttpClientUtil;
 | 
	
		
			
				|  |  | import net.sf.json.JSON;
 | 
	
		
			
				|  |  | import net.sf.json.JSONObject;
 | 
	
		
			
				|  |  | import net.sf.json.xml.XMLSerializer;
 | 
	
	
		
			
				|  | @ -25,6 +27,7 @@ import java.util.Map;
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | public class ResourceRpcImpl implements IResourceRpc {
 | 
	
		
			
				|  |  |     private DBHelper dbHelper = new DBHelper();
 | 
	
		
			
				|  |  |     private HttpClientUtil httpClientUtil = new HttpClientUtil();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public String transport(String RPCRequestXml) {
 | 
	
	
		
			
				|  | @ -43,11 +46,8 @@ public class ResourceRpcImpl implements IResourceRpc {
 | 
	
		
			
				|  |  |             String trancode = root.element("TransactionCode").toString();
 | 
	
		
			
				|  |  |             if (trancode.equals(Constant.PATIENT_INFORMATION)) {
 | 
	
		
			
				|  |  |                 String cardNo = root.element("Data").element("CardNo").toString();
 | 
	
		
			
				|  |  |                 ;
 | 
	
		
			
				|  |  |                 String cardType = root.element("Data").element("CardType").toString();
 | 
	
		
			
				|  |  |                 ;
 | 
	
		
			
				|  |  |                 String patientId = root.element("Data").element("PatientId").toString();
 | 
	
		
			
				|  |  |                 ;
 | 
	
		
			
				|  |  |                 //查询病人基本信息
 | 
	
		
			
				|  |  |                 patientInformation(cardNo, cardType, patientId);
 | 
	
		
			
				|  |  |             } else if (trancode.equals(Constant.PUSHREPORT)) {
 | 
	
	
		
			
				|  | @ -76,24 +76,32 @@ public class ResourceRpcImpl implements IResourceRpc {
 | 
	
		
			
				|  |  |                         "<PatientId>" + patientId + "</PatientId>" +
 | 
	
		
			
				|  |  |                         "</Data>" +
 | 
	
		
			
				|  |  |                         "</Req>";
 | 
	
		
			
				|  |  |         InvokeRequest r = new InvokeRequest(new Url(Config.ip, Integer.valueOf(Config.port)), Config.clazz, Config.method, String.class);
 | 
	
		
			
				|  |  |         r.setSyncMode();//设置调用模式为同步模式
 | 
	
		
			
				|  |  |         Object s = Rpc.invoke(r);
 | 
	
		
			
				|  |  |         Class[] classes = new Class[]{String.class};
 | 
	
		
			
				|  |  |         Object[] v = new Object[1];
 | 
	
		
			
				|  |  |         v[0] = data;
 | 
	
		
			
				|  |  |         Object s = RPCUtil.getRPCData("report.ReportWs.GetReportInfo", classes, v);
 | 
	
		
			
				|  |  |         //解析xml
 | 
	
		
			
				|  |  |         SAXReader saxReader = new SAXReader();
 | 
	
		
			
				|  |  |         Document document = saxReader.read(s.toString());
 | 
	
		
			
				|  |  |         Element root = document.getRootElement();
 | 
	
		
			
				|  |  |         if ("10000".equals(root.element("RespCode"))) {
 | 
	
		
			
				|  |  |             //xml轉json
 | 
	
		
			
				|  |  |             JSONObject obj = new JSONObject();
 | 
	
		
			
				|  |  |             obj.put(root.getName(), iterateElement(root));
 | 
	
		
			
				|  |  |             String jsonString = obj.toString();
 | 
	
		
			
				|  |  |             JSONObject obj = xml2json(root.element("Data"));
 | 
	
		
			
				|  |  |             //調用接口存入mongo
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |             httpClientUtil.doPost(Config.monogoUrl, params, null, null);
 | 
	
		
			
				|  |  |             //出發採集上傳
 | 
	
		
			
				|  |  |             params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |             httpClientUtil.doPost(Config.startCollect, params, null, null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private JSONObject xml2json(Element root) {
 | 
	
		
			
				|  |  |         JSONObject obj = new JSONObject();
 | 
	
		
			
				|  |  |         obj.put(root.getName(), iterateElement(root));
 | 
	
		
			
				|  |  |         return obj;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //检查检验报告
 | 
	
		
			
				|  |  |     private void pushreport(String reportType, String reportId) throws Exception {
 | 
	
		
			
				|  |  |         String data =
 | 
	
	
		
			
				|  | @ -104,9 +112,10 @@ public class ResourceRpcImpl implements IResourceRpc {
 | 
	
		
			
				|  |  |                         "<ReportType>" + reportType + "</ReportType>" +
 | 
	
		
			
				|  |  |                         "</Data>" +
 | 
	
		
			
				|  |  |                         "</Req>";
 | 
	
		
			
				|  |  |         InvokeRequest r = new InvokeRequest(new Url(Config.ip, Integer.valueOf(Config.port)), Config.clazz, Config.method, String.class);
 | 
	
		
			
				|  |  |         r.setSyncMode();//设置调用模式为同步模式
 | 
	
		
			
				|  |  |         Object s = Rpc.invoke(r);
 | 
	
		
			
				|  |  |         Class[] classes = new Class[]{String.class};
 | 
	
		
			
				|  |  |         Object[] v = new Object[1];
 | 
	
		
			
				|  |  |         v[0] = data;
 | 
	
		
			
				|  |  |         Object s = RPCUtil.getRPCData("report.ReportWs.GetReportInfo", classes, v);
 | 
	
		
			
				|  |  |         //解析xml
 | 
	
		
			
				|  |  |         SAXReader saxReader = new SAXReader();
 | 
	
		
			
				|  |  |         Document document = saxReader.read(s.toString());
 | 
	
	
		
			
				|  | @ -121,13 +130,22 @@ public class ResourceRpcImpl implements IResourceRpc {
 | 
	
		
			
				|  |  |             if (elements != null && elements.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Object obj1 : elements) {
 | 
	
		
			
				|  |  |                     Element data1XML = (Element) obj1;
 | 
	
		
			
				|  |  |                     //調用接口存入mongo
 | 
	
		
			
				|  |  |                     Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |                     httpClientUtil.doPost(Config.monogoUrl, params, null, null);
 | 
	
		
			
				|  |  |                     //出發採集上傳
 | 
	
		
			
				|  |  |                     params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |                     httpClientUtil.doPost(Config.startCollect, params, null, null);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             obj.put(root.getName(), iterateElement(root));
 | 
	
		
			
				|  |  |             String jsonString = obj.toString();
 | 
	
		
			
				|  |  |             //調用接口存入mongo
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |             httpClientUtil.doPost(Config.monogoUrl, params, null, null);
 | 
	
		
			
				|  |  |             //出發採集上傳
 | 
	
		
			
				|  |  |             params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |             httpClientUtil.doPost(Config.startCollect, params, null, null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 |