fix:bugs

This commit is contained in:
nieziyan 2023-11-06 14:41:14 +08:00
parent f3406eaae0
commit 6ef350b05b
6 changed files with 58 additions and 29 deletions

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
@Data
public class AnalysesDto {
private String baselinePath;
private String lcPath;
private String scacPath;
private String logPath;
private String reportPath;
}

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.dto.AnalysesDto;
import org.jeecg.modules.base.dto.OwnerDto;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
@ -12,9 +13,9 @@ public interface GardsSampleDataMapper extends BaseMapper<GardsSampleDataSystem>
List<OwnerDto> containSampleId(String filed);
void delTables(@Param("tableNames") List<String> tableNames,
void delTables(@Param("tableName") String tableName,
@Param("sampleId") Integer sampleId);
GardsAnalyses getAnalysis(@Param("sampleId") Integer sampleId,
@Param("owner") String owner);
AnalysesDto getAnalysis(@Param("owner") String owner,
@Param("sampleId") Integer sampleId);
}

View File

@ -2,9 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.system.mapper.GardsSampleDataMapper">
<delete id="delTables">
<foreach collection = "tableNames" item = "tableName" index = "index">
DELETE FROM ${tableName} WHERE SAMPLE_ID = #{sampleId};
</foreach>
DELETE FROM ${tableName} WHERE SAMPLE_ID = #{sampleId}
</delete>
<select id="containSampleId" resultType="org.jeecg.modules.base.dto.OwnerDto">
@ -16,13 +14,13 @@
WHERE
COLUMN_NAME = #{filed}
</select>
<select id="getAnalysis" resultType="org.jeecg.modules.base.entity.rnauto.GardsAnalyses">
<select id="getAnalysis" resultType="org.jeecg.modules.base.dto.AnalysesDto">
SELECT
BASELINE_PATH AS baselinePath,
LC_PATH AS lcPath,
SCAC_PATH AS scacPath,
LOG_PATH AS logPath,
REPORT_PAHT AS reportPath
BASELINE_PATH,
LC_PATH,
SCAC_PATH,
LOG_PATH,
REPORT_PAHT
FROM
${owner}.GARDS_ANALYSES
WHERE

View File

@ -7,6 +7,8 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
import java.util.List;
public interface IGardsSampleDataService extends IService<GardsSampleDataSystem> {
/**
@ -25,4 +27,6 @@ public interface IGardsSampleDataService extends IService<GardsSampleDataSystem>
Result<?> deleteById(Integer sampleId, boolean sampleData, boolean rnAuto, boolean rnMan);
GardsSampleDataSystem getOne(Integer sampleId);
void delTables(List<String> tableNames, Integer sampleId);
}

View File

@ -18,6 +18,7 @@ import org.jeecg.common.constant.enums.FileTypeEnum;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.dto.AnalysesDto;
import org.jeecg.modules.base.dto.OwnerDto;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.system.entity.GardsSampleDataSystem;
@ -111,13 +112,13 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
List<String> allTables = ownerDtos.stream()
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
.collect(Collectors.toList());
// 删除表数据
if (CollUtil.isNotEmpty(allTables))
baseMapper.delTables(allTables, sampleId);
// 收集待删除文件路径
needDel.add(samplePath(savePath, sampleId)); // 原始谱文件
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNMAN)); // 人工交互文件
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNAUTO)); // 自动处理文件
// 删除表数据
if (CollUtil.isNotEmpty(allTables))
delTables(allTables, sampleId);
}
else {
if (rnAuto){
@ -126,11 +127,11 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
.filter(owner -> StrUtil.equals(owner.getOwner(), RNAUTO))
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
.collect(Collectors.toList());
// 删除表数据
if (CollUtil.isNotEmpty(autoTables))
baseMapper.delTables(autoTables, sampleId);
// 收集待删除文件路径
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNAUTO)); // 自动处理文件
// 删除表数据
if (CollUtil.isNotEmpty(autoTables))
delTables(autoTables, sampleId);
}
if (rnMan){
// 收集人工交互库所有表名
@ -138,11 +139,11 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
.filter(owner -> StrUtil.equals(owner.getOwner(), RNMAN))
.map(owner -> owner.getOwner() + DOT + owner.getTableName())
.collect(Collectors.toList());
// 删除表数据
if (CollUtil.isNotEmpty(manTables))
baseMapper.delTables(manTables, sampleId);
// 收集待删除文件路径
needDel.addAll(manOrAutoPath(savePath, logPath, sampleId, RNMAN)); // 人工交互文件
// 删除表数据
if (CollUtil.isNotEmpty(manTables))
delTables(manTables, sampleId);
}
}
transactionManager.commit(txStatus);
@ -169,6 +170,13 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
.orElse(new GardsSampleDataSystem());
}
@Override
public void delTables(List<String> tableNames, Integer sampleId) {
for (String tableName : tableNames) {
baseMapper.delTables(tableName, sampleId);
}
}
private String samplePath(String savePath, Integer sampleId){
GardsSampleDataSystem sampleData = getOne(sampleId);
String inputFileName = sampleData.getInputFileName();
@ -180,21 +188,21 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
private List<String> manOrAutoPath(String savePath, String logPath,
Integer sampleId, String owner){
List<String> fileList = new ArrayList<>();
GardsAnalyses analysisMan = baseMapper.getAnalysis(sampleId, owner);
if (ObjectUtil.isNull(analysisMan))
AnalysesDto AnalysesDto = baseMapper.getAnalysis(owner, sampleId);
if (ObjectUtil.isNull(AnalysesDto))
return fileList;
String baselinePath = analysisMan.getBaselinePath();
String baselinePath = AnalysesDto.getBaselinePath();
if (StrUtil.isNotBlank(baselinePath))
fileList.add(savePath + baselinePath);
String lcPath = analysisMan.getLcPath();
String lcPath = AnalysesDto.getLcPath();
if (StrUtil.isNotBlank(lcPath))
fileList.add(savePath + lcPath);
String scacPath = analysisMan.getScacPath();
String scacPath = AnalysesDto.getScacPath();
if (StrUtil.isNotBlank(scacPath))
fileList.add(savePath + scacPath);
if (StrUtil.isNotBlank(analysisMan.getLogPath()))
fileList.add(logPath + analysisMan.getLogPath());
String reportPath = analysisMan.getReportPath();
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;

View File

@ -16,3 +16,4 @@ spring:
import:
- optional:nacos:armd.yaml
- optional:nacos:armd-@profile.name@.yaml
- optional:nacos:armd-analysis-@profile.name@.yaml