刘韬 2 år sedan
förälder
incheckning
5378641600

+ 2 - 2
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -70,8 +70,8 @@ public class ZskkConfig extends JFinalConfig {
 	@Override
 	public void configPlugin(Plugins me) {
 		// 配置数据库连接池插件
-//		DruidPlugin druidPluginConnected = createConnectedDruidPlugin();
-//		me.add(druidPluginConnected);
+		DruidPlugin druidPluginConnected = createConnectedDruidPlugin();
+		me.add(druidPluginConnected);
 		
 		DruidPlugin druidPluginLocal = createLocalDruidPlugin();
 		me.add(druidPluginLocal);

+ 43 - 1
DataFusion/src/com/zskk/control/ViewController.java

@@ -7,6 +7,8 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.alibaba.fastjson.JSONObject;
 import com.jfinal.core.Controller;
 import com.jfinal.kit.PropKit;
 import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
@@ -24,7 +26,7 @@ import okhttp3.Response;
 
 public class ViewController extends Controller {
 
-	private static final MediaType JSON_CODE = MediaType.get("application/json; charset=utf-8");
+	private static final MediaType JSON_CODE = MediaType.get("application/json");
 
 	private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
 
@@ -76,6 +78,46 @@ public class ViewController extends Controller {
 		}
 	}
 	
+	public void testWeb() {
+		try {
+	        JSONObject jsonObject = new JSONObject();
+	        jsonObject.put("functionCode", "queryPatByPatId");
+	        jsonObject.put("userid", "1301");
+	        JSONObject jsonObject2 = new JSONObject();
+	        jsonObject2.put("pattoken", "appuserrequest");
+	        jsonObject2.put("hispatid", this.getPara("hpid"));
+	        jsonObject.put("data", jsonObject2);
+
+//			String c=postWithJson(this.getPara("hpid")"http://192.168.100.181:8102/api/tjwebapi/CommQuery",jsonObject);
+			String c=postWithJson(this.getPara("url","http://192.168.100.181:8102/api/tjwebapi/CommQuery"),jsonObject);
+
+	        this.renderText(c);
+
+		} catch (Exception e) {
+			// TODO: handle exception
+			this.renderText(e.toString());
+		}
+	}
+	
+	public String postWithJson(String url, JSONObject jsonObject) {
+
+		RequestBody requestBody = RequestBody.create(JSON_CODE, jsonObject.toJSONString());
+
+		Request request = new Request.Builder().url(url).post(requestBody).build();
+
+		try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+			if (!response.isSuccessful())
+				throw new IOException("Unexpected code " + response);
+			String content = response.body().string();
+			System.out.println(content);
+			return content;
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+	}
+	
 	public static DruidPlugin createConnectedDruidPlugin2(String url,String name,String pass) {
 
 		return new DruidPlugin(url, name,pass.trim());