Commit fe8168ae4a2904763a581c7559592f5267d7d918

Authored by 潘钊
2 parents 73975974 b4e40634

Merge branch 'master' of 192.168.168.201:panzhaov5/bsth_control

src/main/java/com/bsth/util/FTPClientUtils.java
... ... @@ -10,7 +10,6 @@ import java.io.UnsupportedEncodingException;
10 10  
11 11 import org.apache.commons.net.ftp.FTPClient;
12 12 import org.apache.commons.net.ftp.FTPReply;
13   -
14 13 /**
15 14 * @Description: 向FTP服务器上传文件
16 15 *
... ... @@ -97,12 +96,14 @@ public class FTPClientUtils {
97 96 }
98 97  
99 98 // 将本地文件上传到FTP服务器上
100   - public void testUpLoadFromDisk(){
  99 + public void testUpLoadFromDisk(File file,String name){
101 100  
102 101 try {
103   - FileInputStream in=new FileInputStream(new File("D:/test.txt"));
  102 + FileInputStream in=new FileInputStream(file);
  103 +
  104 + /*boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "C:/ftptest", name, in);*/
104 105  
105   - boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "C:/ftptest", "test.txt", in);
  106 + boolean flag = uploadFile("222.66.0.205", 21, "transport", "transport123", "ftptest/", name, in);
106 107  
107 108 System.out.println(flag);
108 109  
... ... @@ -123,7 +124,7 @@ public class FTPClientUtils {
123 124  
124 125 InputStream input = new ByteArrayInputStream(str.getBytes("utf-8"));
125 126  
126   - boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "C:/ftptest", "test.txt", input);
  127 + boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", "test.txt", input);
127 128  
128 129 System.out.println(flag);
129 130  
... ... @@ -134,4 +135,102 @@ public class FTPClientUtils {
134 135 }
135 136  
136 137 }
  138 +
  139 + /**
  140 + * <删除FTP上的文件>
  141 + * <远程删除FTP服务器上的录音文件>
  142 + * @param url FTP服务器IP地址
  143 + * @param port FTP服务器端口
  144 + * @param username FTP服务器登录名
  145 + * @param password FTP服务器密码
  146 + * @param remotePath 远程文件路径
  147 + * @param fileName 待删除的文件名
  148 + * @return
  149 + * @see [类、类#方法、类#成员]
  150 + */
  151 + public static boolean deleteFtpFile(String url, int port, String username, String password, String remotePath, String fileName){
  152 +
  153 + boolean success = true;
  154 +
  155 + FTPClient ftp = new FTPClient();
  156 +
  157 + try{
  158 +
  159 + int reply;
  160 +
  161 + // 连接FTP服务器
  162 + if (port > -1)
  163 +
  164 + ftp.connect(url, port);
  165 +
  166 + else
  167 +
  168 + ftp.connect(url);
  169 +
  170 + // 登录
  171 + ftp.login(username, password);
  172 +
  173 + reply = ftp.getReplyCode();
  174 +
  175 + if (!FTPReply.isPositiveCompletion(reply)) {
  176 +
  177 + ftp.disconnect();
  178 +
  179 + return success;
  180 + }
  181 +
  182 + // 转移到FTP服务器目录
  183 +
  184 + ftp.changeWorkingDirectory(remotePath);
  185 +
  186 + success = ftp.deleteFile("C:/ftptest"+ "/" + "aa.txt");
  187 +
  188 + ftp.logout();
  189 + } catch (IOException e){
  190 + /*logger.error("save erro.", e);*/
  191 +
  192 + e.printStackTrace();
  193 + success = false;
  194 +
  195 + } finally {
  196 +
  197 + if (ftp.isConnected()) {
  198 +
  199 + try {
  200 +
  201 + ftp.disconnect();
  202 +
  203 + } catch (IOException e) {
  204 + e.printStackTrace();
  205 + /* logger.error(EXCEPTION_NAME, e); */
  206 +
  207 + }
  208 + }
  209 + }
  210 +
  211 + return success;
  212 + }
  213 +
  214 + public static void main(String[] args) {
  215 +
  216 + FTPClientUtils clientUtils = new FTPClientUtils();
  217 +
  218 + Test test= new Test();
  219 +
  220 + /* File[] sources = new File[] {new File("E:/20079.txt")};
  221 +
  222 + File target = new File("release_package.tar.gz");
  223 +
  224 + File targetFile = test.pack(sources, target);
  225 +
  226 + clientUtils.testUpLoadFromDisk(targetFile,targetFile.getName());*/
  227 +
  228 + /*, 21, , "123", "C:/ftptest", "test.txt", input*/
  229 +
  230 + boolean a =clientUtils.deleteFtpFile("192.168.168.101", 21, "testftpservice", "123", "ftptest", "aa.txt");
  231 +
  232 + System.out.println(a);
  233 +
  234 +
  235 + }
137 236 }
... ...
src/main/java/com/bsth/util/Test.java
... ... @@ -72,6 +72,8 @@ public class Test {
72 72 out = new GZIPOutputStream(new FileOutputStream(target));
73 73 byte[] array = new byte[1024];
74 74 int number = -1;
  75 +
  76 + System.out.println( in.read(array, 0, array.length) != -1);
75 77 while((number = in.read(array, 0, array.length)) != -1) {
76 78 out.write(array, 0, number);
77 79 }
... ... @@ -102,10 +104,20 @@ public class Test {
102 104 }
103 105 return target;
104 106 }
105   -/*
  107 +
106 108 public static void main(String[] args) {
107   - File[] sources = new File[] {new File("D:/test.txt"), new File("D:/test1.txt")};
  109 + /* File[] sources = new File[] {new File("D:/test.txt")};
  110 +
108 111 File target = new File("release_package.tar");
  112 +
  113 + File targetFile = pack(sources, target);
  114 +
  115 + FTPClientUtils clientUtils = new FTPClientUtils();
  116 +
  117 + clientUtils.testUpLoadFromDisk(targetFile,targetFile.getName());
  118 +
109 119 File gzFile = compress(pack(sources, target));
110   - }*/
  120 +
  121 + clientUtils.testUpLoadFromDisk(gzFile,gzFile.getName());*/
  122 + }
111 123 }
... ...
src/main/resources/static/pages/base/station/js/add-form-wizard.js
... ... @@ -248,19 +248,8 @@ var FormWizard = function() {
248 248 }
249 249  
250 250 });
251   -
252   -
  251 + }
253 252  
254   - /* if(current == 3){
255   -
256   - mapB.clearOverlays();
257   -
258   - circle = '';
259   -
260   - drawingManager.close();
261   -
262   - }*/
263   -
264 253 /** 如果为最后一步显示提交按钮,隐藏下一步按钮,否则隐藏提交按钮,显示下一步按钮 */
265 254 if (current >= total) {
266 255  
... ... @@ -384,5 +373,6 @@ var FormWizard = function() {
384 373 $('#submit_station_form').find('.button-previous').hide();
385 374  
386 375 }
387   - };
  376 + }
  377 +
388 378 }();
... ...