fix:1.完成自动处理B分析日志功能2.优化自动处理功能结构测试B分析日志功能
This commit is contained in:
parent
51373c79d2
commit
c49318a57f
|
@ -159,7 +159,7 @@ public class FileSourceHandleManager {
|
|||
}catch (Exception e){
|
||||
//解析失败会把文件上传到undeal目录
|
||||
this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
|
||||
log.error("Parsing the {} file of the undeal directory failed",fileName);
|
||||
log.error("Parsing the {} file of the filesource directory failed",fileName);
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
//解析成功或者失败都会删除源文件
|
||||
|
|
|
@ -2,20 +2,27 @@ package org.jeecg.modules.service;
|
|||
|
||||
public interface BlockConstant {
|
||||
|
||||
public final static String PHD = "PHD";
|
||||
public final static String SYSTEMTYPE_B = "B";
|
||||
public final static String ENERGY_CAL = "energy";
|
||||
public final static String RESOLUTION_CAL = "Resolution";
|
||||
public final static String SYSTEMTYPE_G = "G";
|
||||
public final static String EFFICIENCY_CAL ="efficiency";
|
||||
String PHD = "PHD";
|
||||
String SYSTEMTYPE_B = "B";
|
||||
String ENERGY_CAL = "energy";
|
||||
String RESOLUTION_CAL = "Resolution";
|
||||
String SYSTEMTYPE_G = "G";
|
||||
String EFFICIENCY_CAL ="efficiency";
|
||||
|
||||
public final static String XE_131m = "Xe131m";
|
||||
public final static String XE_133m = "Xe133m";
|
||||
public final static String XE_133 = "Xe133";
|
||||
public final static String XE_135 = "Xe135";
|
||||
String XE_131m = "Xe131m";
|
||||
String XE_133m = "Xe133m";
|
||||
String XE_133 = "Xe133";
|
||||
String XE_135 = "Xe135";
|
||||
|
||||
public final static String CH_Contant = "CH(x)";
|
||||
public final static String E_Contant = "E(x)";
|
||||
String CH_Contant = "CH(x)";
|
||||
String E_Contant = "E(x)";
|
||||
|
||||
String to_flag = " to ";
|
||||
String arithmetic_flag = " +/- ";
|
||||
String and_flag = " and ";
|
||||
|
||||
String unit_kev = " keV";
|
||||
String unit_mbq = " mBq/m3";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ public interface ISpectrumBaseBlockService {
|
|||
* 不添加事务注解由调用方手动事务提交
|
||||
* @param struct
|
||||
* @param fileName
|
||||
* @param status
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception;
|
||||
public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception;
|
||||
}
|
||||
|
|
|
@ -65,19 +65,19 @@ public class GardsCalibrationPairsServiceImpl extends ServiceImpl<GardsCalibrati
|
|||
*/
|
||||
@Override
|
||||
public void createG_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct) {
|
||||
if(struct.g_e_record_count > 0){
|
||||
if(struct.g_record_count > 0){
|
||||
List<GardsCalibrationPairs> list = Lists.newArrayList();
|
||||
for (int i=0;i<struct.g_e_record_count;i++){
|
||||
for (int i=0;i<struct.g_record_count;i++){
|
||||
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||
calibrationPairs.setSampleId(sampleId);
|
||||
calibrationPairs.setIdAnalysis(anayId);
|
||||
calibrationPairs.setSampleType(SYSTEMTYPE_G);
|
||||
calibrationPairs.setCaltype(EFFICIENCY_CAL);
|
||||
calibrationPairs.setCaltype(ENERGY_CAL);
|
||||
calibrationPairs.setInput(PHD);
|
||||
calibrationPairs.setIdCalPoint(i);
|
||||
calibrationPairs.setXValue(struct.g_e_energy.get(i));
|
||||
calibrationPairs.setYValue(struct.g_e_efficiency.get(i));
|
||||
calibrationPairs.setUncYValue(struct.g_e_uncertainty.get(i));
|
||||
calibrationPairs.setXValue(struct.g_centroid_channel.get(i));
|
||||
calibrationPairs.setYValue(struct.g_energy.get(i));
|
||||
calibrationPairs.setUncYValue(struct.g_uncertainty.get(i));
|
||||
|
||||
list.add(calibrationPairs);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
|||
@Override
|
||||
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
|
||||
List<GardsRoiResults> list = Lists.newArrayList();
|
||||
//C++那边没有补0,先加上后续解决后再删除
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
|
||||
for(int i=0;i<analyseResult.ROI.size();i++){
|
||||
GardsRoiResults roiResults = new GardsRoiResults();
|
||||
|
@ -56,24 +54,29 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
|||
int seriNo = 0;
|
||||
//从下标3开始,每次加3
|
||||
for(int i=3;i<analyseResult.s_deduct_d_cts.size();i+=3){
|
||||
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
|
||||
seriNo++;
|
||||
if(seriNo < analyseResult.ROI.size()){
|
||||
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
|
||||
seriNo++;
|
||||
}
|
||||
}
|
||||
|
||||
seriNo = 0;
|
||||
//从下标3开始,每次加3
|
||||
for(int i=3;i<analyseResult.g_deduct_d_cts.size();i+=3){
|
||||
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
|
||||
if(seriNo < analyseResult.ROI.size()){
|
||||
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
|
||||
seriNo++;
|
||||
}
|
||||
}
|
||||
|
||||
//从下标1开始,第一条记录LC值固定为0
|
||||
for(int i=1;i<analyseResult.LC.size();i++){
|
||||
list.get(i).setLc(analyseResult.LC.get(i));
|
||||
//LC 从下标1开始,第一条记录LC值固定为0,所以是i+1
|
||||
for(int i=0;i<analyseResult.LC.size();i++){
|
||||
list.get(i+1).setLc(analyseResult.LC.get(i));
|
||||
}
|
||||
|
||||
//从下标1开始,第一条记录MDC值固定为0
|
||||
for(int i=1;i<analyseResult.MDC.size();i++){
|
||||
list.get(i).setMdc(analyseResult.MDC.get(i));
|
||||
//MDC从下标1开始,第一条记录MDC值固定为0,所以是i+1
|
||||
for(int i=0;i<analyseResult.MDC.size();i++){
|
||||
list.get(i+1).setMdc(analyseResult.MDC.get(i));
|
||||
}
|
||||
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
|
|
|
@ -75,7 +75,7 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
|
|||
xeResults.setConc(analyseResult.Xe133_con);
|
||||
xeResults.setConcErr(analyseResult.Xe133_uncer);
|
||||
xeResults.setMdc(analyseResult.MDC_Xe133);
|
||||
xeResults.setLc(analyseResult.MDC_Xe133);
|
||||
xeResults.setLc(analyseResult.LC_Xe133);
|
||||
xeResults.setNidFlag(analyseResult.XE_133_NID_FLAG);
|
||||
xeResults.setModdate(new Date());
|
||||
|
||||
|
@ -94,11 +94,11 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
|
|||
xeResults.setSampleId(sampleId);
|
||||
xeResults.setIdAnalysis(idAnalysis);
|
||||
xeResults.setNuclideName(nuclideName);
|
||||
xeResults.setConc(analyseResult.Xe131m_con);
|
||||
xeResults.setConcErr(analyseResult.Xe131m_uncer);
|
||||
xeResults.setMdc(analyseResult.MDC_Xe131m);
|
||||
xeResults.setLc(analyseResult.LC_Xe131m);
|
||||
xeResults.setNidFlag(analyseResult.XE_131m_NID_FLAG);
|
||||
xeResults.setConc(analyseResult.Xe133m_con);
|
||||
xeResults.setConcErr(analyseResult.Xe133m_uncer);
|
||||
xeResults.setMdc(analyseResult.MDC_Xe133m);
|
||||
xeResults.setLc(analyseResult.LC_Xe133m);
|
||||
xeResults.setNidFlag(analyseResult.XE_133m_NID_FLAG);
|
||||
xeResults.setModdate(new Date());
|
||||
|
||||
xeResultsList.add(xeResults);
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.jeecg.modules.base.entity.configuration.GardsDetectors;
|
|||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleAux;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.mapper.GardsDetectorsMapper;
|
||||
import org.jeecg.modules.mapper.GardsSampleAuxMapper;
|
||||
import org.jeecg.modules.mapper.GardsSampleDataMapper;
|
||||
|
@ -18,8 +17,6 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
|||
import org.jeecg.modules.service.ISpectrumBaseBlockService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -40,12 +37,13 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
* 不添加事务注解由调用方手动事务提交
|
||||
* @param struct
|
||||
* @param fileName
|
||||
* @param status
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception {
|
||||
final GardsSampleData sampleData = this.saveSampleData(struct,fileName);
|
||||
public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception {
|
||||
final GardsSampleData sampleData = this.saveSampleData(struct,fileName,status);
|
||||
this.saveSampleAux(struct,sampleData);
|
||||
return sampleData;
|
||||
}
|
||||
|
@ -56,7 +54,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private GardsSampleData saveSampleData(EnergySpectrumStruct struct,String fileName) throws Exception{
|
||||
private GardsSampleData saveSampleData(EnergySpectrumStruct struct,String fileName,String status) throws Exception{
|
||||
Assert.notNull(struct.site_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
|
||||
|
||||
|
@ -101,7 +99,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);
|
||||
gardsSampleData.setAcquisitionLiveSec(struct.acquisition_live_time);
|
||||
gardsSampleData.setQuantity(struct.air_volume);
|
||||
gardsSampleData.setStatus(SampleStatus.UNTREATED.getValue());
|
||||
gardsSampleData.setStatus(status);
|
||||
gardsSampleData.setModdate(new Date());
|
||||
|
||||
this.sampleDataMapper.insert(gardsSampleData);
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.jeecg.modules.base.enums.FittingEquation;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractLogOrReport {
|
||||
|
||||
/**
|
||||
* 获取sample、gas、det谱Beta和Gamma的CH(x)、E(x)
|
||||
* @return
|
||||
*/
|
||||
protected String calibration(Integer fitting_type, List<Double> fitting_e_c){
|
||||
String b_fittingEquation = this.getFittingEquation(fitting_type);
|
||||
for(int i=0;i<fitting_e_c.size();i++){
|
||||
b_fittingEquation = b_fittingEquation.replace("?"+(i+1),formatToStr6(fitting_e_c.get(i)));
|
||||
}
|
||||
return b_fittingEquation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取适合的方程
|
||||
* @return
|
||||
*/
|
||||
protected String getFittingEquation(Integer type){
|
||||
String rData = null;
|
||||
switch (type) {
|
||||
case 1:
|
||||
rData = FittingEquation.LINER.getDescription();
|
||||
break;
|
||||
case 2:
|
||||
rData = FittingEquation.POLY2.getDescription();
|
||||
break;
|
||||
case 3:
|
||||
rData = FittingEquation.POLY3.getDescription();
|
||||
break;
|
||||
case 4:
|
||||
rData = FittingEquation.GAUSS.getDescription();
|
||||
break;
|
||||
case 0:
|
||||
rData = FittingEquation.DEFAULT.getDescription();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化值
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
protected String formatToStr5(Double source){
|
||||
return String.format("%.5f",source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化值
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
protected String formatToStr6(Double source){
|
||||
return String.format("%.6f",source);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 探测器本地谱处理
|
||||
|
@ -29,6 +31,8 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
try{
|
||||
//前置检查
|
||||
this.preCheck();
|
||||
//声明日志处理对象
|
||||
super.initLogObj();
|
||||
//打印当前处理的能谱类型
|
||||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
|
@ -39,17 +43,21 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.handleLog();
|
||||
}
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 气体谱处理
|
||||
|
@ -30,6 +32,8 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
try{
|
||||
//前置检查
|
||||
this.preCheck();
|
||||
//声明日志处理对象
|
||||
super.initLogObj();
|
||||
//打印当前处理的能谱类型
|
||||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
|
@ -40,17 +44,21 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.handleLog();
|
||||
}
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Setter;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* B谱邮件解析流程日志
|
||||
|
@ -14,17 +24,33 @@ import java.nio.charset.StandardCharsets;
|
|||
public class ParsingProcessLog {
|
||||
|
||||
/**
|
||||
* 日志内容
|
||||
* 存储日志内容
|
||||
*/
|
||||
private StringBuilder log = new StringBuilder();
|
||||
private StringBuilder storageLog = new StringBuilder();
|
||||
|
||||
/**
|
||||
* 日志存储结束标记
|
||||
* 分析日志内容
|
||||
*/
|
||||
private boolean logStoreEndFlag = false;
|
||||
private StringBuilder analysisLog = new StringBuilder();
|
||||
|
||||
/**
|
||||
* 日志分析结束标记
|
||||
* PHD文件是否重复
|
||||
*/
|
||||
private boolean logAnalyseEndFlag = false;
|
||||
@Setter
|
||||
private boolean fileRepeat = false;
|
||||
|
||||
/**
|
||||
* Gas、Det文件是否存在
|
||||
*/
|
||||
@Setter
|
||||
private boolean fileNotExist = false;
|
||||
|
||||
/**
|
||||
* 分析数据是否存储成功
|
||||
*/
|
||||
@Setter
|
||||
private boolean analysisDataStoreFlag = false;
|
||||
|
||||
/**
|
||||
* 能谱处理父类
|
||||
*/
|
||||
|
@ -38,7 +64,11 @@ public class ParsingProcessLog {
|
|||
/**
|
||||
* 解析过程日志对象
|
||||
*/
|
||||
private StorageProcessLog processLog;
|
||||
private StorageProcessLog storageProcessLog;
|
||||
/**
|
||||
* 分析流程日志对象
|
||||
*/
|
||||
private AnalyseProcessLog analyseProcessLog;
|
||||
|
||||
/**
|
||||
* 存储过程日志处理
|
||||
|
@ -46,7 +76,7 @@ public class ParsingProcessLog {
|
|||
protected class StorageProcessLog{
|
||||
|
||||
private static final String WRITE_INTO_START = "%s Write Data into Database at %s %s";
|
||||
private static final String APPLICATION_PATH = "ApplicationPath:%s,ApplicationName:%s,started by RNAUTO at %s";
|
||||
private static final String APPLICATION_PATH = "ApplicationPath: %s,ApplicationName: %s,started by RNAUTO at %s";
|
||||
private static final String DATABASE_CONNECTED = "Successfully connected to database,source:%s,user=%s";
|
||||
private static final String SOURCE_FILE = "SourceFile:%s";
|
||||
private static final String STANDARD_FILE = "StandardFile:%s";
|
||||
|
@ -61,21 +91,27 @@ public class ParsingProcessLog {
|
|||
/**
|
||||
* 开始处理存储过程日志
|
||||
*/
|
||||
private void start(){
|
||||
private void handleStorageProcessLog(){
|
||||
//获取数据源属性
|
||||
final String oraUsername = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUsername();
|
||||
final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
|
||||
final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath;
|
||||
log.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(STANDARD_FILE,standardFile));
|
||||
storageLog.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
|
||||
storageLog.append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(STANDARD_FILE,standardFile));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
if(fileRepeat){
|
||||
this.endOfFileRepeat();
|
||||
}else{
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,10 +119,10 @@ public class ParsingProcessLog {
|
|||
*/
|
||||
private void endOfFileRepeat(){
|
||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,106 +130,663 @@ public class ParsingProcessLog {
|
|||
*/
|
||||
private void end(){
|
||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
|
||||
log.append(System.lineSeparator());
|
||||
log.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(rowFormat(INSTANCE_STATUS, SampleStatus.UNTREATED.getValue()));
|
||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
log.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
|
||||
storageLog.append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
|
||||
storageLog.append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(rowFormat(INSTANCE_STATUS,spectrumHandler.status));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
storageLog.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||
storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析过程日志
|
||||
*/
|
||||
private class AnalyseProcessLog{
|
||||
private static final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
|
||||
private static final String titleId = "%s Get DetaId and GasId %s";
|
||||
private static final String getDetaId = "%s Search DetFile :%s SampleID :%s";
|
||||
private static final String titleIdEnd = "%s Get DetaId and GasId finished %s";
|
||||
private static final String titleCalibration = "%s Read calibration data %s";
|
||||
private static final String setSampleBEnergyChannel = "Reading sample beta energy pairs(sampleID: %s).....";
|
||||
private static final String setSampleGEnergyChannel = "Reading sample gamma energy pairs(sampleID: %s).....";
|
||||
private static final String setDetaBEnergyChannel = "Reading DETBK Spectrum beta energy pairs(sampleID: %s).....";
|
||||
private static final String setDetaGEnergyChannel = "Reading DETBK Spectrum gamma energy pairs(sampleID: %s).....";
|
||||
private static final String setGasBEnergyChannel = "Reading GASBK Spectrum beta energy pairs(sampleID: %s).....";
|
||||
private static final String setGasGEnergyChannel = "Reading GASBK Spectrum gamma energy pairs(sampleID: %s)";
|
||||
private static final String getMeasurementTime = "Reading mesurement information.....";
|
||||
|
||||
private static final String dataStore = "Data store %s .....";
|
||||
private static final String setStatus = "Instance status successfully set to: %s .....";
|
||||
private static final String anlyseResultsEnd = "%s Sample Analyse Successfully at %s %s";
|
||||
private static final String dataAnlyseError = "Data Anlyse Error:gas or det file is no exist or is error..";
|
||||
private static final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s";
|
||||
private class AnalyseProcessLog extends AbstractLogOrReport implements BlockConstant {
|
||||
|
||||
/**
|
||||
* 开始处理分析过程日志
|
||||
*/
|
||||
private void start(){
|
||||
private void handleAnalysisProcessLog(){
|
||||
final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
|
||||
final String storeResult = "Data store %s .....";
|
||||
final String storeStatus = "Instance status %s set to: %s.....";
|
||||
final String analysisResultsEnd = "%s Sample Analyse %s at %s %s";
|
||||
String storeFlag = "successfully";
|
||||
final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss");
|
||||
log.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
|
||||
final String endAnalysisTime = DateUtils.formatDate(sample_B_Analysis.endAnalysisTime, "yyyy-MM-dd HH:mm:ss");
|
||||
analysisLog.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
this.setDetAndGasIdLog();
|
||||
if(fileNotExist){
|
||||
// Gas谱或Det谱文件找不到异常结束
|
||||
fileNotExistException();
|
||||
}
|
||||
this.readCalibrationData();
|
||||
this.reading_roi_limits();
|
||||
this.reading_roi_ratios();
|
||||
this.reading_B_G_Efficiency();
|
||||
this.NCC_analysis();
|
||||
|
||||
if(analysisDataStoreFlag == true){
|
||||
storeFlag = "error";
|
||||
}
|
||||
analysisLog.append(rowFormat(storeResult,storeFlag));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理获取Det和Gas文件日志
|
||||
*/
|
||||
private void setDetAndGasIdLog(){
|
||||
final String titleId = "%s Get DetaId and GasId %s";
|
||||
log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT));
|
||||
final String title = "%s Get DetaId and GasId %s";
|
||||
final String detaInfo = "%s Search DetFile :%s SampleID :%s";
|
||||
final String gasInfo = "%s Search GasFile :%s SampleID :%s";
|
||||
final String titleEnd = "%s Get DetaId and GasId finished %s";
|
||||
String detExist = "Error";
|
||||
String gasExist = "Error";
|
||||
String detMeasurementId = sample_B_Analysis.sampleStruct.detector_bk_measurement_id;
|
||||
String gasMeasurementId = sample_B_Analysis.sampleStruct.gas_bk_measurement_id;
|
||||
String detSampleId = StringConstant.ZERO;
|
||||
String gasSampleId = StringConstant.ZERO;
|
||||
|
||||
if(Objects.nonNull(sample_B_Analysis.detSampleData)){
|
||||
detExist = "Successfully";
|
||||
detSampleId = sample_B_Analysis.detSampleData.getSampleId().toString();
|
||||
}
|
||||
if(Objects.nonNull(sample_B_Analysis.gasSampleData)){
|
||||
gasExist = "Successfully";
|
||||
gasSampleId = sample_B_Analysis.gasSampleData.getSampleId().toString();
|
||||
}
|
||||
analysisLog.append(titleFormat(title,40,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(detaInfo,detExist,detMeasurementId,detSampleId));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(gasInfo,gasExist,gasMeasurementId,gasSampleId));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(titleEnd,35,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gas谱或Det谱文件找不到异常结束
|
||||
*/
|
||||
private void fileNotExistException(){
|
||||
final String dataAnlyseError = "%s Data Anlyse Error:gas or det file is no exist or is error..";
|
||||
final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s";
|
||||
final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss");
|
||||
analysisLog.append(rowFormat(dataAnlyseError,startAnalysisTime));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(anlyseResultsErrorEnd,28,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* ... Read calibration data ...
|
||||
*/
|
||||
private void readCalibrationData(){
|
||||
final String titleCalibration = "%s Read calibration data %s";
|
||||
final String titleCalibrationFinished = "%s Read calibration finished %s";
|
||||
analysisLog.append(titleFormat(titleCalibration,39,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
this.readSampleEnergyPairs();
|
||||
this.readDetEnergyPairs();
|
||||
this.readGasEnergyPairs();
|
||||
this.readingMesurementInformation();
|
||||
this.readingVolumeData();
|
||||
analysisLog.append(titleFormat(titleCalibrationFinished,37,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading sample beta/Gamma energy pairs
|
||||
*/
|
||||
private void readSampleEnergyPairs(){
|
||||
final String sampleEnergyPairsTitle = "Reading sample %s energy pairs(sampleID: %s).....";
|
||||
String format = "Channel : %-11s Energy : %-15s Error : %s";
|
||||
analysisLog.append(rowFormat(sampleEnergyPairsTitle,"beta",sample_B_Analysis.sampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
|
||||
for(int i=0;i<struct.b_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString(),struct.b_uncertainty.get(i).toString()));
|
||||
if(i < struct.b_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(sampleEnergyPairsTitle,"gamma",sample_B_Analysis.sampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
for(int i=0;i<struct.g_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
|
||||
if(i < struct.g_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading Det beta/Gamma energy pairs
|
||||
*/
|
||||
private void readDetEnergyPairs(){
|
||||
final String detEnergyPairsTitle = "Reading DETBK Spectrum %s energy pairs(sampleID: %s).....";
|
||||
String format = "Channel : %-11s Energy : %-15s Error : %s";
|
||||
analysisLog.append(rowFormat(detEnergyPairsTitle,"beta",sample_B_Analysis.detSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.detStruct;
|
||||
for(int i=0;i<struct.b_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString(),struct.b_uncertainty.get(i).toString()));
|
||||
if(i < struct.b_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(detEnergyPairsTitle,"gamma",sample_B_Analysis.detSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
for(int i=0;i<struct.g_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
|
||||
if(i < struct.g_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading Gas beta/Gamma energy pairs
|
||||
*/
|
||||
private void readGasEnergyPairs(){
|
||||
final String detEnergyPairsTitle = "Reading GASBK Spectrum %s energy pairs(sampleID: %s).....";
|
||||
String format = "Channel : %-11s Energy : %-15s Error : %s";
|
||||
analysisLog.append(rowFormat(detEnergyPairsTitle,"beta",sample_B_Analysis.gasSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.gasStruct;
|
||||
for(int i=0;i<struct.b_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString() + unit_kev,struct.b_uncertainty.get(i).toString()));
|
||||
if(i < struct.b_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(detEnergyPairsTitle,"gamma",sample_B_Analysis.gasSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
for(int i=0;i<struct.g_record_count;i++){
|
||||
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
|
||||
if(i < struct.g_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading mesurement information.....
|
||||
*/
|
||||
private void readingMesurementInformation(){
|
||||
final String title = "Reading mesurement information.....";
|
||||
final String liveSec = "Acquisition_live_sec[s] : %s";
|
||||
final String realSec = "Acquisition_real_sec[s] : %s";
|
||||
final String collTime = "Collection time[s] : %s";
|
||||
final String gas_acq_liveSec = "GASBK Spectrum acquisition_live_sec[s] : %s";
|
||||
final String gas_acq_realSec = "GASBK Spectrum acquisition_real_sec[s] : %s";
|
||||
final String det_acq_liveSec = "DETBK Spectrum acquisition_live_sec[s] : %s";
|
||||
final String det_acq_realSec = "DETBK Spectrum acquisition_real_sec[s] : %s";
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(liveSec,String.valueOf(sample_B_Analysis.sampleStruct.acquisition_live_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(realSec,String.valueOf(sample_B_Analysis.sampleStruct.acquisition_real_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(collTime,String.valueOf(sample_B_Analysis.sampleStruct.collection_start_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(gas_acq_liveSec,String.valueOf(sample_B_Analysis.gasStruct.acquisition_live_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(gas_acq_realSec,String.valueOf(sample_B_Analysis.gasStruct.acquisition_real_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(det_acq_liveSec,String.valueOf(sample_B_Analysis.detStruct.acquisition_live_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(det_acq_realSec,String.valueOf(sample_B_Analysis.detStruct.acquisition_real_time)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading volume data.....
|
||||
*/
|
||||
private void readingVolumeData(){
|
||||
final String title = "Reading volume data.....";
|
||||
final String xe_volume = "XE volume[ml] : %s";
|
||||
final String air_volume = "Air volume[m3] : %s";
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(xe_volume,String.valueOf(sample_B_Analysis.sampleStruct.sample_volume_of_Xe)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(air_volume,String.valueOf(sample_B_Analysis.detStruct.air_volume)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading ROI limits.....
|
||||
*/
|
||||
private void reading_roi_limits(){
|
||||
final String title = "Reading ROI limits.....";
|
||||
String format = "ROI : %-6s Beta : %-26s Gamma : %s";
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
|
||||
for(int i=0;i<struct.roi_record_count;i++){
|
||||
String beta = struct.POI_B_x1.get(i) + to_flag +struct.POI_B_x2.get(i);
|
||||
String gamma = struct.POI_G_y1.get(i) + to_flag +struct.POI_G_y2.get(i);
|
||||
analysisLog.append(rowFormat(format,struct.ROI_number.get(i),beta,gamma));
|
||||
if(i<struct.roi_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading ROI ratios.....
|
||||
*/
|
||||
private void reading_roi_ratios(){
|
||||
final String title = "Reading ROI ratios.....";
|
||||
String format = "Interference between ROI : %-12s Ratio : %-12s Error : %s";
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
|
||||
for(int i=0;i<struct.ratio_record_count;i++){
|
||||
String interference = struct.ROI_num_highter_G_energy_ROI.get(i) + and_flag +struct.ROI_num_lower_G_energy_ROI.get(i);
|
||||
String ratio = String.valueOf(struct.count_ratio.get(i));
|
||||
String error = String.valueOf(struct.count_ratio_uncertainty.get(i));
|
||||
analysisLog.append(rowFormat(format,interference,ratio,error));
|
||||
if(i<struct.ratio_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reading b-g Efficiency.....
|
||||
*/
|
||||
private void reading_B_G_Efficiency(){
|
||||
final String title = "Reading b-g Efficiency.....";
|
||||
final String format = "ROI : %-6s Efficiency : %-12s Error : %s";
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
|
||||
for(int i=0;i<struct.bg_record_count;i++){
|
||||
String roi = String.valueOf(struct.bg_ROI_number.get(i).intValue());
|
||||
String efficiency = String.valueOf(struct.bg_efficiency.get(i));
|
||||
String error = String.valueOf(struct.bg_uncertainty.get(i));
|
||||
analysisLog.append(rowFormat(format,roi,efficiency,error));
|
||||
if(i<struct.bg_record_count-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting NCC analysis
|
||||
*/
|
||||
private void NCC_analysis(){
|
||||
final String loadNCC = "%s load NCC related data finished %s";
|
||||
final String startNcc = "%s Starting NCC analysis %s";
|
||||
final String endNcc = "%s NCC analysis finished %s";
|
||||
analysisLog.append(titleFormat(loadNCC,35,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(startNcc,39,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
this.sampleEnergyPairCalibration();
|
||||
this.sample_limits_per_ROI();
|
||||
this.gasEnergyPairCalibration();
|
||||
this.gas_limits_per_ROI();
|
||||
this.detEnergyPairCalibration();
|
||||
this.det_limits_per_ROI();
|
||||
this.gross_counts_per_roi();
|
||||
this.net_counts_per_roi();
|
||||
this.coll_MDC_per_roi();
|
||||
this.coll_MDC_per_isotope();
|
||||
analysisLog.append(titleFormat(endNcc,40,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample energy pair calibration
|
||||
*/
|
||||
private void sampleEnergyPairCalibration(){
|
||||
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
|
||||
final String ch = "energy to channel equation: CH(x) = %s";
|
||||
final String ex = "channel to energy equation: E(x) = %s";
|
||||
final String endTitle = "%s energy pair calibration finished %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
final String sampleId = sample_B_Analysis.sampleData.getSampleId().toString();
|
||||
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample Limits per ROI
|
||||
*/
|
||||
private void sample_limits_per_ROI(){
|
||||
final String title = "Limits per ROI (SampleID:%s).....";
|
||||
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<Integer> b_chan_start = analyseResult.S_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.S_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.S_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.S_ROI_G_Boundary_stop;
|
||||
List<Integer> roi = analyseResult.S_ROI;
|
||||
|
||||
analysisLog.append(rowFormat(title,sample_B_Analysis.sampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
String channels = " channels";
|
||||
for (int i=0;i<roi.size();i++){
|
||||
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
|
||||
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
|
||||
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gas energy pair calibration
|
||||
*/
|
||||
private void gasEnergyPairCalibration(){
|
||||
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
|
||||
final String ch = "energy to channel equation: CH(x) = %s";
|
||||
final String ex = "channel to energy equation: E(x) = %s";
|
||||
final String endTitle = "%s energy pair calibration finished %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
final String sampleId = sample_B_Analysis.gasSampleData.getSampleId().toString();
|
||||
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gas Limits per ROI
|
||||
*/
|
||||
private void gas_limits_per_ROI(){
|
||||
final String title = "Limits per ROI (SampleID:%s).....";
|
||||
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<Integer> b_chan_start = analyseResult.G_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.G_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.G_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.G_ROI_G_Boundary_stop;
|
||||
List<Integer> roi = analyseResult.G_ROI;
|
||||
|
||||
analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
String channels = " channels";
|
||||
for (int i=0;i<roi.size();i++){
|
||||
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
|
||||
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
|
||||
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Det energy pair calibration
|
||||
*/
|
||||
private void detEnergyPairCalibration(){
|
||||
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
|
||||
final String ch = "energy to channel equation: CH(x) = %s";
|
||||
final String ex = "channel to energy equation: E(x) = %s";
|
||||
final String endTitle = "%s energy pair calibration finished %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
final String sampleId = sample_B_Analysis.detSampleData.getSampleId().toString();
|
||||
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Beta:");
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append("Gamma:");
|
||||
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)));
|
||||
analysisLog.append(System.lineSeparator());
|
||||
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Det Limits per ROI
|
||||
*/
|
||||
private void det_limits_per_ROI(){
|
||||
final String title = "Limits per ROI (SampleID:%s).....";
|
||||
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<Integer> b_chan_start = analyseResult.G_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.G_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.G_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.G_ROI_G_Boundary_stop;
|
||||
List<Integer> roi = analyseResult.G_ROI;
|
||||
|
||||
analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString()));
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
String channels = " channels";
|
||||
for (int i=0;i<roi.size();i++){
|
||||
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
|
||||
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
|
||||
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gross counts per ROI.....
|
||||
*/
|
||||
private void gross_counts_per_roi(){
|
||||
final String title = "Gross counts per ROI.....";
|
||||
final String format = "ROI : %-6s Sample : %-14s GasBkgnd : %-14s DetBkgnd : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
for (int i=0;i<roi.size();i++){
|
||||
analysisLog.append(rowFormat(format,roi.get(i),s_roi_cts.get(i),g_roi_cts.get(i),d_roi_cts.get(i)));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Net counts and Lc per ROI.....
|
||||
*/
|
||||
private void net_counts_per_roi(){
|
||||
final String title = "Net counts and Lc per ROI.....";
|
||||
final String format = "ROI : %-6s Net count : %-25s LC : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<Double> roi_net_count = analyseResult.ROI_net_coutns;
|
||||
List<Double> roi_net_count_err = analyseResult.ROI_net_coutns_err;
|
||||
List<String> roi = analyseResult.ROI.stream().map(String::valueOf).collect(Collectors.toList());
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
for(int i=0;i<roi.size();i++){
|
||||
String netCountStr = super.formatToStr5(roi_net_count.get(i)) + arithmetic_flag + super.formatToStr5(roi_net_count_err.get(i));
|
||||
analysisLog.append(rowFormat(format,roi.get(i),netCountStr,lc.get(i)));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Concentration and MDC per ROI.....
|
||||
*/
|
||||
private void coll_MDC_per_roi(){
|
||||
final String title = "Concentration and MDC per ROI.....";
|
||||
final String format = "ROI : %-6s Conc : %-31s LC : %-19s MDC : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
List<String> con = analyseResult.ROI_con_uncer.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> conErr = analyseResult.ROI_con_uncer_err.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
analyseResult.MDC.add(0,0.0D);
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
for(int i=0;i<roi.size();i++){
|
||||
String concc = con.get(i) + arithmetic_flag + conErr.get(i) + unit_mbq;
|
||||
analysisLog.append(rowFormat(format,roi.get(i),concc,lc.get(i) + unit_mbq,mdc.get(i) + unit_mbq));
|
||||
if(i<roi.size()-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Concentration and MDC per isotope.....
|
||||
*/
|
||||
private void coll_MDC_per_isotope(){
|
||||
final String title = "Concentration and MDC per isotope.....";
|
||||
final String format = "%-10s Conc : %-32s LC : %-19s MDC : %-19s Nid flag : %s";
|
||||
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
|
||||
|
||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer) + unit_mbq};
|
||||
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe131m) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.LC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe133) + unit_mbq};
|
||||
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe131m) + unit_mbq,
|
||||
super.formatToStr5(analyseResult.MDC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe133) + unit_mbq};
|
||||
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
|
||||
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
|
||||
String xe_133m_nid_flag = analyseResult.Xe133m_con>analyseResult.MDC_Xe133m?"1":"0";
|
||||
String xe_133_nid_flag = analyseResult.Xe133_con>analyseResult.MDC_Xe133?"1":"0";
|
||||
String[] nid_flag = {xe_135_nid_flag,xe_131m_nid_flag,xe_133m_nid_flag,xe_133_nid_flag};
|
||||
|
||||
analysisLog.append(title);
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
|
||||
for(int i=0;i<nuclideName.length;i++){
|
||||
analysisLog.append(rowFormat(format,nuclideName[i],conc[i],uncertainty[i],mdc[i],nid_flag[i]));
|
||||
if(i<nuclideName.length-1){
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始存储流程日志
|
||||
* 处理存储流程日志
|
||||
* @return
|
||||
*/
|
||||
protected void storageProcessLogStart(){
|
||||
this.processLog = new StorageProcessLog();
|
||||
this.processLog.start();
|
||||
private void handleStorageProcessLog(){
|
||||
this.storageProcessLog = new StorageProcessLog();
|
||||
this.storageProcessLog.handleStorageProcessLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束存储流程日志
|
||||
* 处理分析流程日志
|
||||
* @return
|
||||
*/
|
||||
protected void storageProcessLogEnd(){
|
||||
if(this.logStoreEndFlag == false){
|
||||
this.processLog.end();
|
||||
this.logStoreEndFlag = true;
|
||||
this.saveLogToFTP();
|
||||
}
|
||||
private void handleAnalysisProcessLog(){
|
||||
this.analyseProcessLog = new AnalyseProcessLog();
|
||||
this.analyseProcessLog.handleAnalysisProcessLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重复异常结束存储流程日志
|
||||
* 处理所有日志
|
||||
*/
|
||||
protected void endOfFileRepeat(){
|
||||
if(this.logStoreEndFlag == false){
|
||||
this.processLog.endOfFileRepeat();
|
||||
this.logStoreEndFlag = true;
|
||||
this.saveLogToFTP();
|
||||
protected void handleLog(){
|
||||
this.handleStorageProcessLog();
|
||||
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
|
||||
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
|
||||
this.fileRepeat == false){
|
||||
|
||||
this.handleAnalysisProcessLog();
|
||||
}
|
||||
if(Objects.nonNull(this.analysisLog)){
|
||||
this.storageLog.append(this.analysisLog);
|
||||
}
|
||||
this.saveLogToFTP(this.storageLog.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存日志到ftp
|
||||
*/
|
||||
private void saveLogToFTP(){
|
||||
private void saveLogToFTP(String log){
|
||||
//保存日志文件到ftp
|
||||
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath();
|
||||
spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
|
||||
|
||||
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ParsingProcessLog s = new ParsingProcessLog();
|
||||
s.storageProcessLogStart();
|
||||
s.endOfFileRepeat();
|
||||
System.out.println(s.log.toString());
|
||||
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* QC谱处理
|
||||
|
@ -29,6 +31,8 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
try{
|
||||
//前置检查
|
||||
this.preCheck();
|
||||
//声明日志处理对象
|
||||
super.initLogObj();
|
||||
//打印当前处理的能谱类型
|
||||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
|
@ -39,17 +43,21 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.handleLog();
|
||||
}
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.jeecg.common.constant.StringConstant;
|
|||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.exception.AcquisitionBlockException;
|
||||
import org.jeecg.modules.exception.FileRepeatException;
|
||||
|
@ -63,6 +64,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
* 流程日志对象
|
||||
*/
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
/**
|
||||
* 能谱文件处理状态,默认为:未处理
|
||||
*/
|
||||
protected String status = SampleStatus.UNTREATED.getValue();
|
||||
|
||||
/**
|
||||
* 前置检查
|
||||
|
@ -211,13 +216,15 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
if(Objects.nonNull(query)){
|
||||
this.sampleData = query;
|
||||
this.endIntoDatabaseTime = new Date();
|
||||
//设置文件重复标记为true
|
||||
this.parsingProcessLog.setFileRepeat(true);
|
||||
throw new FileRepeatException("file repeat");
|
||||
}
|
||||
DataSourceSwitcher.switchToOracle();
|
||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||
try{
|
||||
//存储基础数据
|
||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath);
|
||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath,status);
|
||||
//存储其他块数据
|
||||
for(String labels : spectrumFileLabels){
|
||||
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
|
||||
|
@ -237,6 +244,22 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改解析状态
|
||||
*/
|
||||
protected void updateStatus(){
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.status,this.sampleData.getInputFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 声明日志处理对象
|
||||
*/
|
||||
protected void initLogObj(){
|
||||
ParsingProcessLog parsingProcessLog = new ParsingProcessLog();
|
||||
parsingProcessLog.setSpectrumHandler(this);
|
||||
this.parsingProcessLog = parsingProcessLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目绝对路径
|
||||
* @return
|
||||
|
@ -268,33 +291,4 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
}
|
||||
return Strings.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建流程日志对象处理解析流程日志
|
||||
*/
|
||||
protected void handleProcessLog(){
|
||||
ParsingProcessLog parsingProcessLog = new ParsingProcessLog();
|
||||
parsingProcessLog.setSpectrumHandler(this);
|
||||
parsingProcessLog.storageProcessLogStart();
|
||||
this.parsingProcessLog = parsingProcessLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常结束日志
|
||||
* @param e
|
||||
*/
|
||||
protected void exceptionEndLog(Exception e){
|
||||
if(e instanceof FileRepeatException){
|
||||
this.parsingProcessLog.endOfFileRepeat();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正常结束日志
|
||||
*/
|
||||
protected void storageProcessLogEnd(){
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.storageProcessLogEnd();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import org.jeecg.modules.base.entity.original.GardsSampleData;
|
|||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
||||
import org.jeecg.modules.base.enums.FittingEquation;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.exception.BAnalyseException;
|
||||
|
@ -40,38 +39,30 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private static final String ARR_FILE_SUFFIX = ".txt";
|
||||
private static final String ARR_FILE_NAME_TAIL = "_rpt";
|
||||
/**
|
||||
* 正常分析过程日志
|
||||
*/
|
||||
private StringBuilder analysesLog = new StringBuilder();
|
||||
/**
|
||||
* 分析过程当前状态
|
||||
*/
|
||||
private String currAnalysesStatus = null;
|
||||
/**
|
||||
* Sample谱结构体数据
|
||||
*/
|
||||
private EnergySpectrumStruct sampleStruct = null;
|
||||
protected EnergySpectrumStruct sampleStruct = null;
|
||||
/**
|
||||
* sample谱原始数据
|
||||
*/
|
||||
private GardsSampleData sampleData = null;
|
||||
protected GardsSampleData sampleData = null;
|
||||
/**
|
||||
* gas谱结构体数据
|
||||
*/
|
||||
private EnergySpectrumStruct gasStruct = null;
|
||||
protected EnergySpectrumStruct gasStruct = null;
|
||||
/**
|
||||
* gas谱原始数据
|
||||
*/
|
||||
private GardsSampleData detSampleData = null;
|
||||
protected GardsSampleData detSampleData = null;
|
||||
/**
|
||||
* det谱结构体数据
|
||||
*/
|
||||
private EnergySpectrumStruct detStruct = null;
|
||||
protected EnergySpectrumStruct detStruct = null;
|
||||
/**
|
||||
* det谱原始数据
|
||||
*/
|
||||
private GardsSampleData gasSampleData = null;
|
||||
protected GardsSampleData gasSampleData = null;
|
||||
/**
|
||||
* sample谱PHD文件临时路径
|
||||
*/
|
||||
|
@ -111,7 +102,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
/**
|
||||
* 分析结果
|
||||
*/
|
||||
private BgAnalyseResult analyseResult;
|
||||
protected BgAnalyseResult analyseResult;
|
||||
/**
|
||||
* 开始分析时间
|
||||
*/
|
||||
|
@ -121,11 +112,16 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
protected Date endAnalysisTime;
|
||||
|
||||
/**
|
||||
* 流程日志对象
|
||||
*/
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
|
||||
public Sample_B_Analysis() {
|
||||
}
|
||||
|
||||
public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName){
|
||||
EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName,ParsingProcessLog parsingProcessLog){
|
||||
this.sampleData = sampleData;
|
||||
this.sampleTempFilePath = sampleTempFilePath;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
|
@ -133,6 +129,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.ftpUtil = ftpUtil;
|
||||
this.logFilePath = logFilePath;
|
||||
this.logFileName = logFileName;
|
||||
this.parsingProcessLog = parsingProcessLog;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,8 +137,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
public void start() throws BAnalyseException {
|
||||
try{
|
||||
//修改状态为分析中
|
||||
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
|
||||
this.startAnalysisTime = new Date();
|
||||
//声明分析日志对象
|
||||
parsingProcessLog.setSample_B_Analysis(this);
|
||||
//查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来
|
||||
this.queryPHDFile();
|
||||
//构造报告文件存储路径及文件名称,日志文件存储路径及文件名称在原始库存储阶段已存在,已经传过来
|
||||
|
@ -155,28 +153,16 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
//生成报告
|
||||
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
|
||||
report.start();
|
||||
//修改状态为分析成功
|
||||
this.updateStatus(SampleStatus.COMPLETE.getValue());
|
||||
}catch (Exception e){
|
||||
//修改状态为分析失败
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
e.printStackTrace();
|
||||
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}finally {
|
||||
this.endAnalysisTime = new Date();
|
||||
//删除下载的det和gas临时文件
|
||||
this.deleteLocalTemporaryFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param analysesStatus
|
||||
*/
|
||||
private void updateStatus(String analysesStatus){
|
||||
this.currAnalysesStatus = analysesStatus;
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询det、gas数据,sample在构造函数已经传过来
|
||||
* @throws FileNotExistException
|
||||
|
@ -188,8 +174,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
|
||||
//如果找不到sample、det、gas谱文件数据则解析失败修改记录状态
|
||||
if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
|
||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
}
|
||||
|
@ -224,14 +211,12 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
* 调用dll库的分析B谱结果
|
||||
*/
|
||||
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
||||
this.startAnalysisTime = new Date();
|
||||
System.out.println("sam:"+this.sampleTempFilePath);
|
||||
System.out.println("gas:"+this.gasTempFilePath);
|
||||
System.out.println("det:"+this.detTempFilePath);
|
||||
|
||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
||||
System.out.println(analyseResult);
|
||||
this.endAnalysisTime = new Date();
|
||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
|
||||
}
|
||||
|
@ -263,10 +248,11 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName;
|
||||
|
||||
if(flag){
|
||||
parsingProcessLog.setFileNotExist(true);
|
||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||
}
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(detTempFilePath);
|
||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasTempFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,6 +295,8 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
//提交事务
|
||||
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
//设置分析数据存储失败标记
|
||||
this.parsingProcessLog.setAnalysisDataStoreFlag(false);
|
||||
//回滚事务
|
||||
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
|
||||
throw e;
|
||||
|
@ -343,7 +331,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
/**
|
||||
* B谱分析报告
|
||||
*/
|
||||
private class B_AnalysisReport{
|
||||
private class B_AnalysisReport extends AbstractLogOrReport{
|
||||
/**
|
||||
* 模版内容
|
||||
*/
|
||||
|
@ -483,10 +471,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void handleSampleCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
|
||||
E_Contant+super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
|
||||
E_Contant+super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
@ -515,10 +503,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
* 处理#DET CALIBRATION 模块
|
||||
*/
|
||||
private void handleDetCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
|
||||
String[] betaArr = {CH_Contant+super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
|
||||
String[] gammaArr = {CH_Contant+super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
||||
|
@ -549,10 +537,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void handleGasCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
|
||||
E_Contant+super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
|
||||
E_Contant+super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
|
||||
|
||||
this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
@ -569,10 +557,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
List<String> roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
beta.add(b_chan_start.get(i)+to_flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+to_flag+g_chan_stop.get(i));
|
||||
}
|
||||
handleThreeParamFormat("#GAS LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
@ -582,9 +569,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
*/
|
||||
private void handleGrossCounts() throws IOException {
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
this.handleFourParamFormat("#GROSS COUNTS PER ROI",roi,s_roi_cts,g_roi_cts,d_roi_cts);
|
||||
}
|
||||
|
@ -599,11 +586,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
//此参数需第一位补0
|
||||
analyseResult.LC_CTS.add(0,0D);
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> netCount = Lists.newArrayList();
|
||||
String flag = " +/- ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
netCount.add(formatToStr5(roi_net_count.get(i))+flag+formatToStr5(roi_net_count_err.get(i)));
|
||||
netCount.add(super.formatToStr5(roi_net_count.get(i))+arithmetic_flag+super.formatToStr5(roi_net_count_err.get(i)));
|
||||
}
|
||||
this.handleThreeParamFormat("#NET COUNTS AND LC PER ROI",roi,netCount,lc);
|
||||
}
|
||||
|
@ -615,16 +601,13 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
List<Double> con = analyseResult.ROI_con_uncer;
|
||||
List<Double> conErr = analyseResult.ROI_con_uncer_err;
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
String flag = " +/- ";
|
||||
analyseResult.MDC.add(0,0.0D);
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = Lists.newArrayList();//analyseResult.MDC.stream().map(Object::toString).collect(Collectors.toList());
|
||||
for(int i=0;i<10;i++){
|
||||
mdc.add("0.0");
|
||||
}
|
||||
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> conc = Lists.newArrayList();
|
||||
for(int i=0;i<roi.size();i++){
|
||||
conc.add(formatToStr5(con.get(i))+flag+formatToStr5(conErr.get(i)));
|
||||
conc.add(super.formatToStr5(con.get(i))+arithmetic_flag+super.formatToStr5(conErr.get(i)));
|
||||
}
|
||||
this.handleFourParamFormat("#CONCENTRATION AND LC PER ROI",roi,conc,lc,mdc);
|
||||
}
|
||||
|
@ -633,19 +616,18 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
* #RESULT SUMMARY
|
||||
*/
|
||||
private void handleResultSummary() throws IOException {
|
||||
String flag = " +/- ";
|
||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||
|
||||
String[] conc = {formatToStr5(analyseResult.Xe135_con)+flag+formatToStr5(analyseResult.Xe135_uncer),
|
||||
formatToStr5(analyseResult.Xe131m_con)+flag+formatToStr5(analyseResult.Xe131m_uncer),
|
||||
formatToStr5(analyseResult.Xe133m_con)+flag+formatToStr5(analyseResult.Xe133m_uncer),
|
||||
formatToStr5(analyseResult.Xe133_con)+flag+formatToStr5(analyseResult.Xe133_uncer)};
|
||||
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer),
|
||||
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer),
|
||||
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer),
|
||||
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer)};
|
||||
|
||||
String[] uncertainty = {formatToStr5(analyseResult.LC_Xe135),formatToStr5(analyseResult.LC_Xe131m),
|
||||
formatToStr5(analyseResult.LC_Xe133m),formatToStr5(analyseResult.LC_Xe133)};
|
||||
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135),super.formatToStr5(analyseResult.LC_Xe131m),
|
||||
super.formatToStr5(analyseResult.LC_Xe133m),super.formatToStr5(analyseResult.LC_Xe133)};
|
||||
|
||||
String[] mdc = {formatToStr5(analyseResult.MDC_Xe135),formatToStr5(analyseResult.MDC_Xe131m),
|
||||
formatToStr5(analyseResult.MDC_Xe133m),formatToStr5(analyseResult.MDC_Xe133)};
|
||||
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135),super.formatToStr5(analyseResult.MDC_Xe131m),
|
||||
super.formatToStr5(analyseResult.MDC_Xe133m),super.formatToStr5(analyseResult.MDC_Xe133)};
|
||||
|
||||
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
|
||||
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
|
||||
|
@ -664,46 +646,6 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.reportTmpFile.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sample、gas、det谱Beta和Gamma的CH(x)、E(x)
|
||||
* @return
|
||||
*/
|
||||
private String calibration(Integer fitting_type, List<Double> fitting_e_c){
|
||||
String b_fittingEquation = this.getFittingEquation(fitting_type);
|
||||
for(int i=0;i<fitting_e_c.size();i++){
|
||||
b_fittingEquation = b_fittingEquation.replace("?"+(i+1),formatToStr6(fitting_e_c.get(i)));
|
||||
}
|
||||
return b_fittingEquation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取适合的方程
|
||||
* @return
|
||||
*/
|
||||
private String getFittingEquation(Integer type){
|
||||
String rData = null;
|
||||
switch (type) {
|
||||
case 1:
|
||||
rData = FittingEquation.LINER.getDescription();
|
||||
break;
|
||||
case 2:
|
||||
rData = FittingEquation.POLY2.getDescription();
|
||||
break;
|
||||
case 3:
|
||||
rData = FittingEquation.POLY3.getDescription();
|
||||
break;
|
||||
case 4:
|
||||
rData = FittingEquation.GAUSS.getDescription();
|
||||
break;
|
||||
case 0:
|
||||
rData = FittingEquation.DEFAULT.getDescription();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理两个参数的占位符格式化
|
||||
* 1.#SAMPLE CALIBRATION 模块
|
||||
|
@ -811,51 +753,6 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化值
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
private String formatToStr5(Double source){
|
||||
return String.format("%.5f",source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化值
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
private String formatToStr6(Double source){
|
||||
return String.format("%.6f",source);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Resource resource = new ClassPathResource("template/b_report_template.txt");
|
||||
final File file = resource.getFile();
|
||||
// String templateContent = FileUtil.readUtf8String(resource.getFile());
|
||||
final List<String> lines = FileUtils.readLines(file, "utf-8");
|
||||
|
||||
String[] betaArr = {"CH(x) = (-3.33443)+(0.398048)*x+(-0.000124015)x*x","E(x) = (12.0809)+(2.39764)*x+(0.00331138)x*x"};
|
||||
|
||||
String[] gammaArr = {"CH(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x","E(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x"};
|
||||
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith("#SAMPLE CALIBRATION")){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<betaArr.length;j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,betaArr[j],gammaArr[j]));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
File localFile = new File("E:\\file\\1.txt");
|
||||
FileUtil.writeLines(lines,localFile,"utf-8");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 样品谱处理
|
||||
|
@ -29,6 +31,8 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
try{
|
||||
//前置检查
|
||||
this.preCheck();
|
||||
//声明日志处理对象
|
||||
super.initLogObj();
|
||||
//打印当前处理的能谱类型
|
||||
super.printCurrDataType();
|
||||
//解析邮件内容
|
||||
|
@ -39,19 +43,24 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
super.saveFileToFtp();
|
||||
//结构体数据入库
|
||||
super.handlerOriginalData();
|
||||
//处理流程日志
|
||||
super.handleProcessLog();
|
||||
//进行B、G(P)谱分析
|
||||
this.autoAnalysis();
|
||||
|
||||
//修改状态为解析完成
|
||||
super.status = SampleStatus.COMPLETE.getValue();
|
||||
super.updateStatus();
|
||||
}catch (Exception e){
|
||||
//异常结束日志
|
||||
super.exceptionEndLog(e);
|
||||
//修改状态为解析失败
|
||||
super.status = SampleStatus.FAIL.getValue();
|
||||
super.updateStatus();
|
||||
|
||||
//处理解析失败的文件,上传到ftp->undeal目录
|
||||
super.handleParseingFailFile();
|
||||
throw e;
|
||||
}finally {
|
||||
//结束流程日志
|
||||
super.storageProcessLogEnd();
|
||||
if(Objects.nonNull(this.parsingProcessLog)){
|
||||
this.parsingProcessLog.handleLog();
|
||||
}
|
||||
//删除本地临时文件
|
||||
super.deleteLocalTemporaryFile();
|
||||
}
|
||||
|
@ -65,14 +74,15 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
|||
* @throws Exception
|
||||
*/
|
||||
protected void autoAnalysis() throws Exception {
|
||||
// if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
|
||||
// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
|
||||
// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.logFilePath,super.logFileName);
|
||||
// bAnalysis.start();
|
||||
// }
|
||||
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.analysis();
|
||||
if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
|
||||
Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
|
||||
super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,
|
||||
super.logFilePath,super.logFileName,super.parsingProcessLog);
|
||||
bAnalysis.start();
|
||||
}
|
||||
// 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.analysis();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user