Update CcbFtpUtils.groovy
This commit is contained in:
+11
-11
@@ -7,7 +7,7 @@ import org.apache.commons.codec.digest.DigestUtils
|
|||||||
|
|
||||||
class CcbFtpUtils {
|
class CcbFtpUtils {
|
||||||
|
|
||||||
static def ftpServer = "192.168.0.45"
|
static def ftpServer = "192.168.0.86"
|
||||||
static def ftpPort = 17495
|
static def ftpPort = 17495
|
||||||
static def ftpUser = "ccb"
|
static def ftpUser = "ccb"
|
||||||
static def ftpPassword = "ccb!@#"
|
static def ftpPassword = "ccb!@#"
|
||||||
@@ -20,7 +20,7 @@ class CcbFtpUtils {
|
|||||||
|
|
||||||
|
|
||||||
static def ftpUpload(type,outputPath_dist, month){
|
static def ftpUpload(type,outputPath_dist, month){
|
||||||
//上传到ftp
|
//上传到ftp
|
||||||
sftpChannel = reConnect();
|
sftpChannel = reConnect();
|
||||||
if(type && type=="rh"){
|
if(type && type=="rh"){
|
||||||
sftp.upload(ftpPath_rh+ month+"/", outputPath_dist, sftpChannel);
|
sftp.upload(ftpPath_rh+ month+"/", outputPath_dist, sftpChannel);
|
||||||
@@ -32,33 +32,33 @@ class CcbFtpUtils {
|
|||||||
|
|
||||||
static def reConnect(){
|
static def reConnect(){
|
||||||
if(sftpChannel == null){
|
if(sftpChannel == null){
|
||||||
println "sftpChannel 为空,需重连....."
|
println "sftpChannel 为空,需重连....."
|
||||||
if(sftp == null){
|
if(sftp == null){
|
||||||
sftp = new SFTP();
|
sftp = new SFTP();
|
||||||
}
|
}
|
||||||
sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
|
sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
|
||||||
}else{
|
}else{
|
||||||
println "sftpChannel 正常....."
|
println "sftpChannel 正常....."
|
||||||
}
|
}
|
||||||
return sftpChannel;
|
return sftpChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static def uploadSha512Data(def sb, def dataCodeFileName, def charset){
|
static def uploadSha512Data(def sb, def dataCodeFileName, def charset){
|
||||||
String sha512HexStr= DigestUtils.sha512Hex(sb.getBytes())//生成加密码码
|
String sha512HexStr= DigestUtils.sha512Hex(sb.getBytes())//生成加密码码
|
||||||
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
||||||
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
||||||
}
|
}
|
||||||
|
|
||||||
static def uploadSha512Data2(def dataFileName, def dataCodeFileName, def charset){
|
static def uploadSha512Data2(def dataFileName, def dataCodeFileName, def charset){
|
||||||
|
|
||||||
def data = new FileInputStream(new File(dataFileName))
|
def data = new FileInputStream(new File(dataFileName))
|
||||||
String sha512HexStr= DigestUtils.sha512Hex(data)//生成加密码码
|
String sha512HexStr= DigestUtils.sha512Hex(data)//生成加密码码
|
||||||
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
||||||
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
||||||
}
|
}
|
||||||
|
|
||||||
static def listFileNames(month){
|
static def listFileNames(month){
|
||||||
//上传到ftp
|
//上传到ftp
|
||||||
sftpChannel = reConnect();
|
sftpChannel = reConnect();
|
||||||
Vector files = sftp.listFiles(ftpPath+ month+"/", sftpChannel);
|
Vector files = sftp.listFiles(ftpPath+ month+"/", sftpChannel);
|
||||||
return files
|
return files
|
||||||
|
|||||||
Reference in New Issue
Block a user