|
@@ -1,11 +1,30 @@
|
|
|
package com.zskk.control;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.security.KeyManagementException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
+import org.apache.http.client.ClientProtocolException;
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.jfinal.core.Controller;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
@@ -17,6 +36,9 @@ import com.zskk.model.Studies;
|
|
|
|
|
|
public class ViewController extends Controller {
|
|
|
|
|
|
+ private static final PoolingHttpClientConnectionManager POOL_CM = new PoolingHttpClientConnectionManager();
|
|
|
+ private static final String CAHR_CODE = "UTF-8";
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 在被连接数据库执行sql语句
|
|
@@ -31,6 +53,15 @@ public class ViewController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 在被连接数据库执行sql语句
|
|
|
+ */
|
|
|
+ public void test() {
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("studyuid", "0200355");
|
|
|
+ doPost("http://10.84.138.254:8080/services/getReportByStudyuid?wsdl", params);
|
|
|
+ }
|
|
|
+
|
|
|
public void executeSql2() {
|
|
|
try {
|
|
|
String sqlString = this.getPara("str");
|
|
@@ -113,4 +144,41 @@ public class ViewController extends Controller {
|
|
|
return date;
|
|
|
}
|
|
|
|
|
|
+ private String doPost(String url,Map<String, String> params){
|
|
|
+ StringBuilder apiLog = new StringBuilder();
|
|
|
+ apiLog.append(url).append("\t").append("params:").append(JSON.toJSONString(params));
|
|
|
+ CloseableHttpClient client = HttpClients.custom().setConnectionManager(POOL_CM).build();
|
|
|
+ String content = null;
|
|
|
+ try{
|
|
|
+ HttpPost post = new HttpPost(url);
|
|
|
+ if (params != null){
|
|
|
+ List<NameValuePair> list = new ArrayList<NameValuePair>();
|
|
|
+ for(Map.Entry<String, String> entry: params.entrySet()){
|
|
|
+ list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
|
|
+ }
|
|
|
+ post.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
|
|
|
+ }
|
|
|
+
|
|
|
+ post.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
+ try{
|
|
|
+ response = client.execute(post);
|
|
|
+ int code = response.getStatusLine().getStatusCode();
|
|
|
+ if (code == 200){
|
|
|
+ content = IOUtils.toString(response.getEntity().getContent(), CAHR_CODE);
|
|
|
+ }else{
|
|
|
+ content = "{\"code\":" + code + "}";
|
|
|
+ }
|
|
|
+ }finally{
|
|
|
+ if (response != null){
|
|
|
+ response.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
}
|