|
|
|
@ -4,6 +4,7 @@ import com.jcraft.jsch.ChannelSftp;
|
|
|
|
|
import com.xydl.cac.config.BizConfig;
|
|
|
|
|
import com.xydl.cac.entity.*;
|
|
|
|
|
import com.xydl.cac.entity.constants.Constants;
|
|
|
|
|
import com.xydl.cac.model.StaticVariable;
|
|
|
|
|
import com.xydl.cac.service.RemoteConfigService;
|
|
|
|
|
import com.xydl.cac.service.RemoteDownloadService;
|
|
|
|
|
import com.xydl.cac.socket.WebSocketServer;
|
|
|
|
@ -51,22 +52,15 @@ public class SftpDownloadTask {
|
|
|
|
|
List<RemoteConfig> configList = configService.listAll();
|
|
|
|
|
if (!CollectionUtils.isEmpty(configList)) {
|
|
|
|
|
log.info("AmpliDownloadTask.downloadAll 开始.");
|
|
|
|
|
try {
|
|
|
|
|
for (RemoteConfig config : configList) {
|
|
|
|
|
this.downloadServer(config);
|
|
|
|
|
}
|
|
|
|
|
log.info("AmpliDownloadTask.downloadAll 结束.");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("AmpliDownloadTask.downloadAll error.", e);
|
|
|
|
|
String str = "SFTP下载文件异常: " + e.getMessage();
|
|
|
|
|
webSocketServer.sendMessage(str, null);
|
|
|
|
|
dingTalkPushUtil.pushText(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下载一个远端服务器
|
|
|
|
|
private void downloadServer(RemoteConfig config) throws Exception {
|
|
|
|
|
private void downloadServer(RemoteConfig config) {
|
|
|
|
|
if (shutdown == 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -88,8 +82,12 @@ public class SftpDownloadTask {
|
|
|
|
|
log.error("AmpliDownloadTask.downloadServer error.", e);
|
|
|
|
|
String str = "SFTP下载文件异常: " + config.getName() + " " +
|
|
|
|
|
config.getIp() + " " + e.getMessage();
|
|
|
|
|
String key = "sftp" + config.getId();
|
|
|
|
|
if (!StaticVariable.doneWarnMap.containsKey(key)) {
|
|
|
|
|
StaticVariable.doneWarnMap.put(key, "1");
|
|
|
|
|
webSocketServer.sendMessage(str, null);
|
|
|
|
|
dingTalkPushUtil.pushText(str);
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
sftpTool.disconnect();
|
|
|
|
|
}
|
|
|
|
|