fix:修改FTP为本地文件

This commit is contained in:
nieziyan 2024-04-24 09:34:59 +08:00
parent a025eb5098
commit 6335a3f588

View File

@ -1,8 +1,10 @@
package org.jeecg.modules.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
@ -13,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.google.common.io.Files;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
@ -47,9 +50,6 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
@Autowired
private RedisUtil redisUtil;
@Autowired
private FTPUtil ftpUtil;
@Autowired
private SpectrumPathProperties pathProperties;
@ -110,9 +110,9 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
TransactionDefinition txDef = new DefaultTransactionDefinition();
final TransactionStatus txStatus = transactionManager.getTransaction(txDef);
try {
String ftpRootPath = ftpUtil.getFtpRootPath();
String savePath = ftpRootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
String logPath = ftpRootPath + pathProperties.getLogPath() + StrUtil.SLASH;
String rootPath = pathProperties.getRootPath();
String savePath = rootPath + pathProperties.getSaveFilePath() + StrUtil.SLASH;
String logPath = rootPath + pathProperties.getLogPath() + StrUtil.SLASH;
/* 删除数据库数据 */
// 过滤掉多余的表
String ORIGINAL = "ORIGINAL";String RNAUTO = "RNAUTO";String RNMAN = "RNMAN";
@ -170,16 +170,14 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
needDel = needDel.stream().filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isEmpty(needDel))
return Result.OK("Data cleaning is complete. No files need to be cleaned!");
// 删除FTP文件
List<String> failList = new ArrayList<>();
for (String path:needDel) {
boolean success = ftpUtil.removeFiles(path);
if (!success) {
failList.add(path);
}
// 删除本地文件
List<String> fails = new ArrayList<>();
for (String path : needDel) {
boolean success = FileUtil.del(path);
if (!success) fails.add(path);
}
if (CollUtil.isNotEmpty(failList))
return Result.error("Data clearing is complete, but file clearing fails!", failList);
if (CollUtil.isNotEmpty(fails))
return Result.error("Data clearing is complete, but file clearing fails!", fails);
return Result.OK("Data and file cleanup complete!");
}catch (Exception e){
transactionManager.rollback(txStatus);
@ -215,27 +213,25 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
Integer sampleId, String owner){
List<String> fileList = new ArrayList<>();
List<AnalysesDto> AnalysesDtoList = baseMapper.getAnalysis(owner, sampleId);
if (CollectionUtils.isNotEmpty(AnalysesDtoList)) {
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
String baselinePath = AnalysesDto.getBaselinePath();
if (StrUtil.isNotBlank(baselinePath)) {
fileList.add(savePath + baselinePath);
}
String lcPath = AnalysesDto.getLcPath();
if (StrUtil.isNotBlank(lcPath)) {
fileList.add(savePath + lcPath);
}
String scacPath = AnalysesDto.getScacPath();
if (StrUtil.isNotBlank(scacPath)) {
fileList.add(savePath + scacPath);
}
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
fileList.add(logPath + AnalysesDto.getLogPath());
}
String reportPath = AnalysesDto.getReportPath();
if (StrUtil.isNotBlank(reportPath)) {
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
}
for (AnalysesDto AnalysesDto:AnalysesDtoList) {
String baselinePath = AnalysesDto.getBaselinePath();
if (StrUtil.isNotBlank(baselinePath)) {
fileList.add(savePath + baselinePath);
}
String lcPath = AnalysesDto.getLcPath();
if (StrUtil.isNotBlank(lcPath)) {
fileList.add(savePath + lcPath);
}
String scacPath = AnalysesDto.getScacPath();
if (StrUtil.isNotBlank(scacPath)) {
fileList.add(savePath + scacPath);
}
if (StrUtil.isNotBlank(AnalysesDto.getLogPath())) {
fileList.add(logPath + AnalysesDto.getLogPath());
}
String reportPath = AnalysesDto.getReportPath();
if (StrUtil.isNotBlank(reportPath)) {
fileList.add(savePath + reportPath + FileTypeEnum.txt.getType());
}
}
return fileList;