fix:1.修改B谱分析功能中分析结束时间、日志路径信息没有正确存到库里面的问题

This commit is contained in:
panbaolin 2023-09-25 18:44:51 +08:00
parent 0ac2c77e27
commit 2845a41af7
6 changed files with 73 additions and 43 deletions

View File

@ -27,4 +27,11 @@ public interface GardsAnalysesService extends IService<GardsAnalyses> {
public GardsAnalyses create(Integer sampleId, GardsSampleData detSampleData, GardsSampleData gasSampleData, Date beginDate, Date endDate, String logPath, String reportPath); public GardsAnalyses create(Integer sampleId, GardsSampleData detSampleData, GardsSampleData gasSampleData, Date beginDate, Date endDate, String logPath, String reportPath);
Integer getIdAnalysis(Integer sampleId); Integer getIdAnalysis(Integer sampleId);
/**
* 修改分析结束时间
* @param idAnalysis
* @param endTime
*/
void updateAnalysesEndTime(Integer idAnalysis,Date endTime);
} }

View File

@ -13,6 +13,7 @@ import org.jeecg.modules.mapper.GardsAnalysesMapper;
import org.jeecg.modules.service.GardsAnalysesService; import org.jeecg.modules.service.GardsAnalysesService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.Objects;
/** /**
* 存储谱数据分析的基本信息 * 存储谱数据分析的基本信息
@ -66,4 +67,21 @@ public class GardsAnalysesServiceImpl extends ServiceImpl<GardsAnalysesMapper, G
GardsAnalyses gardsAnalyses = getOne(wrapper); GardsAnalyses gardsAnalyses = getOne(wrapper);
return ObjectUtil.isNull(gardsAnalyses) ? null : gardsAnalyses.getIdAnalysis(); return ObjectUtil.isNull(gardsAnalyses) ? null : gardsAnalyses.getIdAnalysis();
} }
/**
* 修改分析结束时间
* @param idAnalysis
* @param endTime
*/
@DS(value = "ora")
@Override
public void updateAnalysesEndTime(Integer idAnalysis,Date endTime) {
LambdaQueryWrapper<GardsAnalyses> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalyses::getIdAnalysis,idAnalysis);
final GardsAnalyses gardsAnalyses = this.getOne(wrapper);
if(Objects.nonNull(gardsAnalyses)){
gardsAnalyses.setAnalysisEnd(endTime);
this.updateById(gardsAnalyses);
}
}
} }

View File

@ -781,10 +781,10 @@ public class ParsingProcessLog {
private void saveLogToFTP(String log){ private void saveLogToFTP(String log){
//保存日志文件到ftp //保存日志文件到ftp
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties(); final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath(); String logFilePath = properties.getLogPath()+StringConstant.SLASH+spectrumHandler.getFileSavePath();
spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); String logFileName = spectrumHandler.mailFile.getName().replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8))); spectrumHandler.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8)));
} }
/** /**

View File

@ -52,14 +52,6 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
* 基础数据 * 基础数据
*/ */
protected GardsSampleData sampleData; protected GardsSampleData sampleData;
/**
* 日志文件路径
*/
protected String logFilePath;
/**
* 日志文件名称
*/
protected String logFileName;
/** /**
* 流程日志对象 * 流程日志对象
*/ */

View File

@ -75,6 +75,15 @@ public class Sample_B_Analysis implements BlockConstant {
* gas谱PHD文件临时路径 * gas谱PHD文件临时路径
*/ */
private String gasTempFilePath; private String gasTempFilePath;
/**
* SamplephdSpectrum类->saveFileToFtp()构造的能谱文件ftp保存路径
* 可根据此路径构造log和arr保存路径
*/
protected String ftpSavePath;
/**
* SamplephdSpectrum类->updateSpectrumFileName()构造的能谱文件名称 可根据此路径构造log和arr文件名称
*/
protected String phdFileName;
/** /**
* 日志文件路径 * 日志文件路径
*/ */
@ -111,6 +120,10 @@ public class Sample_B_Analysis implements BlockConstant {
* 结束分析时间 * 结束分析时间
*/ */
protected Date endAnalysisTime; protected Date endAnalysisTime;
/**
* 分析基础数据
*/
protected GardsAnalyses analyses;
/** /**
* 流程日志对象 * 流程日志对象
@ -120,30 +133,32 @@ public class Sample_B_Analysis implements BlockConstant {
public Sample_B_Analysis() { public Sample_B_Analysis() {
} }
public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes, public Sample_B_Analysis(S_D_Q_G_SpectrumHandler spectrumHandler){
EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName,ParsingProcessLog parsingProcessLog){ this.sampleData = spectrumHandler.sampleData;
this.sampleData = sampleData; this.sampleTempFilePath = spectrumHandler.mailFile.getAbsolutePath();
this.sampleTempFilePath = sampleTempFilePath; this.spectrumServiceQuotes = spectrumHandler.spectrumServiceQuotes;
this.spectrumServiceQuotes = spectrumServiceQuotes; this.sampleStruct = spectrumHandler.sourceData;
this.sampleStruct = sampleStruct; this.ftpUtil = spectrumHandler.ftpUtil;
this.ftpUtil = ftpUtil; this.parsingProcessLog = spectrumHandler.parsingProcessLog;
this.logFilePath = logFilePath; this.ftpSavePath = spectrumHandler.getFileSavePath();
this.logFileName = logFileName; this.phdFileName = spectrumHandler.mailFile.getName();
this.parsingProcessLog = parsingProcessLog;
} }
/** /**
* 执行解析过程 * 执行解析过程
*/ */
public void start() throws BAnalyseException { public void start() throws BAnalyseException {
//标记整个分析过程是否分析失败
boolean analyseFail = false;
try{ try{
this.startAnalysisTime = new Date(); this.startAnalysisTime = new Date();
//声明分析日志对象 //声明分析日志对象
parsingProcessLog.setSample_B_Analysis(this); parsingProcessLog.setSample_B_Analysis(this);
//查询detgas数据sampleId,inputFileNamesample数据在构造函数已经传过来 //查询detgas数据sampleId,inputFileNamesample数据在构造函数已经传过来
this.queryPHDFile(); this.queryPHDFile();
//构造报告文件存储路径及文件名称日志文件存储路径及文件名称在原始库存储阶段已存在已经传过来 //构造报告文件存储路径及文件名称日志文件存储路径及文件名称
this.structureArrFilePath(); this.structureLogAndArrFilePath();
//下载det和gas谱PHD文件sample谱PHD文件位置在构造函数已经传过来 //下载det和gas谱PHD文件sample谱PHD文件位置在构造函数已经传过来
this.downloadPHDFile(); this.downloadPHDFile();
//传入sampledet和gas谱PHD文件调用dll进行分析 //传入sampledet和gas谱PHD文件调用dll进行分析
@ -154,10 +169,15 @@ public class Sample_B_Analysis implements BlockConstant {
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
report.start(); report.start();
}catch (Exception e){ }catch (Exception e){
analyseFail = true;
e.printStackTrace(); e.printStackTrace();
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
}finally { }finally {
this.endAnalysisTime = new Date(); this.endAnalysisTime = new Date();
//如果分析成功并且analyses对象不为空
if(!analyseFail && Objects.nonNull(this.analyses)){
spectrumServiceQuotes.getAnalysesService().updateAnalysesEndTime(this.analyses.getIdAnalysis(),this.endAnalysisTime);
}
//删除下载的det和gas临时文件 //删除下载的det和gas临时文件
this.deleteLocalTemporaryFile(); this.deleteLocalTemporaryFile();
} }
@ -168,7 +188,7 @@ public class Sample_B_Analysis implements BlockConstant {
* @throws FileNotExistException * @throws FileNotExistException
*/ */
private void queryPHDFile() throws FileNotExistException { private void queryPHDFile() throws FileNotExistException {
//查询det和gas能谱文 //查询det和gas能谱文
this.detSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType()); this.detSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType());
this.gasSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.gas_bk_measurement_id, DataTypeAbbr.GASBKPHD.getType()); this.gasSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.gas_bk_measurement_id, DataTypeAbbr.GASBKPHD.getType());
@ -184,27 +204,19 @@ public class Sample_B_Analysis implements BlockConstant {
/** /**
* 创建报告文件路径 * 创建报告文件路径
*/ */
private void structureArrFilePath(){ private void structureLogAndArrFilePath(){
//处理此文件需要保存到ftp服务的路径
//measurement_id切割后的字符数组
String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH);
//切割后第一个元素是年第二个是月
final String[] yearMonth = arr[1].split(StringConstant.SLASH);
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
//构造报告文件路径
StringBuilder ftpPath = new StringBuilder(); StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getArrPath()); ftpPath.append(properties.getArrPath());
ftpPath.append(StringConstant.SLASH); ftpPath.append(StringConstant.SLASH);
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type)); ftpPath.append(this.ftpSavePath);
ftpPath.append(StringConstant.SLASH);
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type));
ftpPath.append(StringConstant.SLASH);
ftpPath.append(yearMonth[0]);
ftpPath.append(StringConstant.SLASH);
ftpPath.append(yearMonth[1]);
this.arrFilePath = ftpPath.toString(); this.arrFilePath = ftpPath.toString();
String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX; String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX;
String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1); this.arrFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail);
this.arrFileName = sourceFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail); //构造日志文件路径
this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.ftpSavePath;
this.logFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
} }
/** /**
@ -271,7 +283,7 @@ public class Sample_B_Analysis implements BlockConstant {
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
try{ try{
//存储基础数据 //存储基础数据
final GardsAnalyses analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData, this.analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData,
this.gasSampleData,this.startAnalysisTime,this.endAnalysisTime,logFileRelativePath,arrFileRelativePath); this.gasSampleData,this.startAnalysisTime,this.endAnalysisTime,logFileRelativePath,arrFileRelativePath);
//调用原始数据dll获取gasdet谱数据入库sample已有数据直接入库 //调用原始数据dll获取gasdet谱数据入库sample已有数据直接入库
//存储sample谱B_Energy和G_Energy块数据 //存储sample谱B_Energy和G_Energy块数据

View File

@ -75,10 +75,11 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
*/ */
protected void autoAnalysis() throws Exception { protected void autoAnalysis() throws Exception {
if(this.sourceData.system_type.equals(SystemType.BETA.getType())){ if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(), Sample_B_Analysis bAnalysis = new Sample_B_Analysis(this);
super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,
super.logFilePath,super.logFileName,super.parsingProcessLog);
bAnalysis.start(); bAnalysis.start();
// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.parsingProcessLog);
// bAnalysis.start();
} }
// if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) { // if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) {
// Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData); // Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData);