| | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | //定时上传指定目录下文件 |
| | | @Scheduled(cron = "59 59 23 ? * FRI") |
| | | //@Scheduled(cron = "0/10 * * * * ?") |
| | | private void sendFtpFile() throws IOException, FTPException, InterruptedException { |
| | | private void sendFtpFile() throws IOException, FTPException, InterruptedException, ParseException { |
| | | //先连接ftp服务器,获取备份目录,保留3次.这里是从2023年4月开始进行保留 |
| | | FtpHelper ftpRemote = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword); |
| | | String[] dirList = ftpRemote.getDirList(); |
| | |
| | | ftpRemote.disconnect(); |
| | | |
| | | |
| | | FtpHelper ftp = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword); |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=fileDirName+File.separator+"face"; |
| | | |
| | | String rootDoc=fileDirName+File.separator+"doc_file"; |
| | | String timeStr= ActionUtil.sdfwithFTP.format(new Date()); |
| | | try { |
| | | FileOutputStream forootFace = new FileOutputStream(new File(rootFace+".zip")); |
| | | ZipUtils.toZip(rootFace, forootFace,true); |
| | | File filerootFace = new File(rootFace+".zip"); |
| | | ftp.uploadFile(filerootFace, timeStr+"/face.zip"); |
| | | filerootFace.delete(); |
| | | ftp.disconnect(); |
| | | |
| | | /*FileOutputStream forootDoc = new FileOutputStream(new File(rootDoc+".zip")); |
| | | ZipUtils.toZip(rootDoc, forootDoc,true); |
| | | File filerootDoc = new File(rootDoc+".zip"); |
| | | ftp.uploadFile(filerootDoc, timeStr+"/doc_file.zip"); |
| | | filerootDoc.delete();*/ |
| | | //List<File> list=ftp.getFileList(rootDoc); |
| | | File docFile = new File(rootDoc); |
| | | //File docFile = new File("F:\\BaiduNetdiskDownload"); |
| | | File[] list = docFile.listFiles(); |
| | | CountDownLatch latch = new CountDownLatch(list.length+1); |
| | | if(list!=null&&list.length>0){ |