fix:1.修改能谱解析完成后再移动能谱文件

This commit is contained in:
panbaolin 2024-01-02 17:02:42 +08:00
parent f266a98bb2
commit ad90c521d0
9 changed files with 48 additions and 25 deletions

View File

@ -169,6 +169,9 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
}
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
//设置能谱文件保存相对路径包含文件名称
String fileSavePath = this.getFileSaveRelativePath();
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}
/**

View File

@ -144,8 +144,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
* 保存能谱文件到savefile
*/
protected void saveFileToSavefile() throws Exception{
//修改能谱文件名称
this.updateSpectrumFileName();
//获取文件保存路径
String fileSavePath = this.getFileSaveRelativePath();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
@ -159,8 +157,6 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
finalPath.append(this.spectrumFile.getName());
FileOperation.moveFile(this.spectrumFile,finalPath.toString(),true);
this.spectrumFile = new File(finalPath.toString());
//设置能谱文件保存相对路径包含文件名称
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}
/**
@ -256,7 +252,7 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
if (isDateFormatErr) {
//修改能谱文件名称
this.updateErrorSpectrumFileName();
//解析失败会把文件移动到undeal目录
//解析失败会把文件移动到errorfile目录
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
final String finalPath = rootPath+File.separator+errorFilePath;
@ -266,11 +262,13 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
final String finalPath = rootPath+File.separator+undealPath;
FileOperation.copyFile(spectrumFile,finalPath,true);
FileOperation.moveFile(spectrumFile,finalPath,true);
}
} catch (IOException ex) {
ex.printStackTrace();
}
}else if(SpectrumSource.FROM_FILE_SOURCE.getSourceType().equals(spectrumSource) && (e instanceof FileRepeatException)){
this.spectrumFile.delete();
}
}

View File

@ -78,10 +78,12 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
super.printCurrDataType();
//解析邮件内容
this.parseingEmail();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
this.updateSpectrumFileName();
//结构体数据入库
this.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//若本次文件来自于undel目录解析成功则删除
deleteIfFromUndelFile();
}catch (Exception e){
@ -149,6 +151,9 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
}
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
//设置能谱文件保存相对路径包含文件名称
String fileSavePath = this.getFileSaveRelativePath();
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}
@Override

View File

@ -38,10 +38,12 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
super.updateSpectrumFileName();
//结构体数据入库
super.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
@ -54,7 +56,7 @@ public class DetbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到undeal目录
//处理解析失败的文件
super.handleParseingFailFile(e);
throw e;
}finally {

View File

@ -40,10 +40,12 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
super.updateSpectrumFileName();
//结构体数据入库
super.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
@ -56,7 +58,7 @@ public class GasbkphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到undeal目录
//处理解析失败的文件
super.handleParseingFailFile(e);
throw e;
}finally {

View File

@ -78,10 +78,12 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
super.printCurrDataType();
//解析邮件内容
this.parseingEmail();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
this.updateSpectrumFileName();
//结构体数据入库
this.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//把流程日志保存到日志目录
this.saveLogToLogDir();
//若本次文件来自于undel目录解析成功则删除
@ -149,6 +151,9 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
}
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
//设置能谱文件保存相对路径包含文件名称
String fileSavePath = this.getFileSaveRelativePath();
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}
@Override

View File

@ -68,10 +68,12 @@ public class MetSpectrum extends AbstractSpectrumHandler{
super.printCurrDataType();
//解析邮件内容
this.parseingEmail();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
this.updateSpectrumFileName();
//结构体数据入库
this.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//把流程日志保存到日志目录
this.saveLogToLogDir();
//若本次文件来自于undel目录解析成功则删除
@ -138,6 +140,9 @@ public class MetSpectrum extends AbstractSpectrumHandler{
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
}
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
//设置能谱文件保存相对路径包含文件名称
String fileSavePath = this.getFileSaveRelativePath();
this.spectrumFileRelativePath = fileSavePath+File.separator+this.spectrumFile.getName();
}
@Override

View File

@ -39,10 +39,12 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
super.updateSpectrumFileName();
//结构体数据入库
super.handlerOriginalData();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
@ -55,7 +57,7 @@ public class QcphdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到undeal目录
//处理解析失败的文件
super.handleParseingFailFile(e);
throw e;
}finally {

View File

@ -39,13 +39,14 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.parseingEmail();
//读取邮件内容标签
super.readFileLabel();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改能谱文件名称
super.updateSpectrumFileName();
//结构体数据入库
super.handlerOriginalData();
//进行BG(P)谱分析
this.autoAnalysis();
//保存PHD文件到savefile
super.saveFileToSavefile();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
@ -58,7 +59,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler {
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到undeal目录
//处理解析失败的文件
super.handleParseingFailFile(e);
throw e;
}finally {