|
@@ -1,12 +1,20 @@
|
|
|
package com.zskk.service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.net.URI;
|
|
|
+import java.net.URISyntaxException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.nio.file.StandardOpenOption;
|
|
|
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.inspurcloud.oss.client.impl.OSSClientImpl;
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
|
import okhttp3.FormBody;
|
|
@@ -20,9 +28,14 @@ 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 SAVE_ANNEX_URL = "https://risserver3.pacsonline.cn/butt/saveAnnex";
|
|
|
|
|
|
private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
|
|
|
+ private static final OSSClientImpl OSS_CLIENT = new OSSClientImpl(PropKit.get("oss_endpoint"), PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取未出报告的检查列表
|
|
|
* @param instutionId
|
|
@@ -52,6 +65,18 @@ public class DataService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存附件
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public void saveAnnex(String filePath) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+
|
|
|
+ postWithParameters(SAVE_ANNEX_URL, map);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static String postWithParameters(String url, Map<String, String> map) {
|
|
|
|
|
|
FormBody.Builder formbody = new FormBody.Builder();
|
|
@@ -77,11 +102,60 @@ public class DataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static String getWithUrl(String url) {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ byte[] bytes = response.body().bytes();
|
|
|
+ //本地文件夹目录(下载位置)
|
|
|
+ String folder = "/home/zskk/";
|
|
|
+ //切割出图片名称==》PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png
|
|
|
+ String filename = "";
|
|
|
+
|
|
|
+ Path filePath = Paths.get(folder + filename);
|
|
|
+ //不存在文件 => 创建
|
|
|
+ Files.write(filePath, bytes, StandardOpenOption.CREATE);
|
|
|
+
|
|
|
+ System.out.println(response.body().string());
|
|
|
+ return filename;
|
|
|
+
|
|
|
+ } 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", "47600001");
|
|
|
- map.put("num", "10");
|
|
|
- postWithParameters(GET_EXAM_URL, map);
|
|
|
+// Map <String,String> map = new HashMap<String,String>();
|
|
|
+// map.put("institution_id", "47600001");
|
|
|
+// map.put("num", "10");
|
|
|
+// postWithParameters(GET_EXAM_URL, map);
|
|
|
+ System.out.print(GET_EXAM_URL);
|
|
|
+ String bucketName = "annex";
|
|
|
+ String key = "111/a.pdf";
|
|
|
+ File file = new File("/Users/liutao/Desktop/1-销售部标准化操作手册(SOP)v1.0版-销售服务流程-中世康恺20220304.pdf");
|
|
|
+ URI abvUri =null;
|
|
|
+ try {
|
|
|
+ abvUri =new URI("https://annex.oss.cn-north-3.inspurcloudoss.com/111/a.pdf");
|
|
|
+ File file2 = new File(abvUri);
|
|
|
+// OSSClientImpl ossClient = new OSSClientImpl(endpoint, accessKey, secretKey);
|
|
|
+
|
|
|
+ //简单文件上传
|
|
|
+ OSS_CLIENT.putObject(bucketName, key, file);
|
|
|
+ } catch (URISyntaxException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+//创建OSSClient实例
|
|
|
+
|
|
|
+// Boolean aBoolean = ossClient.doesObjectExist(bucketName, key);
|
|
|
+// System.out.print(aBoolean);
|
|
|
}
|
|
|
|
|
|
}
|