perf: 优化路径配置

iec104
huangfeng 9 months ago
parent 1c7839afa6
commit b059da1d20

@ -16,6 +16,6 @@ import java.util.List;
public class BizConfig {
private String rsakey;
private String datapath;
}

@ -1,6 +1,7 @@
package com.xydl.cac.task;
import com.jcraft.jsch.ChannelSftp;
import com.xydl.cac.config.BizConfig;
import com.xydl.cac.entity.*;
import com.xydl.cac.service.RemoteConfigService;
import com.xydl.cac.service.RemoteDownloadService;
@ -9,7 +10,6 @@ import com.xydl.cac.util.DingTalkPushUtil;
import com.xydl.cac.util.SFTPTool;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -22,11 +22,13 @@ import java.util.Vector;
@Service
@Slf4j
public class SftpDownloadTask {
public class AmpliDownloadTask {
@Value("${cac.data-path}")
public String dataPath;
String nginxPath = "/data";
String folder = "/ampli";
@Resource
BizConfig bizConfig;
@Resource
RemoteConfigService configService;
@Resource
@ -36,7 +38,7 @@ public class SftpDownloadTask {
@Resource
WebSocketServer webSocketServer;
@Scheduled(cron = "0 3 * * * ?")
@Scheduled(cron = "0 10 * * * ?")
public void downloadAll() {
List<RemoteConfig> configList = configService.listAll();
if (!CollectionUtils.isEmpty(configList)) {
@ -84,8 +86,8 @@ public class SftpDownloadTask {
private void downloadPath(String remotePath, RemoteConfig config, SFTPTool sftpTool) throws Exception {
String str = "abcd" + remotePath.replaceAll("/", "").replaceAll("\\\\", "");
str = str.substring(str.length() - 4);
String localPath = "/ampli/" + config.getIp() + "/" + str;
File dir = new File(dataPath + localPath);
String localPath = folder + "/" + config.getIp() + "/" + str;
File dir = new File(bizConfig.getDatapath() + localPath);
dir.mkdirs();
Vector<ChannelSftp.LsEntry> files = sftpTool.listFiles(remotePath);
@ -105,11 +107,11 @@ public class SftpDownloadTask {
boolean exist = downloadService.exist(item);
if (!exist) {
String localFilePath = localPath + "/" + filename;
sftpTool.download(filename, dataPath + localFilePath);
sftpTool.download(filename, bizConfig.getDatapath() + localFilePath);
if (config.getTodel() != null && config.getTodel().intValue() == 1) {
sftpTool.delete(filename);
}
item.setPath("/data" + localFilePath);
item.setPath(nginxPath + localFilePath);
item.setCreateTime(new Date());
downloadService.add(item);
}

@ -30,7 +30,7 @@ spring:
size: 5
cac:
data-path: /home/xydl/ncac/data
datapath: /home/xydl/ncac/data
i2:
enable: false
url: http://192.168.1.190:8080/busi-back-ws/service/XydlService

@ -30,7 +30,7 @@ spring:
size: 5
cac:
data-path: /home/xydl/ncac/data
datapath: /home/xydl/ncac/data
i2:
enable: false
url: http://192.168.1.190:8080/busi-back-ws/service/XydlService

Loading…
Cancel
Save