| | |
| | | @EnableScheduling // 2.开启定时任务 |
| | | public class FtpService { |
| | | //定时上传指定目录下文件 |
| | | @Scheduled(cron = "59 59 23 * * ?") |
| | | @Scheduled(cron = "0/20 57 16 * * ?") |
| | | private void sendFtpFile(){ |
| | | FtpHelper ftp = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword); |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String root=fileDirName+File.separator+"face"; |
| | | String rootFace=fileDirName+File.separator+"face"; |
| | | String rootDoc=fileDirName+File.separator+"doc_file"; |
| | | try { |
| | | FileOutputStream fos = new FileOutputStream(new File(root+".zip")); |
| | | ZipUtils.toZip(root, fos,true); |
| | | File file = new File(root+".zip"); |
| | | ftp.uploadFile(file, "face.zip"); |
| | | FileOutputStream forootFace = new FileOutputStream(new File(rootFace+".zip")); |
| | | ZipUtils.toZip(rootFace, forootFace,true); |
| | | File filerootFace = new File(rootFace+".zip"); |
| | | ftp.uploadFile(filerootFace, "face.zip"); |
| | | |
| | | FileOutputStream forootDoc = new FileOutputStream(new File(rootDoc+".zip")); |
| | | ZipUtils.toZip(rootDoc, forootDoc,true); |
| | | File filerootDoc = new File(rootDoc+".zip"); |
| | | ftp.uploadFile(filerootDoc, "doc_file.zip"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |