fix:1.完成自动处理B分析日志功能2.优化自动处理功能结构测试B分析日志功能
This commit is contained in:
parent
51373c79d2
commit
c49318a57f
|
@ -159,7 +159,7 @@ public class FileSourceHandleManager {
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//解析失败会把文件上传到undeal目录
|
//解析失败会把文件上传到undeal目录
|
||||||
this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
|
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();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
//解析成功或者失败都会删除源文件
|
//解析成功或者失败都会删除源文件
|
||||||
|
|
|
@ -2,20 +2,27 @@ package org.jeecg.modules.service;
|
||||||
|
|
||||||
public interface BlockConstant {
|
public interface BlockConstant {
|
||||||
|
|
||||||
public final static String PHD = "PHD";
|
String PHD = "PHD";
|
||||||
public final static String SYSTEMTYPE_B = "B";
|
String SYSTEMTYPE_B = "B";
|
||||||
public final static String ENERGY_CAL = "energy";
|
String ENERGY_CAL = "energy";
|
||||||
public final static String RESOLUTION_CAL = "Resolution";
|
String RESOLUTION_CAL = "Resolution";
|
||||||
public final static String SYSTEMTYPE_G = "G";
|
String SYSTEMTYPE_G = "G";
|
||||||
public final static String EFFICIENCY_CAL ="efficiency";
|
String EFFICIENCY_CAL ="efficiency";
|
||||||
|
|
||||||
public final static String XE_131m = "Xe131m";
|
String XE_131m = "Xe131m";
|
||||||
public final static String XE_133m = "Xe133m";
|
String XE_133m = "Xe133m";
|
||||||
public final static String XE_133 = "Xe133";
|
String XE_133 = "Xe133";
|
||||||
public final static String XE_135 = "Xe135";
|
String XE_135 = "Xe135";
|
||||||
|
|
||||||
public final static String CH_Contant = "CH(x)";
|
String CH_Contant = "CH(x)";
|
||||||
public final static String E_Contant = "E(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 struct
|
||||||
* @param fileName
|
* @param fileName
|
||||||
|
* @param status
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @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
|
@Override
|
||||||
public void createG_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct) {
|
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();
|
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();
|
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
|
||||||
calibrationPairs.setSampleId(sampleId);
|
calibrationPairs.setSampleId(sampleId);
|
||||||
calibrationPairs.setIdAnalysis(anayId);
|
calibrationPairs.setIdAnalysis(anayId);
|
||||||
calibrationPairs.setSampleType(SYSTEMTYPE_G);
|
calibrationPairs.setSampleType(SYSTEMTYPE_G);
|
||||||
calibrationPairs.setCaltype(EFFICIENCY_CAL);
|
calibrationPairs.setCaltype(ENERGY_CAL);
|
||||||
calibrationPairs.setInput(PHD);
|
calibrationPairs.setInput(PHD);
|
||||||
calibrationPairs.setIdCalPoint(i);
|
calibrationPairs.setIdCalPoint(i);
|
||||||
calibrationPairs.setXValue(struct.g_e_energy.get(i));
|
calibrationPairs.setXValue(struct.g_centroid_channel.get(i));
|
||||||
calibrationPairs.setYValue(struct.g_e_efficiency.get(i));
|
calibrationPairs.setYValue(struct.g_energy.get(i));
|
||||||
calibrationPairs.setUncYValue(struct.g_e_uncertainty.get(i));
|
calibrationPairs.setUncYValue(struct.g_uncertainty.get(i));
|
||||||
|
|
||||||
list.add(calibrationPairs);
|
list.add(calibrationPairs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
||||||
@Override
|
@Override
|
||||||
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
|
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
|
||||||
List<GardsRoiResults> list = Lists.newArrayList();
|
List<GardsRoiResults> list = Lists.newArrayList();
|
||||||
//C++那边没有补0,先加上后续解决后再删除
|
|
||||||
analyseResult.LC.add(0,0.0D);
|
|
||||||
|
|
||||||
for(int i=0;i<analyseResult.ROI.size();i++){
|
for(int i=0;i<analyseResult.ROI.size();i++){
|
||||||
GardsRoiResults roiResults = new GardsRoiResults();
|
GardsRoiResults roiResults = new GardsRoiResults();
|
||||||
|
@ -56,24 +54,29 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
||||||
int seriNo = 0;
|
int seriNo = 0;
|
||||||
//从下标3开始,每次加3
|
//从下标3开始,每次加3
|
||||||
for(int i=3;i<analyseResult.s_deduct_d_cts.size();i+=3){
|
for(int i=3;i<analyseResult.s_deduct_d_cts.size();i+=3){
|
||||||
|
if(seriNo < analyseResult.ROI.size()){
|
||||||
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
|
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
|
||||||
seriNo++;
|
seriNo++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
seriNo = 0;
|
seriNo = 0;
|
||||||
//从下标3开始,每次加3
|
//从下标3开始,每次加3
|
||||||
for(int i=3;i<analyseResult.g_deduct_d_cts.size();i+=3){
|
for(int i=3;i<analyseResult.g_deduct_d_cts.size();i+=3){
|
||||||
|
if(seriNo < analyseResult.ROI.size()){
|
||||||
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
|
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
|
||||||
|
seriNo++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//从下标1开始,第一条记录LC值固定为0
|
//LC 从下标1开始,第一条记录LC值固定为0,所以是i+1
|
||||||
for(int i=1;i<analyseResult.LC.size();i++){
|
for(int i=0;i<analyseResult.LC.size();i++){
|
||||||
list.get(i).setLc(analyseResult.LC.get(i));
|
list.get(i+1).setLc(analyseResult.LC.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//从下标1开始,第一条记录MDC值固定为0
|
//MDC从下标1开始,第一条记录MDC值固定为0,所以是i+1
|
||||||
for(int i=1;i<analyseResult.MDC.size();i++){
|
for(int i=0;i<analyseResult.MDC.size();i++){
|
||||||
list.get(i).setMdc(analyseResult.MDC.get(i));
|
list.get(i+1).setMdc(analyseResult.MDC.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CollectionUtils.isEmpty(list)){
|
if(!CollectionUtils.isEmpty(list)){
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
|
||||||
xeResults.setConc(analyseResult.Xe133_con);
|
xeResults.setConc(analyseResult.Xe133_con);
|
||||||
xeResults.setConcErr(analyseResult.Xe133_uncer);
|
xeResults.setConcErr(analyseResult.Xe133_uncer);
|
||||||
xeResults.setMdc(analyseResult.MDC_Xe133);
|
xeResults.setMdc(analyseResult.MDC_Xe133);
|
||||||
xeResults.setLc(analyseResult.MDC_Xe133);
|
xeResults.setLc(analyseResult.LC_Xe133);
|
||||||
xeResults.setNidFlag(analyseResult.XE_133_NID_FLAG);
|
xeResults.setNidFlag(analyseResult.XE_133_NID_FLAG);
|
||||||
xeResults.setModdate(new Date());
|
xeResults.setModdate(new Date());
|
||||||
|
|
||||||
|
@ -94,11 +94,11 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
|
||||||
xeResults.setSampleId(sampleId);
|
xeResults.setSampleId(sampleId);
|
||||||
xeResults.setIdAnalysis(idAnalysis);
|
xeResults.setIdAnalysis(idAnalysis);
|
||||||
xeResults.setNuclideName(nuclideName);
|
xeResults.setNuclideName(nuclideName);
|
||||||
xeResults.setConc(analyseResult.Xe131m_con);
|
xeResults.setConc(analyseResult.Xe133m_con);
|
||||||
xeResults.setConcErr(analyseResult.Xe131m_uncer);
|
xeResults.setConcErr(analyseResult.Xe133m_uncer);
|
||||||
xeResults.setMdc(analyseResult.MDC_Xe131m);
|
xeResults.setMdc(analyseResult.MDC_Xe133m);
|
||||||
xeResults.setLc(analyseResult.LC_Xe131m);
|
xeResults.setLc(analyseResult.LC_Xe133m);
|
||||||
xeResults.setNidFlag(analyseResult.XE_131m_NID_FLAG);
|
xeResults.setNidFlag(analyseResult.XE_133m_NID_FLAG);
|
||||||
xeResults.setModdate(new Date());
|
xeResults.setModdate(new Date());
|
||||||
|
|
||||||
xeResultsList.add(xeResults);
|
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.configuration.GardsStations;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleAux;
|
import org.jeecg.modules.base.entity.original.GardsSampleAux;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
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.GardsDetectorsMapper;
|
||||||
import org.jeecg.modules.mapper.GardsSampleAuxMapper;
|
import org.jeecg.modules.mapper.GardsSampleAuxMapper;
|
||||||
import org.jeecg.modules.mapper.GardsSampleDataMapper;
|
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.jeecg.modules.service.ISpectrumBaseBlockService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -40,12 +37,13 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
||||||
* 不添加事务注解由调用方手动事务提交
|
* 不添加事务注解由调用方手动事务提交
|
||||||
* @param struct
|
* @param struct
|
||||||
* @param fileName
|
* @param fileName
|
||||||
|
* @param status
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception {
|
public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception {
|
||||||
final GardsSampleData sampleData = this.saveSampleData(struct,fileName);
|
final GardsSampleData sampleData = this.saveSampleData(struct,fileName,status);
|
||||||
this.saveSampleAux(struct,sampleData);
|
this.saveSampleAux(struct,sampleData);
|
||||||
return sampleData;
|
return sampleData;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +54,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @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.site_code,"此次解析结构体中的台站“台站代码”为空");
|
||||||
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
|
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
|
||||||
|
|
||||||
|
@ -101,7 +99,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
||||||
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);
|
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);
|
||||||
gardsSampleData.setAcquisitionLiveSec(struct.acquisition_live_time);
|
gardsSampleData.setAcquisitionLiveSec(struct.acquisition_live_time);
|
||||||
gardsSampleData.setQuantity(struct.air_volume);
|
gardsSampleData.setQuantity(struct.air_volume);
|
||||||
gardsSampleData.setStatus(SampleStatus.UNTREATED.getValue());
|
gardsSampleData.setStatus(status);
|
||||||
gardsSampleData.setModdate(new Date());
|
gardsSampleData.setModdate(new Date());
|
||||||
|
|
||||||
this.sampleDataMapper.insert(gardsSampleData);
|
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.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{
|
try{
|
||||||
//前置检查
|
//前置检查
|
||||||
this.preCheck();
|
this.preCheck();
|
||||||
|
//声明日志处理对象
|
||||||
|
super.initLogObj();
|
||||||
//打印当前处理的能谱类型
|
//打印当前处理的能谱类型
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
|
@ -39,17 +43,21 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
super.saveFileToFtp();
|
super.saveFileToFtp();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
//处理流程日志
|
//修改状态为解析完成
|
||||||
super.handleProcessLog();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
|
super.updateStatus();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常结束日志
|
//修改状态为解析失败
|
||||||
super.exceptionEndLog(e);
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到ftp->undeal目录
|
//处理解析失败的文件,上传到ftp->undeal目录
|
||||||
super.handleParseingFailFile();
|
super.handleParseingFailFile();
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
//结束流程日志
|
if(Objects.nonNull(this.parsingProcessLog)){
|
||||||
super.storageProcessLogEnd();
|
this.parsingProcessLog.handleLog();
|
||||||
|
}
|
||||||
//删除本地临时文件
|
//删除本地临时文件
|
||||||
super.deleteLocalTemporaryFile();
|
super.deleteLocalTemporaryFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
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{
|
try{
|
||||||
//前置检查
|
//前置检查
|
||||||
this.preCheck();
|
this.preCheck();
|
||||||
|
//声明日志处理对象
|
||||||
|
super.initLogObj();
|
||||||
//打印当前处理的能谱类型
|
//打印当前处理的能谱类型
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
|
@ -40,17 +44,21 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
super.saveFileToFtp();
|
super.saveFileToFtp();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
//处理流程日志
|
//修改状态为解析完成
|
||||||
super.handleProcessLog();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
|
super.updateStatus();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常结束日志
|
//修改状态为解析失败
|
||||||
super.exceptionEndLog(e);
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到ftp->undeal目录
|
//处理解析失败的文件,上传到ftp->undeal目录
|
||||||
super.handleParseingFailFile();
|
super.handleParseingFailFile();
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
//结束流程日志
|
if(Objects.nonNull(this.parsingProcessLog)){
|
||||||
super.storageProcessLogEnd();
|
this.parsingProcessLog.handleLog();
|
||||||
|
}
|
||||||
//删除本地临时文件
|
//删除本地临时文件
|
||||||
super.deleteLocalTemporaryFile();
|
super.deleteLocalTemporaryFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
package org.jeecg.modules.spectrum;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
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.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.io.ByteArrayInputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* B谱邮件解析流程日志
|
* B谱邮件解析流程日志
|
||||||
|
@ -14,17 +24,33 @@ import java.nio.charset.StandardCharsets;
|
||||||
public class ParsingProcessLog {
|
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{
|
protected class StorageProcessLog{
|
||||||
|
|
||||||
private static final String WRITE_INTO_START = "%s Write Data into Database at %s %s";
|
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 DATABASE_CONNECTED = "Successfully connected to database,source:%s,user=%s";
|
||||||
private static final String SOURCE_FILE = "SourceFile:%s";
|
private static final String SOURCE_FILE = "SourceFile:%s";
|
||||||
private static final String STANDARD_FILE = "StandardFile:%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 oraUsername = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUsername();
|
||||||
final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
|
final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
|
||||||
final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||||
final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath;
|
final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath;
|
||||||
log.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
storageLog.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
storageLog.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
storageLog.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
|
storageLog.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
|
||||||
log.append(System.lineSeparator());
|
storageLog.append(System.lineSeparator());
|
||||||
log.append(rowFormat(STANDARD_FILE,standardFile));
|
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(){
|
private void endOfFileRepeat(){
|
||||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
|
||||||
log.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||||
log.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(){
|
private void end(){
|
||||||
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
|
||||||
log.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
|
storageLog.append(System.lineSeparator());
|
||||||
log.append(System.lineSeparator());
|
storageLog.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
|
||||||
log.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
|
storageLog.append(System.lineSeparator());
|
||||||
log.append(System.lineSeparator());
|
storageLog.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
|
||||||
log.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(rowFormat(INSTANCE_STATUS,spectrumHandler.status));
|
||||||
log.append(rowFormat(INSTANCE_STATUS, SampleStatus.UNTREATED.getValue()));
|
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
|
||||||
log.append(System.lineSeparator()).append(System.lineSeparator());
|
storageLog.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
|
||||||
log.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 class AnalyseProcessLog extends AbstractLogOrReport implements BlockConstant {
|
||||||
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 void start(){
|
private void handleAnalysisProcessLog(){
|
||||||
final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
|
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");
|
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(){
|
private void setDetAndGasIdLog(){
|
||||||
final String titleId = "%s Get DetaId and GasId %s";
|
final String title = "%s Get DetaId and GasId %s";
|
||||||
log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT));
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
protected void storageProcessLogStart(){
|
private void handleStorageProcessLog(){
|
||||||
this.processLog = new StorageProcessLog();
|
this.storageProcessLog = new StorageProcessLog();
|
||||||
this.processLog.start();
|
this.storageProcessLog.handleStorageProcessLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束存储流程日志
|
* 处理分析流程日志
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
protected void storageProcessLogEnd(){
|
private void handleAnalysisProcessLog(){
|
||||||
if(this.logStoreEndFlag == false){
|
this.analyseProcessLog = new AnalyseProcessLog();
|
||||||
this.processLog.end();
|
this.analyseProcessLog.handleAnalysisProcessLog();
|
||||||
this.logStoreEndFlag = true;
|
|
||||||
this.saveLogToFTP();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件重复异常结束存储流程日志
|
* 处理所有日志
|
||||||
*/
|
*/
|
||||||
protected void endOfFileRepeat(){
|
protected void handleLog(){
|
||||||
if(this.logStoreEndFlag == false){
|
this.handleStorageProcessLog();
|
||||||
this.processLog.endOfFileRepeat();
|
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
|
||||||
this.logStoreEndFlag = true;
|
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
|
||||||
this.saveLogToFTP();
|
this.fileRepeat == false){
|
||||||
|
|
||||||
|
this.handleAnalysisProcessLog();
|
||||||
}
|
}
|
||||||
|
if(Objects.nonNull(this.analysisLog)){
|
||||||
|
this.storageLog.append(this.analysisLog);
|
||||||
|
}
|
||||||
|
this.saveLogToFTP(this.storageLog.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存日志到ftp
|
* 保存日志到ftp
|
||||||
*/
|
*/
|
||||||
private void saveLogToFTP(){
|
private void saveLogToFTP(String log){
|
||||||
//保存日志文件到ftp
|
//保存日志文件到ftp
|
||||||
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
|
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
|
||||||
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath();
|
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath();
|
||||||
spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
|
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)));
|
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8)));
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ParsingProcessLog s = new ParsingProcessLog();
|
|
||||||
s.storageProcessLogStart();
|
|
||||||
s.endOfFileRepeat();
|
|
||||||
System.out.println(s.log.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.jeecg.modules.spectrum;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
import org.jeecg.modules.base.enums.DataType;
|
||||||
|
import org.jeecg.modules.base.enums.SampleStatus;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QC谱处理
|
* QC谱处理
|
||||||
|
@ -29,6 +31,8 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
try{
|
try{
|
||||||
//前置检查
|
//前置检查
|
||||||
this.preCheck();
|
this.preCheck();
|
||||||
|
//声明日志处理对象
|
||||||
|
super.initLogObj();
|
||||||
//打印当前处理的能谱类型
|
//打印当前处理的能谱类型
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
|
@ -39,17 +43,21 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
super.saveFileToFtp();
|
super.saveFileToFtp();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
//处理流程日志
|
//修改状态为解析完成
|
||||||
super.handleProcessLog();
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
|
super.updateStatus();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常结束日志
|
//修改状态为解析失败
|
||||||
super.exceptionEndLog(e);
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到ftp->undeal目录
|
//处理解析失败的文件,上传到ftp->undeal目录
|
||||||
super.handleParseingFailFile();
|
super.handleParseingFailFile();
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
//结束流程日志
|
if(Objects.nonNull(this.parsingProcessLog)){
|
||||||
super.storageProcessLogEnd();
|
this.parsingProcessLog.handleLog();
|
||||||
|
}
|
||||||
//删除本地临时文件
|
//删除本地临时文件
|
||||||
super.deleteLocalTemporaryFile();
|
super.deleteLocalTemporaryFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
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.config.datasource.DataSourceSwitcher;
|
||||||
import org.jeecg.modules.exception.AcquisitionBlockException;
|
import org.jeecg.modules.exception.AcquisitionBlockException;
|
||||||
import org.jeecg.modules.exception.FileRepeatException;
|
import org.jeecg.modules.exception.FileRepeatException;
|
||||||
|
@ -63,6 +64,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
||||||
* 流程日志对象
|
* 流程日志对象
|
||||||
*/
|
*/
|
||||||
protected ParsingProcessLog parsingProcessLog;
|
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)){
|
if(Objects.nonNull(query)){
|
||||||
this.sampleData = query;
|
this.sampleData = query;
|
||||||
this.endIntoDatabaseTime = new Date();
|
this.endIntoDatabaseTime = new Date();
|
||||||
|
//设置文件重复标记为true
|
||||||
|
this.parsingProcessLog.setFileRepeat(true);
|
||||||
throw new FileRepeatException("file repeat");
|
throw new FileRepeatException("file repeat");
|
||||||
}
|
}
|
||||||
DataSourceSwitcher.switchToOracle();
|
DataSourceSwitcher.switchToOracle();
|
||||||
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||||
try{
|
try{
|
||||||
//存储基础数据
|
//存储基础数据
|
||||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath);
|
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath,status);
|
||||||
//存储其他块数据
|
//存储其他块数据
|
||||||
for(String labels : spectrumFileLabels){
|
for(String labels : spectrumFileLabels){
|
||||||
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
|
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
|
* @return
|
||||||
|
@ -268,33 +291,4 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
||||||
}
|
}
|
||||||
return Strings.EMPTY;
|
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.entity.rnauto.GardsAnalyses;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
import org.jeecg.modules.base.enums.DataType;
|
||||||
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
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.base.enums.SampleStatus;
|
||||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||||
import org.jeecg.modules.exception.BAnalyseException;
|
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_SUFFIX = ".txt";
|
||||||
private static final String ARR_FILE_NAME_TAIL = "_rpt";
|
private static final String ARR_FILE_NAME_TAIL = "_rpt";
|
||||||
/**
|
|
||||||
* 正常分析过程日志
|
|
||||||
*/
|
|
||||||
private StringBuilder analysesLog = new StringBuilder();
|
|
||||||
/**
|
|
||||||
* 分析过程当前状态
|
|
||||||
*/
|
|
||||||
private String currAnalysesStatus = null;
|
|
||||||
/**
|
/**
|
||||||
* Sample谱结构体数据
|
* Sample谱结构体数据
|
||||||
*/
|
*/
|
||||||
private EnergySpectrumStruct sampleStruct = null;
|
protected EnergySpectrumStruct sampleStruct = null;
|
||||||
/**
|
/**
|
||||||
* sample谱原始数据
|
* sample谱原始数据
|
||||||
*/
|
*/
|
||||||
private GardsSampleData sampleData = null;
|
protected GardsSampleData sampleData = null;
|
||||||
/**
|
/**
|
||||||
* gas谱结构体数据
|
* gas谱结构体数据
|
||||||
*/
|
*/
|
||||||
private EnergySpectrumStruct gasStruct = null;
|
protected EnergySpectrumStruct gasStruct = null;
|
||||||
/**
|
/**
|
||||||
* gas谱原始数据
|
* gas谱原始数据
|
||||||
*/
|
*/
|
||||||
private GardsSampleData detSampleData = null;
|
protected GardsSampleData detSampleData = null;
|
||||||
/**
|
/**
|
||||||
* det谱结构体数据
|
* det谱结构体数据
|
||||||
*/
|
*/
|
||||||
private EnergySpectrumStruct detStruct = null;
|
protected EnergySpectrumStruct detStruct = null;
|
||||||
/**
|
/**
|
||||||
* det谱原始数据
|
* det谱原始数据
|
||||||
*/
|
*/
|
||||||
private GardsSampleData gasSampleData = null;
|
protected GardsSampleData gasSampleData = null;
|
||||||
/**
|
/**
|
||||||
* sample谱PHD文件临时路径
|
* 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 Date endAnalysisTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程日志对象
|
||||||
|
*/
|
||||||
|
protected ParsingProcessLog parsingProcessLog;
|
||||||
|
|
||||||
public Sample_B_Analysis() {
|
public Sample_B_Analysis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes,
|
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.sampleData = sampleData;
|
||||||
this.sampleTempFilePath = sampleTempFilePath;
|
this.sampleTempFilePath = sampleTempFilePath;
|
||||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||||
|
@ -133,6 +129,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
this.ftpUtil = ftpUtil;
|
this.ftpUtil = ftpUtil;
|
||||||
this.logFilePath = logFilePath;
|
this.logFilePath = logFilePath;
|
||||||
this.logFileName = logFileName;
|
this.logFileName = logFileName;
|
||||||
|
this.parsingProcessLog = parsingProcessLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,8 +137,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
*/
|
*/
|
||||||
public void start() throws BAnalyseException {
|
public void start() throws BAnalyseException {
|
||||||
try{
|
try{
|
||||||
//修改状态为分析中
|
this.startAnalysisTime = new Date();
|
||||||
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
|
//声明分析日志对象
|
||||||
|
parsingProcessLog.setSample_B_Analysis(this);
|
||||||
//查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来
|
//查询det、gas数据(sampleId,inputFileName),sample数据在构造函数已经传过来
|
||||||
this.queryPHDFile();
|
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();
|
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
|
||||||
report.start();
|
report.start();
|
||||||
//修改状态为分析成功
|
|
||||||
this.updateStatus(SampleStatus.COMPLETE.getValue());
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//修改状态为分析失败
|
|
||||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
}finally {
|
}finally {
|
||||||
|
this.endAnalysisTime = new Date();
|
||||||
//删除下载的det和gas临时文件
|
//删除下载的det和gas临时文件
|
||||||
this.deleteLocalTemporaryFile();
|
this.deleteLocalTemporaryFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改状态
|
|
||||||
* @param analysesStatus
|
|
||||||
*/
|
|
||||||
private void updateStatus(String analysesStatus){
|
|
||||||
this.currAnalysesStatus = analysesStatus;
|
|
||||||
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询det、gas数据,sample在构造函数已经传过来
|
* 查询det、gas数据,sample在构造函数已经传过来
|
||||||
* @throws FileNotExistException
|
* @throws FileNotExistException
|
||||||
|
@ -188,8 +174,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
|
|
||||||
//如果找不到sample、det、gas谱文件数据则解析失败修改记录状态
|
//如果找不到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())){
|
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..");
|
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谱结果
|
* 调用dll库的分析B谱结果
|
||||||
*/
|
*/
|
||||||
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
||||||
this.startAnalysisTime = new Date();
|
|
||||||
System.out.println("sam:"+this.sampleTempFilePath);
|
System.out.println("sam:"+this.sampleTempFilePath);
|
||||||
System.out.println("gas:"+this.gasTempFilePath);
|
System.out.println("gas:"+this.gasTempFilePath);
|
||||||
System.out.println("det:"+this.detTempFilePath);
|
System.out.println("det:"+this.detTempFilePath);
|
||||||
|
|
||||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
||||||
System.out.println(analyseResult);
|
System.out.println(analyseResult);
|
||||||
this.endAnalysisTime = new Date();
|
|
||||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||||
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
|
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;
|
detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName;
|
||||||
|
|
||||||
if(flag){
|
if(flag){
|
||||||
|
parsingProcessLog.setFileNotExist(true);
|
||||||
throw new FileNotExistException("gas or det file is no exist or is error..");
|
throw new FileNotExistException("gas or det file is no exist or is error..");
|
||||||
}
|
}
|
||||||
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
this.detStruct = EnergySpectrumHandler.getSourceData(detTempFilePath);
|
||||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
this.gasStruct = EnergySpectrumHandler.getSourceData(gasTempFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,6 +295,8 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
//提交事务
|
//提交事务
|
||||||
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
|
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
//设置分析数据存储失败标记
|
||||||
|
this.parsingProcessLog.setAnalysisDataStoreFlag(false);
|
||||||
//回滚事务
|
//回滚事务
|
||||||
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
|
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -343,7 +331,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
/**
|
/**
|
||||||
* B谱分析报告
|
* 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 {
|
private void handleSampleCalibration() throws IOException {
|
||||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
|
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),
|
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);
|
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
|
||||||
}
|
}
|
||||||
|
@ -515,10 +503,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
* 处理#DET CALIBRATION 模块
|
* 处理#DET CALIBRATION 模块
|
||||||
*/
|
*/
|
||||||
private void handleDetCalibration() throws IOException {
|
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)};
|
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)};
|
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)};
|
||||||
|
|
||||||
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
||||||
|
@ -549,10 +537,10 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
*/
|
*/
|
||||||
private void handleGasCalibration() throws IOException {
|
private void handleGasCalibration() throws IOException {
|
||||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
|
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),
|
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);
|
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> roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||||
List<String> beta = Lists.newArrayList();
|
List<String> beta = Lists.newArrayList();
|
||||||
List<String> gamma = Lists.newArrayList();
|
List<String> gamma = Lists.newArrayList();
|
||||||
String flag = " to ";
|
|
||||||
for(int i=0;i<roi.size();i++){
|
for(int i=0;i<roi.size();i++){
|
||||||
beta.add(b_chan_start.get(i)+flag+b_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)+flag+g_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);
|
handleThreeParamFormat("#GAS LIMITS PER ROI",roi,beta,gamma);
|
||||||
}
|
}
|
||||||
|
@ -582,9 +569,9 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
*/
|
*/
|
||||||
private void handleGrossCounts() throws IOException {
|
private void handleGrossCounts() throws IOException {
|
||||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
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> 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->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->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);
|
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());
|
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||||
//此参数需第一位补0
|
//此参数需第一位补0
|
||||||
analyseResult.LC_CTS.add(0,0D);
|
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();
|
List<String> netCount = Lists.newArrayList();
|
||||||
String flag = " +/- ";
|
|
||||||
for(int i=0;i<roi.size();i++){
|
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);
|
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> con = analyseResult.ROI_con_uncer;
|
||||||
List<Double> conErr = analyseResult.ROI_con_uncer_err;
|
List<Double> conErr = analyseResult.ROI_con_uncer_err;
|
||||||
analyseResult.LC.add(0,0.0D);
|
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> 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> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||||
List<String> mdc = Lists.newArrayList();//analyseResult.MDC.stream().map(Object::toString).collect(Collectors.toList());
|
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
|
||||||
for(int i=0;i<10;i++){
|
|
||||||
mdc.add("0.0");
|
|
||||||
}
|
|
||||||
List<String> conc = Lists.newArrayList();
|
List<String> conc = Lists.newArrayList();
|
||||||
for(int i=0;i<roi.size();i++){
|
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);
|
this.handleFourParamFormat("#CONCENTRATION AND LC PER ROI",roi,conc,lc,mdc);
|
||||||
}
|
}
|
||||||
|
@ -633,19 +616,18 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
* #RESULT SUMMARY
|
* #RESULT SUMMARY
|
||||||
*/
|
*/
|
||||||
private void handleResultSummary() throws IOException {
|
private void handleResultSummary() throws IOException {
|
||||||
String flag = " +/- ";
|
|
||||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||||
|
|
||||||
String[] conc = {formatToStr5(analyseResult.Xe135_con)+flag+formatToStr5(analyseResult.Xe135_uncer),
|
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer),
|
||||||
formatToStr5(analyseResult.Xe131m_con)+flag+formatToStr5(analyseResult.Xe131m_uncer),
|
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer),
|
||||||
formatToStr5(analyseResult.Xe133m_con)+flag+formatToStr5(analyseResult.Xe133m_uncer),
|
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer),
|
||||||
formatToStr5(analyseResult.Xe133_con)+flag+formatToStr5(analyseResult.Xe133_uncer)};
|
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer)};
|
||||||
|
|
||||||
String[] uncertainty = {formatToStr5(analyseResult.LC_Xe135),formatToStr5(analyseResult.LC_Xe131m),
|
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135),super.formatToStr5(analyseResult.LC_Xe131m),
|
||||||
formatToStr5(analyseResult.LC_Xe133m),formatToStr5(analyseResult.LC_Xe133)};
|
super.formatToStr5(analyseResult.LC_Xe133m),super.formatToStr5(analyseResult.LC_Xe133)};
|
||||||
|
|
||||||
String[] mdc = {formatToStr5(analyseResult.MDC_Xe135),formatToStr5(analyseResult.MDC_Xe131m),
|
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135),super.formatToStr5(analyseResult.MDC_Xe131m),
|
||||||
formatToStr5(analyseResult.MDC_Xe133m),formatToStr5(analyseResult.MDC_Xe133)};
|
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_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_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();
|
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 模块
|
* 1.#SAMPLE CALIBRATION 模块
|
||||||
|
@ -811,51 +753,6 @@ public class Sample_B_Analysis implements BlockConstant {
|
||||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
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;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
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.base.enums.SystemType;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 样品谱处理
|
* 样品谱处理
|
||||||
|
@ -29,6 +31,8 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
try{
|
try{
|
||||||
//前置检查
|
//前置检查
|
||||||
this.preCheck();
|
this.preCheck();
|
||||||
|
//声明日志处理对象
|
||||||
|
super.initLogObj();
|
||||||
//打印当前处理的能谱类型
|
//打印当前处理的能谱类型
|
||||||
super.printCurrDataType();
|
super.printCurrDataType();
|
||||||
//解析邮件内容
|
//解析邮件内容
|
||||||
|
@ -39,19 +43,24 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
super.saveFileToFtp();
|
super.saveFileToFtp();
|
||||||
//结构体数据入库
|
//结构体数据入库
|
||||||
super.handlerOriginalData();
|
super.handlerOriginalData();
|
||||||
//处理流程日志
|
|
||||||
super.handleProcessLog();
|
|
||||||
//进行B、G(P)谱分析
|
//进行B、G(P)谱分析
|
||||||
this.autoAnalysis();
|
this.autoAnalysis();
|
||||||
|
|
||||||
|
//修改状态为解析完成
|
||||||
|
super.status = SampleStatus.COMPLETE.getValue();
|
||||||
|
super.updateStatus();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//异常结束日志
|
//修改状态为解析失败
|
||||||
super.exceptionEndLog(e);
|
super.status = SampleStatus.FAIL.getValue();
|
||||||
|
super.updateStatus();
|
||||||
|
|
||||||
//处理解析失败的文件,上传到ftp->undeal目录
|
//处理解析失败的文件,上传到ftp->undeal目录
|
||||||
super.handleParseingFailFile();
|
super.handleParseingFailFile();
|
||||||
throw e;
|
throw e;
|
||||||
}finally {
|
}finally {
|
||||||
//结束流程日志
|
if(Objects.nonNull(this.parsingProcessLog)){
|
||||||
super.storageProcessLogEnd();
|
this.parsingProcessLog.handleLog();
|
||||||
|
}
|
||||||
//删除本地临时文件
|
//删除本地临时文件
|
||||||
super.deleteLocalTemporaryFile();
|
super.deleteLocalTemporaryFile();
|
||||||
}
|
}
|
||||||
|
@ -65,14 +74,15 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected void autoAnalysis() throws Exception {
|
protected void autoAnalysis() throws Exception {
|
||||||
// if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
|
if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
|
||||||
// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
|
Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
|
||||||
// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.logFilePath,super.logFileName);
|
super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,
|
||||||
// bAnalysis.start();
|
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();
|
||||||
// }
|
// }
|
||||||
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