LAPTOP-5NTQJPUS\LT 10 months ago
parent
commit
5fb79792d5

+ 1 - 1
DataFusion/res/config.properties

@@ -11,7 +11,7 @@ oss_secretKey = h3WBubtjzRIMGIi6K3VWBT05LvdXiuNlSifSHKG5
 oss_bucketName = annex
 oss_endpoint = https://eos.jinan-4.cmecloud.cn
 region = jinan4
-oss_localPath = /home/zskk/REPORT_FILE
+oss_localPath = /home/zskk/FTP_FILE
 #DATE-FTP
 ftp_host     = 188.188.2.1
 ftp_port 	 = 6161

+ 17 - 0
DataFusion/src/com/zskk/control/ViewController.java

@@ -16,6 +16,8 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
 import com.jfinal.plugin.druid.DruidPlugin;
+import com.zskk.service.DataService;
+import com.zskk.service.ServiceFactory;
 
 import okhttp3.FormBody;
 import okhttp3.MediaType;
@@ -58,6 +60,21 @@ public class ViewController extends Controller {
 		}
 	}
 	
+	public void testDown() {
+		// TODO Auto-generated method stub
+		DataService dService = ServiceFactory.getService(DataService.class);
+		Map<String, String> annex_params = new HashMap<>();
+		annex_params.put("institution_id", PropKit.get("institution_id"));
+		annex_params.put("type", "1");
+		annex_params.put("code", "11");
+		//附件类型1.mp4 2.pdf 3.jpeg
+		annex_params.put("annex_class_code", "3");
+  		dService.saveAnnex(annex_params, "ftp://FTPUser:ftpuser@188.188.2.1:6161/202\r\n"
+  				+ "10922/000096550AB54AEF944DAD32556D560D/Report/Report.jpg");
+    
+
+	}
+	
 	public static DruidPlugin createConnectedDruidPlugin() {
 
 		return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());

+ 21 - 50
DataFusion/src/com/zskk/service/DataService.java

@@ -121,28 +121,30 @@ public class DataService {
                 .withEndpointConfiguration(endpointConfiguration)
                 .withCredentials(credentialsProvider).build();
         
-		String fileNameStr[] = filePath.split("=");
-		String fileName = fileNameStr[fileNameStr.length - 2];
-		String fileStorePath = getFileWithUrl(filePath, fileName);
+		String fileNameStr[] = filePath.split("/");
+		String fileName = fileNameStr[fileNameStr.length - 3]+".jpg";
+		String fpString = fileNameStr[fileNameStr.length - 4]+"/"+fileNameStr[fileNameStr.length - 3]+"/"+fileNameStr[fileNameStr.length - 2]+"/"+fileNameStr[fileNameStr.length - 1];
+//		String fileStorePath = getFileWithUrl(fpString, fileName);
+		String fileStorePath = downloadFtpFile(fpString, fileName);
 		File file = new File(fileStorePath);
 		String key = PropKit.get("institution_id") + "/" + fileName;
                
-		boolean exists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
-		if (!exists) {
-			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, file);
-	            request.setCannedAcl(CannedAccessControlList.PublicRead);
-	            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);
+//		boolean exists = client.doesObjectExist(PropKit.get("oss_bucketName"), key);
+//		if (!exists) {
+//			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, file);
+//	            request.setCannedAcl(CannedAccessControlList.PublicRead);
+//	            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);
 		
 		file.delete();
 
@@ -173,37 +175,6 @@ public class DataService {
 			}	
 	}
     
-    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 "";
-
-		}
-	}
     //ftp://FTPUser:ftpuser@188.188.2.1:6161/20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg"
     public String downloadFtpFile(String remoteFileName, String fileName) {
         FTPClient ftpClient = new FTPClient();

+ 9 - 0
DataFusion/src/com/zskk/task/ReviewTask.java

@@ -85,6 +85,15 @@ public class ReviewTask implements ITask {
 				// TODO: handle exception
 				continue;
 			}
+			
+			//上传报告附件
+//			Map<String, String> annex_params = new HashMap<>();
+//			annex_params.put("institution_id", PropKit.get("institution_id"));
+//			annex_params.put("type", "4");
+//			annex_params.put("code", record.getStr("studyuid"));
+//			//附件类型1.mp4 2.pdf 3.jpeg
+//			annex_params.put("annex_class_code", "3");
+//      		dService.saveAnnex(annex_params, record.getStr("report_url"));
 		}
 	}