|
@@ -1,12 +1,19 @@
|
|
|
package com.zskk.control;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
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.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -96,19 +103,54 @@ public class ViewController extends Controller {
|
|
|
public void sdxz2() {
|
|
|
try {
|
|
|
DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
-// JSONArray array= dService.getImage(this.getPara("accnum"));
|
|
|
-// for (Object object : array) {
|
|
|
-// JSONObject jsonObject = JSON.parseObject(object.toString());
|
|
|
-// String[] strings = jsonObject.getString("Path").split("\\\\");
|
|
|
- dService.downloadFtpFile("datacenterf\\20241118\\00434012.img", "100434012.img");
|
|
|
-// }
|
|
|
- this.renderJson("succ");
|
|
|
+ FTPClient ftpClient = new FTPClient();
|
|
|
+ ftpClient.setConnectTimeout(1000*30);
|
|
|
+ ftpClient.enterLocalPassiveMode();
|
|
|
+ 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();
|
|
|
+// this.renderText("disconnect");
|
|
|
+// }
|
|
|
+// ftpClient.setControlEncoding("UTF-8");
|
|
|
+// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
|
|
+// ftpClient.enterLocalPassiveMode();
|
|
|
+//
|
|
|
+// File localFile = new File("/home/tmszyy/FTP_FILE" + File.separatorChar + "test.img");
|
|
|
+// OutputStream os = new FileOutputStream(localFile);
|
|
|
+// //ftp中文名需要iso-8859-1字符
|
|
|
+// boolean flag2 = ftpClient.retrieveFile(new String("datacenterf/20241118/00434012.img".getBytes("GBK"), "iso-8859-1"), os);
|
|
|
+// if (!flag2) {
|
|
|
+// System.out.println("没有找到" + "datacenterf/20241118/00434012.img" + "---该文件");
|
|
|
+// localFile.delete();
|
|
|
+// this.renderText("nofind");
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// System.out.println("=================== save success");
|
|
|
+// this.renderText("succ");
|
|
|
+//
|
|
|
+// }
|
|
|
+// os.close();
|
|
|
+// ftpClient.logout();
|
|
|
+// ftpClient.disconnect();
|
|
|
+ this.renderText(String.valueOf(reply));
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ this.renderText(e.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
this.renderText(e.toString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static DruidPlugin createConnectedDruidPlugin() {
|
|
|
|
|
|
return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
|