fix: 修改删除能谱功能 增加日志输入和文件夹判断
This commit is contained in:
parent
926aa9fe10
commit
10e07c5969
|
@ -3,6 +3,7 @@ package org.jeecg.modules.system.service.impl;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
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;
|
||||
|
@ -38,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -112,9 +114,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";
|
||||
|
@ -172,16 +174,20 @@ 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<>();
|
||||
// 删除本地文件
|
||||
List<String> fails = new ArrayList<>();
|
||||
for (String path : needDel) {
|
||||
boolean success = ftpUtil.removeFiles(path);
|
||||
if (!success) {
|
||||
failList.add(path);
|
||||
log.info("删除能谱文件:{}", path);
|
||||
File file = new File(path);
|
||||
if (file.isDirectory()) {
|
||||
fails.add(path);
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user