feat:自建台站谱解析类
This commit is contained in:
parent
108f2db587
commit
7daebd98b8
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,7 @@ import org.jeecg.common.properties.*;
|
|||
import org.jeecg.common.util.NameStandUtil;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SelfUtil;
|
||||
import org.jeecg.modules.datasource.OraDataSourceProperties;
|
||||
import org.jeecg.modules.service.*;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -88,11 +89,12 @@ public class SpectrumServiceQuotes {
|
|||
|
||||
private final IGardsGPSDataService gardsGPSDataService;
|
||||
|
||||
private final SelfUtil selfStationUtil;
|
||||
|
||||
/**
|
||||
* 原始库插入数据锁
|
||||
*/
|
||||
private final Object originalLibraryLock = new Object();
|
||||
|
||||
private final BatchesCounter batchesCounter;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import org.jeecg.modules.base.enums.CalName;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class SelfUtil {
|
||||
|
||||
public List<Long> roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
|
||||
// g_counts
|
||||
List<Long> counts = new LinkedList<>();
|
||||
//存储同一列不同行加和后的数量
|
||||
List<Integer> sumList = new LinkedList<>();
|
||||
//遍历所有列
|
||||
for (int i=0; i<gammaChannels; i++) {
|
||||
long sum = 0;
|
||||
//根据起始道值和结束道值 获取这一列的所有对应道值的数据
|
||||
for (int j=startChannel; j <= endChannel; j++) {
|
||||
//列数 * 总行数 + 当前行下标 获取对应的数据数组下标
|
||||
int index = (int) (i * betaChannels + j);
|
||||
long count = 0;
|
||||
//判断下标是否在h_counts范围内
|
||||
if (index > 0 && index < h_counts.size()) {
|
||||
count = h_counts.get(index);
|
||||
}
|
||||
sum+=count;
|
||||
}
|
||||
counts.add(sum);
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
public void createGammaFile(String pathName, String fileName, EnergySpectrumStruct struct, List<Long> g_counts) {
|
||||
File file = new File(pathName + "\\" + fileName);
|
||||
// 创建PrintWriter对象
|
||||
PrintWriter out = null;
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
|
||||
try {
|
||||
out = new PrintWriter(file);
|
||||
out.println("BEGIN IMS2.0");
|
||||
out.println("MSG_TYPE DATA");
|
||||
// todo msg_type用的不对,dll没解析出这个字段
|
||||
out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type);
|
||||
out.println("#Header 3");
|
||||
// 解析出的Gamma谱 系统类型暂时使用G
|
||||
out.println(struct.site_code + " " + struct.detector_code + " G " +
|
||||
struct.sample_geometry + " " + struct.spectrum_quantity);
|
||||
out.println(struct.sample_ref_id);
|
||||
out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0");
|
||||
out.println(struct.transmit_date + " " + struct.transmit_time);
|
||||
out.println("#Collection");
|
||||
out.println(struct.collection_start_date + " " + struct.collection_start_time + " " +
|
||||
struct.collection_stop_date + " " + struct.collection_stop_time + " "
|
||||
+ decimalFormat.format(struct.air_volume));
|
||||
out.println("#Acquisition");
|
||||
out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " +
|
||||
decimalFormat.format(struct.acquisition_real_time) + " " +
|
||||
decimalFormat.format(struct.acquisition_live_time));
|
||||
out.println("#g_Energy");
|
||||
|
||||
|
||||
format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out);
|
||||
out.println("#g_Resolution");
|
||||
format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out);
|
||||
out.println("#g_Efficiency");
|
||||
format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out);
|
||||
out.println("#g_Spectrum");
|
||||
// num_g_channel 根据g_counts数量得来和PHD写的数字没有关系;g_energy_span是PHD写的值
|
||||
out.println(struct.num_g_channel + " " + struct.g_energy_span);
|
||||
// 存储前一个数字
|
||||
String beforeStr = "";
|
||||
for (int i = 0; i < g_counts.size(); i++) {
|
||||
String str = g_counts.get(i).toString();
|
||||
if(i % 5 == 0) {
|
||||
if (i == 0) {
|
||||
out.printf(i+"");
|
||||
} else {
|
||||
out.printf("\n" + i );
|
||||
}
|
||||
beforeStr = i+"";
|
||||
}
|
||||
|
||||
if(StrUtil.isEmpty(beforeStr)){
|
||||
beforeStr = str;
|
||||
}
|
||||
// 根据前一个字符长度计算需要的空格
|
||||
out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i));
|
||||
if(i == g_counts.size() - 1) {
|
||||
out.println();
|
||||
}
|
||||
beforeStr = str;
|
||||
}
|
||||
out.print("STOP");
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (null != out) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
* @param aList 第一列数据
|
||||
* @param bList 第二列数据
|
||||
* @param cList 第三列数据
|
||||
* @param out
|
||||
*/
|
||||
private static void format(List<Double> aList, List<Double> bList,List<Double> cList,PrintWriter out) {
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
|
||||
String a = decimalFormat.format(aList.get(i));
|
||||
String b = decimalFormat.format(bList.get(i));
|
||||
String c = decimalFormat.format(cList.get(i));
|
||||
out.print(a);
|
||||
out.printf("%" + ( b.length() + (17 - a.length())) + "s", b);
|
||||
out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据DLL解析GammaPHD内容 得到PHDFile实体
|
||||
* @param fileName
|
||||
* @param pathName
|
||||
* @return
|
||||
*/
|
||||
public PHDFile getGammaPHD(String fileName, String pathName) {
|
||||
PHDFile phd = new PHDFile();
|
||||
phd.setFilepath(pathName);
|
||||
phd.setFilename(fileName);
|
||||
File file = new File(pathName + StringPool.SLASH + fileName);
|
||||
phd.setTmpFilePath(file.getAbsolutePath());
|
||||
try {
|
||||
//读取文件信息
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
//MsgInfo
|
||||
phd.getMsgInfo().setMsg_id(struct.msg_id);
|
||||
phd.getMsgInfo().setMsg_type(struct.msg_type);
|
||||
phd.getMsgInfo().setData_type(struct.data_type);
|
||||
//Header
|
||||
phd.getHeader().setDesignator(struct.designator);
|
||||
phd.getHeader().setSite_code(struct.site_code);
|
||||
phd.getHeader().setDetector_code(struct.detector_code);
|
||||
phd.getHeader().setSystem_type(struct.system_type);
|
||||
phd.getHeader().setSample_geometry(struct.sample_geometry);
|
||||
phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity);
|
||||
phd.getHeader().setSample_ref_id(struct.sample_ref_id);
|
||||
phd.getHeader().setMeasurement_id(struct.measurement_id);
|
||||
phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id);
|
||||
phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id);
|
||||
phd.getHeader().setTransmit_date(struct.transmit_date);
|
||||
phd.getHeader().setTransmit_time(struct.transmit_time);
|
||||
//Comment
|
||||
phd.setOriTotalCmt(struct.comment);
|
||||
//Collection
|
||||
if (StrUtil.isNotBlank(struct.collection_start_date) && StrUtil.isNotBlank(struct.collection_start_time)
|
||||
&& StrUtil.isNotBlank(struct.collection_stop_date) && StrUtil.isNotBlank(struct.collection_stop_time)
|
||||
&& Objects.nonNull(struct.air_volume)) {
|
||||
phd.getCollect().setCollection_start_date(struct.collection_start_date);
|
||||
phd.getCollect().setCollection_start_time(struct.collection_start_time);
|
||||
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
|
||||
phd.getCollect().setCollection_stop_time(struct.collection_stop_time);
|
||||
phd.getCollect().setAir_volume(struct.air_volume);
|
||||
if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0");
|
||||
}
|
||||
if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0");
|
||||
}
|
||||
} else {
|
||||
phd.getCollect().setAir_volume(0.0);
|
||||
}
|
||||
//Acquisition
|
||||
if (StrUtil.isNotBlank(struct.acquisition_start_date) && StrUtil.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_time(struct.acquisition_start_time);
|
||||
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
|
||||
phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time);
|
||||
if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) {
|
||||
phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0");
|
||||
}
|
||||
} else {
|
||||
phd.getAcq().setAcquisition_live_time(0.0);
|
||||
phd.getAcq().setAcquisition_real_time(0.0);
|
||||
}
|
||||
//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)
|
||||
&& StrUtil.isNotBlank(struct.archive_bottle_id)) {
|
||||
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
|
||||
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
|
||||
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
|
||||
phd.getProcess().setUncertainty_2(struct.uncertainty_2);
|
||||
phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id);
|
||||
} else {
|
||||
phd.getProcess().setSample_volume_of_Xe(0.0);
|
||||
phd.getProcess().setXe_collection_yield(0.0);
|
||||
phd.getProcess().setUncertainty_1(0.0);
|
||||
phd.getProcess().setUncertainty_2(0.0);
|
||||
}
|
||||
//Sample
|
||||
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
|
||||
phd.getSampleBlock().setDimension_1(struct.dimension_1);
|
||||
phd.getSampleBlock().setDimension_2(struct.dimension_2);
|
||||
} else {
|
||||
phd.getSampleBlock().setDimension_1(0.0);
|
||||
phd.getSampleBlock().setDimension_2(0.0);
|
||||
}
|
||||
//Calibration
|
||||
if (StrUtil.isNotBlank(struct.date_calibration) && StrUtil.isNotBlank(struct.time_calibration)) {
|
||||
phd.getCalibration().setDate_calibration(struct.date_calibration);
|
||||
phd.getCalibration().setTime_calibration(struct.time_calibration);
|
||||
}
|
||||
//Certificate
|
||||
if (Objects.nonNull(struct.total_source_activity) && StrUtil.isNotBlank(struct.assay_date)
|
||||
&& StrUtil.isNotBlank(struct.assay_time) && StrUtil.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.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().setAssay_date(struct.assay_date);
|
||||
phd.getCertificate().setAssay_time(struct.assay_time);
|
||||
phd.getCertificate().setUnits_activity(struct.units_activity);
|
||||
phd.getCertificate().setNuclide_name(struct.nuclide_name);
|
||||
phd.getCertificate().setHalf_life_time(struct.half_life_time);
|
||||
phd.getCertificate().setTime_unit(struct.time_unit);
|
||||
phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay);
|
||||
phd.getCertificate().setUncertainty(struct.uncertainty);
|
||||
phd.getCertificate().setG_energy(struct.cer_g_energy);
|
||||
phd.getCertificate().setG_intensity(struct.g_intensity);
|
||||
phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode);
|
||||
phd.getCertificate().setMaximum_energy(struct.maximum_energy);
|
||||
phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle);
|
||||
phd.getCertificate().setRecord_count(struct.record_count);
|
||||
}
|
||||
//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)) {
|
||||
phd.getSpec().setNum_g_channel(struct.g_counts.size()); // todo 原Num_g_channel有误
|
||||
phd.getSpec().setG_energy_span(struct.g_energy_span);
|
||||
phd.getSpec().setBegin_channel(struct.g_begin_channel);
|
||||
phd.getSpec().setCounts(struct.g_counts);
|
||||
int i = 0;
|
||||
for (; i < phd.getSpec().getNum_g_channel(); i++) {
|
||||
if (phd.getSpec().getCounts().get(i) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == phd.getSpec().getNum_g_channel()) {
|
||||
phd.setValid(false);
|
||||
}
|
||||
}
|
||||
//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)) {
|
||||
GEnergyBlock gEnergyBlock = new GEnergyBlock();
|
||||
gEnergyBlock.setG_energy(struct.g_energy);
|
||||
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
|
||||
gEnergyBlock.setUncertainty(struct.g_uncertainty);
|
||||
gEnergyBlock.setRecord_count(struct.g_record_count);
|
||||
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
|
||||
}
|
||||
//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)) {
|
||||
GResolutionBlock gResolutionBlock = new GResolutionBlock();
|
||||
gResolutionBlock.setG_energy(struct.g_r_energy);
|
||||
gResolutionBlock.setFWHM(struct.g_r_FWHM);
|
||||
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
|
||||
gResolutionBlock.setRecord_count(struct.g_r_record_count);
|
||||
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
|
||||
}
|
||||
//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)) {
|
||||
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
|
||||
gEfficiencyBlock.setG_energy(struct.g_e_energy);
|
||||
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
|
||||
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
|
||||
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
|
||||
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
|
||||
}
|
||||
//TotalEff
|
||||
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.setG_energy(struct.t_g_energy);
|
||||
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
|
||||
totaleffBlock.setUncertainty(struct.t_uncertainty);
|
||||
totaleffBlock.setRecord_count(struct.t_record_count);
|
||||
phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock);
|
||||
}
|
||||
|
||||
// 初始化默认分析设置
|
||||
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
|
||||
phd.getSetting().setECutAnalysis_Low(35.0);
|
||||
phd.getSetting().setBUpdateCal(true);
|
||||
}
|
||||
if (StrUtil.isNotBlank(phd.getCollect().getCollection_start_date())
|
||||
&& StrUtil.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 (StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StrUtil.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);
|
||||
|
||||
phd.setBAnalyed(false);
|
||||
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return phd;
|
||||
}
|
||||
}
|
|
@ -405,6 +405,30 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
|||
return map;
|
||||
}
|
||||
|
||||
public List<Long> roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
|
||||
// g_counts
|
||||
List<Long> counts = new LinkedList<>();
|
||||
//存储同一列不同行加和后的数量
|
||||
List<Integer> sumList = new LinkedList<>();
|
||||
//遍历所有列
|
||||
for (int i=0; i<gammaChannels; i++) {
|
||||
long sum = 0;
|
||||
//根据起始道值和结束道值 获取这一列的所有对应道值的数据
|
||||
for (int j=startChannel; j <= endChannel; j++) {
|
||||
//列数 * 总行数 + 当前行下标 获取对应的数据数组下标
|
||||
int index = (int) (i * betaChannels + j);
|
||||
long count = 0;
|
||||
//判断下标是否在h_counts范围内
|
||||
if (index > 0 && index < h_counts.size()) {
|
||||
count = h_counts.get(index);
|
||||
}
|
||||
sum+=count;
|
||||
}
|
||||
counts.add(sum);
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
public String UpdateEquationEnergy(ParameterInfo m_curParam) {
|
||||
String equation ="";
|
||||
int p_size = m_curParam.getP().size()-1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user