Merge branch 'dev' of https://gitee.com/it-xiaoxiong/e9-project-ebu7-dev1 into dev
commit
8587eafee4
|
@ -24,10 +24,11 @@ log
|
||||||
|
|
||||||
/target/
|
/target/
|
||||||
/log/
|
/log/
|
||||||
/test/java/baseTest/BaseTest.java
|
/src/test/java/baseTest/BaseTest.java
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/src/main/resources/WEB-INF/prop/weaver.properties
|
/src/main/resources/WEB-INF/prop/weaver.properties
|
||||||
/lib/classbean
|
/lib/classbean
|
||||||
|
/file/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SftpConnectUtil extends ChannelSftp {
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("从sftp下载需要的ppk文件未找到");
|
throw new RuntimeException("从sftp下载需要的ppk文件未找到");
|
||||||
}
|
}
|
||||||
if (port > 0) {
|
if (port != null && port > 0) {
|
||||||
this.session = jSch.getSession(userName, sftpIp, port);
|
this.session = jSch.getSession(userName, sftpIp, port);
|
||||||
} else {
|
} else {
|
||||||
this.session = jSch.getSession(userName, sftpIp);
|
this.session = jSch.getSession(userName, sftpIp);
|
||||||
|
|
|
@ -2,8 +2,14 @@ package weaver.youhong.ai.pcn.hrorganization.sftp;
|
||||||
|
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
|
import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
|
||||||
|
import com.jcraft.jsch.ChannelSftp;
|
||||||
import com.jcraft.jsch.SftpException;
|
import com.jcraft.jsch.SftpException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>获取数据工具</h1>
|
* <h1>获取数据工具</h1>
|
||||||
*
|
*
|
||||||
|
@ -30,9 +36,20 @@ public class FetchDataUtil {
|
||||||
public void downloadFile(SftpConnectUtil sftpConnectUtil,String fileName,
|
public void downloadFile(SftpConnectUtil sftpConnectUtil,String fileName,
|
||||||
String targetFile){
|
String targetFile){
|
||||||
try {
|
try {
|
||||||
sftpConnectUtil.get(fileName, targetFile);
|
sftpConnectUtil.cd("/");
|
||||||
} catch (SftpException e) {
|
Vector<ChannelSftp.LsEntry> ls = sftpConnectUtil.ls("/");
|
||||||
throw new CustomerException("下载文件出错,down file error!");
|
for (ChannelSftp.LsEntry l : ls) {
|
||||||
|
System.out.println(l.getFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(targetFile);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
sftpConnectUtil.get(fileName + "/", new FileOutputStream(file));
|
||||||
|
} catch (SftpException | FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// throw new CustomerException("下载文件出错,down file error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class TestOrganization extends BaseTest {
|
||||||
public void testSftp(){
|
public void testSftp(){
|
||||||
SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
|
SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
|
||||||
"HR Digital_PROD",
|
"HR Digital_PROD",
|
||||||
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.ppk",null,"222.73.197.242",
|
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.pem",null,"222.73.197.242",
|
||||||
null,1000 * 10
|
null,1000 * 10
|
||||||
);
|
);
|
||||||
FetchDataUtil fetchDataUtil = new FetchDataUtil();
|
FetchDataUtil fetchDataUtil = new FetchDataUtil();
|
||||||
|
|
Loading…
Reference in New Issue