LAPTOP-5NTQJPUS\LT 1 year ago
parent
commit
c4685318a8

+ 53 - 0
DataFusion/src/com/zskk/service/DataService.java

@@ -44,6 +44,9 @@ public class DataService {
 	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 String SAVE_ANNEX_URL = "https://risserver3.pacsonline.cn/butt/saveAnnex";
+
 
 	private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
 
@@ -162,6 +165,56 @@ public class DataService {
             }
         }
     }
+	
+	/**
+	 * 保存附件
+	 * 
+	 * @param instutionId
+	 * @param number
+	 * @throws FileNotFoundException 
+	 */
+	public void saveAnnex(Map<String, String> map, String filePath) {
+		AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(endpoint, 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 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();
+
+	}
 
 	public static String postWithParameters(String url, Map<String, String> map) {
 		FormBody.Builder formbody = new FormBody.Builder();

+ 1 - 1
DataFusion/src/com/zskk/task/USReportTask.java

@@ -129,7 +129,7 @@ public class USReportTask implements ITask {
 				annex_params.put("code", examid);
 				//附件类型1.mp4 2.pdf 3.jpeg
 				annex_params.put("annex_class_code", "3");
-//	      		dService.saveAnnex(annex_params, record.getStr("reportpath"));
+	      		dService.saveAnnex(annex_params, record.getStr("RPTURL"));