| | |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.ZipUtils; |
| | | import com.whyc.util.ActionUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | | import org.apache.commons.net.ftp.FTPFile; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | |
| | | @ConditionalOnProperty(prefix = "configFile",name = "type",havingValue = "2") |
| | | @Service |
| | | @EnableScheduling // 2.开启定时任务 |
| | | @Slf4j |
| | | public class FtpService2 { |
| | | //定时上传指定目录下文件,每周五凌晨开启备份 |
| | | @Scheduled(cron = "59 59 23 ? * FRI") |
| | |
| | | //System.out.println(fileZip+"传输中转压缩包删除完毕"); |
| | | } catch (Exception e) { |
| | | isError = true; |
| | | e.printStackTrace(); |
| | | log.error("---------------文件"+ file.getName() +" FTP 传输异常2:"+e.toString()+"------------------"); |
| | | fileZip.delete(); |
| | | } |
| | | } |
| | |
| | | client2.disconnect(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("备份失败:"+e.toString()); |
| | | } |
| | | } |
| | | } |