From 6c3a2bc795610e359ba0fb8513f5822f2b7c008a Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Tue, 22 Nov 2022 16:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- .../utils/fileUtil/sftp/SftpConnectUtil.java | 2 +- .../hrorganization/sftp/FetchDataUtil.java | 23 ++++++++++++++++--- .../java/youhong/ai/pcn/TestOrganization.java | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5edce1b..cc07bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,11 @@ log /target/ /log/ -/test/java/baseTest/BaseTest.java +/src/test/java/baseTest/BaseTest.java .DS_Store /src/main/resources/WEB-INF/prop/weaver.properties /lib/classbean +/file/ diff --git a/src/main/java/aiyh/utils/fileUtil/sftp/SftpConnectUtil.java b/src/main/java/aiyh/utils/fileUtil/sftp/SftpConnectUtil.java index 5456dd0..61c5d3b 100644 --- a/src/main/java/aiyh/utils/fileUtil/sftp/SftpConnectUtil.java +++ b/src/main/java/aiyh/utils/fileUtil/sftp/SftpConnectUtil.java @@ -94,7 +94,7 @@ public class SftpConnectUtil extends ChannelSftp { } else { throw new RuntimeException("从sftp下载需要的ppk文件未找到"); } - if (port > 0) { + if (port != null && port > 0) { this.session = jSch.getSession(userName, sftpIp, port); } else { this.session = jSch.getSession(userName, sftpIp); diff --git a/src/main/java/weaver/youhong/ai/pcn/hrorganization/sftp/FetchDataUtil.java b/src/main/java/weaver/youhong/ai/pcn/hrorganization/sftp/FetchDataUtil.java index 234418f..0a99315 100644 --- a/src/main/java/weaver/youhong/ai/pcn/hrorganization/sftp/FetchDataUtil.java +++ b/src/main/java/weaver/youhong/ai/pcn/hrorganization/sftp/FetchDataUtil.java @@ -2,8 +2,14 @@ package weaver.youhong.ai.pcn.hrorganization.sftp; import aiyh.utils.excention.CustomerException; import aiyh.utils.fileUtil.sftp.SftpConnectUtil; +import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.SftpException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.Vector; + /** *