fix:1.优化S、Q、G、D谱文件解析后使用移动策略2优化修改解析状态

This commit is contained in:
panbaolin 2023-10-25 14:36:51 +08:00
parent 79300438d8
commit 8d1cb29214
8 changed files with 26 additions and 19 deletions

View File

@ -117,7 +117,7 @@ public class FileOperation {
* @throws IOException
*/
public static void moveFile(File srcFile,String destDir,boolean isOverride) throws IOException {
FileUtil.move(srcFile,new File(destDir),true);
FileUtil.move(srcFile,new File(destDir),isOverride);
}
/**
@ -128,7 +128,7 @@ public class FileOperation {
* @throws IOException
*/
public static void copyFile(File srcFile,String destDir,boolean isOverride) throws IOException {
FileUtil.copy(srcFile,new File(destDir),true);
FileUtil.copy(srcFile,new File(destDir),isOverride);
}
/**

View File

@ -195,7 +195,9 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
* 修改解析状态
*/
protected void updateStatus(){
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.status,this.sampleData.getInputFileName());
if(Objects.nonNull(this.sampleData)){
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.status,this.sampleData.getInputFileName());
}
}
/**

View File

@ -111,7 +111,8 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
finalPath.append(fileSavePath);
finalPath.append(File.separator);
finalPath.append(this.spectrumFile.getName());
FileOperation.copyFile(this.spectrumFile,finalPath.toString(),true);
FileOperation.moveFile(this.spectrumFile,finalPath.toString(),true);
this.spectrumFile = new File(finalPath.toString());
//设置能谱文件保存相对路径包含文件名称
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}

View File

@ -57,8 +57,6 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
}else{
super.next.handler();

View File

@ -59,8 +59,6 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
}else{
super.next.handler();

View File

@ -58,8 +58,6 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
}else{
super.next.handler();

View File

@ -64,7 +64,7 @@ public class Sample_B_Analysis implements BlockConstant {
/**
* sample谱PHD文件临时路径
*/
private String sampleTempFilePath;
private String sampleFileFinalPath;
/**
* det谱PHD文件临时路径
*/
@ -129,7 +129,7 @@ public class Sample_B_Analysis implements BlockConstant {
public Sample_B_Analysis(AbstractS_D_Q_G_SpectrumHandler spectrumHandler){
this.sampleData = spectrumHandler.sampleData;
this.sampleTempFilePath = spectrumHandler.spectrumFile.getAbsolutePath();
this.sampleFileFinalPath = spectrumHandler.spectrumFile.getAbsolutePath();
this.spectrumServiceQuotes = spectrumHandler.spectrumServiceQuotes;
this.sampleStruct = spectrumHandler.sourceData;
this.parsingProcessLog = spectrumHandler.parsingProcessLog;
@ -217,10 +217,10 @@ public class Sample_B_Analysis implements BlockConstant {
* 调用dll库的分析B谱结果
*/
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasFileFinalPath,this.detFileFinalPath);
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleFileFinalPath,this.gasFileFinalPath,this.detFileFinalPath);
System.out.println(analyseResult);
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasFileFinalPath+","+this.detFileFinalPath);
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleFileFinalPath+","+this.gasFileFinalPath+","+this.detFileFinalPath);
}
this.analyseResult = analyseResult;
}
@ -232,14 +232,26 @@ public class Sample_B_Analysis implements BlockConstant {
private void getPHDFile() throws IOException, FileNotExistException {
boolean flag = false;
//gas谱PHD文件本地路径
this.gasFileFinalPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+File.separator+this.spectrumServiceQuotes.getSpectrumPathProperties().getSaveFilePath()+File.separator+gasSampleData.getInputFileName();
StringBuilder gasFileFinalPath = new StringBuilder();
gasFileFinalPath.append(this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath());
gasFileFinalPath.append(File.separator);
gasFileFinalPath.append(this.spectrumServiceQuotes.getSpectrumPathProperties().getSaveFilePath());
gasFileFinalPath.append(File.separator);
gasFileFinalPath.append(gasSampleData.getInputFileName());
this.gasFileFinalPath = gasFileFinalPath.toString();
File gasFile = new File(this.gasFileFinalPath);
if(!gasFile.exists()){
flag = true;
}
//det谱PHD文件本地路径
this.detFileFinalPath = this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath()+File.separator+this.spectrumServiceQuotes.getSpectrumPathProperties().getSaveFilePath()+File.separator+detSampleData.getInputFileName();
StringBuilder detFileFinalPath = new StringBuilder();
detFileFinalPath.append(this.spectrumServiceQuotes.getSpectrumPathProperties().getRootPath());
detFileFinalPath.append(File.separator);
detFileFinalPath.append(this.spectrumServiceQuotes.getSpectrumPathProperties().getSaveFilePath());
detFileFinalPath.append(File.separator);
detFileFinalPath.append(detSampleData.getInputFileName());
this.detFileFinalPath = detFileFinalPath.toString();
File detFile = new File(this.detFileFinalPath);
if(!detFile.exists()){
flag = true;
@ -263,7 +275,7 @@ public class Sample_B_Analysis implements BlockConstant {
//如果数据已经存储不在重复存储
final Integer idAnalysis = spectrumServiceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId());
if(Objects.nonNull(idAnalysis)){
log.warn("{} file analysis data has been stored",new File(this.sampleTempFilePath).getName());
log.warn("{} file analysis data has been stored",new File(this.sampleFileFinalPath).getName());
return;
}
DataSourceSwitcher.switchToOracle();

View File

@ -61,8 +61,6 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
}else{
super.next.handler();