Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
qiaoqinzheng 2023-09-26 15:23:53 +08:00
commit ab2506e5c1
7 changed files with 547 additions and 233 deletions

View File

@ -514,7 +514,7 @@ public interface CommonConstant {
/** /**
* 自动处理Gamma报告前缀 * 自动处理Gamma报告前缀
*/ */
String REPORT_PREFIX_AUTO = "RNAUTO_"; String REPORT_PREFIX_AUTO = "RNAUTO";
/** /**
* 自动处理报告后缀 * 自动处理报告后缀

View File

@ -1,20 +1,28 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.entity.vo.BaseControls; import org.jeecg.modules.entity.vo.BaseControls;
import org.jeecgframework.core.util.ApplicationContextUtil;
import java.io.File; import java.io.*;
import java.io.FileNotFoundException; import java.math.BigDecimal;
import java.io.PrintWriter; import java.math.MathContext;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class GammaReportUtil { public class GammaReportUtil {
private static FTPUtil ftpUtil = ApplicationContextUtil.getContext().getBean(FTPUtil.class);
public static void writeFile(BaseControls baseCtrl, String path){ public static void writeFile(BaseControls baseCtrl, String path){
// 获取系统的临时目录
String tempDir = System.getProperty("java.io.tmpdir");
// 创建文件 // 创建文件
File file = new File(path); File file = new File(tempDir += System.currentTimeMillis());
// 创建PrintWriter对象
PrintWriter out = null;
try { try {
// 创建PrintWriter对象 out = new PrintWriter(file);
PrintWriter out = new PrintWriter(file);
out.println("#AnalyseRange"); out.println("#AnalyseRange");
String low = String.valueOf(baseCtrl.getRg_low()); String low = String.valueOf(baseCtrl.getRg_low());
String high = String.valueOf(baseCtrl.getRg_high()); String high = String.valueOf(baseCtrl.getRg_high());
@ -35,22 +43,41 @@ public class GammaReportUtil {
out.println("#StepCounts"); out.println("#StepCounts");
format(baseCtrl.getStepCounts(), out); format(baseCtrl.getStepCounts(), out);
String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH);
String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH);
ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (null != out) {
out.close();
}
} }
} }
public static void writeFile(List<Double> data, String fileType, String path){ public static void writeFile(List<Double> data, String fileType, String path){
// 获取系统的临时目录
String tempDir = System.getProperty("java.io.tmpdir");
// 创建文件 // 创建文件
File file = new File(path); File file = new File(tempDir + System.currentTimeMillis());
// 创建PrintWriter对象
PrintWriter out = null;
try { try {
// 创建PrintWriter对象 out = new PrintWriter(file);
PrintWriter out = new PrintWriter(file);
out.println("#" + fileType); out.println("#" + fileType);
out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n");
format(data, out); format(data, out);
String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH);
String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH);
ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (null != out) {
out.close();
}
} }
} }
@ -69,8 +96,8 @@ public class GammaReportUtil {
for(i = 0; i < nGroupBL; i++) for(i = 0; i < nGroupBL; i++)
{ {
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i)); System.out.print(i+">>>>"+data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", col); out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i)));
if((i+1) % numPerLine == 0) { if((i+1) % numPerLine == 0) {
out.println(""); out.println("");
} }
@ -78,10 +105,20 @@ public class GammaReportUtil {
if(i < n) if(i < n)
{ {
for(; i<n; ++i){ for(; i<n; ++i){
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i)); out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i)));
out.printf("%" + (columnWidths[i] + 15) + "s", col);
} }
} }
out.println(""); out.println("");
} }
private static String getValue(Double val){
BigDecimal divisor = BigDecimal.ONE;
MathContext mc = new MathContext(6);
String col = Objects.isNull(val) ? "nan" : String.valueOf(val);
if (!"nan".equals(col)) {
BigDecimal b = new BigDecimal(col);
col = String.valueOf(b.divide(divisor, mc));
}
return col;
}
} }

View File

@ -1,9 +1,15 @@
package org.jeecg.common; package org.jeecg.common;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPFile;
import org.ejml.simple.SimpleMatrix; import org.ejml.simple.SimpleMatrix;
@ -11,6 +17,7 @@ import org.jeecg.common.api.vo.Result;
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.common.util.FTPUtil; import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.GammaReportUtil;
import org.jeecg.common.util.NameStandUtil; import org.jeecg.common.util.NameStandUtil;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
@ -27,6 +34,8 @@ import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut; import org.jeecg.modules.native_jni.struct.CalValuesOut;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -37,10 +46,13 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
@ -61,7 +73,7 @@ public class GammaFileUtil {
@Autowired @Autowired
private NameStandUtil nameStandUtil; private NameStandUtil nameStandUtil;
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result){ public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
phd.setFilepath(pathName); phd.setFilepath(pathName);
phd.setFilename(fileName); phd.setFilename(fileName);
//连接ftp //连接ftp
@ -70,6 +82,7 @@ public class GammaFileUtil {
result.error500("ftp连接失败"); result.error500("ftp连接失败");
return false; return false;
} }
InputStream inputStream = null;
//加载dll工具库 //加载dll工具库
System.loadLibrary("ReadPHDFile"); System.loadLibrary("ReadPHDFile");
try { try {
@ -80,15 +93,8 @@ public class GammaFileUtil {
ftpClient.setControlEncoding("UTF-8"); ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
ftpClient.changeWorkingDirectory(pathName); ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles()); inputStream = ftpClient.retrieveFileStream(fileName);
ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); if (Objects.nonNull(inputStream)) {
if (ftpFiles.size() == 0) {
result.error500("ftp获取文件数据失败");
return false;
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)) {
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件 //声明一个临时文件
File file = File.createTempFile("tmp", null); File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件 //将ftp文件的输入流复制给临时文件
@ -115,7 +121,7 @@ public class GammaFileUtil {
//Comment //Comment
phd.setOriTotalCmt(struct.comment); phd.setOriTotalCmt(struct.comment);
//Collection //Collection
if (StringUtils.isNotBlank(struct.collection_start_date) || StringUtils.isNotBlank(struct.collection_start_time) || StringUtils.isNotBlank(struct.collection_stop_date) || StringUtils.isNotBlank(struct.collection_stop_time) || Objects.nonNull(struct.air_volume)) { if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) {
phd.getCollect().setCollection_start_date(struct.collection_start_date); phd.getCollect().setCollection_start_date(struct.collection_start_date);
phd.getCollect().setCollection_start_time(struct.collection_start_time); phd.getCollect().setCollection_start_time(struct.collection_start_time);
phd.getCollect().setCollection_stop_date(struct.collection_stop_date); phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
@ -131,7 +137,7 @@ public class GammaFileUtil {
phd.getCollect().setAir_volume(0.0); phd.getCollect().setAir_volume(0.0);
} }
//Acquisition //Acquisition
if (StringUtils.isNotBlank(struct.acquisition_start_date) || StringUtils.isNotBlank(struct.acquisition_start_time) || Objects.nonNull(struct.acquisition_real_time) || Objects.nonNull(struct.acquisition_live_time)) { if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date); phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time); phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time); phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
@ -144,7 +150,7 @@ public class GammaFileUtil {
phd.getAcq().setAcquisition_real_time(0.0); phd.getAcq().setAcquisition_real_time(0.0);
} }
//Processing //Processing
if (Objects.nonNull(struct.sample_volume_of_Xe) || Objects.nonNull(struct.uncertainty_1) || Objects.nonNull(struct.Xe_collection_yield) || Objects.nonNull(struct.uncertainty_2) || StringUtils.isNotBlank(struct.archive_bottle_id)) { if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.archive_bottle_id)) {
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe); phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
phd.getProcess().setUncertainty_1(struct.uncertainty_1); phd.getProcess().setUncertainty_1(struct.uncertainty_1);
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield); phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
@ -157,7 +163,7 @@ public class GammaFileUtil {
phd.getProcess().setUncertainty_2(0.0); phd.getProcess().setUncertainty_2(0.0);
} }
//Sample //Sample
if (Objects.nonNull(struct.dimension_1) || Objects.nonNull(struct.dimension_2)) { if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
phd.getSampleBlock().setDimension_1(struct.dimension_1); phd.getSampleBlock().setDimension_1(struct.dimension_1);
phd.getSampleBlock().setDimension_2(struct.dimension_2); phd.getSampleBlock().setDimension_2(struct.dimension_2);
} else { } else {
@ -165,14 +171,14 @@ public class GammaFileUtil {
phd.getSampleBlock().setDimension_2(0.0); phd.getSampleBlock().setDimension_2(0.0);
} }
//Calibration //Calibration
if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) { if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.date_calibration) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.time_calibration)) {
phd.getCalibration().setDate_calibration(struct.date_calibration); phd.getCalibration().setDate_calibration(struct.date_calibration);
phd.getCalibration().setTime_calibration(struct.time_calibration); phd.getCalibration().setTime_calibration(struct.time_calibration);
} }
//Certificate //Certificate
if (Objects.nonNull(struct.total_source_activity) || StringUtils.isNotBlank(struct.assay_date) || StringUtils.isNotBlank(struct.assay_time) || StringUtils.isNotBlank(struct.units_activity) || CollectionUtils.isNotEmpty(struct.nuclide_name) if (Objects.nonNull(struct.total_source_activity) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name)
|| CollectionUtils.isNotEmpty(struct.half_life_time) || CollectionUtils.isNotEmpty(struct.time_unit) || CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) || CollectionUtils.isNotEmpty(struct.uncertainty) && CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
|| CollectionUtils.isNotEmpty(struct.cer_g_energy) || CollectionUtils.isNotEmpty(struct.g_intensity) || CollectionUtils.isNotEmpty(struct.electron_decay_mode) || CollectionUtils.isNotEmpty(struct.maximum_energy) || CollectionUtils.isNotEmpty(struct.intensity_b_particle) || Objects.nonNull(struct.record_count)) { && CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
phd.getCertificate().setTotal_source_activity(struct.total_source_activity); phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
phd.getCertificate().setAssay_date(struct.assay_date); phd.getCertificate().setAssay_date(struct.assay_date);
phd.getCertificate().setAssay_time(struct.assay_time); phd.getCertificate().setAssay_time(struct.assay_time);
@ -190,7 +196,7 @@ public class GammaFileUtil {
phd.getCertificate().setRecord_count(struct.record_count); phd.getCertificate().setRecord_count(struct.record_count);
} }
//g_Spectrum //g_Spectrum
if (Objects.nonNull(struct.num_g_channel) || Objects.nonNull(struct.g_energy_span) || Objects.nonNull(struct.g_begin_channel) || CollectionUtils.isNotEmpty(struct.g_counts)) { if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
phd.getSpec().setNum_g_channel(struct.num_g_channel); phd.getSpec().setNum_g_channel(struct.num_g_channel);
phd.getSpec().setG_energy_span(struct.g_energy_span); phd.getSpec().setG_energy_span(struct.g_energy_span);
phd.getSpec().setBegin_channel(struct.g_begin_channel); phd.getSpec().setBegin_channel(struct.g_begin_channel);
@ -206,7 +212,7 @@ public class GammaFileUtil {
} }
} }
//g_Energy //g_Energy
if (CollectionUtils.isNotEmpty(struct.g_energy) || CollectionUtils.isNotEmpty(struct.g_centroid_channel) || CollectionUtils.isNotEmpty(struct.g_uncertainty) || Objects.nonNull(struct.g_record_count)) { if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
GEnergyBlock gEnergyBlock = new GEnergyBlock(); GEnergyBlock gEnergyBlock = new GEnergyBlock();
gEnergyBlock.setG_energy(struct.g_energy); gEnergyBlock.setG_energy(struct.g_energy);
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel); gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
@ -215,7 +221,7 @@ public class GammaFileUtil {
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock); phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
} }
//g_Resolution //g_Resolution
if (CollectionUtils.isNotEmpty(struct.g_r_energy) || CollectionUtils.isNotEmpty(struct.g_r_FWHM) || CollectionUtils.isNotEmpty(struct.g_r_uncertainty) || Objects.nonNull(struct.g_r_record_count)) { if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
GResolutionBlock gResolutionBlock = new GResolutionBlock(); GResolutionBlock gResolutionBlock = new GResolutionBlock();
gResolutionBlock.setG_energy(struct.g_r_energy); gResolutionBlock.setG_energy(struct.g_r_energy);
gResolutionBlock.setFWHM(struct.g_r_FWHM); gResolutionBlock.setFWHM(struct.g_r_FWHM);
@ -224,7 +230,7 @@ public class GammaFileUtil {
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock); phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
} }
//g_Efficiency //g_Efficiency
if (CollectionUtils.isNotEmpty(struct.g_e_energy) || CollectionUtils.isNotEmpty(struct.g_e_efficiency) || CollectionUtils.isNotEmpty(struct.g_e_uncertainty) || Objects.nonNull(struct.g_e_record_count)) { if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
gEfficiencyBlock.setG_energy(struct.g_e_energy); gEfficiencyBlock.setG_energy(struct.g_e_energy);
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency); gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
@ -233,7 +239,7 @@ public class GammaFileUtil {
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock); phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
} }
//TotalEff //TotalEff
if (CollectionUtils.isNotEmpty(struct.t_g_energy) || CollectionUtils.isNotEmpty(struct.total_efficiency) || CollectionUtils.isNotEmpty(struct.t_uncertainty) || Objects.nonNull(struct.t_record_count)) { if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
TotaleffBlock totaleffBlock = new TotaleffBlock(); TotaleffBlock totaleffBlock = new TotaleffBlock();
totaleffBlock.setG_energy(struct.t_g_energy); totaleffBlock.setG_energy(struct.t_g_energy);
totaleffBlock.setTotal_efficiency(struct.total_efficiency); totaleffBlock.setTotal_efficiency(struct.total_efficiency);
@ -247,9 +253,11 @@ public class GammaFileUtil {
phd.getSetting().setECutAnalysis_Low(35.0); phd.getSetting().setECutAnalysis_Low(35.0);
phd.getSetting().setBUpdateCal(true); phd.getSetting().setBUpdateCal(true);
} }
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); 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() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_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"));
phd.setUsedSetting(phd.getSetting()); SpecSetup usedSetting = new SpecSetup();
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
phd.setUsedSetting(usedSetting);
phd.setBAnalyed(false); phd.setBAnalyed(false);
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss")); phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
@ -264,6 +272,9 @@ public class GammaFileUtil {
if (Objects.nonNull(ftpClient)){ if (Objects.nonNull(ftpClient)){
ftpClient.disconnect(); ftpClient.disconnect();
} }
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -1517,8 +1528,194 @@ public class GammaFileUtil {
return true; return true;
} }
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> map){ public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
return false; System.loadLibrary("GammaAnaly");
//解析获取临时文件信息
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String nuclideLinesMap = mapper.writeValueAsString(mapLines);
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath());
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class);
phd.setBAnalyed(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapTotEPara(value);
}
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_stepRatio(value);
}
if (entry.getKey().equalsIgnoreCase("para_tail")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tail(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRight")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRight(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRightAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("newEner")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setNewEner(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GEnergyBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class);
value.put(key, entryValue);
}
phd.setMapEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GResolutionBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class);
value.put(key, entryValue);
}
phd.setMapResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVEnergy(value);
}
if (entry.getKey().equalsIgnoreCase("vBase")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVBase(value);
}
if (entry.getKey().equalsIgnoreCase("vLc")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVLc(value);
}
if (entry.getKey().equalsIgnoreCase("vScac")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVScac(value);
}
if (entry.getKey().equalsIgnoreCase("vPeak")) {
List<PeakInfo> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class);
phd.setVPeak(value);
}
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class);
phd.setBaseCtrls(value);
}
if (entry.getKey().equalsIgnoreCase("usedEner")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEner(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class);
phd.setUsedEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedReso")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedReso(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class);
phd.setUsedResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEffi(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class);
phd.setUsedEffiKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedTotE(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class);
phd.setUsedTotEKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedTotEPara(value);
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
for (PeakInfo peak:phd.getVPeak()) {
if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilBetaChan)) {
peak.recoilBetaChan = "1";
}
if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilDeltaChan)) {
peak.recoilDeltaChan = "1";
}
}
//重新分析各峰值对应的核素信息
NuclidesIdent(phd, mapLines);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return true;
} }
public int SettingChanged(PHDFile phd) { public int SettingChanged(PHDFile phd) {
@ -1705,7 +1902,7 @@ public class GammaFileUtil {
private void ReadSpecialNuclides(Map<String, Double> mapHalflife, List<String> vNuclides) { private void ReadSpecialNuclides(Map<String, Double> mapHalflife, List<String> vNuclides) {
try { try {
String fileName = parameterFilePath+"/setup/nuclide_ActMdc.txt"; String fileName = parameterFilePath+"/nuclide_ActMdc.txt";
File t_file = new File(fileName); File t_file = new File(fileName);
List<String> readLines = FileUtils.readLines(t_file, "UTF-8"); List<String> readLines = FileUtils.readLines(t_file, "UTF-8");
for (int i=0;i< readLines.size();i++){ for (int i=0;i< readLines.size();i++){
@ -2783,7 +2980,6 @@ public class GammaFileUtil {
public boolean GetMiddleData(PHDFile fileAnlyse, String userName,Map<String, NuclideLines> nucline,GStoreMiddleProcessData middleData, String type) throws ParseException { public boolean GetMiddleData(PHDFile fileAnlyse, String userName,Map<String, NuclideLines> nucline,GStoreMiddleProcessData middleData, String type) throws ParseException {
boolean bRet=true; boolean bRet=true;
//标准名称规范化 //标准名称规范化
String dataType = fileAnlyse.getMsgInfo().getData_type(); String dataType = fileAnlyse.getMsgInfo().getData_type();
String subDirSavePath = ""; String subDirSavePath = "";
@ -2834,9 +3030,11 @@ public class GammaFileUtil {
String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath; String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath;
String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath; String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath;
String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath; String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath;
middleData.analyses_baseline_filePath = qsSaveBaseLine;
middleData.analyses_lc_filePath = qsSaveLc; GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), qsSaveBaseLine);
middleData.analyses_scac_filePath = qsSaveScac; GammaReportUtil.writeFile(fileAnlyse.getVLc(), "LC", qsSaveLc);
GammaReportUtil.writeFile(fileAnlyse.getVScac(), "SCSC", qsSaveScac);
// ftpUtil.saveFile(org.apache.commons.lang3.StringUtils.substringBeforeLast(qsSaveBaseLine, StringPool.SLASH), baselineName, new FileInputStream(fileAnlyse.getBaseCtrls()));
// WriteBaseInfo(fileAnlyse.getBaseCtrls(),qsSaveBaseLine); // WriteBaseInfo(fileAnlyse.getBaseCtrls(),qsSaveBaseLine);
// WriteLcScac(fileAnlyse.getVLc(),"Lc",qsSaveLc); // WriteLcScac(fileAnlyse.getVLc(),"Lc",qsSaveLc);
// WriteLcScac(fileAnlyse.getVScac(),"Scac",qsSaveScac); // WriteLcScac(fileAnlyse.getVScac(),"Scac",qsSaveScac);
@ -2855,6 +3053,16 @@ public class GammaFileUtil {
middleData.analyses_searchThreshold = fileAnlyse.getUsedSetting().getEnergyTolerance(); middleData.analyses_searchThreshold = fileAnlyse.getUsedSetting().getEnergyTolerance();
middleData.analyses_numberOfPeaks = fileAnlyse.getVPeak().size(); middleData.analyses_numberOfPeaks = fileAnlyse.getVPeak().size();
middleData.analyses_totalCounts = totalNumber; middleData.analyses_totalCounts = totalNumber;
middleData.analyses_baseline_filePath = qsBaseLinePath;
middleData.analyses_lc_filePath = qsLcPath;
middleData.analyses_scac_filePath = qsScacPath;
middleData.analyses_baseline_absolute_filePath =qsSaveLc;
middleData.analyses_lc_absolute_filePath=qsSaveLc;
middleData.analyses_scac_absolute_filePath=qsSaveScac;
middleData.analyses_save_absolute_filePath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsSaveFile;
middleData.analyses_absolute_LogPath=spectrumPathProperties.getLogPath()+StringPool.SLASH+qsLogPath;
middleData.analyses_absolute_ReportPath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsReportPath;
if(fileAnlyse.getUsedEnerKD() != null && fileAnlyse.getUsedEnerKD().getG_energy().size() != 0) { if(fileAnlyse.getUsedEnerKD() != null && fileAnlyse.getUsedEnerKD().getG_energy().size() != 0) {
middleData.calibration_pairs_E_Caltype = CalType.ENERGY_CAL.getType(); middleData.calibration_pairs_E_Caltype = CalType.ENERGY_CAL.getType();
@ -2865,13 +3073,13 @@ public class GammaFileUtil {
for(int pos=0;pos<fileAnlyse.getUsedEnerKD().getG_energy().size();pos++) { for(int pos=0;pos<fileAnlyse.getUsedEnerKD().getG_energy().size();pos++) {
temp.add(String.valueOf(pos)); temp.add(String.valueOf(pos));
} }
middleData.calibration_pairs_E_idCalPoint = DoubleLimit(temp); middleData.calibration_pairs_E_idCalPoint = temp;
middleData.calibration_pairs_E_xValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getCentroid_channel()); middleData.calibration_pairs_E_xValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getCentroid_channel());
middleData.calibration_pairs_E_yValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getG_energy()); middleData.calibration_pairs_E_yValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getG_energy());
middleData.calibration_pairs_E_uncYValue =DoubleLimit(fileAnlyse.getUsedEnerKD().getUncertainty()); middleData.calibration_pairs_E_uncYValue =DoubleLimit(fileAnlyse.getUsedEnerKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()))) { if(Objects.nonNull(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_E_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_S_E_idCalPoint =temp;
middleData.calibration_pairs_S_E_xValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getCentroid_channel()); middleData.calibration_pairs_S_E_xValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getCentroid_channel());
middleData.calibration_pairs_S_E_yValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy()); middleData.calibration_pairs_S_E_yValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_E_uncYValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getUncertainty()); middleData.calibration_pairs_S_E_uncYValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2890,13 +3098,13 @@ public class GammaFileUtil {
{ {
temp.add(String.valueOf(pos)); temp.add(String.valueOf(pos));
} }
middleData.calibration_pairs_EF_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_EF_idCalPoint =temp;
middleData.calibration_pairs_EF_xValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getG_energy()); middleData.calibration_pairs_EF_xValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getG_energy());
middleData.calibration_pairs_EF_yValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getEfficiency()); middleData.calibration_pairs_EF_yValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getEfficiency());
middleData.calibration_pairs_EF_uncYValue=DoubleLimit(fileAnlyse.getUsedEffiKD().getUncertainty()); middleData.calibration_pairs_EF_uncYValue=DoubleLimit(fileAnlyse.getUsedEffiKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()))) { if(Objects.nonNull(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_EF_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_S_EF_idCalPoint =temp;
middleData.calibration_pairs_S_EF_xValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy()); middleData.calibration_pairs_S_EF_xValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_EF_yValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getEfficiency()); middleData.calibration_pairs_S_EF_yValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getEfficiency());
middleData.calibration_pairs_S_EF_uncYValue=DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getUncertainty()); middleData.calibration_pairs_S_EF_uncYValue=DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2914,13 +3122,13 @@ public class GammaFileUtil {
for(int pos=0;pos<fileAnlyse.getUsedResoKD().getFWHM().size();pos++) { for(int pos=0;pos<fileAnlyse.getUsedResoKD().getFWHM().size();pos++) {
temp.add(String.valueOf(pos)); temp.add(String.valueOf(pos));
} }
middleData.calibration_pairs_R_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_R_idCalPoint =temp;
middleData.calibration_pairs_R_xValue =DoubleLimit(fileAnlyse.getUsedResoKD().getG_energy()); middleData.calibration_pairs_R_xValue =DoubleLimit(fileAnlyse.getUsedResoKD().getG_energy());
middleData.calibration_pairs_R_yValue =DoubleLimit(fileAnlyse.getUsedResoKD().getFWHM()); middleData.calibration_pairs_R_yValue =DoubleLimit(fileAnlyse.getUsedResoKD().getFWHM());
middleData.calibration_pairs_R_uncYValue =DoubleLimit(fileAnlyse.getUsedResoKD().getUncertainty()); middleData.calibration_pairs_R_uncYValue =DoubleLimit(fileAnlyse.getUsedResoKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()))) { if(Objects.nonNull(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_R_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_S_R_idCalPoint =temp;
middleData.calibration_pairs_S_R_xValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy()); middleData.calibration_pairs_S_R_xValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_R_yValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getFWHM()); middleData.calibration_pairs_S_R_yValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getFWHM());
middleData.calibration_pairs_S_R_uncYValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getUncertainty()); middleData.calibration_pairs_S_R_uncYValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2938,12 +3146,12 @@ public class GammaFileUtil {
temp.add(String.valueOf(pos)); temp.add(String.valueOf(pos));
} }
middleData.calibration_pairs_T_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_T_idCalPoint =temp;
middleData.calibration_pairs_T_xValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getG_energy()); middleData.calibration_pairs_T_xValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getG_energy());
middleData.calibration_pairs_T_yValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getTotal_efficiency()); middleData.calibration_pairs_T_yValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getTotal_efficiency());
middleData.calibration_pairs_T_uncYValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getUncertainty()); middleData.calibration_pairs_T_uncYValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()))) { if(Objects.nonNull(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_T_idCalPoint =DoubleLimit(temp); middleData.calibration_pairs_S_T_idCalPoint =temp;
middleData.calibration_pairs_S_T_xValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy()); middleData.calibration_pairs_S_T_xValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_T_yValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getTotal_efficiency()); middleData.calibration_pairs_S_T_yValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getTotal_efficiency());
middleData.calibration_pairs_S_T_uncYValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getUncertainty()); middleData.calibration_pairs_S_T_uncYValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2954,7 +3162,6 @@ public class GammaFileUtil {
//拼写刻度字符串 //拼写刻度字符串
//获取刻度描述字符串 //获取刻度描述字符串
middleData.calibration_sample_type = fileAnlyse.getHeader().getSystem_type(); middleData.calibration_sample_type = fileAnlyse.getHeader().getSystem_type();
NumberFormat numberFormat = new DecimalFormat("0.######E0");
String coeffEnergy = ""; String coeffEnergy = "";
String uncerEnergy = ""; String uncerEnergy = "";
String funcDefEnergy = ""; String funcDefEnergy = "";
@ -2967,18 +3174,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedEnerPara().getP().get(0).intValue(); funcType = fileAnlyse.getUsedEnerPara().getP().get(0).intValue();
} }
for(int m=1;m<coeffNumber-1;m++) { for(int m=1;m<coeffNumber-1;m++) {
coeffEnergy += numberFormat.format(fileAnlyse.getUsedEnerPara().getP().get(m))+','; coeffEnergy += String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(m))+ ",";
} }
if(coeffNumber>0) { if(coeffNumber>0) {
coeffEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1)); coeffEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1));
} }
uncerNumber = fileAnlyse.getUsedEnerPara().getPerr().size(); uncerNumber = fileAnlyse.getUsedEnerPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) { for(int m=0;m<uncerNumber-1;m++) {
uncerEnergy += numberFormat.format(fileAnlyse.getUsedEnerPara().getPerr().get(m))+','; uncerEnergy += String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(m))+ ",";
} }
if(uncerNumber>0) { if(uncerNumber>0) {
uncerEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1)); uncerEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1));
} }
funcDefEnergy = EquationDescription(funcType); funcDefEnergy = EquationDescription(funcType);
funcTypeDefEnergy = EquationName(funcType); funcTypeDefEnergy = EquationName(funcType);
@ -3000,18 +3207,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue(); funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue();
} }
for(int m=1;m<coeffNumber-1;m++) { for(int m=1;m<coeffNumber-1;m++) {
coeffEffi += numberFormat.format(fileAnlyse.getUsedEffiPara().getP().get(m))+','; coeffEffi += String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(m))+ ",";
} }
if(coeffNumber>0) { if(coeffNumber>0) {
coeffEffi+=numberFormat.format(fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1)); coeffEffi+=String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1));
} }
uncerNumber = fileAnlyse.getUsedEffiPara().getPerr().size(); uncerNumber = fileAnlyse.getUsedEffiPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) { for(int m=0;m<uncerNumber-1;m++) {
uncerEffi += numberFormat.format(fileAnlyse.getUsedEffiPara().getPerr().get(m))+','; uncerEffi += String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(m))+ ",";
} }
if(uncerNumber>0) { if(uncerNumber>0) {
uncerEffi+= numberFormat.format(fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1)); uncerEffi+= String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1));
} }
funcDefEffi = EquationDescription(funcType); funcDefEffi = EquationDescription(funcType);
funcTypeDefEffi = EquationName(funcType); funcTypeDefEffi = EquationName(funcType);
@ -3032,18 +3239,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue(); funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue();
} }
for(int m=1;m<coeffNumber-1;m++) { for(int m=1;m<coeffNumber-1;m++) {
coeffReso += numberFormat.format(fileAnlyse.getUsedResoPara().getP().get(m))+','; coeffReso += String.format("%e", fileAnlyse.getUsedResoPara().getP().get(m))+ ",";
} }
if(coeffNumber>0) { if(coeffNumber>0) {
coeffReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1)); coeffReso+= String.format("%e", fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1));
} }
uncerNumber = fileAnlyse.getUsedResoPara().getPerr().size(); uncerNumber = fileAnlyse.getUsedResoPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) { for(int m=0;m<uncerNumber-1;m++) {
uncerReso += numberFormat.format(fileAnlyse.getUsedResoPara().getPerr().get(m))+','; uncerReso += String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(m))+ ",";
} }
if(uncerNumber>0) { if(uncerNumber>0) {
uncerReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1)); uncerReso+= String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1));
} }
funcDefReso = EquationDescription(funcType); funcDefReso = EquationDescription(funcType);
funcTypeDefReso = EquationName(funcType); funcTypeDefReso = EquationName(funcType);
@ -3064,18 +3271,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue(); funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue();
} }
for(int m=1;m<coeffNumber-1;m++) { for(int m=1;m<coeffNumber-1;m++) {
coeffTotE += numberFormat.format(fileAnlyse.getUsedTotEPara().getP().get(m))+','; coeffTotE += String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(m))+ ",";
} }
if(coeffNumber>0) { if(coeffNumber>0) {
coeffTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1)); coeffTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1));
} }
uncerNumber = fileAnlyse.getUsedTotEPara().getPerr().size(); uncerNumber = fileAnlyse.getUsedTotEPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) { for(int m=0;m<uncerNumber-1;m++) {
uncerTotE += numberFormat.format(fileAnlyse.getUsedTotEPara().getPerr().get(m))+','; uncerTotE += String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(m))+ ",";
} }
if(uncerNumber>0) { if(uncerNumber>0) {
uncerTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1)); uncerTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1));
} }
funcDefTotE = EquationDescription(funcType); funcDefTotE = EquationDescription(funcType);
funcTypeDefTotE = EquationName(funcType); funcTypeDefTotE = EquationName(funcType);
@ -3090,7 +3297,7 @@ public class GammaFileUtil {
//gards_ peaks数据表 //gards_ peaks数据表
if(fileAnlyse.getVPeak().size() != 0) { if(fileAnlyse.getVPeak().size() != 0) {
List<Double> dvctIDPEAK = new LinkedList<>(); List<String> dvctIDPEAK = new LinkedList<>();
List<Double> dvctCENTROIDCHANNEL = new LinkedList<>(); List<Double> dvctCENTROIDCHANNEL = new LinkedList<>();
List<Double> dvctUNCCENTROIDCHANNEL = new LinkedList<>(); List<Double> dvctUNCCENTROIDCHANNEL = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>(); List<Double> dvctENERGY = new LinkedList<>();
@ -3122,8 +3329,8 @@ public class GammaFileUtil {
List<Double> dvctLD = new LinkedList<>(); List<Double> dvctLD = new LinkedList<>();
List<String> dvctNuclide_name = new LinkedList<>(); List<String> dvctNuclide_name = new LinkedList<>();
List<String> dvctComments = new LinkedList<>(); List<String> dvctComments = new LinkedList<>();
for(int m=0;m<fileAnlyse.getVPeak().size();m++) { for(int m=0; m<fileAnlyse.getVPeak().size(); m++) {
dvctIDPEAK.add(Double.valueOf(m+1)); dvctIDPEAK.add(String.valueOf(m+1));
dvctCENTROIDCHANNEL.add(fileAnlyse.getVPeak().get(m).peakCentroid); dvctCENTROIDCHANNEL.add(fileAnlyse.getVPeak().get(m).peakCentroid);
dvctENERGY.add(fileAnlyse.getVPeak().get(m).energy); dvctENERGY.add(fileAnlyse.getVPeak().get(m).energy);
dvctAREA.add(fileAnlyse.getVPeak().get(m).area); dvctAREA.add(fileAnlyse.getVPeak().get(m).area);
@ -3150,21 +3357,14 @@ public class GammaFileUtil {
dvctMEANBACKCOUNT.add(fileAnlyse.getVPeak().get(m).meanBackCount); dvctMEANBACKCOUNT.add(fileAnlyse.getVPeak().get(m).meanBackCount);
dvctLC.add(fileAnlyse.getVPeak().get(m).lc); dvctLC.add(fileAnlyse.getVPeak().get(m).lc);
dvctLD.add(fileAnlyse.getVPeak().get(m).ld); dvctLD.add(fileAnlyse.getVPeak().get(m).ld);
String t_comment = fileAnlyse.getVPeak().get(m).comments==null?"":fileAnlyse.getVPeak().get(m).comments.replace("\'", "\'\'").trim(); String t_comment = fileAnlyse.getVPeak().get(m).comments==null?"":fileAnlyse.getVPeak().get(m).comments.replace("\'", "\'\'").trim();
if(t_comment.length() > 1024){ if(t_comment.length() > 1024){
t_comment = t_comment.substring(0, 1025); t_comment = t_comment.substring(0, 1025);
} }
dvctComments.add(t_comment); dvctComments.add(t_comment);
dvctNuclide_name.add(org.apache.commons.lang3.StringUtils.join(fileAnlyse.getVPeak().get(m).nuclides, ";"));
String qsName = "";
for(int n=0;n<fileAnlyse.getVPeak().get(m).nuclides.size();n++) {
qsName = qsName+fileAnlyse.getVPeak().get(m).nuclides.get(n)+";";
}
dvctNuclide_name.add(qsName);
} }
middleData.peaks_idPeak =DoubleLimit_G(dvctIDPEAK); middleData.peaks_idPeak =dvctIDPEAK;
middleData.peaks_peakCentroid =DoubleLimit_G(dvctCENTROIDCHANNEL); middleData.peaks_peakCentroid =DoubleLimit_G(dvctCENTROIDCHANNEL);
middleData.peaks_uncpeakCentroid =DoubleLimit_G(dvctUNCCENTROIDCHANNEL); middleData.peaks_uncpeakCentroid =DoubleLimit_G(dvctUNCCENTROIDCHANNEL);
middleData.peaks_Energy =DoubleLimit_G(dvctENERGY); middleData.peaks_Energy =DoubleLimit_G(dvctENERGY);
@ -3194,28 +3394,27 @@ public class GammaFileUtil {
middleData.peaks_Ld =DoubleLimit_G(dvctLD); middleData.peaks_Ld =DoubleLimit_G(dvctLD);
middleData.peaks_comments = dvctComments; middleData.peaks_comments = dvctComments;
middleData.peaks_Nuclide_name = dvctNuclide_name; middleData.peaks_Nuclide_name = dvctNuclide_name;
} }
// gards_ nucl_lines_ided数据表 // gards_ nucl_lines_ided数据表
GStoreMiddleProcessDataNuclLinesIded nucl_lines_ided_data = new GStoreMiddleProcessDataNuclLinesIded(); GStoreMiddleProcessDataNuclLinesIded nucl_lines_ided_data = new GStoreMiddleProcessDataNuclLinesIded();
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<Double> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> itor:fileAnlyse.getMapNucActMda().entrySet()) { for(Map.Entry<String, NuclideActMda> itor:fileAnlyse.getMapNucActMda().entrySet()) {
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<String> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
int first=itor.getValue().getFullNames().size(); int first=itor.getValue().getFullNames().size();
int second=itor.getValue().getVPeakIdx().size(); int second=itor.getValue().getVPeakIdx().size();
first = first<second?first:second; first = first<second?first:second;
@ -3227,19 +3426,18 @@ public class GammaFileUtil {
first = first<second?first:second; first = first<second?first:second;
second = itor.getValue().getVUncertY().size(); second = itor.getValue().getVUncertY().size();
first = first<second?first:second; first = first<second?first:second;
for(int m=0;m<first;m++) { for(int m=0;m<first;m++) {
svctNUCLIDEFULLNAME.add( itor.getValue().getFullNames().get(m).replace("\'", "\'\'") ); svctNUCLIDEFULLNAME.add( itor.getValue().getFullNames().get(m).replace("\'", "\'\'") );
dvctIDPEAK.add(itor.getValue().getVPeakIdx().get(m).doubleValue()); dvctIDPEAK.add(itor.getValue().getVPeakIdx().get(m).toString());
dvctENERGY.add(itor.getValue().getVEnergy().get(m)); dvctENERGY.add(itor.getValue().getVEnergy().get(m));
dvctUNCENERGY.add(itor.getValue().getVUncertE().get(m)); dvctUNCENERGY.add(itor.getValue().getVUncertE().get(m));
dvctABUNDANCE.add(itor.getValue().getVYield().get(m)); dvctABUNDANCE.add(itor.getValue().getVYield().get(m));
dvctUNCABUNDANCE.add(itor.getValue().getVUncertY().get(m)); dvctUNCABUNDANCE.add(itor.getValue().getVUncertY().get(m));
dvctACTIVITY.add(numberFormat.format(itor.getValue().getActivity())); dvctACTIVITY.add(String.format("%e", itor.getValue().getActivity()));
dvctUNCACTIVITY.add(itor.getValue().getAct_err()); dvctUNCACTIVITY.add(itor.getValue().getAct_err());
dvctEFFIC.add(itor.getValue().getEfficiency()); dvctEFFIC.add(itor.getValue().getEfficiency());
dvctUNEFFIC.add(itor.getValue().getEffi_err()); dvctUNEFFIC.add(itor.getValue().getEffi_err());
dvctMDA.add(numberFormat.format(itor.getValue().getMda())); dvctMDA.add(itor.getValue().getMda()>0?String.format("%e", itor.getValue().getMda()):"0.0");
// dvctKEY_FLAG.add(itor.value().vYield.get(m)); // dvctKEY_FLAG.add(itor.value().vYield.get(m));
dvctCSC_RATIO.add(1.0); dvctCSC_RATIO.add(1.0);
dvctCSC_RATIO_ERR.add(0.0); dvctCSC_RATIO_ERR.add(0.0);
@ -3249,11 +3447,11 @@ public class GammaFileUtil {
} else { } else {
dvctKEY_FLAG.add(0.0); dvctKEY_FLAG.add(0.0);
} }
dvctMDC.add(numberFormat.format(itor.getValue().getMdc())); dvctMDC.add(String.format("%e", itor.getValue().getMdc()));
dvctCONCENTRATION.add(numberFormat.format(itor.getValue().getConcentration())); dvctCONCENTRATION.add(String.format("%e", itor.getValue().getConcentration()));
} }
nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME; nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME;
nucl_lines_ided_data.idPeak =DoubleLimit_G(dvctIDPEAK); nucl_lines_ided_data.idPeak =dvctIDPEAK;
nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY); nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY);
nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY); nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY);
nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE); nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE);
@ -3272,36 +3470,35 @@ public class GammaFileUtil {
middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data); middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data);
} }
// gards_ nucl_ided数据表 // gards_ nucl_ided数据表
List<String> svctNUCLIDEFULLNAME1 = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA1 = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO1 = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR1 = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG1 = new LinkedList<>();
List<String> dvctMDC1 = new LinkedList<>();
List<String> dvctCONCENTRATION1 = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
if( fileAnlyse.getMapNucActMda().size() != 0) { if( fileAnlyse.getMapNucActMda().size() != 0) {
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> itor_v: fileAnlyse.getMapNucActMda().entrySet()) { for(Map.Entry<String, NuclideActMda> itor_v: fileAnlyse.getMapNucActMda().entrySet()) {
String nuclideName = itor_v.getKey(); String nuclideName = itor_v.getKey();
svctNUCLIDEFULLNAME1.add(nuclideName); svctNUCLIDEFULLNAME.add(nuclideName);
dvctHALFLIFE.add(itor_v.getValue().getHalflife()); dvctHALFLIFE.add(itor_v.getValue().getHalflife());
dvctACTIV_KEY.add(itor_v.getValue().getActivity()); dvctACTIV_KEY.add(itor_v.getValue().getActivity());
dvctACTIV_KEY_ERR.add(itor_v.getValue().getAct_err()); dvctACTIV_KEY_ERR.add(itor_v.getValue().getAct_err());
dvctMDA1.add(numberFormat.format(itor_v.getValue().getMda())); dvctMDA.add(String.format("%e", itor_v.getValue().getMda()));
dvctMDC1.add(numberFormat.format(itor_v.getValue().getMdc())); dvctMDC.add(itor_v.getValue().getMdc()>0?String.format("%e", itor_v.getValue().getMdc()):"0.0");
dvctCONCENTRATION1.add(numberFormat.format(itor_v.getValue().getConcentration())); dvctCONCENTRATION.add(String.format("%e", itor_v.getValue().getConcentration()));
dvctCSC_RATIO1.add(1.0); dvctCSC_RATIO.add(1.0);
dvctCSC_RATIO_ERR1.add(0.0); dvctCSC_RATIO_ERR.add(0.0);
if(itor_v.getValue().getCalculateIdx() >= 0 && itor_v.getValue().getCalculateIdx()<itor_v.getValue().getVEnergy().size()) { if(itor_v.getValue().getCalculateIdx() >= 0 && itor_v.getValue().getCalculateIdx()<itor_v.getValue().getVEnergy().size()) {
dvctKey_Energy.add(itor_v.getValue().getVEnergy().get(itor_v.getValue().getCalculateIdx())); dvctKey_Energy.add(itor_v.getValue().getVEnergy().get(itor_v.getValue().getCalculateIdx()));
} }
@ -3309,32 +3506,30 @@ public class GammaFileUtil {
dvctKey_Yield.add(itor_v.getValue().getVYield().get(itor_v.getValue().getCalculateIdx())); dvctKey_Yield.add(itor_v.getValue().getVYield().get(itor_v.getValue().getCalculateIdx()));
} }
} }
middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME;
middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME1;
middleData.nucl_ided_Type= svctTYPE; middleData.nucl_ided_Type= svctTYPE;
middleData.nucl_ided_Halflife =DoubleLimit_G(dvctHALFLIFE); middleData.nucl_ided_Halflife =DoubleLimit_G(dvctHALFLIFE);
middleData.nucl_ided_ave_activ = dvctAVE_ACTIV; middleData.nucl_ided_ave_activ = dvctAVE_ACTIV;
middleData.nucl_ided_ave_activ_err =DoubleLimit_G(dvctAVE_ACTIV_ERR); middleData.nucl_ided_ave_activ_err =DoubleLimit_G(dvctAVE_ACTIV_ERR);
middleData.nucl_ided_activ_key =DoubleLimit_G(dvctACTIV_KEY); middleData.nucl_ided_activ_key =DoubleLimit_G(dvctACTIV_KEY);
middleData.nucl_ided_activ_key_err =DoubleLimit_G(dvctACTIV_KEY_ERR); middleData.nucl_ided_activ_key_err =DoubleLimit_G(dvctACTIV_KEY_ERR);
middleData.nucl_ided_mda = dvctMDA1; middleData.nucl_ided_mda = dvctMDA;
middleData.nucl_ided_mda_err =DoubleLimit_G(dvctMDA_ERR); middleData.nucl_ided_mda_err =DoubleLimit_G(dvctMDA_ERR);
middleData.nucl_ided_nid_flag =DoubleLimit_G(dvctNID_FLAG); middleData.nucl_ided_nid_flag =DoubleLimit_G(dvctNID_FLAG);
middleData.nucl_ided_csc_ratio =DoubleLimit_G(dvctCSC_RATIO1); middleData.nucl_ided_csc_ratio =DoubleLimit_G(dvctCSC_RATIO);
middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR1); middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR);
middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG1); middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG);
middleData.nucl_ided_MDC = dvctMDC1; middleData.nucl_ided_MDC = dvctMDC;
middleData.nucl_ided_Concentration = dvctCONCENTRATION; middleData.nucl_ided_Concentration = dvctCONCENTRATION;
middleData.nucl_ided_Key_Energy = DoubleLimit_G(dvctKey_Energy); middleData.nucl_ided_Key_Energy = DoubleLimit_G(dvctKey_Energy);
middleData.nucl_ided_Key_Yield = DoubleLimit_G(dvctKey_Yield); middleData.nucl_ided_Key_Yield = DoubleLimit_G(dvctKey_Yield);
} }
// GARDS_QC_CHECK数据表 // GARDS_QC_CHECK数据表
List<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
if( fileAnlyse.getQcItems().size() != 0) { if( fileAnlyse.getQcItems().size() != 0) {
List<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
for(Map.Entry<String, QcCheckItem> itor_q:fileAnlyse.getQcItems().entrySet()) { for(Map.Entry<String, QcCheckItem> itor_q:fileAnlyse.getQcItems().entrySet()) {
String nuclideName = itor_q.getKey(); String nuclideName = itor_q.getKey();
qvctQC_NAME.add(nuclideName); qvctQC_NAME.add(nuclideName);
@ -3347,11 +3542,9 @@ public class GammaFileUtil {
middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD; middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD;
middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE); middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE);
} }
//sample info //sample info
middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+" "+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 = fileAnlyse.getCollect().getCollection_stop_date()+" "+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"))) { if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) {
middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue());
if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) { if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) {
@ -3365,18 +3558,16 @@ public class GammaFileUtil {
middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue()); 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_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume());
middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+" "+fileAnlyse.getAcq().getAcquisition_start_time(); middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time();
String acquisition_start = middleData.sample_acquisiton_start; String acquisition_start = middleData.sample_acquisiton_start;
Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); Date dataTime = DateUtils.parseDate(acquisition_start);
acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss"); middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss");
middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss");
middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ; middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ;
middleData.sample_stationID = fileAnlyse.getHeader().getSite_code(); middleData.sample_stationID = fileAnlyse.getHeader().getSite_code();
middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code(); middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code();
middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry(); middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry();
middleData.sample_Type = fileAnlyse.getHeader().getSystem_type(); middleData.sample_Type = fileAnlyse.getHeader().getSystem_type();
middleData.setting_specSetup = fileAnlyse.getUsedSetting(); middleData.setting_specSetup = fileAnlyse.getUsedSetting();
middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt(); middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt();
middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt(); middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt();
return bRet; return bRet;
@ -4027,4 +4218,41 @@ public class GammaFileUtil {
} }
} }
public File analyzeFile(String path, String fileName) {
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
InputStream inputStream = null;
File file = null;
try {
//被动模式
ftpClient.enterLocalPassiveMode();
//设置文件类型--二进制文件
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
//
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//切换文件路径
ftpClient.changeWorkingDirectory(path);
inputStream = ftpClient.retrieveFileStream(fileName);
if (Objects.nonNull(inputStream)){
file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return file;
}
} }

View File

@ -1,8 +1,8 @@
package org.jeecg.modules.native_jni; package org.jeecg.modules.native_jni;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.eneity.vo.StructInsertInput; import org.jeecg.modules.eneity.vo.StructInsertInput;
import org.jeecg.modules.eneity.vo.StructInsertOutput; import org.jeecg.modules.eneity.vo.StructInsertOutput;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.native_jni.struct.CalValuesOut; import org.jeecg.modules.native_jni.struct.CalValuesOut;
import java.util.List; import java.util.List;
@ -25,22 +25,6 @@ public class CalValuesHandler {
public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List<Double> vCentroid, List<Double> vFwhmCh, List<Double> vTail, List<Double> vUpperTail); public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List<Double> vCentroid, List<Double> vFwhmCh, List<Double> vTail, List<Double> vUpperTail);
public static native List<Double> calValues(int cal, int m_nChans); public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath);
public static native List<Double> GetFwhmcAll(int m_nChans);
public static native List<Double> calculateLC(List<Double> BaseLine, List<Double> FwhmcAll, double RiskLevelK);
public static native List<Double> calculateSCAC(List<Double> Spectrum, List<Double> BaseLine, List<Double> FwhmcAll);
public static native boolean armaAny(List<Double> Spectrum);
public static native String calUpdate(String dataType, List<Double> certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta);
public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta);
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta);
public static native String fitPeakFull();
} }

View File

@ -1,11 +1,14 @@
package org.jeecg.modules.native_jni.struct; package org.jeecg.modules.native_jni.struct;
import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
* 能谱结构体字段信息 * 能谱结构体字段信息
*/ */
@Data
public class EnergySpectrumStruct { public class EnergySpectrumStruct {
/************************* Infomations ******************/ /************************* Infomations ******************/

View File

@ -18,8 +18,8 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl<GardsGammaDe
@Override @Override
public Map<String, String> mapSetting() { public Map<String, String> mapSetting() {
Map<String, String> paramsMap = list().stream() Map<String, String> paramsMap = list().stream()
.collect(Collectors.toMap(GardsGammaDefaultParams::getName, .collect(Collectors.toMap(v-> v.getName().trim(),
v->v.getValue() == null ? "" : v.getValue())); v->v.getValue() == null ? "-9999" : v.getValue()));
return paramsMap; return paramsMap;
} }
} }

View File

@ -7,10 +7,14 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.GammaFileUtil; import org.jeecg.common.GammaFileUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.*; import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.SpectrumSystemType; import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.properties.SpectrumPathProperties;
@ -20,13 +24,22 @@ import org.jeecg.common.util.MyLogFormatUtil;
import org.jeecg.modules.base.dto.*; import org.jeecg.modules.base.dto.*;
import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnauto.*; import org.jeecg.modules.base.entity.rnauto.*;
import org.jeecg.modules.base.enums.MiddleDataType;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.ftp.FTPUtils;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.springframework.transaction.TransactionStatus;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
@Data @Data
@Slf4j
public class Sample_G_Analysis { public class Sample_G_Analysis {
private final Map<String,String> fieldMap = fieldMap(); private final Map<String,String> fieldMap = fieldMap();
@ -82,8 +95,10 @@ public class Sample_G_Analysis {
*/ */
private String arrFileName; private String arrFileName;
private FTPUtils ftpUtil;
public Sample_G_Analysis(EnergySpectrumStruct energySpectrumStruct,SpectrumServiceQuotes serviceQuotes, public Sample_G_Analysis(EnergySpectrumStruct energySpectrumStruct,SpectrumServiceQuotes serviceQuotes,
GardsSampleData sampleData) { GardsSampleData sampleData, FTPUtils ftpUtil) {
this.sampleData = sampleData; this.sampleData = sampleData;
this.serviceQuotes = serviceQuotes; this.serviceQuotes = serviceQuotes;
this.energySpectrumStruct = energySpectrumStruct; this.energySpectrumStruct = energySpectrumStruct;
@ -92,6 +107,7 @@ public class Sample_G_Analysis {
this.sampleInputFilename = sampleData.getInputFileName(); this.sampleInputFilename = sampleData.getInputFileName();
this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(), this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(),
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH)+1)); sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH)+1));
this.ftpUtil = ftpUtil;
} }
public void analysis(){ public void analysis(){
@ -100,11 +116,17 @@ public class Sample_G_Analysis {
GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); GStoreMiddleProcessData middleData = new GStoreMiddleProcessData();
Integer sampleId = sampleData.getSampleId(); Integer sampleId = sampleData.getSampleId();
GammaFileUtil gammaFileUtil = new GammaFileUtil(); GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class);
PHDFile phdFile = new PHDFile(); PHDFile phdFile = new PHDFile();
// 解析PHD文件
spectrumPathProperties = ApplicationContextUtil.getContext().getBean(SpectrumPathProperties.class);
String sampleFilePath = sampleData.getInputFileName();
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result());
// 获取数据库 Gamma 默认参数 // 获取数据库 Gamma 默认参数
getSettingFromDB(phdFile); // getSettingFromDB(phdFile);
// 文件路径 // 文件路径
middleData.setAnalyses_save_filePath(this.sampleInputFilename); middleData.setAnalyses_save_filePath(this.sampleInputFilename);
// 读取文件内容并附值 // 读取文件内容并附值
@ -117,26 +139,11 @@ public class Sample_G_Analysis {
if (this.systemType.equals(SpectrumSystemType.G.name())) { if (this.systemType.equals(SpectrumSystemType.G.name())) {
nuclideLibs = this.getNuclideLinesG(); nuclideLibs = this.getNuclideLinesG();
} }
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, "1"); gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType());
// 数据插入数据库
this.storageDataToDatabase(middleData, phdFile.getQcItems());
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
saveAnalysis(middleData,sampleId);
// 获取分析结果ID ==> SELECT IDANALYSIS
Integer IdAnalysis = getIdAnalysis(sampleId);
// 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA
serviceQuotes.getSampleDataService().updateStatus(null,null);
/* GARDS_CALIBRATION_PAIRS 数据表保存 */
saveCalibrationPairs(middleData, sampleId, IdAnalysis);
/* GARDS_CALIBRATION 数据表保存 */
saveCalibration(middleData, sampleId, IdAnalysis);
/* Gards_Peaks 数据表保存 */
savePeaks(middleData);
/* Gards_Nucl_Lines_Ided 数据表保存 */
saveNuclLinesIded(middleData, sampleId, IdAnalysis);
/* Gards_Nucl_Ided 数据表保存 */
saveNuclIded(middleData, sampleId, IdAnalysis);
/* Gards_Qc_Check 数据表保存 */
saveQcCheck(middleData, sampleId, IdAnalysis, phdFile.getQcItems());
// 生成日志文件 // 生成日志文件
writeLog(middleData.getAnalyses_LogPath(), middleData); writeLog(middleData.getAnalyses_LogPath(), middleData);
// todo 报告文件 // todo 报告文件
@ -148,6 +155,47 @@ public class Sample_G_Analysis {
} }
} }
private void storageDataToDatabase(GStoreMiddleProcessData middleData, Map<String, QcCheckItem> qcItems){
//如果数据已经存储不在重复存储
final Integer idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId());
if(Objects.nonNull(idAnalysis)){
// log.warn("{} file analysis data has been stored",new File(this.sampleTempFilePath).getName());
return;
}
DataSourceSwitcher.switchToOracle();
final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition());
try {
Integer sampleId = this.sampleData.getSampleId();
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
saveAnalysis(middleData, sampleId);
// 获取分析结果ID ==> SELECT IDANALYSIS
Integer IdAnalysis = getIdAnalysis(sampleId);
// 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA
// serviceQuotes.getSampleDataService().updateStatus(null,null);
/* GARDS_CALIBRATION_PAIRS 数据表保存 */
saveCalibrationPairs(middleData, sampleId, IdAnalysis);
/* GARDS_CALIBRATION 数据表保存 */
saveCalibration(middleData, sampleId, IdAnalysis);
/* Gards_Peaks 数据表保存 */
savePeaks(middleData);
/* Gards_Nucl_Lines_Ided 数据表保存 */
saveNuclLinesIded(middleData, sampleId, IdAnalysis);
/* Gards_Nucl_Ided 数据表保存 */
saveNuclIded(middleData, sampleId, IdAnalysis);
/* Gards_Qc_Check 数据表保存 */
saveQcCheck(middleData, sampleId, IdAnalysis, qcItems);
//提交事务
serviceQuotes.getTransactionManager().commit(transactionStatus);
} catch (Exception e) {
//设置分析数据存储失败标记
// this.parsingProcessLog.setAnalysisDataStoreFlag(false);
//回滚事务
serviceQuotes.getTransactionManager().rollback(transactionStatus);
throw e;
} finally {
DataSourceSwitcher.clearDataSource();
}
}
/** /**
* 生成日志文件 * 生成日志文件
* @param logFilePath * @param logFilePath
@ -434,57 +482,69 @@ public class Sample_G_Analysis {
String base_E_Paris = "calibration_pairs_E_idCalPoint"; String base_E_Paris = "calibration_pairs_E_idCalPoint";
PairsEDto pairsEDto = new PairsEDto(); PairsEDto pairsEDto = new PairsEDto();
BeanUtil.copyProperties(middleData,pairsEDto); BeanUtil.copyProperties(middleData,pairsEDto);
List<GardsCalibrationPairs> pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap); List<GardsCalibrationPairs> pairsE = Lists.newArrayList();
String pairsECaltype = middleData.getCalibration_pairs_E_Caltype(); if (pairsEDto.getCalibration_pairs_E_idCalPoint().size() > 0) {
String pairsEInput = middleData.getCalibration_pairs_E_Input(); pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap);
for (GardsCalibrationPairs onePairs : pairsE) { String pairsECaltype = middleData.getCalibration_pairs_E_Caltype();
onePairs.setSampleId(sampleId); String pairsEInput = middleData.getCalibration_pairs_E_Input();
onePairs.setIdAnalysis(IdAnalysis); for (GardsCalibrationPairs onePairs : pairsE) {
onePairs.setSampleType(pairsSampleType); onePairs.setSampleId(sampleId);
onePairs.setCaltype(pairsECaltype); onePairs.setIdAnalysis(IdAnalysis);
onePairs.setInput(pairsEInput); onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsECaltype);
onePairs.setInput(pairsEInput);
}
} }
// GARDS_CALIBRATION_PAIRS (Efficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS // GARDS_CALIBRATION_PAIRS (Efficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_EF_Paris = "calibration_pairs_EF_idCalPoint"; String base_EF_Paris = "calibration_pairs_EF_idCalPoint";
PairsEFDto pairsEFDto = new PairsEFDto(); PairsEFDto pairsEFDto = new PairsEFDto();
BeanUtil.copyProperties(middleData,pairsEFDto); BeanUtil.copyProperties(middleData,pairsEFDto);
List<GardsCalibrationPairs> pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap); List<GardsCalibrationPairs> pairsEF = Lists.newArrayList();
String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype(); if (pairsEFDto.getCalibration_pairs_EF_idCalPoint().size() > 0) {
String pairsEFInput = middleData.getCalibration_pairs_EF_Input(); pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap);
for (GardsCalibrationPairs onePairs : pairsEF) { String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype();
onePairs.setSampleId(sampleId); String pairsEFInput = middleData.getCalibration_pairs_EF_Input();
onePairs.setIdAnalysis(IdAnalysis); for (GardsCalibrationPairs onePairs : pairsEF) {
onePairs.setSampleType(pairsSampleType); onePairs.setSampleId(sampleId);
onePairs.setCaltype(pairsEFCaltype); onePairs.setIdAnalysis(IdAnalysis);
onePairs.setInput(pairsEFInput); onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsEFCaltype);
onePairs.setInput(pairsEFInput);
}
} }
// GARDS_CALIBRATION_PAIRS (Resolution) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS // GARDS_CALIBRATION_PAIRS (Resolution) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_R_Paris = "calibration_pairs_R_idCalPoint"; String base_R_Paris = "calibration_pairs_R_idCalPoint";
PairsRDto pairsRDto = new PairsRDto(); PairsRDto pairsRDto = new PairsRDto();
BeanUtil.copyProperties(middleData,pairsRDto); BeanUtil.copyProperties(middleData,pairsRDto);
List<GardsCalibrationPairs> pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap); List<GardsCalibrationPairs> pairsR = Lists.newArrayList();
String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype(); if (pairsRDto.getCalibration_pairs_R_idCalPoint().size() > 0) {
String pairsRInput = middleData.getCalibration_pairs_R_Input(); pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap);
for (GardsCalibrationPairs onePairs : pairsR) { String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype();
onePairs.setSampleId(sampleId); String pairsRInput = middleData.getCalibration_pairs_R_Input();
onePairs.setIdAnalysis(IdAnalysis); for (GardsCalibrationPairs onePairs : pairsR) {
onePairs.setSampleType(pairsSampleType); onePairs.setSampleId(sampleId);
onePairs.setCaltype(pairsRCaltype); onePairs.setIdAnalysis(IdAnalysis);
onePairs.setInput(pairsRInput); onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsRCaltype);
onePairs.setInput(pairsRInput);
}
} }
// GARDS_CALIBRATION_PAIRS (TotalEfficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS // GARDS_CALIBRATION_PAIRS (TotalEfficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_T_Paris = "calibration_pairs_T_idCalPoint"; String base_T_Paris = "calibration_pairs_T_idCalPoint";
PairsTDto pairsTDto = new PairsTDto(); PairsTDto pairsTDto = new PairsTDto();
BeanUtil.copyProperties(middleData,pairsTDto); BeanUtil.copyProperties(middleData,pairsTDto);
List<GardsCalibrationPairs> pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap); List<GardsCalibrationPairs> pairsT = Lists.newArrayList();
String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype(); if (pairsTDto.getCalibration_pairs_T_idCalPoint().size() > 0) {
String pairsTInput = middleData.getCalibration_pairs_T_Input(); pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap);
for (GardsCalibrationPairs onePairs : pairsT) { String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype();
onePairs.setSampleId(sampleId); String pairsTInput = middleData.getCalibration_pairs_T_Input();
onePairs.setIdAnalysis(IdAnalysis); for (GardsCalibrationPairs onePairs : pairsT) {
onePairs.setSampleType(pairsSampleType); onePairs.setSampleId(sampleId);
onePairs.setCaltype(pairsTCaltype); onePairs.setIdAnalysis(IdAnalysis);
onePairs.setInput(pairsTInput); onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsTCaltype);
onePairs.setInput(pairsTInput);
}
} }
// GARDS_CALIBRATION_PAIRS 汇总保存 // GARDS_CALIBRATION_PAIRS 汇总保存
List<GardsCalibrationPairs> allPairs = new ArrayList<>(); List<GardsCalibrationPairs> allPairs = new ArrayList<>();
@ -646,11 +706,13 @@ public class Sample_G_Analysis {
} }
public Map<String, NuclideLines> getNuclideLinesG() { public Map<String, NuclideLines> getNuclideLinesG() {
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G"); Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G");
return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs; return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs;
} }
public Map<String, NuclideLines> getNuclideLinesP(){ public Map<String, NuclideLines> getNuclideLinesP(){
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "P"); Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "P");
return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs; return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs;
} }
@ -788,7 +850,7 @@ public class Sample_G_Analysis {
private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){ private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){
GardsAnalyses gardsAnalyses = new GardsAnalyses(); GardsAnalyses gardsAnalyses = new GardsAnalyses();
String dateTime = DateConstant.DATE_TIME; String dateTime = DateConstant.DATE_BIAS_TIME;
String analysisBegin = middleData.getAnalyses_analysisBegin(); String analysisBegin = middleData.getAnalyses_analysisBegin();
Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime) Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime)
.toJdkDate(); .toJdkDate();