|
@@ -1,12 +1,20 @@
|
|
|
package com.zskk.service;
|
|
|
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
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.aliyun.oss.OSS;
|
|
|
+import com.aliyun.oss.OSSClientBuilder;
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
|
import okhttp3.FormBody;
|
|
@@ -25,6 +33,10 @@ 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 SAVE_ANNEX_URL = "https://risserver3.pacsonline.cn/butt/saveAnnex";
|
|
|
+
|
|
|
+ private static String SAVE_PRINT_URL = "https://risserver3.pacsonline.cn/butt/savePrint";
|
|
|
|
|
|
private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
|
|
@@ -77,6 +89,94 @@ public class DataService {
|
|
|
postWithJson(FEE_URL, jsonObject);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存附件
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ * @throws FileNotFoundException
|
|
|
+ */
|
|
|
+ public void saveAnnex(Map<String, String> map, String filePath) {
|
|
|
+ OSS OSS_CLIENT = new OSSClientBuilder().build(PropKit.get("oss_endpoint"), PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
|
|
|
+
|
|
|
+ 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;
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = new FileInputStream(fileStorePath);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+ if (!eBoolean) {
|
|
|
+ OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, inputStream);
|
|
|
+ Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
+ if (!bBoolean) {
|
|
|
+ OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, inputStream);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("url", "https://zskk-image.oss-cn-beijing.aliyuncs.com/" + key);
|
|
|
+ map.put("name", key);
|
|
|
+ postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ file.delete();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未出报告的检查列表
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public void savePrint(Map<String, String> map) {
|
|
|
+
|
|
|
+ String content = postWithParameters(SAVE_PRINT_URL, map);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 String postWithParameters(String url, Map<String, String> map) {
|
|
|
|
|
|
FormBody.Builder formbody = new FormBody.Builder();
|