Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
ae2dfc2697
|
@ -18,7 +18,7 @@ import java.time.LocalDate;
|
|||
@TableName(value = "sys_email")
|
||||
public class SysEmail implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id;
|
||||
|
||||
@TableField("name")
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.jeecg.modules.base.enums;
|
||||
|
||||
public enum FittingEquation {
|
||||
|
||||
DEFAULT(0, "(?1)+(?2)*x+(?3)x*x"),
|
||||
LINER(1, "(?1)+(?2)*x"),
|
||||
POLY2(2, "(?1)+(?2)*x+(?3)x*x"),
|
||||
POLY3(3, "_3PloynimialFitEquation"),
|
||||
GAUSS(4, "GaussFitEquation");
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String description;
|
||||
|
||||
FittingEquation(Integer code, String description){
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
|
@ -14,5 +14,8 @@ public interface BlockConstant {
|
|||
public final static String XE_133 = "Xe133";
|
||||
public final static String XE_135 = "Xe135";
|
||||
|
||||
public final static String CH_Contant = "CH(x)";
|
||||
public final static String E_Contant = "E(x)";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,15 +3,11 @@ package org.jeecg.modules.service.impl;
|
|||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
|
||||
import org.jeecg.modules.mapper.GardsCalibrationMapper;
|
||||
import org.jeecg.modules.mapper.GardsCalibrationPairsMapper;
|
||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.jeecg.modules.service.GardsCalibrationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
|
@ -196,13 +192,4 @@ public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMap
|
|||
|
||||
this.baseMapper.create(calibration);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// System.loadLibrary("ReadPHDFile");
|
||||
// String sampleTempFilePath = "E:\\file\\AUX09_003-20151224_1855_S_FULL_40184.505.PHD";
|
||||
// String gasTempFilePath = "E:\\file\\AUX09_003-20151224_0655_G_FULL_40182.873.PHD";
|
||||
// String detTempFilePath = "E:\\file\\AUX09_003-20150527_0425_D_FULL_259449.672.PHD";
|
||||
// BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(sampleTempFilePath,gasTempFilePath,detTempFilePath);
|
||||
// System.out.println(analyseResult);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
|||
@Override
|
||||
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
|
||||
List<GardsRoiResults> list = Lists.newArrayList();
|
||||
//C++那边没有补0,先加上后续解决后再删除
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
for(int i=0;i<analyseResult.ROI.size();i++){
|
||||
GardsRoiResults roiResults = new GardsRoiResults();
|
||||
roiResults.setSampleId(sampleId);
|
||||
|
@ -40,41 +42,17 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
|
|||
roiResults.setBGross(analyseResult.d_roi_cts.get(i));
|
||||
roiResults.setSNet(analyseResult.s_deduct_d_cts.get(i));
|
||||
roiResults.setGNet(analyseResult.g_deduct_d_cts.get(i));
|
||||
roiResults.setNet(0D);
|
||||
roiResults.setNetErr(0D);
|
||||
roiResults.setConc(0D);
|
||||
roiResults.setConcErr(0D);
|
||||
roiResults.setLc(0D);
|
||||
roiResults.setNet(analyseResult.ROI_net_coutns.get(i));
|
||||
roiResults.setNetErr(analyseResult.ROI_net_coutns_err.get(i));
|
||||
roiResults.setConc(analyseResult.ROI_con_uncer.get(i));
|
||||
roiResults.setConcErr(analyseResult.ROI_con_uncer_err.get(i));
|
||||
roiResults.setLc(analyseResult.LC.get(i));
|
||||
roiResults.setMdc(0D);
|
||||
roiResults.setNidFlag(0);
|
||||
roiResults.setModdate(new Date());
|
||||
|
||||
list.add(roiResults);
|
||||
}
|
||||
//从下班1开始,第一条记录NET值固定为0
|
||||
for(int i=1;i<analyseResult.ROI_net_coutns.size();i++){
|
||||
list.get(i).setNet(analyseResult.ROI_net_coutns.get(i));
|
||||
}
|
||||
|
||||
//从下班1开始,第一条记录NETERR值固定为0
|
||||
for(int i=1;i<analyseResult.ROI_net_coutns_err.size();i++){
|
||||
list.get(i).setNetErr(analyseResult.ROI_net_coutns_err.get(i));
|
||||
}
|
||||
|
||||
//从下班1开始,第一条记录CONC值固定为0
|
||||
for(int i=1;i<analyseResult.ROI_con_uncer.size();i++){
|
||||
list.get(i).setConc(analyseResult.ROI_con_uncer.get(i));
|
||||
}
|
||||
|
||||
//从下班1开始,第一条记录CONCERR值固定为0
|
||||
for(int i=1;i<analyseResult.ROI_con_uncer_err.size();i++){
|
||||
list.get(i).setConcErr(analyseResult.ROI_con_uncer_err.get(i));
|
||||
}
|
||||
|
||||
//从下班1开始,第一条记录LC值固定为0
|
||||
for(int i=1;i<analyseResult.LC.size();i++){
|
||||
list.get(i).setLc(analyseResult.LC.get(i));
|
||||
}
|
||||
|
||||
//从下班1开始,第一条记录MDC值固定为0
|
||||
// for(int i=1;i<analyseResult.MDC.size();i++){
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
|
@ -82,16 +83,16 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
gardsSampleData.setGeometry(struct.sample_geometry);
|
||||
gardsSampleData.setSpectralQualifie(struct.spectrum_quantity);
|
||||
if(StringUtils.isNotBlank(struct.transmit_date) && StringUtils.isNotBlank(struct.transmit_time)){
|
||||
gardsSampleData.setTransmitDtg(DateUtils.parseDate(struct.transmit_date+" "+struct.transmit_time));
|
||||
gardsSampleData.setTransmitDtg(DateUtils.parseDate(struct.transmit_date+StringConstant.SPACE+struct.transmit_time));
|
||||
}
|
||||
if(StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time)){
|
||||
gardsSampleData.setCollectStart(DateUtils.parseDate(struct.collection_start_date+" "+struct.collection_start_time));
|
||||
gardsSampleData.setCollectStart(DateUtils.parseDate(struct.collection_start_date+StringConstant.SPACE+struct.collection_start_time));
|
||||
}
|
||||
if(StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time)){
|
||||
gardsSampleData.setCollectStart(DateUtils.parseDate(struct.collection_stop_date+" "+struct.collection_stop_time));
|
||||
gardsSampleData.setCollectStop(DateUtils.parseDate(struct.collection_stop_date+StringConstant.SPACE+struct.collection_stop_time));
|
||||
}
|
||||
if(StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time)){
|
||||
gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+" "+struct.acquisition_start_time));
|
||||
gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+StringConstant.SPACE+struct.acquisition_start_time));
|
||||
}
|
||||
if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_live_time > 0){
|
||||
Date acquisitionStop = new Date((long) (gardsSampleData.getAcquisitionStart().getTime()+(struct.acquisition_live_time*1000)));
|
||||
|
@ -122,7 +123,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
|
|||
gardsSampleAux.setSampleHeight(struct.dimension_2);
|
||||
gardsSampleAux.setSampleDiameter(struct.dimension_1);
|
||||
if(StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)){
|
||||
gardsSampleAux.setCalibrationDtg(DateUtils.parseDate(struct.date_calibration+" "+struct.time_calibration));
|
||||
gardsSampleAux.setCalibrationDtg(DateUtils.parseDate(struct.date_calibration+StringConstant.SPACE+struct.time_calibration));
|
||||
}
|
||||
gardsSampleAux.setMsgId(struct.msg_id);
|
||||
gardsSampleAux.setArchiveBottleId(struct.archive_bottle_id);
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.jeecg.common.constant.StringConstant;
|
|||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.exception.AcquisitionBlockException;
|
||||
import org.jeecg.modules.exception.FileRepeatException;
|
||||
|
@ -20,6 +21,8 @@ import org.springframework.boot.system.ApplicationHome;
|
|||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -149,11 +152,37 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
|
|||
newFileName.append(StringConstant.UNDER_LINE);
|
||||
newFileName.append(this.sourceData.spectrum_quantity);
|
||||
newFileName.append(StringConstant.UNDER_LINE);
|
||||
newFileName.append(this.sourceData.acquisition_live_time);
|
||||
newFileName.append(handleLiveTime());
|
||||
newFileName.append(super.currDataType.getSuffix());
|
||||
mailFile = FileUtil.rename(mailFile,newFileName.toString(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理acquisition_live_time字段
|
||||
* @return
|
||||
*/
|
||||
private String handleLiveTime(){
|
||||
BigDecimal bg = new BigDecimal(this.sourceData.acquisition_live_time);
|
||||
//将acquisition_live_time保留一位小数 如果保留一位小数后小数点后的值是0则四舍五入保留整数,否则按正常条件四舍五入保留小数位
|
||||
String scale = bg.setScale(1, RoundingMode.HALF_UP).toPlainString();
|
||||
if(DataType.SAMPLEPHD.getType().equals(super.currDataType.getType()) || DataType.GASBKPHD.getType().equals(super.currDataType.getType())){
|
||||
if (scale.indexOf(".0") > 0) {
|
||||
bg = bg.setScale(0, RoundingMode.HALF_UP);
|
||||
} else {
|
||||
bg = bg.setScale(1, RoundingMode.HALF_UP);
|
||||
}
|
||||
}else if(DataType.DETBKPHD.getType().equals(super.currDataType.getType())){
|
||||
bg = bg.setScale(0, RoundingMode.HALF_UP);
|
||||
}else if(DataType.QCPHD.getType().equals(super.currDataType.getType())){
|
||||
if (scale.indexOf(".0") > 0) {
|
||||
bg = bg.setScale(0, RoundingMode.HALF_UP);
|
||||
} else {
|
||||
bg = bg.setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
return bg.toPlainString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取邮件内容#开头的标签
|
||||
* @throws Exception
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.StringConstant;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.base.enums.DataType;
|
||||
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
||||
import org.jeecg.modules.base.enums.FittingEquation;
|
||||
import org.jeecg.modules.base.enums.SampleStatus;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.exception.BAnalyseException;
|
||||
|
@ -15,22 +22,27 @@ import org.jeecg.modules.ftp.FTPUtils;
|
|||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* B谱分析过程
|
||||
*/
|
||||
public class Sample_B_Analysis {
|
||||
public class Sample_B_Analysis implements BlockConstant {
|
||||
|
||||
/**
|
||||
* 报告文件后缀
|
||||
*/
|
||||
private static final String ARR_FILE_SUFFIX = ".txt";
|
||||
private static final String ARR_FILE_NAME_TAIL = "_rpt";
|
||||
/**
|
||||
* 正常分析过程日志
|
||||
*/
|
||||
|
@ -47,10 +59,18 @@ public class Sample_B_Analysis {
|
|||
* sample谱原始数据
|
||||
*/
|
||||
private GardsSampleData sampleData = null;
|
||||
/**
|
||||
* gas谱结构体数据
|
||||
*/
|
||||
private EnergySpectrumStruct gasStruct = null;
|
||||
/**
|
||||
* gas谱原始数据
|
||||
*/
|
||||
private GardsSampleData detSampleData = null;
|
||||
/**
|
||||
* det谱结构体数据
|
||||
*/
|
||||
private EnergySpectrumStruct detStruct = null;
|
||||
/**
|
||||
* det谱原始数据
|
||||
*/
|
||||
|
@ -104,8 +124,11 @@ public class Sample_B_Analysis {
|
|||
*/
|
||||
private Date endAnalysisTime;
|
||||
|
||||
public Sample_B_Analysis(GardsSampleData sampleData,String sampleTempFilePath,SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EnergySpectrumStruct sampleStruct,FTPUtils ftpUtil,String logFilePath,String logFileName){
|
||||
public Sample_B_Analysis() {
|
||||
}
|
||||
|
||||
public Sample_B_Analysis(GardsSampleData sampleData, String sampleTempFilePath, SpectrumServiceQuotes spectrumServiceQuotes,
|
||||
EnergySpectrumStruct sampleStruct, FTPUtils ftpUtil, String logFilePath, String logFileName){
|
||||
this.sampleData = sampleData;
|
||||
this.sampleTempFilePath = sampleTempFilePath;
|
||||
this.spectrumServiceQuotes = spectrumServiceQuotes;
|
||||
|
@ -132,6 +155,9 @@ public class Sample_B_Analysis {
|
|||
this.autoAnalyse();
|
||||
//存储数据
|
||||
this.storageDataToDatabase();
|
||||
//生成报告
|
||||
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
|
||||
report.start();
|
||||
//删除下载的det和gas临时文件
|
||||
this.deleteLocalTemporaryFile();
|
||||
}catch (Exception e){
|
||||
|
@ -187,8 +213,9 @@ public class Sample_B_Analysis {
|
|||
ftpPath.append(StringConstant.SLASH);
|
||||
ftpPath.append(month>=10?month:"0"+month);
|
||||
this.arrFilePath = ftpPath.toString();
|
||||
final String filePath = this.sampleData.getInputFileName().replace(DataType.SAMPLEPHD.getSuffix(), ARR_FILE_SUFFIX);
|
||||
this.arrFileName = filePath.substring(filePath.lastIndexOf(StringConstant.SLASH)+1);
|
||||
String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX;
|
||||
String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1);
|
||||
this.arrFileName = sourceFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,9 +228,8 @@ public class Sample_B_Analysis {
|
|||
System.out.println("det:"+this.detTempFilePath);
|
||||
|
||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
||||
System.out.println(analyseResult);
|
||||
this.endAnalysisTime = new Date();
|
||||
if(Objects.isNull(analyseResult)){
|
||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
|
||||
}
|
||||
this.analyseResult = analyseResult;
|
||||
|
@ -252,16 +278,16 @@ public class Sample_B_Analysis {
|
|||
this.gasSampleData,this.startAnalysisTime,this.endAnalysisTime,logFileRelativePath,arrFileRelativePath);
|
||||
//调用原始数据dll获取gas、det谱数据入库,sample已有数据直接入库
|
||||
//存储sample谱B_Energy和G_Energy块数据
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),sampleStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),sampleStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),this.sampleStruct);
|
||||
//存储det谱B_Energy和G_Energy块数据
|
||||
final EnergySpectrumStruct detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),detStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),detStruct);
|
||||
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),this.detStruct);
|
||||
//存储gas谱B_Energy和G_Energy块数据
|
||||
final EnergySpectrumStruct gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),gasStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),gasStruct);
|
||||
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct);
|
||||
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),this.gasStruct);
|
||||
|
||||
//存储gards_calibration表数据sample、det、gas谱B_Energy和G_Energy块数据
|
||||
spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,gasSampleData.getSampleId(),analyses.getIdAnalysis());
|
||||
|
@ -296,4 +322,526 @@ public class Sample_B_Analysis {
|
|||
gasFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public Sample_B_Analysis.B_AnalysisReport getReport(){
|
||||
|
||||
return new Sample_B_Analysis.B_AnalysisReport();
|
||||
}
|
||||
|
||||
/**
|
||||
* B谱分析报告
|
||||
*/
|
||||
private class B_AnalysisReport{
|
||||
/**
|
||||
* 模版内容
|
||||
*/
|
||||
private String templateContent;
|
||||
/**
|
||||
* 报告临时文件
|
||||
*/
|
||||
private File reportTmpFile;
|
||||
|
||||
/**
|
||||
* 开始处理报告内容
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
//获取报告内容
|
||||
this.getTemplateContent();
|
||||
//创建报告临时文件
|
||||
this.createTmpReportFile();
|
||||
//处理报告时间
|
||||
this.handleReportCreateDate();
|
||||
//处理#FILE INFORMATION 模块
|
||||
this.handleFileInfoMation();
|
||||
//处理#COLLECTION INFORMATION 模块
|
||||
this.handleCollectionInfoMation();
|
||||
//处理#ACQUISITION INFORMATION 模块
|
||||
this.handleAcquistionInfoMation();
|
||||
//处理#SOFTWARE 模块
|
||||
this.handleSoftware();
|
||||
//处理Sample谱、Gas谱、Det谱sampleId
|
||||
this.handleSampleId();
|
||||
//把已经替换好的字符写入文件
|
||||
this.reportTmpFile = FileUtil.writeString(this.templateContent,this.reportTmpFile,"utf-8");
|
||||
//处理#SAMPLE CALIBRATION 模块
|
||||
this.handleSampleCalibration();
|
||||
//处理#SAMPLE LIMITS PER ROI 模块
|
||||
this.handleSampleLimits();
|
||||
//处理#DET CALIBRATION 模块
|
||||
this.handleDetCalibration();
|
||||
//处理#DET LIMITS PER ROI 模块
|
||||
this.handleDetLimits();
|
||||
//处理#GAS CALIBRATION 模块
|
||||
this.handleGasCalibration();
|
||||
//处理#GAS LIMITS PER ROI 模块
|
||||
this.handleGasLimits();
|
||||
//处理 #GROSS COUNTS PER ROI 模块
|
||||
this.handleGrossCounts();
|
||||
//处理#NET COUNTS AND LC PER ROI模块
|
||||
this.handleNetCountsAndLC();
|
||||
//处理#CONCENTRATION AND LC PER ROI 模块
|
||||
this.handleConcentrationAndLC();
|
||||
//处理#RESULT SUMMARY 模块
|
||||
this.handleResultSummary();
|
||||
//把报告存储到ftp
|
||||
this.saveReportToFtp();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告内容
|
||||
* @throws IOException
|
||||
*/
|
||||
private void getTemplateContent() throws IOException {
|
||||
Resource resource = new ClassPathResource("template/b_report_template.txt");
|
||||
this.templateContent = FileUtil.readUtf8String(resource.getFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建报告临时文件
|
||||
* @throws IOException
|
||||
*/
|
||||
private void createTmpReportFile() throws IOException {
|
||||
String reportTmpFilePath = spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+arrFileName;
|
||||
this.reportTmpFile = new File(reportTmpFilePath);
|
||||
if(!this.reportTmpFile.exists()){
|
||||
this.reportTmpFile.createNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理报告时间
|
||||
*/
|
||||
private void handleReportCreateDate(){
|
||||
final String createDate = DateUtils.formatDate(new Date(), "yyyy/MM/dd-HH:mm:ss");
|
||||
this.templateContent = this.templateContent.replace("${create_date}",createDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#FILE INFORMATION 模块
|
||||
*/
|
||||
private void handleFileInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${SampleMeasID}",sampleStruct.measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${GASBKMeasID}",sampleStruct.gas_bk_measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${DETBKMeasID}",sampleStruct.detector_bk_measurement_id);
|
||||
this.templateContent = this.templateContent.replace("${SRID}",sampleStruct.sample_ref_id);
|
||||
this.templateContent = this.templateContent.replace("${DetectorType}","3D b-g");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#COLLECTION INFORMATION 模块
|
||||
*/
|
||||
private void handleCollectionInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${StationID}",sampleStruct.site_code);
|
||||
this.templateContent = this.templateContent.replace("${DetectorID}",sampleStruct.detector_code);
|
||||
this.templateContent = this.templateContent.replace("${CollectionStart}",sampleStruct.collection_start_date+StringConstant.SPACE+sampleStruct.collection_start_time);
|
||||
this.templateContent = this.templateContent.replace("${CollectionStop}",sampleStruct.collection_stop_date+StringConstant.SPACE+sampleStruct.collection_stop_time);
|
||||
this.templateContent = this.templateContent.replace("${CollectionTIME}",String.valueOf((sampleData.getCollectStart().getTime()-sampleData.getCollectStop().getTime())/1000));
|
||||
this.templateContent = this.templateContent.replace("${AirVolume}",String.valueOf(sampleStruct.air_volume));
|
||||
this.templateContent = this.templateContent.replace("${XeVolume}",String.valueOf(sampleStruct.sample_volume_of_Xe));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#ACQUISITION INFORMATION 模块
|
||||
*/
|
||||
private void handleAcquistionInfoMation(){
|
||||
this.templateContent = this.templateContent.replace("${AcquisitionStart}",sampleStruct.acquisition_start_date+StringConstant.SPACE+sampleStruct.acquisition_start_time);
|
||||
this.templateContent = this.templateContent.replace("${AcqRealTime}",String.valueOf(sampleStruct.acquisition_real_time));
|
||||
this.templateContent = this.templateContent.replace("${AcqLiveTime}",String.valueOf(sampleStruct.acquisition_live_time));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SOFTWARE 模块
|
||||
*/
|
||||
private void handleSoftware(){
|
||||
this.templateContent = this.templateContent.replace("${version}",spectrumServiceQuotes.getSoftwareProperties().getSwVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理Sample谱、Gas谱、Det谱sampleId
|
||||
*/
|
||||
private void handleSampleId(){
|
||||
this.templateContent = this.templateContent.replace("${SampleID}",sampleData.getSampleId().toString());
|
||||
this.templateContent = this.templateContent.replace("${DET_SampleID}",detSampleData.getSampleId().toString());
|
||||
this.templateContent = this.templateContent.replace("${GAS_SampleID}",gasSampleData.getSampleId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SAMPLE CALIBRATION 模块
|
||||
* 还需和周雨涵确认s_b_fitting_c_e、s_g_fitting_c_e
|
||||
*/
|
||||
private void handleSampleCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_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_e_c)};
|
||||
|
||||
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#SAMPLE LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleSampleLimits() throws IOException {
|
||||
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<String> roi = analyseResult.S_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
}
|
||||
handleThreeParamFormat("#SAMPLE LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#DET CALIBRATION 模块
|
||||
*/
|
||||
private void handleDetCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.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_e_c)};
|
||||
|
||||
String[] gammaArr = {CH_Contant+this.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_e_c)};
|
||||
|
||||
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#DET LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleDetLimits() throws IOException {
|
||||
List<Integer> b_chan_start = analyseResult.D_ROI_B_Boundary_start;
|
||||
List<Integer> b_chan_stop = analyseResult.D_ROI_B_Boundary_stop;
|
||||
List<Integer> g_chan_start = analyseResult.D_ROI_G_Boundary_start;
|
||||
List<Integer> g_chan_stop = analyseResult.D_ROI_G_Boundary_stop;
|
||||
|
||||
List<String> roi = analyseResult.D_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
}
|
||||
handleThreeParamFormat("#DET LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GAS CALIBRATION 模块
|
||||
*/
|
||||
private void handleGasCalibration() throws IOException {
|
||||
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
|
||||
E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_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_e_c)};
|
||||
|
||||
this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GAS LIMITS PER ROI 模块
|
||||
*/
|
||||
private void handleGasLimits() throws IOException {
|
||||
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<String> roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> beta = Lists.newArrayList();
|
||||
List<String> gamma = Lists.newArrayList();
|
||||
String flag = " to ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
|
||||
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
|
||||
}
|
||||
handleThreeParamFormat("#GAS LIMITS PER ROI",roi,beta,gamma);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#GROSS COUNTS PER ROI模块
|
||||
*/
|
||||
private void handleGrossCounts() throws IOException {
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
|
||||
this.handleFourParamFormat("#GROSS COUNTS PER ROI",roi,s_roi_cts,g_roi_cts,d_roi_cts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#NET COUNTS AND LC PER ROI模块
|
||||
*/
|
||||
private void handleNetCountsAndLC() throws IOException {
|
||||
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(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> netCount = Lists.newArrayList();
|
||||
String flag = " +/- ";
|
||||
for(int i=0;i<roi.size();i++){
|
||||
netCount.add(formatToStr5(roi_net_count.get(i))+flag+formatToStr5(roi_net_count_err.get(i)));
|
||||
}
|
||||
this.handleThreeParamFormat("#NET COUNTS AND LC PER ROI",roi,netCount,lc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理#CONCENTRATION AND LC PER ROI模块
|
||||
*/
|
||||
private void handleConcentrationAndLC() throws IOException {
|
||||
List<Double> con = analyseResult.ROI_con_uncer;
|
||||
List<Double> conErr = analyseResult.ROI_con_uncer_err;
|
||||
analyseResult.LC.add(0,0.0D);
|
||||
String flag = " +/- ";
|
||||
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
|
||||
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
|
||||
List<String> mdc = Lists.newArrayList();//analyseResult.MDC.stream().map(Object::toString).collect(Collectors.toList());
|
||||
for(int i=0;i<10;i++){
|
||||
mdc.add("0.0");
|
||||
}
|
||||
List<String> conc = Lists.newArrayList();
|
||||
for(int i=0;i<roi.size();i++){
|
||||
conc.add(formatToStr5(con.get(i))+flag+formatToStr5(conErr.get(i)));
|
||||
}
|
||||
this.handleFourParamFormat("#CONCENTRATION AND LC PER ROI",roi,conc,lc,mdc);
|
||||
}
|
||||
|
||||
/**
|
||||
* #RESULT SUMMARY
|
||||
*/
|
||||
private void handleResultSummary() throws IOException {
|
||||
String flag = " +/- ";
|
||||
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
|
||||
|
||||
String[] conc = {formatToStr5(analyseResult.Xe135_con)+flag+formatToStr5(analyseResult.Xe135_uncer),
|
||||
formatToStr5(analyseResult.Xe131m_con)+flag+formatToStr5(analyseResult.Xe131m_uncer),
|
||||
formatToStr5(analyseResult.Xe133m_con)+flag+formatToStr5(analyseResult.Xe133m_uncer),
|
||||
formatToStr5(analyseResult.Xe133_con)+flag+formatToStr5(analyseResult.Xe133_uncer)};
|
||||
|
||||
String[] uncertainty = {formatToStr5(analyseResult.LC_Xe135),formatToStr5(analyseResult.LC_Xe131m),
|
||||
formatToStr5(analyseResult.LC_Xe133m),formatToStr5(analyseResult.LC_Xe133)};
|
||||
|
||||
String[] mdc = {formatToStr5(analyseResult.MDC_Xe135),formatToStr5(analyseResult.MDC_Xe131m),
|
||||
formatToStr5(analyseResult.MDC_Xe133m),formatToStr5(analyseResult.MDC_Xe133)};
|
||||
|
||||
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
|
||||
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
|
||||
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};
|
||||
|
||||
this.handleFiveParamFormat("#RESULT SUMMARY",nuclideName,conc,uncertainty,mdc,nid_flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存报告到ftp
|
||||
*/
|
||||
private void saveReportToFtp() throws FileNotFoundException {
|
||||
ftpUtil.saveFile(arrFilePath,arrFileName,new FileInputStream(this.reportTmpFile));
|
||||
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 模块
|
||||
* 2.#DET CALIBRATION 模块
|
||||
* 3.#GAS CALIBRATION 模块
|
||||
*/
|
||||
private void handleTwoParamFormat(String key,String[] param,String[] param1) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.length;j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param[j],param1[j]));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理三个参数的占位符格式化
|
||||
* 1.#SAMPLE、DET、GAS LIMITS PER ROI 模块
|
||||
* 2.#NET COUNTS AND LC PER ROI 模块
|
||||
*/
|
||||
private void handleThreeParamFormat(String key,List<String> param,List<String> param1,List<String> param2) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.size();j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param.get(j),param1.get(j),param2.get(j)));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理四个参数的占位符格式化
|
||||
* 1.#GROSS COUNTS PER ROI 模块
|
||||
* 2.#CONCENTRATION AND LC PER ROI 模块
|
||||
*/
|
||||
private void handleFourParamFormat(String key,List<String> param,List<String> param1,List<String> param2,List<String> param3) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.size();j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param.get(j),param1.get(j),param2.get(j),param3.get(j)));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理五个参数的占位符格式化
|
||||
* 1.#RESULT SUMMARY 模块
|
||||
* @param key
|
||||
* @param param
|
||||
* @param param1
|
||||
* @param param2
|
||||
* @param param3
|
||||
* @param param4
|
||||
* @throws IOException
|
||||
*/
|
||||
private void handleFiveParamFormat(String key,String[] param,String[] param1,String[] param2,String[] param3,String[] param4) throws IOException {
|
||||
final List<String> lines = FileUtils.readLines(this.reportTmpFile, "utf-8");
|
||||
for(int i=0;i<lines.size();i++){
|
||||
if(lines.get(i).startsWith(key)){
|
||||
//i+1行是行头
|
||||
//i+2行是占位符,所以要删除i+2行返回行格式
|
||||
final String format = lines.remove(i+2);
|
||||
for(int j=0;j<param.length;j++){
|
||||
String copyFormat = new String(format);
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(String.format(copyFormat,param[j],param1[j],param2[j],param3[j],param4[j]));
|
||||
//i+2行是占位符,已经删除,此时添加数据应从i+1行开始
|
||||
lines.add((i+1+j+1),line.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
mailContent = new StringBuilder();
|
||||
emailServiceManager.getMailContent(message,mailContent);
|
||||
//所有邮件都需以.eml格式存储到ftp eml文件夹中
|
||||
// downloadEmailToFtp();
|
||||
downloadEmailToFtp();
|
||||
//判断是否是IMS2.0协议文件
|
||||
if(checkMailContent(mailContent,subject)){
|
||||
SpectrumHandler spectrumHandler = new SamplephdSpectrum();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum;
|
|||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.common.properties.SoftwareProperties;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.datasource.OraDataSourceProperties;
|
||||
|
@ -66,4 +67,6 @@ public class SpectrumServiceQuotes {
|
|||
|
||||
private final GardsRoiChannelsService roiChannelsService;
|
||||
|
||||
private final SoftwareProperties softwareProperties;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
CNL06 GENERATED REPORT
|
||||
AUTO RADIONUCLIDE REPORT
|
||||
(Noble Gas Version)
|
||||
Creation Date ${create_date}
|
||||
|
||||
#FILE INFORMATION
|
||||
SampleMeasID: ${SampleMeasID}
|
||||
GASBKMeasID: ${GASBKMeasID}
|
||||
DETBKMeasID: ${DETBKMeasID}
|
||||
SRID: ${SRID}
|
||||
Detector Type: ${DetectorType}
|
||||
|
||||
#COLLECTION INFORMATION
|
||||
Station ID: ${StationID}
|
||||
Detector ID: ${DetectorID}
|
||||
Sample ID: ${SampleID}
|
||||
Collection Start: ${CollectionStart}
|
||||
Collection Stop: ${CollectionStop}
|
||||
Collection TIME(h): ${CollectionTIME}
|
||||
Air Volume[cm3]: ${AirVolume}
|
||||
Xe Volume[cm3]: ${XeVolume}
|
||||
|
||||
#ACQUISITION INFORMATION
|
||||
Acquisition Start: ${AcquisitionStart}
|
||||
Acq Real Time(s): ${AcqRealTime}
|
||||
Acq Live Time(s): ${AcqLiveTime}
|
||||
|
||||
#SOFTWARE
|
||||
version: ${version}
|
||||
|
||||
#SAMPLE CALIBRATION (SAMPLEID:${SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#SAMPLE LIMITS PER ROI (SAMPLEID:${SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#DET CALIBRATION (SAMPLEID:${DET_SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#DET LIMITS PER ROI (SAMPLEID:${DET_SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#GAS CALIBRATION (SAMPLEID:${GAS_SampleID})
|
||||
Beta Gamma
|
||||
%-49s %-49s
|
||||
|
||||
#GAS LIMITS PER ROI (SAMPLEID:${GAS_SampleID})
|
||||
Roi Beta Gamma
|
||||
%-2s %-11s %-11s
|
||||
|
||||
#GROSS COUNTS PER ROI
|
||||
Roi Sample GasBkgnd DetBkgnd
|
||||
%-2s %-10s %-10s %-10s
|
||||
|
||||
#NET COUNTS AND LC PER ROI
|
||||
Roi Net count LC
|
||||
%-2s %-22s %-7s
|
||||
|
||||
#CONCENTRATION AND LC PER ROI
|
||||
Roi Conc(mBq/m3) LC(mBq/m3) MDC(mBq/m3):
|
||||
%-2s %-22s %-10s %-10s
|
||||
|
||||
#RESULT SUMMARY
|
||||
Nuclide Name Conc(mBq/m3) Uncertainty(mBq/m3) MDC(mBq/m3) NID Flag
|
||||
%-6s %-20s %-7s %-7s %-1s
|
||||
|
Loading…
Reference in New Issue
Block a user