|
@@ -1,6 +1,9 @@
|
|
package com.zskk.control;
|
|
package com.zskk.control;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -8,6 +11,9 @@ import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
+import org.apache.commons.net.ftp.FTPClient;
|
|
|
|
+import org.apache.commons.net.ftp.FTPReply;
|
|
|
|
+
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.jfinal.core.Controller;
|
|
import com.jfinal.core.Controller;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.kit.PropKit;
|
|
@@ -63,14 +69,55 @@ public class ViewController extends Controller {
|
|
public void testDown() {
|
|
public void testDown() {
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
try {
|
|
try {
|
|
- 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/20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg");
|
|
|
|
|
|
+
|
|
|
|
+ FTPClient ftpClient = new FTPClient();
|
|
|
|
+ int reply;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ ftpClient.connect(PropKit.get("ftp_host"), PropKit.getInt("ftp_port"));
|
|
|
|
+ ftpClient.login(PropKit.get("ftp_user"), PropKit.get("ftp_password"));
|
|
|
|
+ reply = ftpClient.getReplyCode();
|
|
|
|
+ if (!FTPReply.isPositiveCompletion(reply)) {
|
|
|
|
+ ftpClient.disconnect();
|
|
|
|
+// return null;
|
|
|
|
+ this.renderText("noconn");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ ftpClient.setControlEncoding("UTF-8");
|
|
|
|
+ ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
|
|
|
+ ftpClient.enterLocalPassiveMode();
|
|
|
|
+
|
|
|
|
+ File localFile = new File("/home/zskk/FTP_FILE" + File.separatorChar + "123.jpg");
|
|
|
|
+ OutputStream os = new FileOutputStream(localFile);
|
|
|
|
+ //ftp中文名需要iso-8859-1字符
|
|
|
|
+ boolean flag2 = ftpClient.retrieveFile(new String("20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg".getBytes("GBK"), "iso-8859-1"), os);
|
|
|
|
+ if (!flag2) {
|
|
|
|
+ System.out.println("没有找到" + "20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg" + "---该文件");
|
|
|
|
+ localFile.delete();
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("=================== save success");
|
|
|
|
+ }
|
|
|
|
+ os.close();
|
|
|
|
+ ftpClient.logout();
|
|
|
|
+ ftpClient.disconnect();
|
|
|
|
+// return "/home/zskk/FTP_FILE" + File.separatorChar + fileName;
|
|
|
|
+ this.renderText("succ");
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ this.renderText(e.toString());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// 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/20240726/1AFB48FCF39241AA8DE61F85EE6D847F/Report/Report.jpg");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
// TODO: handle exception
|
|
this.renderText(e.toString());
|
|
this.renderText(e.toString());
|