|
@@ -1,14 +1,17 @@
|
|
|
package com.zskk.service;
|
|
|
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
+
|
|
|
+
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
-import javax.xml.parsers.ParserConfigurationException;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
import com.zskk.tools.XmlHelper;
|
|
|
|
|
@@ -18,111 +21,172 @@ import okhttp3.Request;
|
|
|
import okhttp3.RequestBody;
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
+import com.amazonaws.AmazonServiceException;
|
|
|
+import com.amazonaws.SdkClientException;
|
|
|
+import com.amazonaws.auth.AWSCredentialsProvider;
|
|
|
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
|
|
+import com.amazonaws.auth.BasicAWSCredentials;
|
|
|
+import com.amazonaws.client.builder.AwsClientBuilder;
|
|
|
+import com.amazonaws.services.s3.AmazonS3;
|
|
|
+import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
|
|
+import com.amazonaws.services.s3.model.CannedAccessControlList;
|
|
|
+import com.amazonaws.services.s3.model.PutObjectRequest;
|
|
|
+
|
|
|
+
|
|
|
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 UPDATE_PATIENT_URL = "https://risserver3.pacsonline.cn/butt/saveExam";
|
|
|
-
|
|
|
- private static String CREATE_REGISTER_URL = "https://risserver3.pacsonline.cn/butt/register";
|
|
|
-
|
|
|
- private static String SAVE_FILE_URL = "https://risserver3.pacsonline.cn/butt/saveFile";
|
|
|
-
|
|
|
- private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取未出报告的检查列表
|
|
|
- * @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"));
|
|
|
+ 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 CREATE_REGISTER_URL = "https://risserver3.pacsonline.cn/butt/register";
|
|
|
+
|
|
|
+ private static String SAVE_FILE_URL = "https://risserver3.pacsonline.cn/butt/saveFile";
|
|
|
+
|
|
|
+ private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未出报告的检查列表
|
|
|
+ *
|
|
|
+ * @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("institution_id", "43600001");
|
|
|
|
|
|
- map.put("num", number.toString());
|
|
|
+ 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;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 写入报告
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public void saveReport(Map <String,String> map) {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 写入报告
|
|
|
+ *
|
|
|
+ * @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);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建登记信息
|
|
|
- *
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public String createRegisterInfo(Map<String, String> map) {
|
|
|
- String content = postWithParameters(CREATE_REGISTER_URL, map);
|
|
|
- JSONObject jsonObject = JSON.parseObject(content);
|
|
|
- if (!jsonObject.getString("msg").equals("success")) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- String data = jsonObject.getString("data");
|
|
|
- return data;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 上传登记检查的文件
|
|
|
- *
|
|
|
- * @param instutionId
|
|
|
- * @param number
|
|
|
- */
|
|
|
- public void saveFile(Map<String, String> map) {
|
|
|
- postWithParameters(SAVE_FILE_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 updatePatientInfo(Map<String, String> map) {
|
|
|
+ postWithParameters(UPDATE_PATIENT_URL, map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建登记信息
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public String createRegisterInfo(Map<String, String> map) {
|
|
|
+ String content = postWithParameters(CREATE_REGISTER_URL, map);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ if (!jsonObject.getString("msg").equals("success")) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- 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;
|
|
|
- }
|
|
|
+ String data = jsonObject.getString("data");
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传登记检查的文件
|
|
|
+ *
|
|
|
+ * @param instutionId
|
|
|
+ * @param number
|
|
|
+ */
|
|
|
+ public static void saveFile(String examid, String filepath) {
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("institution_id", "13000003");
|
|
|
+ postWithParameters(SAVE_FILE_URL, map);
|
|
|
+ // 填写存储桶(Bucket)所在地域对应的 endpoint 和 Region。
|
|
|
+ // 以华东 - 苏州为例,endpoint 填写 https://eos-wuxi-1.cmecloud.cn,Region 填写 wuxi1。
|
|
|
+ String endpoint = "https://eos.jinan-4.cmecloud.cn";
|
|
|
+ String region = "jinan4";
|
|
|
+
|
|
|
+ // 填写 EOS 账号的认证信息,或者子账号的认证信息。
|
|
|
+ String accessKey = "94LX6HHDAV6AS4830IH8";
|
|
|
+ String secretKey = "h3WBubtjzRIMGIi6K3VWBT05LvdXiuNlSifSHKG5";
|
|
|
+
|
|
|
+ // 填写要上传到的存储桶名称,例如'example-bucket'。
|
|
|
+ String bucketName = "annex";
|
|
|
+ // 填写上传后要显示的对象名,例如'object.txt'。
|
|
|
+ String objectName = "43600001/<your-object-name>";
|
|
|
+ // 填写要上传的对象内容,例如'abcde'。
|
|
|
+// String content = "<your-object-content>";
|
|
|
+ File content = new File("C:\\Users\\LT\\Desktop\\afe1bc7906a0855b4e7432bf5a81492.jpg");
|
|
|
+
|
|
|
+ // 创建 AmazonS3 实例。
|
|
|
+ AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, region);
|
|
|
+ BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
|
|
|
+ AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
|
|
|
+ AmazonS3 client = AmazonS3ClientBuilder.standard()
|
|
|
+ .withEndpointConfiguration(endpointConfiguration)
|
|
|
+ .withCredentials(credentialsProvider).build();
|
|
|
+ // 上传文件。
|
|
|
+ try {
|
|
|
+ // 上传同时设置访问权限,例如'Private'私有权限。
|
|
|
+ PutObjectRequest request = new PutObjectRequest(bucketName, objectName, content);
|
|
|
+ request.setCannedAcl(CannedAccessControlList.PublicRead);
|
|
|
+ client.putObject(request);
|
|
|
+ // 关闭 client。
|
|
|
+ client.shutdown();
|
|
|
+ } catch (AmazonServiceException e) {
|
|
|
+ // 上传失败。
|
|
|
+ System.out.println("发生异常 AmazonServiceException,通常原因是请求内容错误。");
|
|
|
+ System.out.println("Error Code: " + e.getErrorCode());
|
|
|
+ } catch (SdkClientException e) {
|
|
|
+ // 上传失败。
|
|
|
+ System.out.println("发生异常 SdkClientException,通常原因是未能连接到 EOS 服务。");
|
|
|
+ System.out.println("Error Message: " + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (client != null) {
|
|
|
+ client.shutdown();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 static void main(String[] args) {
|
|
|
+ saveFile("cnb515xp6rq064ds","");
|
|
|
+ }
|
|
|
|
|
|
}
|