feat:自建台站自动处理完善
This commit is contained in:
parent
979f24a10c
commit
02083f93f5
|
@ -27,14 +27,14 @@ import org.jeecg.modules.base.bizVo.AttributeItemVo;
|
||||||
import org.jeecg.modules.base.dto.*;
|
import org.jeecg.modules.base.dto.*;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.entity.rnauto.*;
|
import org.jeecg.modules.base.entity.rnauto.*;
|
||||||
import org.jeecg.modules.base.enums.DSType;
|
import org.jeecg.modules.base.enums.*;
|
||||||
import org.jeecg.modules.base.enums.MiddleDataType;
|
|
||||||
import org.jeecg.modules.base.enums.SpectrumType;
|
|
||||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
|
import org.jeecg.modules.enums.ErrorType;
|
||||||
import org.jeecg.modules.exception.AnalySpectrumException;
|
import org.jeecg.modules.exception.AnalySpectrumException;
|
||||||
import org.jeecg.modules.exception.CAnalyseException;
|
import org.jeecg.modules.exception.CAnalyseException;
|
||||||
|
import org.jeecg.modules.exception.FileNotExistException;
|
||||||
import org.jeecg.modules.file.FileOperation;
|
import org.jeecg.modules.file.FileOperation;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
||||||
|
@ -124,9 +124,9 @@ public class Sample_C_Analysis {
|
||||||
*/
|
*/
|
||||||
private String arrFileName;
|
private String arrFileName;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 自建台站谱解析所需的四个Gamms谱对象
|
* 自建台站谱解析所需的四个Gamms谱对象
|
||||||
* */
|
*/
|
||||||
private PHDFile phdFile1;
|
private PHDFile phdFile1;
|
||||||
private PHDFile phdFile2;
|
private PHDFile phdFile2;
|
||||||
private PHDFile phdFile3;
|
private PHDFile phdFile3;
|
||||||
|
@ -136,6 +136,18 @@ public class Sample_C_Analysis {
|
||||||
|
|
||||||
private Map<Integer, GStoreMiddleProcessData> middleDataMap;
|
private Map<Integer, GStoreMiddleProcessData> middleDataMap;
|
||||||
|
|
||||||
|
protected Date startAnalysisTime;
|
||||||
|
|
||||||
|
protected Date endAnalysisTime;
|
||||||
|
|
||||||
|
protected GardsSampleData detSampleData = null;
|
||||||
|
|
||||||
|
protected EnergySpectrumStruct detStruct = null;
|
||||||
|
|
||||||
|
private String detFileFinalPath;
|
||||||
|
|
||||||
|
protected ParsingProcessLog parsingProcessLog;
|
||||||
|
|
||||||
public Sample_C_Analysis(AbstractS_D_Q_G_SpectrumHandler spectrumHandler, EnergySpectrumStruct sampleStruct, SpectrumServiceQuotes serviceQuotes,
|
public Sample_C_Analysis(AbstractS_D_Q_G_SpectrumHandler spectrumHandler, EnergySpectrumStruct sampleStruct, SpectrumServiceQuotes serviceQuotes,
|
||||||
GardsSampleData sampleData) {
|
GardsSampleData sampleData) {
|
||||||
this.spectrumHandler = spectrumHandler;
|
this.spectrumHandler = spectrumHandler;
|
||||||
|
@ -144,6 +156,7 @@ public class Sample_C_Analysis {
|
||||||
this.sampleStruct = sampleStruct;
|
this.sampleStruct = sampleStruct;
|
||||||
this.systemType = sampleStruct.system_type;
|
this.systemType = sampleStruct.system_type;
|
||||||
this.dataType = sampleStruct.data_type;
|
this.dataType = sampleStruct.data_type;
|
||||||
|
this.parsingProcessLog = spectrumHandler.parsingProcessLog;
|
||||||
this.sampleInputFilename = sampleData.getInputFileName();
|
this.sampleInputFilename = sampleData.getInputFileName();
|
||||||
this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(),
|
this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(),
|
||||||
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1);
|
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1);
|
||||||
|
@ -152,6 +165,20 @@ public class Sample_C_Analysis {
|
||||||
public void analysis() throws CAnalyseException, AnalySpectrumException{
|
public void analysis() throws CAnalyseException, AnalySpectrumException{
|
||||||
log.info("SelfStaion自动处理分析--Start");
|
log.info("SelfStaion自动处理分析--Start");
|
||||||
try {
|
try {
|
||||||
|
this.startAnalysisTime = new Date();
|
||||||
|
|
||||||
|
//声明分析日志对象
|
||||||
|
// parsingProcessLog.setSample_C_Analysis(this);
|
||||||
|
|
||||||
|
//查询det数据(sampleId,inputFileName) sample数据在构造函数已经传过来
|
||||||
|
this.queryPHDFile();
|
||||||
|
|
||||||
|
//查找det谱PHD文件 sample谱PHD文件位置在构造函数已经传过来
|
||||||
|
this.getPHDFile();
|
||||||
|
|
||||||
|
// Beta谱进行分析 TODO Analysis
|
||||||
|
|
||||||
|
|
||||||
//获取PHD文件的路径以及文件名称信息
|
//获取PHD文件的路径以及文件名称信息
|
||||||
String sampleFilePathName = spectrumHandler.spectrumFile.getAbsolutePath().replace("\\", StringPool.SLASH);
|
String sampleFilePathName = spectrumHandler.spectrumFile.getAbsolutePath().replace("\\", StringPool.SLASH);
|
||||||
this.sampleFilePath = sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH));
|
this.sampleFilePath = sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH));
|
||||||
|
@ -235,6 +262,8 @@ public class Sample_C_Analysis {
|
||||||
} else {
|
} else {
|
||||||
throw new CAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
throw new CAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
}
|
}
|
||||||
|
}finally {
|
||||||
|
this.endAnalysisTime = new Date();
|
||||||
}
|
}
|
||||||
log.info("SelfStaion自动处理分析--End");
|
log.info("SelfStaion自动处理分析--End");
|
||||||
}
|
}
|
||||||
|
@ -342,6 +371,43 @@ public class Sample_C_Analysis {
|
||||||
return rootPath + saveFilePath + StrUtil.SLASH + saveRelativePath;
|
return rootPath + saveFilePath + StrUtil.SLASH + saveRelativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void queryPHDFile() throws FileNotExistException {
|
||||||
|
//查询det和gas能谱文
|
||||||
|
this.detSampleData = serviceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType(), this.sampleStruct.system_type);
|
||||||
|
|
||||||
|
//如果找不到sample、det、gas谱文件数据则解析失败修改记录状态
|
||||||
|
if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName())){
|
||||||
|
parsingProcessLog.setFileNotExist(true);
|
||||||
|
|
||||||
|
this.serviceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||||
|
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.sampleFilename));
|
||||||
|
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getPHDFile() throws FileNotExistException {
|
||||||
|
boolean flag = false;
|
||||||
|
|
||||||
|
//det谱PHD文件本地路径
|
||||||
|
StringBuilder detFileFinalPath = new StringBuilder();
|
||||||
|
detFileFinalPath.append(this.serviceQuotes.getSpectrumPathProperties().getRootPath());
|
||||||
|
detFileFinalPath.append(this.serviceQuotes.getSpectrumPathProperties().getSaveFilePath());
|
||||||
|
detFileFinalPath.append(StrUtil.SLASH);
|
||||||
|
detFileFinalPath.append(detSampleData.getInputFileName());
|
||||||
|
this.detFileFinalPath = detFileFinalPath.toString();
|
||||||
|
File detFile = new File(this.detFileFinalPath);
|
||||||
|
if(!detFile.exists()){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag){
|
||||||
|
parsingProcessLog.setFileNotExist(true);
|
||||||
|
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.sampleFilename));
|
||||||
|
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||||
|
}
|
||||||
|
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取计算MDC参数文件方法
|
* 读取计算MDC参数文件方法
|
||||||
*/
|
*/
|
||||||
|
@ -451,8 +517,9 @@ public class Sample_C_Analysis {
|
||||||
final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition());
|
final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition());
|
||||||
try {
|
try {
|
||||||
Integer sampleId = this.sampleData.getSampleId();
|
Integer sampleId = this.sampleData.getSampleId();
|
||||||
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
|
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES TODO 填充Beta分析产生的报告和日志地址
|
||||||
saveAnalysis(middleDatas[0], sampleId);
|
saveAnalysis(sampleId, this.detSampleData, this.startAnalysisTime,
|
||||||
|
this.endAnalysisTime, null, null);
|
||||||
// 获取分析结果ID ==> SELECT IDANALYSIS
|
// 获取分析结果ID ==> SELECT IDANALYSIS
|
||||||
idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(sampleId);
|
idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(sampleId);
|
||||||
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
|
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
|
||||||
|
@ -1334,31 +1401,25 @@ public class Sample_C_Analysis {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAnalysis(GStoreMiddleProcessData middleData, Integer sampleId){
|
public void saveAnalysis(Integer sampleId, GardsSampleData detSampleData, Date analysisBegin,
|
||||||
GardsAnalyses analysis = toAnalysis(middleData);
|
Date analysisEnd, String logPath, String reportPath){
|
||||||
|
GardsAnalyses analysis = new GardsAnalyses();
|
||||||
analysis.setSampleId(sampleId);
|
analysis.setSampleId(sampleId);
|
||||||
|
analysis.setCategory(1);//按C++代码写死的1,该字段是分级结果张博士还没有想好数据要不要分级1,2,3,4
|
||||||
|
analysis.setAnalysisBegin(analysisBegin);
|
||||||
|
analysis.setAnalysisEnd(analysisEnd);
|
||||||
|
analysis.setType(AnalysesType.AUTO.getValue());
|
||||||
|
analysis.setSoftware(serviceQuotes.getSoftwareProperties().getSwName());
|
||||||
|
analysis.setSwVersion(serviceQuotes.getSoftwareProperties().getSwVersion());
|
||||||
|
analysis.setAnalyst(serviceQuotes.getSoftwareProperties().getAnalyst());
|
||||||
|
analysis.setComments("test");//按C++代码写死的test
|
||||||
|
analysis.setUseddetphd(detSampleData.getInputFileName());
|
||||||
|
analysis.setUseddetphdId(detSampleData.getSampleId());
|
||||||
|
analysis.setLogPath(FileOperation.separatorConvert(logPath));
|
||||||
|
analysis.setReportPath(FileOperation.separatorConvert(reportPath));
|
||||||
serviceQuotes.getAnalysesService().save(analysis);
|
serviceQuotes.getAnalysesService().save(analysis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){
|
|
||||||
GardsAnalyses gardsAnalyses = new GardsAnalyses();
|
|
||||||
String dateTime = DateConstant.DATE_BIAS_TIME;
|
|
||||||
String analysisBegin = middleData.getAnalyses_analysisBegin();
|
|
||||||
Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime)
|
|
||||||
.toJdkDate();
|
|
||||||
gardsAnalyses.setAnalysisBegin(analysis_Begin);
|
|
||||||
String analysisEnd = middleData.getAnalyses_analysisEnd();
|
|
||||||
Date analysis_End = DateUtil.parse(analysisEnd, dateTime)
|
|
||||||
.toJdkDate();
|
|
||||||
gardsAnalyses.setAnalysisEnd(analysis_End);
|
|
||||||
gardsAnalyses.setType(middleData.getAnalyses_type());
|
|
||||||
gardsAnalyses.setSoftware(middleData.getAnalyses_software());
|
|
||||||
gardsAnalyses.setSwVersion(middleData.getAnalyses_swVersion());
|
|
||||||
gardsAnalyses.setAnalyst(middleData.getAnalyses_analyst());
|
|
||||||
gardsAnalyses.setComments(middleData.getAnalyses_comments());
|
|
||||||
return gardsAnalyses;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) {
|
/* public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) {
|
||||||
try {
|
try {
|
||||||
List<T2> result = new ArrayList<>();
|
List<T2> result = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user