Browse Source

超声报告

LAPTOP-5NTQJPUS\LT 1 year ago
parent
commit
766739d32f
2 changed files with 18 additions and 83 deletions
  1. 8 1
      DataFusion/res/config.properties
  2. 10 82
      DataFusion/src/com/zskk/service/DataService.java

+ 8 - 1
DataFusion/res/config.properties

@@ -10,4 +10,11 @@ institution_id     = 43600001
 jdbcUrl_local  = jdbc:mysql://127.0.0.1:3306/pacsonline?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
 #jdbcUrl_connected  = jdbc:oracle:thin:@192.168.100.4:1521:pacs
 user_local	   = zskk
-password_local = Zskk_2021
+password_local = Zskk_2021
+
+#OSS
+oss_accessKey = 94LX6HHDAV6AS4830IH8
+oss_secretKey = h3WBubtjzRIMGIi6K3VWBT05LvdXiuNlSifSHKG5
+oss_bucketName = annex
+oss_endpoint = https://eos.jinan-4.cmecloud.cn
+region = jinan4

+ 10 - 82
DataFusion/src/com/zskk/service/DataService.java

@@ -111,63 +111,6 @@ public class DataService {
 		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();
-            }
-        }
-    }
 	
 	/**
 	 * 保存附件
@@ -177,47 +120,36 @@ public class DataService {
 	 * @throws FileNotFoundException 
 	 */
 	public void saveAnnex(Map<String, String> map, String filePath) {
-		AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, region);
+		AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(PropKit.get("oss_endpoint"), PropKit.get("region"));
         BasicAWSCredentials credentials = new BasicAWSCredentials(PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
         AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
         AmazonS3 client = AmazonS3ClientBuilder.standard()
                 .withEndpointConfiguration(endpointConfiguration)
                 .withCredentials(credentialsProvider).build();
         
-	    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 fileNameStr[] = filePath.split("=");
+		String fileName = fileNameStr[fileNameStr.length - 2];
 		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 exists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
 		if (!exists) {
-			PutObjectRequest request = new PutObjectRequest(PropKit.get("oss_bucketName"), key, );
+			PutObjectRequest request = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
             request.setCannedAcl(CannedAccessControlList.PublicRead);
             client.putObject(request);
             boolean bexists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
 			if (!bexists) {
-				PutObjectRequest request2 = new PutObjectRequest(PropKit.get("oss_bucketName"), key, content);
+				PutObjectRequest request2 = new PutObjectRequest(PropKit.get("oss_bucketName"), key, file);
 	            request.setCannedAcl(CannedAccessControlList.PublicRead);
-	            client.putObject(request);			}
+	            client.putObject(request);			
+	            }
 		}
+        client.shutdown();
 		map.put("url", "https://annex.eos.jinan-4.cmecloud.cn/" + 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();
 
 	}
@@ -276,8 +208,4 @@ public class DataService {
 		}
 	}
 	
-	public static void main(String[] args) {
-		saveFile("cnb515xp6rq064ds","");
-	}
-
 }