PHD文件gamma有关Collect,Acquisition部分字段缺失问题导致无法计算修改

PHD文件关于Collect,Acquisition日期判断增加
This commit is contained in:
qiaoqinzheng 2023-12-29 13:57:15 +08:00
parent ed00d25f4d
commit 9c01b2664f
5 changed files with 129 additions and 41 deletions

View File

@ -9,7 +9,7 @@ public class QcCheckItem implements Serializable {
private String standard;
private double value;
private Double value;
private boolean bPass;

View File

@ -225,8 +225,12 @@ public class GammaFileUtil extends AbstractLogOrReport {
phd.getSetting().setECutAnalysis_Low(35.0);
phd.getSetting().setBUpdateCal(true);
}
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
if (StringUtils.isNotBlank(phd.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_start_time())) {
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()));
}
if (StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()));
}
SpecSetup usedSetting = new SpecSetup();
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
phd.setUsedSetting(usedSetting);
@ -490,17 +494,32 @@ public class GammaFileUtil extends AbstractLogOrReport {
public void RunQC(PHDFile phd) {
try {
//获取phdFile的 采集开始时间
Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
Date start = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_start_time())) {
start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
}
//获取phdFile的 采集结束时间
Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
Date end = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_stop_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_stop_time())) {
end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
}
//获取phdFile的 分析开始时间
Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
Date acq = null;
if (StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
}
//计算得到采集耗时
double collect_hour = ((end.getTime() - start.getTime())/1000) / 3600.0;
double collect_hour = 0.0;
if (Objects.nonNull(end) && Objects.nonNull(start)) {
collect_hour = ((end.getTime() - start.getTime())/1000) / 3600.0;
}
//获取 实际分析时长
double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0;
//计算得到衰减耗时
double Decay_hour = ((acq.getTime() - end.getTime())/1000) / 3600.0;
double Decay_hour = 0.0;
if (Objects.nonNull(acq) && Objects.nonNull(end)) {
Decay_hour = ((acq.getTime() - end.getTime())/1000) / 3600.0;
}
//声明一个double数据
List<Double> Be7Value = new LinkedList<>();
//声明一个map用于存储计算数据
@ -633,16 +652,32 @@ public class GammaFileUtil extends AbstractLogOrReport {
if(vMdcInfo.size() < 3 || vMdcInfo.get(2) == 0) {
return 0.0;
}
//获取采集开始时间
Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
Date collectStart = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_start_time())) {
collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
}
//获取采样结束时间
Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
Date collectStop = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_stop_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_stop_time())) {
collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
}
//获取能谱获取时间
Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
Date acqStart = null;
if (StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
}
//计算采样时间
double Ts = ((collectStop.getTime() - collectStart.getTime())/1000);
double Ts = 0.0;
if (Objects.nonNull(collectStop) && Objects.nonNull(collectStart)) {
Ts = ((collectStop.getTime() - collectStart.getTime())/1000);
}
//计算衰变时间
double Td = ((acqStart.getTime() - collectStop.getTime())/1000);
double Td = 0.0;
if (Objects.nonNull(acqStart) && Objects.nonNull(collectStop)) {
Td = ((acqStart.getTime() - collectStop.getTime())/1000);
}
//获取能谱获取实时间
double Ta = phd.getAcq().getAcquisition_real_time();
//获取能谱获取活时间
@ -670,7 +705,10 @@ public class GammaFileUtil extends AbstractLogOrReport {
DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta));
}
//计算得到DCF_conc
double DCF_conc = Math.exp(lambda * ((collectStart.getTime() - phd.getUsedSetting().getRefTime_conc().getTime())/1000));
double DCF_conc = Double.POSITIVE_INFINITY;
if (Objects.nonNull(collectStart) && Objects.nonNull(phd.getUsedSetting().getRefTime_conc())) {
DCF_conc = Math.exp(lambda * ((collectStart.getTime() - phd.getUsedSetting().getRefTime_conc().getTime())/1000));
}
//声明一个集合
List<Double> energy = new LinkedList<>();
energy.add(vMdcInfo.get(0));
@ -881,22 +919,41 @@ public class GammaFileUtil extends AbstractLogOrReport {
detailInfo.set(5, phd.getHeader().getSpectrum_quantity()); // Spectral_Qualifier
detailInfo.set(6, phd.getHeader().getSample_ref_id()); // SRID
detailInfo.set(7, phd.getStatus()); // Sample_Status
String collect_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT));
Date collect_stop_dt = DateUtils.parseDate(collect_stop,"yyyy/MM/dd HH:mm:ss");
detailInfo.set(8, phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
Date date = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss");
double timeSpan = (collect_stop_dt.getTime()/1000 - date.getTime()/1000) / 3600.0;
String collect_stop = "";
Date collect_stop_dt = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_stop_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_stop_time())) {
collect_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time();
collect_stop_dt = DateUtils.parseDate(collect_stop,"yyyy/MM/dd HH:mm:ss");
}
String collect_start = "";
Date collect_start_dt = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_start_time())) {
collect_start = phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time();
collect_start_dt = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
}
detailInfo.set(8, collect_start);
double timeSpan = 0.0;
if (Objects.nonNull(collect_start_dt) && Objects.nonNull(collect_stop_dt)) {
timeSpan = (collect_stop_dt.getTime()/1000 - collect_start_dt.getTime()/1000) / 3600.0;
}
detailInfo.set(9, String.format("%.2f", timeSpan));// Sampling_Time
detailInfo.set(10, String.format("%.2f", phd.getCollect().getAir_volume()));
if(timeSpan != 0){
detailInfo.set(11, String.format("%.2f", phd.getCollect().getAir_volume()/timeSpan));
}
detailInfo.set(12, phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
String start_time = phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT));
Date start_date = DateUtils.parseDate(start_time, "yyyy/MM/dd HH:mm:ss");
String acq_start = "";
Date start_date = null;
if (StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
acq_start = phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time();
start_date = DateUtils.parseDate(acq_start);
}
detailInfo.set(12, acq_start);
detailInfo.set(13, String.format("%.2f", phd.getAcq().getAcquisition_real_time()));
detailInfo.set(14, String.format("%.2f", phd.getAcq().getAcquisition_live_time()));
double timespan = (start_date.getTime()/1000 - collect_stop_dt.getTime()/1000);
double timespan = 0.0;
if (Objects.nonNull(start_date) && Objects.nonNull(collect_start_dt)) {
timespan = (start_date.getTime()/1000 - collect_stop_dt.getTime()/1000);
}
detailInfo.set(15, String.format("%.2f", timespan / 3600.0));
detailInfo.set(17, phd.getCategory());
return detailInfo;
@ -1728,11 +1785,26 @@ public class GammaFileUtil extends AbstractLogOrReport {
private boolean CalculateMDCs(PHDFile phd, NuclideActMda nucActMda, int mainPeakIdx, double lambda, double keyLineYield, double CCF) {
// 计算衰变校正因子DCF
try {
Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
double Ts = collectStop.getTime()/1000 - collectStart.getTime()/1000; // 采样时间
double Td = acqStart.getTime()/1000 - collectStop.getTime()/1000; // 衰变时间
Date collectStart = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_start_time())) {
collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
}
Date collectStop = null;
if (StringUtils.isNotBlank(phd.getCollect().getCollection_stop_date()) && StringUtils.isNotBlank(phd.getCollect().getCollection_stop_time())) {
collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
}
Date acqStart = null;
if (StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
}
double Ts = 0.0;
if (Objects.nonNull(collectStop) && Objects.nonNull(collectStart)) {
Ts = collectStop.getTime()/1000 - collectStart.getTime()/1000; // 采样时间
}
double Td = 0.0;
if (Objects.nonNull(acqStart) && Objects.nonNull(collectStop)) {
Td = acqStart.getTime()/1000 - collectStop.getTime()/1000; // 衰变时间
}
double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间
double Tl = phd.getAcq().getAcquisition_live_time(); // 能谱获取活时间
double Svol = phd.getCollect().getAir_volume(); // 样品采样体积
@ -3653,7 +3725,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
for(Map.Entry<String, QcCheckItem> itor_q:fileAnlyse.getQcItems().entrySet()) {
String nuclideName = itor_q.getKey();
qvctQC_NAME.add(nuclideName);
dvctQC_VALUE.add(itor_q.getValue().getValue());
dvctQC_VALUE.add(Double.isFinite(itor_q.getValue().getValue())?itor_q.getValue().getValue():null);
qvctQC_STANDARD.add(itor_q.getValue().getStandard());
dvctQC_RESULT.add(itor_q.getValue().isBPass()?1.0:0.0);
}
@ -3663,8 +3735,14 @@ public class GammaFileUtil extends AbstractLogOrReport {
middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE);
}
//sample info
middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time();
middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time();
middleData.sample_collection_start = "";
if (StringUtils.isNotBlank(fileAnlyse.getCollect().getCollection_start_date()) && StringUtils.isNotBlank(fileAnlyse.getCollect().getCollection_start_time())) {
middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time();
}
middleData.sample_collection_stop = "";
if (StringUtils.isNotBlank(fileAnlyse.getCollect().getCollection_stop_date()) && StringUtils.isNotBlank(fileAnlyse.getCollect().getCollection_stop_time())) {
middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time();
}
if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) {
middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue());
if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) {
@ -3678,10 +3756,14 @@ public class GammaFileUtil extends AbstractLogOrReport {
middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue());
}
middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume());
middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time();
String acquisition_start = middleData.sample_acquisiton_start;
Date dataTime = DateUtils.parseDate(acquisition_start);
middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime() + fileAnlyse.getAcq().getAcquisition_real_time()*1000)), "yyyy/MM/dd HH:mm:ss");
middleData.sample_acquisiton_start = "";
Date dataTime = null;
middleData.sample_acquistion_stop = "";
if (StringUtils.isNotBlank(fileAnlyse.getAcq().getAcquisition_start_date()) && StringUtils.isNotBlank(fileAnlyse.getAcq().getAcquisition_start_time())) {
middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time();
dataTime = DateUtils.parseDate(middleData.sample_acquisiton_start);
middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime() + fileAnlyse.getAcq().getAcquisition_real_time()*1000)), "yyyy/MM/dd HH:mm:ss");
}
middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ;
middleData.sample_stationID = fileAnlyse.getHeader().getSite_code();
middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code();

View File

@ -72,7 +72,7 @@ public class PHDFileUtil extends AbstractLogOrReport {
}
//Acquisition Start
Date AcquisitionStart = null;
if ( StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) ){
if ( StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) ){
AcquisitionStart = DateUtils.parseDate(struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time);
}
//Acq Real Time

View File

@ -805,7 +805,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
for (GardsQcCheckSpectrum qcCheckSpectrum : qcChecks) {
String str_key = qcCheckSpectrum.getQcName();
QcCheckItem qcCheckItem = new QcCheckItem();
qcCheckItem.setValue(qcCheckSpectrum.getQcValue());
qcCheckItem.setValue(qcCheckSpectrum.getQcValue() == null?0.0:qcCheckSpectrum.getQcValue());
qcCheckItem.setBPass(qcCheckSpectrum.getQcResult() == 1);
qcCheckItem.setStandard(qcCheckSpectrum.getQcStandard());
phd.getQcItems().put(str_key, qcCheckItem);
@ -4523,7 +4523,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
item.setName(name);
item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL");
item.setValue(Double.parseDouble(NumberFormatUtil.numberFormat(String.valueOf(iter.getValue().getValue()))));
if (Double.isFinite(iter.getValue().getValue())) {
item.setValue(Double.parseDouble(NumberFormatUtil.numberFormat(String.valueOf(iter.getValue().getValue()))));
} else if (Double.isInfinite(iter.getValue().getValue())) {
item.setValue(iter.getValue().getValue());
} else if (Double.isNaN(iter.getValue().getValue())) {
item.setValue(iter.getValue().getValue());
}
String standard = "";
List<String> strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA));
for (String str : strList) {

View File

@ -1381,14 +1381,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
String sit_det_code = struct.site_code;
String detect_code = struct.detector_code;
String sample_id = Objects.nonNull(sampleId)?sampleId.toString():"";
Date collectStartDate = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time.substring(0, struct.collection_start_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
Date collectStopDate = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time.substring(0, struct.collection_stop_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
Date collectStartDate = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time);
Date collectStopDate = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time);
String collect_start = DateUtils.formatDate(collectStartDate, "yyyy/MM/dd HH:mm:ss");
String collect_stop = DateUtils.formatDate(collectStopDate, "yyyy/MM/dd HH:mm:ss");
String collection_time_value = String.format ("%.2f",Double.valueOf((collectStopDate.getTime() - collectStartDate.getTime())/ 1000));
String s_volume_of_Xe = String.valueOf(struct.air_volume);
String s_xe_stable_volume = String.valueOf(struct.sample_volume_of_Xe);
Date acquisitionStartDate = DateUtils.parseDate(struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time.substring(0, struct.acquisition_start_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
Date acquisitionStartDate = DateUtils.parseDate(struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time);
String acquisition_start = DateUtils.formatDate(acquisitionStartDate, "yyyy/MM/dd HH:mm:ss");
String acquisition_real_sec = String.valueOf(struct.acquisition_real_time);
String acquisition_live_sec = String.valueOf(struct.acquisition_live_time);