GammaController新增testFun测试dll分析方法

PHDFile新增userId,xmlFilePath字段
修改部分实体类内字段大小写问题
CalValuesHandler去掉多余的计算方法,新增实现analyseSpectrum方法
新增BaseCtrlStack实体类
This commit is contained in:
qiaoqinzheng 2023-09-24 18:43:20 +08:00
parent c49318a57f
commit 0e4b4039e3
18 changed files with 254 additions and 145 deletions

View File

@ -12,9 +12,9 @@ public class AcquisitionBlock implements Serializable {
private String acquisition_start_time; // acquisition start time (hh : mm : ss . s) private String acquisition_start_time; // acquisition start time (hh : mm : ss . s)
private Double acquisition_real_time; // acquisition real time (s) private double acquisition_real_time; // acquisition real time (s)
private Double acquisition_live_time; // acquisition live time (s) private double acquisition_live_time; // acquisition live time (s)
public AcquisitionBlock(){ public AcquisitionBlock(){
acquisition_start_date=""; acquisition_start_date="";

View File

@ -17,17 +17,19 @@ public class BaseControls implements Serializable {
private List<Double> YSlope; private List<Double> YSlope;
private List<Double> Baseline; private List<Double> Baseline;
private List<Double> StepCounts; private List<Double> StepCounts;
private List<BaseCtrlStack> BaseStack;
public BaseControls(){ public BaseControls(){
rg_low = 1; rg_low = 1;
rg_high = 1; rg_high = 1;
ReplotUsed = false; ReplotUsed = false;
ReplotNeeded = false; ReplotNeeded = false;
XCtrl=new LinkedList<>(); XCtrl = new LinkedList<>();
YCtrl=new LinkedList<>(); YCtrl = new LinkedList<>();
YSlope=new LinkedList<>(); YSlope = new LinkedList<>();
Baseline=new LinkedList<>(); Baseline = new LinkedList<>();
StepCounts=new LinkedList<>(); StepCounts = new LinkedList<>();
BaseStack = new LinkedList<>();
} }
} }

View File

@ -0,0 +1,24 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
@Data
public class BaseCtrlStack implements Serializable {
private List<Double> cx;
private List<Double> cy;
private List<Double> cdy;
public BaseCtrlStack(){
cx = new LinkedList<>();
cy = new LinkedList<>();
cdy = new LinkedList<>();
}
}

View File

@ -15,7 +15,7 @@ public class GEfficiencyBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (counts in peak/photon emitted) private List<Double> uncertainty; // uncertainty (counts in peak/photon emitted)
private Integer record_count; private int record_count;
public GEfficiencyBlock(){ public GEfficiencyBlock(){
g_energy = new LinkedList<>(); g_energy = new LinkedList<>();

View File

@ -15,7 +15,7 @@ public class GEnergyBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (channels) private List<Double> uncertainty; // uncertainty (channels)
private Integer record_count; private int record_count;
public GEnergyBlock(){ public GEnergyBlock(){
g_energy = new LinkedList<>(); g_energy = new LinkedList<>();

View File

@ -15,7 +15,7 @@ public class GResolutionBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (keV) private List<Double> uncertainty; // uncertainty (keV)
private Integer record_count; private int record_count;
public GResolutionBlock(){ public GResolutionBlock(){
g_energy = new LinkedList<>(); g_energy = new LinkedList<>();

View File

@ -9,10 +9,10 @@ import java.util.List;
@Data @Data
public class NuclideLines implements Serializable { public class NuclideLines implements Serializable {
public List<String> fullNames; // 核素全名 public List<String> fullNames; // 核素全名
public List<Double> vEnergy; // 核素的所有γ射线能量 public List<Double> venergy; // 核素的所有γ射线能量
public List<Double> vUncertE; public List<Double> vuncertE;
public List<Double> vYield; // 核素γ射线分支比 public List<Double> vyield; // 核素γ射线分支比
public List<Double> vUncertY; public List<Double> vuncertY;
public double halflife;// 单位 public double halflife;// 单位
public int key_flag; // 记录主射线下标 public int key_flag; // 记录主射线下标
public int maxYeildIdx; public int maxYeildIdx;
@ -22,10 +22,10 @@ public class NuclideLines implements Serializable {
key_flag = -1; key_flag = -1;
halflife = 0; halflife = 0;
fullNames=new LinkedList<>(); fullNames=new LinkedList<>();
vEnergy=new LinkedList<>(); venergy=new LinkedList<>();
vUncertE=new LinkedList<>(); vuncertE=new LinkedList<>();
vYield=new LinkedList<>(); vyield=new LinkedList<>();
vUncertY=new LinkedList<>(); vuncertY=new LinkedList<>();
} }
} }

View File

@ -13,6 +13,10 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class PHDFile implements Serializable { public class PHDFile implements Serializable {
private String userId;
private String xmlFilePath;
private boolean isValid; // 是否有效谱 private boolean isValid; // 是否有效谱
private boolean bAnalyed; // 记录是否被分析 private boolean bAnalyed; // 记录是否被分析

View File

@ -46,7 +46,7 @@ public class SpecSetup implements Serializable {
public SpecSetup(){ public SpecSetup(){
eCutAnalysis_Low = 12.0; eCutAnalysis_Low = 12.0;
eCutAnalysis_High = 12.0; eCutAnalysis_High = -9999.0;
energyTolerance = 0.5; energyTolerance = 0.5;
calibrationPSS_high = 10.0; calibrationPSS_high = 10.0;
calibrationPSS_low = 5.0; calibrationPSS_low = 5.0;

View File

@ -1603,8 +1603,8 @@ public class GammaFileUtil {
} }
FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线
List<Double> vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 List<Double> vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vYield; List<Double> vYield = iter.getValue().vyield;
List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率
List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识
for (int i=0; i<vEnergy.size(); i++){ for (int i=0; i<vEnergy.size(); i++){
@ -1690,9 +1690,9 @@ public class GammaFileUtil {
ActMda.getVPeakIdx().add(peakIdx+1); ActMda.getVPeakIdx().add(peakIdx+1);
ActMda.getFullNames().add(iter.getValue().fullNames.get(ii)); ActMda.getFullNames().add(iter.getValue().fullNames.get(ii));
ActMda.getVEnergy().add(vEnergy.get(ii)); ActMda.getVEnergy().add(vEnergy.get(ii));
ActMda.getVUncertE().add(iter.getValue().vUncertE.get(ii)); ActMda.getVUncertE().add(iter.getValue().vuncertE.get(ii));
ActMda.getVYield().add(vYield.get(ii)); ActMda.getVYield().add(vYield.get(ii));
ActMda.getVUncertY().add(iter.getValue().vUncertY.get(ii)); ActMda.getVUncertY().add(iter.getValue().vuncertY.get(ii));
++fitLineNum; ++fitLineNum;
} }
} }
@ -1741,14 +1741,14 @@ public class GammaFileUtil {
} }
private void FilterNuclideLine(NuclideLines lines, double lowE) { private void FilterNuclideLine(NuclideLines lines, double lowE) {
List<Double> vE = lines.vEnergy; List<Double> vE = lines.venergy;
for(int i=0, j=0; i<vE.size(); ++i) { for(int i=0, j=0; i<vE.size(); ++i) {
if(vE.get(i) < lowE) { if(vE.get(i) < lowE) {
lines.fullNames.remove(j); lines.fullNames.remove(j);
lines.vEnergy.remove(lines.vEnergy.get(0)+j); lines.venergy.remove(lines.venergy.get(0)+j);
lines.vYield.remove(lines.vYield.get(0)+j); lines.vyield.remove(lines.vyield.get(0)+j);
lines.vUncertE.remove(lines.vUncertE.get(0)+j); lines.vuncertE.remove(lines.vuncertE.get(0)+j);
lines.vUncertY.remove(lines.vUncertY.get(0)+j); lines.vuncertY.remove(lines.vuncertY.get(0)+j);
if(i == lines.key_flag){ if(i == lines.key_flag){
lines.key_flag = -1; lines.key_flag = -1;
} else if(i < lines.key_flag){ } else if(i < lines.key_flag){
@ -1758,8 +1758,8 @@ public class GammaFileUtil {
++j; ++j;
} }
} }
if(lines.key_flag < 0 && lines.vEnergy.size() > 0) { if(lines.key_flag < 0 && lines.venergy.size() > 0) {
List<Double> vY = lines.vYield; List<Double> vY = lines.vyield;
lines.maxYeildIdx = 0; lines.maxYeildIdx = 0;
double maxYield = vY.get(0); double maxYield = vY.get(0);
for(int ii=1; ii<vY.size(); ++ii) { for(int ii=1; ii<vY.size(); ++ii) {
@ -1843,10 +1843,10 @@ public class GammaFileUtil {
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) { for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName()); nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVEnergy().add(nuclideLineList.get(j).getEnergy()); nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVUncertE().add(nuclideLineList.get(j).getEnergy_uncert()); nlines.getVuncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVYield().add(nuclideLineList.get(j).getYield() / 100); nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVUncertY().add(nuclideLineList.get(j).getYield_uncert()); nlines.getVuncertY().add(nuclideLineList.get(j).getYield_uncert());
if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) { if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) {
nlines.key_flag = j; nlines.key_flag = j;
nlines.maxYeildIdx = j; nlines.maxYeildIdx = j;
@ -3932,7 +3932,7 @@ public class GammaFileUtil {
ReadSpecialNuclides(mapHalflife, vNuclides); ReadSpecialNuclides(mapHalflife, vNuclides);
double energyWidth = phd.getUsedSetting().getEnergyTolerance(); double energyWidth = phd.getUsedSetting().getEnergyTolerance();
List<Double> vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 List<Double> vEnergy = lines.venergy; // 该核素的所有γ射线能量
double maxYield = 0; double maxYield = 0;
int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 int mainPeakIdx = -1; // 记录核素主γ峰的索引下标
@ -3945,9 +3945,9 @@ public class GammaFileUtil {
break; break;
} else if(vEnergy.get(i) <= energy + energyWidth) { } else if(vEnergy.get(i) <= energy + energyWidth) {
ActMda.getVEnergy().add(vEnergy.get(i)); ActMda.getVEnergy().add(vEnergy.get(i));
ActMda.getVUncertE().add(lines.vUncertE.get(i)); ActMda.getVUncertE().add(lines.vuncertE.get(i));
ActMda.getVYield().add(lines.vYield.get(i)); ActMda.getVYield().add(lines.vyield.get(i));
ActMda.getVUncertY().add(lines.vUncertY.get(i)); ActMda.getVUncertY().add(lines.vuncertY.get(i));
ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i));
ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1);
if(lines.key_flag == i) { if(lines.key_flag == i) {

View File

@ -1,9 +1,13 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import com.alibaba.fastjson.JSONObject;
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.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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.ejml.simple.SimpleMatrix; import org.ejml.simple.SimpleMatrix;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
@ -101,7 +105,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 (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)) {
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);
@ -117,7 +121,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 (StringUtils.isNotBlank(struct.acquisition_start_date) && 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);
@ -130,7 +134,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) && 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);
@ -143,7 +147,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 {
@ -151,14 +155,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 (StringUtils.isNotBlank(struct.date_calibration) && 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) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && 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);
@ -176,7 +180,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);
@ -192,7 +196,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);
@ -201,7 +205,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);
@ -210,7 +214,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);
@ -219,7 +223,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);
@ -365,10 +369,7 @@ public class GammaFileUtil {
String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; String baselineFileName = "RNAUTO_"+subFileName + ".baseline";
inputStream = ftpClient.retrieveFileStream(baselineFileName); inputStream = ftpClient.retrieveFileStream(baselineFileName);
if (Objects.nonNull(inputStream)){ if (Objects.nonNull(inputStream)){
long start = System.currentTimeMillis();
ReadBaseCtrlInfo(phd, inputStream); ReadBaseCtrlInfo(phd, inputStream);
long end = System.currentTimeMillis();
System.out.println(end-start);
phd.setVBase(phd.getBaseCtrls().getBaseline()); phd.setVBase(phd.getBaseCtrls().getBaseline());
} }
} catch (IOException e) { } catch (IOException e) {
@ -1469,7 +1470,7 @@ public class GammaFileUtil {
return datalist; return datalist;
} }
public boolean AnalyseData(PHDFile phd, ConfigureData configureData, List<String> nuclides, boolean bSingle) { public int AnalyseData(PHDFile phd, ConfigureData configureData, List<String> nuclides, Result result) {
//调用方法判断是否修改了参数 //调用方法判断是否修改了参数
if (Objects.nonNull(configureData)){ if (Objects.nonNull(configureData)){
SpecSetup phdSetting = phd.getSetting(); SpecSetup phdSetting = phd.getSetting();
@ -1487,8 +1488,9 @@ public class GammaFileUtil {
} }
int change = SettingChanged(phd); int change = SettingChanged(phd);
if(change == 0 && phd.getVPeak().size() > 0) return false; if(change == 0 && phd.getVPeak().size() > 0) {
else if(change == -1) { return change;
} else if(change == -1) {
phd.setUsedEffi(phd.getNewEffi()); phd.setUsedEffi(phd.getNewEffi());
phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi())); phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi()));
phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi())); phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi()));
@ -1496,24 +1498,31 @@ public class GammaFileUtil {
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides); Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
NuclidesIdent(phd, nuclideLinesMap); NuclidesIdent(phd, nuclideLinesMap);
RunQC(phd); RunQC(phd);
String Warning = "Finish three tasks:\n"+ result.error500("Finish three tasks:\n"+
"\t1.Update efficiencies of all peaks;\n"+ "\t1.Update efficiencies of all peaks;\n"+
"\t2.Identify nuclides again;\n"+ "\t2.Identify nuclides again;\n"+
"\t3.Test QC again."; "\t3.Test QC again.");
} else { } else {
if(bSingle) { Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
// AnalyseFlowChart flow_dlg(this); AnalyseSpectrum(phd, nuclideLinesMap);
// flow_dlg.exec();
} else {
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
// AnalyseSpectrum(phd, nuclideLinesMap);
}
} }
return true; return change;
} }
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> map){ public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
return false; System.loadLibrary("GammaAnaly");
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String mapLinesStr = mapper.writeValueAsString(mapLines);
String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, "");
JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum);
String jsonString = jsonObject.toJSONString();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return true;
} }
public int SettingChanged(PHDFile phd) { public int SettingChanged(PHDFile phd) {
@ -1598,8 +1607,8 @@ public class GammaFileUtil {
} }
FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线
List<Double> vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 List<Double> vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vYield; List<Double> vYield = iter.getValue().vyield;
List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率
List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识
for (int i=0; i<vEnergy.size(); i++){ for (int i=0; i<vEnergy.size(); i++){
@ -1685,9 +1694,9 @@ public class GammaFileUtil {
ActMda.getVPeakIdx().add(peakIdx+1); ActMda.getVPeakIdx().add(peakIdx+1);
ActMda.getFullNames().add(iter.getValue().fullNames.get(ii)); ActMda.getFullNames().add(iter.getValue().fullNames.get(ii));
ActMda.getVEnergy().add(vEnergy.get(ii)); ActMda.getVEnergy().add(vEnergy.get(ii));
ActMda.getVUncertE().add(iter.getValue().vUncertE.get(ii)); ActMda.getVUncertE().add(iter.getValue().vuncertE.get(ii));
ActMda.getVYield().add(vYield.get(ii)); ActMda.getVYield().add(vYield.get(ii));
ActMda.getVUncertY().add(iter.getValue().vUncertY.get(ii)); ActMda.getVUncertY().add(iter.getValue().vuncertY.get(ii));
++fitLineNum; ++fitLineNum;
} }
} }
@ -1736,14 +1745,14 @@ public class GammaFileUtil {
} }
private void FilterNuclideLine(NuclideLines lines, double lowE) { private void FilterNuclideLine(NuclideLines lines, double lowE) {
List<Double> vE = lines.vEnergy; List<Double> vE = lines.venergy;
for(int i=0, j=0; i<vE.size(); ++i) { for(int i=0, j=0; i<vE.size(); ++i) {
if(vE.get(i) < lowE) { if(vE.get(i) < lowE) {
lines.fullNames.remove(j); lines.fullNames.remove(j);
lines.vEnergy.remove(lines.vEnergy.get(0)+j); lines.venergy.remove(lines.venergy.get(0)+j);
lines.vYield.remove(lines.vYield.get(0)+j); lines.vyield.remove(lines.vyield.get(0)+j);
lines.vUncertE.remove(lines.vUncertE.get(0)+j); lines.vuncertE.remove(lines.vuncertE.get(0)+j);
lines.vUncertY.remove(lines.vUncertY.get(0)+j); lines.vuncertY.remove(lines.vuncertY.get(0)+j);
if(i == lines.key_flag){ if(i == lines.key_flag){
lines.key_flag = -1; lines.key_flag = -1;
} else if(i < lines.key_flag){ } else if(i < lines.key_flag){
@ -1753,8 +1762,8 @@ public class GammaFileUtil {
++j; ++j;
} }
} }
if(lines.key_flag < 0 && lines.vEnergy.size() > 0) { if(lines.key_flag < 0 && lines.venergy.size() > 0) {
List<Double> vY = lines.vYield; List<Double> vY = lines.vyield;
lines.maxYeildIdx = 0; lines.maxYeildIdx = 0;
double maxYield = vY.get(0); double maxYield = vY.get(0);
for(int ii=1; ii<vY.size(); ++ii) { for(int ii=1; ii<vY.size(); ++ii) {
@ -1838,10 +1847,10 @@ public class GammaFileUtil {
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) { for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName()); nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVEnergy().add(nuclideLineList.get(j).getEnergy()); nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVUncertE().add(nuclideLineList.get(j).getEnergy_uncert()); nlines.getVuncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVYield().add(nuclideLineList.get(j).getYield() / 100); nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVUncertY().add(nuclideLineList.get(j).getYield_uncert()); nlines.getVuncertY().add(nuclideLineList.get(j).getYield_uncert());
if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) { if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) {
nlines.key_flag = j; nlines.key_flag = j;
nlines.maxYeildIdx = j; nlines.maxYeildIdx = j;
@ -3941,7 +3950,7 @@ public class GammaFileUtil {
ReadSpecialNuclides(mapHalflife, vNuclides); ReadSpecialNuclides(mapHalflife, vNuclides);
double energyWidth = phd.getUsedSetting().getEnergyTolerance(); double energyWidth = phd.getUsedSetting().getEnergyTolerance();
List<Double> vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 List<Double> vEnergy = lines.venergy; // 该核素的所有γ射线能量
double maxYield = 0; double maxYield = 0;
int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 int mainPeakIdx = -1; // 记录核素主γ峰的索引下标
@ -3954,9 +3963,9 @@ public class GammaFileUtil {
break; break;
} else if(vEnergy.get(i) <= energy + energyWidth) { } else if(vEnergy.get(i) <= energy + energyWidth) {
ActMda.getVEnergy().add(vEnergy.get(i)); ActMda.getVEnergy().add(vEnergy.get(i));
ActMda.getVUncertE().add(lines.vUncertE.get(i)); ActMda.getVUncertE().add(lines.vuncertE.get(i));
ActMda.getVYield().add(lines.vYield.get(i)); ActMda.getVYield().add(lines.vyield.get(i));
ActMda.getVUncertY().add(lines.vUncertY.get(i)); ActMda.getVUncertY().add(lines.vuncertY.get(i));
ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i));
ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1);
if(lines.key_flag == i) { if(lines.key_flag == i) {
@ -4160,4 +4169,42 @@ public class GammaFileUtil {
return datalist; return datalist;
} }
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

@ -43,18 +43,19 @@ public class GammaController {
@GetMapping("analysisProcess") @GetMapping("analysisProcess")
@ApiOperation(value = "分析进度", notes = "分析进度") @ApiOperation(value = "分析进度", notes = "分析进度")
public void message(String message) { public void message(String message) {
Result<SysUser> user = systemClient.getUserData(); // Result<SysUser> user = systemClient.getUserData();
BaseMap params = new BaseMap(); BaseMap params = new BaseMap();
params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER); params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
params.put("userId", user.getResult().getId()); params.put("userId", "message.userId");
// userId, fileName, process
params.put("message", message); params.put("message", message);
// 通过 redis 订阅发送 websocket 消息 // 通过 redis 订阅发送 websocket 消息
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);;
} }
@GetMapping("testFun") @GetMapping("testFun")
public Result testFun(String fileName){ public Result testFun(String fileName,HttpServletRequest request){
return gammaService.testFun(fileName); return gammaService.testFun(fileName, request);
} }
@GetMapping("gammaByDB") @GetMapping("gammaByDB")

View File

@ -64,6 +64,8 @@ public class PeakInfo implements Serializable {
public PeakInfo(){ public PeakInfo(){
nuclides = new LinkedList<>(); nuclides = new LinkedList<>();
comments = ""; comments = "";
recoilBetaChan = "1";
recoilDeltaChan = "1";
} }
} }

View File

@ -1,13 +1,11 @@
package org.jeecg.modules.native_jni; package org.jeecg.modules.native_jni;
import com.alibaba.fastjson.JSON;
import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.entity.vo.StructInsertInput; import org.jeecg.modules.entity.vo.StructInsertInput;
import org.jeecg.modules.entity.vo.StructInsertOutput; import org.jeecg.modules.entity.vo.StructInsertOutput;
import org.jeecg.modules.native_jni.struct.CalValuesOut; import org.jeecg.modules.native_jni.struct.CalValuesOut;
import java.util.List; import java.util.List;
import java.util.Map;
public class CalValuesHandler { public class CalValuesHandler {
@ -27,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, List<PeakInfo> Peaks);
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow);
public static native String fitPeakFull();
} }

View File

@ -13,7 +13,7 @@ public interface IGammaService{
Result initValue(Integer sampleId, String dbName, HttpServletRequest request); Result initValue(Integer sampleId, String dbName, HttpServletRequest request);
Result testFun(String fileName); Result testFun(String fileName, HttpServletRequest request);
Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request);

View File

@ -8,13 +8,18 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
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.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.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.codehaus.jettison.json.JSONString;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache; import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.DateConstant;
@ -30,6 +35,7 @@ import org.jeecg.modules.entity.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.service.*; import org.jeecg.modules.service.*;
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.Service; import org.springframework.stereotype.Service;
@ -77,6 +83,8 @@ public class GammaServiceImpl implements IGammaService {
private FTPUtil ftpUtil; private FTPUtil ftpUtil;
@Value("${ZeroTime}") @Value("${ZeroTime}")
private String ZeroTimeStr; private String ZeroTimeStr;
@Value("${parameter.filePath}")
private String parameterFilePath;
@Autowired @Autowired
private IGardsAnalysesSpectrumService analysesSpectrumService; private IGardsAnalysesSpectrumService analysesSpectrumService;
@Autowired @Autowired
@ -144,31 +152,62 @@ public class GammaServiceImpl implements IGammaService {
} }
@Override @Override
public Result testFun(String fileName) { public Result testFun(String fileName, HttpServletRequest request) {
Result result = new Result(); Result result = new Result();
Map<String, Object> map = new HashMap<>();
Cache<String, PHDFile> phdCache = localCache.getPHDCache(); Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName); PHDFile phd = phdCache.getIfPresent(fileName);
Map<String, Object> map = new HashMap<>(); if (Objects.isNull(phd)){
System.loadLibrary("GammaAnaly"); result.error500("请先选择解析文件!");
// List<Double> baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size()); return result;
// map.put("baseInfo_s_Energy", baseInfo_s_Energy); }
// List<Double> baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size()); phd.setUserId("1");
// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll); phd.setXmlFilePath(parameterFilePath);
// List<Double> baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK()); String userName = JwtUtil.getUserNameByToken(request);
// map.put("baseInfo_s_Lc", baseInfo_s_Lc); //获取当前角色的颜色配置
// List<Double> values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts()); Map<String, String> colorMap = sysUserColorService.initColor(userName);
// List<Double> baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll); //查询当前用户关联的核素信息
// map.put("baseInfo_s_Scac", baseInfo_s_Scac); List<String> nuclides = new LinkedList<>();
// boolean armaAny = CalValuesHandler.armaAny(values); //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
// map.put("armaAny", armaAny); nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
String dataType = phd.getMsgInfo().getData_type().substring(0, 1); if (CollectionUtils.isEmpty(nuclides)){
List<Double> gEnergy = phd.getCertificate().getG_energy(); nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta()); }
map.put("calUpdateStr", calUpdateStr); Map<String, NuclideLines> nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides);
// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(), //解析获取临时文件信息
// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak()); File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName);
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String mapLines = mapper.writeValueAsString(nuclideLinesMap);
String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath());
PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class);
phd.setVLc(phdFile.getVLc());
phd.setVScac(phdFile.getVScac());
phd.setVBase(phdFile.getVBase());
phd.setVEnergy(phdFile.getVEnergy());
phd.setVPeak(phdFile.getVPeak());
for (PeakInfo peak:phd.getVPeak()) {
if (StringUtils.isBlank(peak.recoilBetaChan)) {
peak.recoilBetaChan = "1";
}
if (StringUtils.isBlank(peak.recoilDeltaChan)) {
peak.recoilDeltaChan = "1";
}
}
gammaFileUtil.UpdateChart(phd, map, colorMap);
//
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
// 更新 QC Flags 状态
List<String> qcstate = gammaFileUtil.Qcstate(phd);
map.put("QCFlag", qcstate);
phdCache.put(fileName, phd);
localCache.setPHDCache(phdCache);
result.setResult(map);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
result.setSuccess(true); result.setSuccess(true);
result.setResult(map);
return result; return result;
} }
@ -369,8 +408,19 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(nuclides)){ if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
} }
boolean flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, true); int flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, result);
if (flag){ if (flag == 0){
String warning = "The spectrum needn't Analyed. Maybe:\n"+
"1. It has already Analyed.\n"+
"2. You didn't change any setting or calibration.";
result.error500(warning);
} else if (flag == -1){
String warning = "Finish three tasks:\n"+
"\t1.Update efficiencies of all peaks;\n"+
"\t2.Identify nuclides again;\n"+
"\t3.Test QC again.";
result.error500(warning);
} else {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low()); phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low());
phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High()); phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High());
@ -386,11 +436,6 @@ public class GammaServiceImpl implements IGammaService {
gammaFileUtil.UpdateChart(phd, map, colorMap); gammaFileUtil.UpdateChart(phd, map, colorMap);
result.setSuccess(true); result.setSuccess(true);
result.setResult(map); result.setResult(map);
}else {
String warning = "The spectrum needn't Analyed. Maybe:\n"+
"1. It has already Analyed.\n"+
"2. You didn't change any setting or calibration.";
result.error500(warning);
} }
return result; return result;
} }
@ -440,6 +485,8 @@ public class GammaServiceImpl implements IGammaService {
map.put("energy", phd.getVEnergy()); map.put("energy", phd.getVEnergy());
//赋值BaseCtrls //赋值BaseCtrls
map.put("BaseCtrls", phd.getBaseCtrls()); map.put("BaseCtrls", phd.getBaseCtrls());
//FitBaseLine颜色
map.put("FitBaseLine", colorMap.get("Color_Fitbase"));
result.setSuccess(true); result.setSuccess(true);
result.setResult(map); result.setResult(map);
return result; return result;

View File

@ -76,10 +76,10 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl<GardsNuclLinesLibM
nuclideLines = result.containsKey(lib.getName()) ? result.get(lib.getName()) : new NuclideLines(); nuclideLines = result.containsKey(lib.getName()) ? result.get(lib.getName()) : new NuclideLines();
nuclideLines.getFullNames().add(lib.getFullName()); nuclideLines.getFullNames().add(lib.getFullName());
nuclideLines.getVEnergy().add(lib.getEnergy()); nuclideLines.getVenergy().add(lib.getEnergy());
nuclideLines.getVUncertE().add(lib.getEnergyUncert()); nuclideLines.getVuncertE().add(lib.getEnergyUncert());
nuclideLines.getVYield().add(lib.getYield() / 100); nuclideLines.getVyield().add(lib.getYield() / 100);
nuclideLines.getVUncertY().add(lib.getYieldUncert()); nuclideLines.getVuncertY().add(lib.getYieldUncert());
int keyFlag = lib.getKeyFlag(); int keyFlag = lib.getKeyFlag();
if (keyFlag > 0){ if (keyFlag > 0){

View File

@ -15,5 +15,5 @@ spring:
config: config:
import: import:
- optional:nacos:jeecg.yaml - optional:nacos:jeecg.yaml
- optional:nacos:jeecg-@profile.name@-pbl.yaml - optional:nacos:jeecg-@profile.name@.yaml