update
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package com.fangjia.script.ccbevaluation
|
||||||
|
|
||||||
|
import com.fangjia.script.common.DataHandleUtils
|
||||||
|
import com.fangjia.script.jiangnanblank.SFTP
|
||||||
|
import com.jcraft.jsch.ChannelSftp
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
|
|
||||||
|
class CcbFtpUtils {
|
||||||
|
|
||||||
|
static def ftpServer = "192.168.0.45"
|
||||||
|
static def ftpPort = 17495
|
||||||
|
static def ftpUser = "ccb"
|
||||||
|
static def ftpPassword = "0I1k8EAM+O8iA"
|
||||||
|
static def ftpPath = "/home/ccb/output/"
|
||||||
|
|
||||||
|
static SFTP sftp = new SFTP();
|
||||||
|
static ChannelSftp sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
|
||||||
|
|
||||||
|
|
||||||
|
static def ftpUpload(outputPath_dist, month){
|
||||||
|
//上传到ftp
|
||||||
|
sftpChannel = reConnect();
|
||||||
|
sftp.upload(ftpPath+ month+"/", outputPath_dist, sftpChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static def reConnect(){
|
||||||
|
if(sftpChannel == null){
|
||||||
|
println "sftpChannel 为空,需重连....."
|
||||||
|
if(sftp == null){
|
||||||
|
sftp = new SFTP();
|
||||||
|
}
|
||||||
|
sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
|
||||||
|
}else{
|
||||||
|
println "sftpChannel 正常....."
|
||||||
|
}
|
||||||
|
return sftpChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
static def uploadSha512Data(def sb, def dataCodeFileName, def charset){
|
||||||
|
String sha512HexStr= DigestUtils.sha512Hex(sb.getBytes())//生成加密码码
|
||||||
|
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
||||||
|
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
||||||
|
}
|
||||||
|
|
||||||
|
static def uploadSha512Data2(def dataFileName, def dataCodeFileName, def charset){
|
||||||
|
|
||||||
|
def data = new FileInputStream(new File(dataFileName))
|
||||||
|
String sha512HexStr= DigestUtils.sha512Hex(data)//生成加密码码
|
||||||
|
DataHandleUtils.outPutFile(dataCodeFileName, sha512HexStr,charset);//生成加密码文件
|
||||||
|
ftpUpload(dataCodeFileName)//上传加密码文件到FTP
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static main(args) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user