diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java index 22984ab2..71e490fc 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java @@ -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 failList = new ArrayList<>(); - for (String path:needDel) { - boolean success = ftpUtil.removeFiles(path); - if (!success) { - failList.add(path); - } + // 删除本地文件 + List 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 fileList = new ArrayList<>(); List 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;