Sfoglia il codice sorgente

增加报告回写接口

刘韬 3 anni fa
parent
commit
f54e24e306

+ 5 - 1
DataFusion/res/config.properties

@@ -4,4 +4,8 @@ jdbcUrl_connected  = jdbc:sqlserver://172.17.2.100:1433;DatabaseName=healthone
 user_connected 	   = yunpacs
 password_connected = Yun@pacs.163.com
 #DATA-Parms
-institution_id     = 41000009
+institution_id     = 41000009
+jdbcUrl_local  = jdbc:sqlserver://172.17.2.100:1433;DatabaseName=healthone
+#jdbcUrl_connected  = jdbc:oracle:thin:@192.168.100.4:1521:pacs
+user_local 	   = yunpacs
+password_local = Yun@pacs.163.com

+ 11 - 1
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -57,20 +57,30 @@ public class ZskkConfig extends JFinalConfig {
 	}
 
 	public static DruidPlugin createConnectedDruidPlugin() {
-
 		return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
 	}
+	
+	public static DruidPlugin createLocalDruidPlugin() {
+		return new DruidPlugin(PropKit.get("jdbcUrl_local"), PropKit.get("user_local"),PropKit.get("password_local").trim());
+	}
 
 	@Override
 	public void configPlugin(Plugins me) {
 		// 配置数据库连接池插件
 		DruidPlugin druidPluginConnected = createConnectedDruidPlugin();
 		me.add(druidPluginConnected);
+		
+		DruidPlugin druidPluginLocal = createLocalDruidPlugin();
+		me.add(druidPluginLocal);
 
 		// 配置ActiveRecord插件
 		ActiveRecordPlugin arpConnected = new ActiveRecordPlugin("connected", druidPluginConnected);
 		arpConnected.setDialect(new SqlServerDialect());
 		me.add(arpConnected);
+		
+		ActiveRecordPlugin arpLocal = new ActiveRecordPlugin("local", druidPluginLocal);
+		arpLocal.setDialect(new MysqlDialect());
+		me.add(arpLocal);
 
 		Cron4jPlugin cpData = new Cron4jPlugin();
 		cpData.addTask("*/5 * * * *", new DataTask());

+ 5 - 0
DataFusion/src/com/zskk/control/ViewController.java

@@ -32,8 +32,13 @@ public class ViewController extends Controller {
 	 * 在被连接数据库执行sql语句
 	 */
 	public void executeSql() {
+		try {
 		List<Record> d = Db.use("connected").find(this.getPara("sqlstr"));
 		this.renderJson(d);
+		} catch (Exception e) {
+			// TODO: handle exception
+			this.renderText(e.toString());
+		}
 	}
 
 	public void testConn() {

+ 9 - 0
DataFusion/src/com/zskk/service/DataService.java

@@ -25,6 +25,8 @@ public class DataService {
     private static String UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
     
     private static String FEE_URL = "https://risserver3.pacsonline.cn/film/callback";
+    
+    private static String GET_REPORT_URL = "https://risserver3.pacsonline.cn/butt/getNotInsReport";
 	
     private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
     
@@ -77,6 +79,13 @@ public class DataService {
     	postWithJson(FEE_URL, jsonObject);
     }
     
+    /*
+     * 医院代收
+     */
+    public void getReport(Map<String, String> map) {
+    	postWithParameters(GET_REPORT_URL, map);
+    }
+    
     public static String postWithParameters(String url, Map<String, String> map) {
     	
     	FormBody.Builder formbody = new FormBody.Builder();

+ 140 - 0
DataFusion/src/com/zskk/service/InsertService.java

@@ -0,0 +1,140 @@
+package com.zskk.service;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jfinal.kit.PropKit;
+
+import okhttp3.FormBody;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
+public class InsertService {
+	
+    private static String GET_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getExam";
+    
+    private static String SAVE_REPORT_URL = "https://risserver3.pacsonline.cn/butt/saveReport";
+    
+    private static String UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
+    
+    private static String FEE_URL = "https://risserver3.pacsonline.cn/film/callback";
+    
+    private static String GET_REPORT_URL = "https://risserver3.pacsonline.cn/butt/getNotInsReport";
+	
+    private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
+    
+	private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8");
+
+    
+    /**
+     * 获取未出报告的检查列表
+     * @param instutionId
+     * @param number
+     */
+    public JSONArray getExamList(Integer number) {
+    	Map <String,String> map = new HashMap<String,String>();
+    	map.put("institution_id", PropKit.get("institution_id"));
+    	map.put("num", number.toString());
+		String content = postWithParameters(GET_EXAM_URL, map);
+	    JSONObject jsonObject = JSON.parseObject(content);
+	    if (!jsonObject.getString("msg").equals("success")) {
+			return null;
+		}
+		JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));		
+		return jsonArray;
+		
+	}
+    
+    /**
+     * 写入报告
+     * @param instutionId
+     * @param number
+     */
+    public void saveReport(Map <String,String> map) {
+		postWithParameters(SAVE_REPORT_URL, map);
+		
+	}
+    
+    /**
+    * 更新患者信息
+    * 
+    * @param instutionId
+    * @param number
+    */
+    public void updatePatientInfo(Map<String, String> map) {
+    postWithParameters(UPDATE_PATIENT_URL, map);
+    }
+    
+    /*
+     * 医院代收
+     */
+    public void fee(JSONObject jsonObject) {
+    	postWithJson(FEE_URL, jsonObject);
+    }
+    
+    /*
+     * 医院代收
+     */
+    public void getReport(Map<String, String> map) {
+    	postWithParameters(GET_REPORT_URL, map);
+    }
+    
+    public static String postWithParameters(String url, Map<String, String> map) {
+    	
+    	FormBody.Builder formbody = new FormBody.Builder();
+    	
+    	for (Map.Entry<String, String> entry : map.entrySet()) {
+    		formbody.add(entry.getKey(), entry.getValue());
+		}
+		RequestBody requestBody = formbody.build();
+		
+		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();
+		      return content;
+		    } catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				return null;
+			}	
+	}
+    
+    public String postWithJson(String url, JSONObject jsonObject) {
+
+		RequestBody requestBody = RequestBody.create(JSON_TYPE, 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 void main(String[] args) {
+    	Map <String,String> map = new HashMap<String,String>();
+    	map.put("institution_id", "47600001");
+    	map.put("num", "10");
+		postWithParameters(GET_EXAM_URL, map);
+	}
+
+}