fix:FileNameByStandardForm使用ftp改为本地目录
This commit is contained in:
parent
277485ddda
commit
9bbdd5eb5d
|
@ -891,39 +891,44 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
||||||
List<String> fileNames = new LinkedList<>();
|
List<String> fileNames = new LinkedList<>();
|
||||||
String station = sampleFileName.substring(0, 9);
|
String station = sampleFileName.substring(0, 9);
|
||||||
//连接ftp
|
//连接ftp
|
||||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
// FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||||
if (Objects.isNull(ftpClient)){
|
// if (Objects.isNull(ftpClient)){
|
||||||
return fileNames;
|
// return fileNames;
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
//被动模式
|
//被动模式
|
||||||
ftpClient.enterLocalPassiveMode();
|
// ftpClient.enterLocalPassiveMode();
|
||||||
//设置文件类型--二进制文件
|
// //设置文件类型--二进制文件
|
||||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||||
//
|
// //
|
||||||
ftpClient.setControlEncoding("UTF-8");
|
// ftpClient.setControlEncoding("UTF-8");
|
||||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||||
//切换文件路径
|
// //切换文件路径
|
||||||
ftpClient.changeWorkingDirectory(filePath);
|
// ftpClient.changeWorkingDirectory(filePath);
|
||||||
//获取路径下所有文件信息
|
// //获取路径下所有文件信息
|
||||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
// List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||||
|
File file = new File(filePath);
|
||||||
|
List<File> ftpFiles = Arrays.asList(file.listFiles());
|
||||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
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);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
// try {
|
||||||
ftpClient.disconnect();
|
// ftpClient.disconnect();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return fileNames;
|
return fileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetMatchFile(String tmpFileName, List<String> fileNames, String type) {
|
public String GetMatchFile(String tmpFileName, List<String> fileNames, String type) {
|
||||||
String matchFileName = "";
|
String matchFileName = "";
|
||||||
|
if (StringUtils.isBlank(tmpFileName)) {
|
||||||
|
return matchFileName;
|
||||||
|
}
|
||||||
fileNames = fileNames.stream().filter(item-> item.contains(type)).sorted().collect(Collectors.toList());
|
fileNames = fileNames.stream().filter(item-> item.contains(type)).sorted().collect(Collectors.toList());
|
||||||
//用于比较的字符串
|
//用于比较的字符串
|
||||||
String fileCompare = tmpFileName.substring(0,23);
|
String fileCompare = tmpFileName.substring(0,23);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user