Import Java.io.BufferedReader;
Import Java.io.DataOutputStream;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import java.net.HttpURLConnection;
Import java.net.MalformedURLException;
Import Java.net.URL;
Import Javax.servlet.http.HttpServletRequest;
Import Org.springframework.ui.Model;
Import Com.alibaba.fastjson.JSONObject;
public class Httpgbkutf {
public static void Getremoteid () {
String Add_url = "Http://10.20.18.55:8004/open/mhis-fwa-platform/public?access_token=4F429E6F698B4572BE6B4CD5520FFFFB";
String Add_url = "http://10.20.17.22:7001/mhis-fwa-platform/public.do?auth_token= PJOKE9HWJ3QRY86ZTOWNQKKKMAZQFJFU9NOHWHMDINF4MSD23ORZCNZLP3JBC3ESWMDYQY7LT4LTKOJLZMFTSG ";
String Add_url = "Http://10.20.18.55:8004/open/mhis-fwa-platform/public?access_token=4F429E6F698B4572BE6B4CD5520FFFFB";
FWA Direct Connection
String query = "&content=%7b%22advice_details%22:%0a++%5b%7b%22amount%22:10.25,%22dose_day%22:1,%22dose_ Form%22:%22042%22,%22dose_unit%22:%22%22,%22invoice_project%22:%2201%22,%22medical_number%22:0,%22medical_ Specification%22:%221%e5%85%8b%22,%0a++%22price%22:48,%22project_code%22:%22h010102010010006%22,%22project_ name%22:%22%e5%92%aa%e5%94%91%e6%96%af%e6%b1%80%e7%bc%93%e9%87%8a%e7%89%87 (%e7%9a%bf%e6%b2%bb%e6%9e%97)%22,% 22recipe_no%22:%221%22,%22single_dose_number%22:1,%22single_dose_unit%22:%221%22%0a++,%22take_frequence%22:2,% 22take_medical_number%22:1,%22take_medical_unit%22:%22%22,%22use_day%22:1,%22deliver_way%22:%22%22%7d%5d,%0a++ %22diagnoses%22:%0a++%5b%7b%22diagnose_code%22:%22h33.001%22,%22diagnose_desc%22:%22%e5%ad%94%e6%ba%90%e6%80% A7%e8%a7%86%e7%bd%91%e8%86%9c%e8%84%b1%e7%a6%bb%22%7d,%5d,%0a++%22doctor_advice_no%22:%22%22,%22doctor_code%22 :%221234%22,%22doctor_name%22:%22%e6%9d%a8%e8%bf%87%22,%22in_hosp_date%22:%2220141020%22,%22medical_dept_code% 22:%22123456%22,%22Medical_dept_name%22:%22%e6%80%a5%e8%af%8a%e5%86%85%e7%a7%91%22,%0a++%22card_no%22:%22d49752662c%22,%22visit_ no%22:%2200012147%22,%22visit_type%22:%222%22%7d&public_type=audit&temp=2015-11-17t03:02:46.205z ";
Connect via Hub
String query = "&auth_token= pjoke9hwj3qry86ztownqkkkmazqfjfu9nohwhmdinf4msd23orzcnzlp3jbc3eswmdyqy7lt4ltkojlzmftsg&content=%7b% 22advice_details%22:%0a++%5b%7b%22amount%22:10.25,%22dose_day%22:1,%22dose_form%22:%22042%22,%22dose_unit%22:% 22%22,%22invoice_project%22:%2201%22,%22medical_number%22:0,%22medical_specification%22:%221%e5%85%8b%22,%0a++ %22price%22:48,%22project_code%22:%22h010102010010006%22,%22project_name%22:%22%e5%92%aa%e5%94%91%e6%96%af%e6% b1%80%e7%bc%93%e9%87%8a%e7%89%87 (%e7%9a%bf%e6%b2%bb%e6%9e%97)%22,%22recipe_no%22:%221%22,%22single_dose_number %22:1,%22single_dose_unit%22:%221%22%0a++,%22take_frequence%22:2,%22take_medical_number%22:1,%22take_medical_ Unit%22:%22%22,%22use_day%22:1,%22deliver_way%22:%22%22%7d%5d,%0a++%22diagnoses%22:%0a++%5b%7b%22diagnose_code %22:%22h33.001%22,%22diagnose_desc%22:%22%e5%ad%94%e6%ba%90%e6%80%a7%e8%a7%86%e7%bd%91%e8%86%9c%e8%84%b1%e7%a6 %bb%22%7d,%5d,%0a++%22doctor_advice_no%22:%22%22,%22doctor_code%22:%221234%22,%22doctor_name%22:%22%e6%9d%a8%e8%bf%87%22,%22in_hosp_date%22:%2220141020%22,%22medical_dept_code%22:%22123456%22,%22medical_ dept_name%22:%22%e6%80%a5%e8%af%8a%e5%86%85%e7%a7%91%22,%0a++%22card_no%22:%22d49752662c%22,%22visit_no%22:% 2200012147%22,%22visit_type%22:%222%22%7d&public_type=audit&temp=2015-11-17t03:02:46.205z ";
try {
URL url = new URL (add_url);
HttpURLConnection connection = (httpurlconnection) url.openconnection ();
Connection.setdoinput (TRUE);
Connection.setdooutput (TRUE);
Connection.setrequestmethod ("POST");
Connection.setusecaches (FALSE);
Connection.setinstancefollowredirects (TRUE);
Connection.setrequestproperty ("Accept-charset", "GBK");
Connection.setrequestproperty ("Charset", "GBK");
Connection.setrequestproperty ("Content-type", "application/x-www-form-urlencoded");
Connection.connect ();
Jsonobject obj = new Jsonobject ();
query = add_url + query;
String token = "PJOKE9HWJ3QRY86ZTOWNQKKKMAZQFJFU9NOHWHMDINF4MSD23ORZCNZLP3JBC3ESWMDYQY7LT4LTKOJLZMFTSG";
Obj.put ("content", query);
Obj.put ("Auth_token", token);
Obj.put ("Public_type", "Audit");
System.out.println (query);
DataOutputStream out = new DataOutputStream (Connection.getoutputstream ());
Out.writebytes (query);
Out.flush ();
Out.close ();
BufferedReader reader = new BufferedReader (New InputStreamReader (Connection.getinputstream ()));
String lines;
StringBuffer SBF = new StringBuffer ();
while ((lines = Reader.readline ()) = null) {
lines = new String (lines.getbytes ("UTF-8"));
Sbf.append (lines);
}
System.out.println (SBF);
Reader.close ();
Disconnect Connection
Connection.disconnect ();
} catch (Malformedurlexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
public static void Main (string[] args) {
Getremoteid ();
}
}
JSON sends HPPT requests