|
@@ -13,6 +13,13 @@ import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
|
|
import com.jfinal.plugin.druid.DruidPlugin;
|
|
import com.jfinal.plugin.druid.DruidPlugin;
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
import com.zskk.model.*;
|
|
import com.zskk.model.*;
|
|
|
|
+
|
|
|
|
+import okhttp3.FormBody;
|
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
|
+import okhttp3.Request;
|
|
|
|
+import okhttp3.RequestBody;
|
|
|
|
+import okhttp3.Response;
|
|
|
|
+
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
@@ -26,6 +33,7 @@ import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
public class ViewController extends Controller {
|
|
public class ViewController extends Controller {
|
|
|
|
+ private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
|
|
|
// static{
|
|
// static{
|
|
// DruidPlugin druidPluginZskk = createZskkDruidPlugin();
|
|
// DruidPlugin druidPluginZskk = createZskkDruidPlugin();
|
|
@@ -182,8 +190,9 @@ public class ViewController extends Controller {
|
|
params.put("data", JSON.toJSONString(data));
|
|
params.put("data", JSON.toJSONString(data));
|
|
//System.out.println(params);
|
|
//System.out.println(params);
|
|
//调用接口
|
|
//调用接口
|
|
- String string2 = sendPost("http://39.106.136.96/pacs/zskk/writePatientReport", params);
|
|
|
|
- string = string + string2 + "*******";
|
|
|
|
|
|
+ String s = post(null, data);
|
|
|
|
+ string = string+s;
|
|
|
|
+
|
|
}
|
|
}
|
|
System.out.println(string);
|
|
System.out.println(string);
|
|
this.renderText(string);
|
|
this.renderText(string);
|
|
@@ -314,7 +323,26 @@ public class ViewController extends Controller {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static String post(String url, Map<String, String> map) throws IOException {
|
|
|
|
+ RequestBody formBody = new FormBody.Builder()
|
|
|
|
+ .add("timestamp", String.valueOf(getSecondTimestamp(new Date())))
|
|
|
|
+ .add("signature", Ksort(map))
|
|
|
|
+ .add("data", JSON.toJSONString(map))
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
+ .url("http://39.106.136.96/pacs/zskk/writePatientReport")
|
|
|
|
+ .post(formBody)
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
|
+ if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
|
|
|
+
|
|
|
|
+ System.out.println(response.body().string());
|
|
|
|
+ return response.body().string();
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
public static String Ksort(Map<String, String> map){
|
|
public static String Ksort(Map<String, String> map){
|
|
String sb = "";
|
|
String sb = "";
|
|
String[] key = new String[map.size()];
|
|
String[] key = new String[map.size()];
|
|
@@ -335,7 +363,6 @@ public class ViewController extends Controller {
|
|
}// 使用常见的UTF-8编码
|
|
}// 使用常见的UTF-8编码
|
|
sb = sb.replace("%3D", "=").replace("%26", "&");
|
|
sb = sb.replace("%3D", "=").replace("%26", "&");
|
|
|
|
|
|
-// System.out.println(sb);
|
|
|
|
String resultString = HashKit.md5(sb+"YgpxjVeIx0yoK6Atz413IAj7hU9dygH4");
|
|
String resultString = HashKit.md5(sb+"YgpxjVeIx0yoK6Atz413IAj7hU9dygH4");
|
|
return resultString;
|
|
return resultString;
|
|
}
|
|
}
|