|
@@ -10,7 +10,6 @@ import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -28,145 +27,145 @@ import okhttp3.Response;
|
|
|
import okhttp3.ResponseBody;
|
|
|
|
|
|
public class DataService {
|
|
|
-
|
|
|
- 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 GET_CONFIRM_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getConfirmExam";
|
|
|
-
|
|
|
- private static String UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
|
|
|
-
|
|
|
- private static String RETURN_BIND_URL = "https://risserver3.pacsonline.cn/butt/getBindInfo";
|
|
|
-
|
|
|
- private static String SAVE_ANNEX_URL = "https://risserver3.pacsonline.cn/butt/saveAnnex";
|
|
|
-
|
|
|
- private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
-
|
|
|
- private static final OSS OSS_CLIENT = new OSSClientBuilder().build(PropKit.get("oss_endpoint"), PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
|
|
|
- /**
|
|
|
- * 获取未出报告的检查列表
|
|
|
- * @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());
|
|
|
+
|
|
|
+ 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 GET_CONFIRM_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getConfirmExam";
|
|
|
+
|
|
|
+ private static String UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
|
|
|
+
|
|
|
+ private static String RETURN_BIND_URL = "https://risserver3.pacsonline.cn/butt/getBindInfo";
|
|
|
+
|
|
|
+ private static String SAVE_ANNEX_URL = "https://risserver3.pacsonline.cn/butt/saveAnnex";
|
|
|
+
|
|
|
+ private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
+
|
|
|
+ private static final OSS OSS_CLIENT = new OSSClientBuilder().build(PropKit.get("oss_endpoint"),
|
|
|
+ PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未出报告的检查列表
|
|
|
+ *
|
|
|
+ * @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")) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ if (!jsonObject.getString("msg").equals("success")) {
|
|
|
return null;
|
|
|
}
|
|
|
- JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
return jsonArray;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- public JSONArray getExamListConfirmed(Integer number) {
|
|
|
- Map <String,String> map = new HashMap<String,String>();
|
|
|
- map.put("institution_id", PropKit.get("institution_id"));
|
|
|
- map.put("num", number.toString());
|
|
|
+
|
|
|
+ public JSONArray getExamListConfirmed(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_CONFIRM_EXAM_URL, map);
|
|
|
- JSONObject jsonObject = JSON.parseObject(content);
|
|
|
- if (!jsonObject.getString("msg").equals("success")) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ if (!jsonObject.getString("msg").equals("success")) {
|
|
|
return null;
|
|
|
}
|
|
|
- JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
return jsonArray;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- public JSONArray getBindList(String start,String finish) {
|
|
|
- Map <String,String> map = new HashMap<String,String>();
|
|
|
- map.put("institution_id", PropKit.get("institution_id"));
|
|
|
- map.put("start", start);
|
|
|
- map.put("finish", finish);
|
|
|
+
|
|
|
+ public JSONArray getBindList(String start, String finish) {
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ map.put("start", start);
|
|
|
+ map.put("finish", finish);
|
|
|
String content = getWithUrl(RETURN_BIND_URL, map);
|
|
|
- JSONObject jsonObject = JSON.parseObject(content);
|
|
|
- if (!jsonObject.getString("msg").equals("success")) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ if (!jsonObject.getString("msg").equals("success")) {
|
|
|
return null;
|
|
|
}
|
|
|
- JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
return jsonArray;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 写入报告
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public String saveReport(Map <String,String> map) {
|
|
|
- String content = postWithParameters(SAVE_REPORT_URL, map);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 写入报告
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public String saveReport(Map<String, String> map) {
|
|
|
+ String content = postWithParameters(SAVE_REPORT_URL, map);
|
|
|
return content;
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新患者信息
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public void updatePatientInfo(Map<String, String> map) {
|
|
|
+ postWithParameters(UPDATE_PATIENT_URL, map);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新患者信息
|
|
|
- *
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public void updatePatientInfo(Map<String, String> map) {
|
|
|
- postWithParameters(UPDATE_PATIENT_URL, map);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存附件
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public void saveAnnex(Map <String,String> map, String filePath) {
|
|
|
- String fileNameStr[] = filePath.split("/");
|
|
|
- String fileName = fileNameStr[fileNameStr.length-1];
|
|
|
- String fileStorePath =getFileWithUrl(filePath, fileName);
|
|
|
- File file =new File(fileStorePath);
|
|
|
- String key = PropKit.get("institution_id")+"/"+fileName;
|
|
|
-
|
|
|
- Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (!eBoolean) {
|
|
|
- OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, file);
|
|
|
- Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
- if (bBoolean) {
|
|
|
- file.delete();
|
|
|
- map.put("url", "https://zskk-image.oss-cn-beijing.aliyuncs.com/"+key);
|
|
|
- map.put("name", key);
|
|
|
- postWithParameters(SAVE_ANNEX_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());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存附件
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+// public void saveAnnex(Map<String, String> map, String filePath) {
|
|
|
+// String fileNameStr[] = filePath.split("/");
|
|
|
+// String fileName = fileNameStr[fileNameStr.length - 1];
|
|
|
+// String fileStorePath = getFileWithUrl(filePath, fileName);
|
|
|
+// File file = new File(fileStorePath);
|
|
|
+// String key = PropKit.get("institution_id") + "/" + fileName;
|
|
|
+//
|
|
|
+// Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (!eBoolean) {
|
|
|
+// OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, file);
|
|
|
+// Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+// if (bBoolean) {
|
|
|
+// file.delete();
|
|
|
+// map.put("url", "https://zskk-image.oss-cn-beijing.aliyuncs.com/" + key);
|
|
|
+// map.put("name", key);
|
|
|
+// postWithParameters(SAVE_ANNEX_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;
|
|
|
- }
|
|
|
+
|
|
|
+ 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 static String getWithUrl(String url, Map<String, String> map) {
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
String s = url.contains("?") ? "&" : "?";
|
|
@@ -187,48 +186,47 @@ public class DataService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-public static String getFileWithUrl(String url, String filename) {
|
|
|
-
|
|
|
- Request request = new Request.Builder()
|
|
|
- .url(url)
|
|
|
- .build();
|
|
|
- try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
- if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
|
|
- InputStream inputStream = response.body().source().inputStream();
|
|
|
- //本地文件夹目录(下载位置)
|
|
|
- String folder = PropKit.get("oss_localPath");
|
|
|
- //下载文件保存位置
|
|
|
- String savepath=folder+"/"+filename;
|
|
|
- BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(savepath)));
|
|
|
- byte[] data=new byte[1024];
|
|
|
- int len;
|
|
|
- int available = inputStream.available();
|
|
|
- while ((len=inputStream.read(data))!=-1){
|
|
|
- bufferedOutputStream.write(data,0,len);
|
|
|
- }
|
|
|
- bufferedOutputStream.flush();
|
|
|
- bufferedOutputStream.close();
|
|
|
- inputStream.close();
|
|
|
-
|
|
|
- return savepath;
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- return "";
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- Map <String,String> map = new HashMap<String,String>();
|
|
|
- map.put("institution_id", "06300006");
|
|
|
- map.put("start", "2022-02-01");
|
|
|
- map.put("finish", "2022-03-01");
|
|
|
- String content=getWithUrl(RETURN_BIND_URL, map);
|
|
|
- System.out.println(content);
|
|
|
+// public static String getFileWithUrl(String url, String filename) {
|
|
|
+//
|
|
|
+// Request request = new Request.Builder().url(url).build();
|
|
|
+// try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
+// if (!response.isSuccessful())
|
|
|
+// throw new IOException("Unexpected code " + response);
|
|
|
+// InputStream inputStream = response.body().source().inputStream();
|
|
|
+// // 本地文件夹目录(下载位置)
|
|
|
+// String folder = PropKit.get("oss_localPath");
|
|
|
+// // 下载文件保存位置
|
|
|
+// String savepath = folder + "/" + filename;
|
|
|
+// BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
|
|
|
+// new FileOutputStream(new File(savepath)));
|
|
|
+// byte[] data = new byte[1024];
|
|
|
+// int len;
|
|
|
+// int available = inputStream.available();
|
|
|
+// while ((len = inputStream.read(data)) != -1) {
|
|
|
+// bufferedOutputStream.write(data, 0, len);
|
|
|
+// }
|
|
|
+// bufferedOutputStream.flush();
|
|
|
+// bufferedOutputStream.close();
|
|
|
+// inputStream.close();
|
|
|
+//
|
|
|
+// return savepath;
|
|
|
+//
|
|
|
+// } catch (IOException e) {
|
|
|
+// // TODO Auto-generated catch block
|
|
|
+// e.printStackTrace();
|
|
|
+// return "";
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("institution_id", "06300006");
|
|
|
+ map.put("start", "2022-02-01");
|
|
|
+ map.put("finish", "2022-03-01");
|
|
|
+ String content = getWithUrl(RETURN_BIND_URL, map);
|
|
|
+ System.out.println(content);
|
|
|
}
|
|
|
|
|
|
}
|