From 9bbdd5eb5db81bcbca8ef68cd3bad73238fca248 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 17 Jul 2024 09:49:56 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9AFileNameByStandardForm=E4=BD=BF?= =?UTF-8?q?=E7=94=A8ftp=E6=94=B9=E4=B8=BA=E6=9C=AC=E5=9C=B0=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/PHDFileUtil.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index 4f7d35cb..18c73448 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -891,39 +891,44 @@ public class PHDFileUtil extends AbstractLogOrReport { List fileNames = new LinkedList<>(); String station = sampleFileName.substring(0, 9); //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - return fileNames; - } +// FTPClient ftpClient = ftpUtil.LoginFTP(); +// if (Objects.isNull(ftpClient)){ +// return fileNames; +// } try { //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - //切换文件路径 - ftpClient.changeWorkingDirectory(filePath); - //获取路径下所有文件信息 - List ftpFiles = Arrays.asList(ftpClient.listFiles()); +// ftpClient.enterLocalPassiveMode(); +// //设置文件类型--二进制文件 +// ftpClient.setFileType(FTP.BINARY_FILE_TYPE); +// // +// ftpClient.setControlEncoding("UTF-8"); +// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); +// //切换文件路径 +// ftpClient.changeWorkingDirectory(filePath); +// //获取路径下所有文件信息 +// List ftpFiles = Arrays.asList(ftpClient.listFiles()); + File file = new File(filePath); + List ftpFiles = Arrays.asList(file.listFiles()); if (CollectionUtils.isNotEmpty(ftpFiles)){ - fileNames = ftpFiles.stream().filter(item-> item.getName().contains(station)).map(FTPFile::getName).collect(Collectors.toList()); + fileNames = ftpFiles.stream().filter(item-> item.getName().contains(station)).map(File::getName).collect(Collectors.toList()); } - } catch (IOException e) { + } catch (Exception e) { throw new RuntimeException(e); } finally { - try { - ftpClient.disconnect(); - } catch (IOException e) { - throw new RuntimeException(e); - } +// try { +// ftpClient.disconnect(); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } } return fileNames; } public String GetMatchFile(String tmpFileName, List fileNames, String type) { String matchFileName = ""; + if (StringUtils.isBlank(tmpFileName)) { + return matchFileName; + } fileNames = fileNames.stream().filter(item-> item.contains(type)).sorted().collect(Collectors.toList()); //用于比较的字符串 String fileCompare = tmpFileName.substring(0,23);