整合GammaFileUtil工具类

新增模块jeecg-module-BetaGammaAnalyser
移动部分实体类到jeecg-module-BetaGammaAnalyser模块下
This commit is contained in:
qiaoqinzheng 2023-10-07 16:48:07 +08:00
parent cc7775edaa
commit 950407d6da
22 changed files with 1807 additions and 4886 deletions

View File

@ -79,14 +79,15 @@ public class NameStandUtil {
}
public Map<String, String> NameStandard(PHDFile fileAnlyse) {
String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(),fileAnlyse.getHeader().getSystem_type(),fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time()));
String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(), fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time()));
Map<String, String> fileNames = NameStandardByName(fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix);
return fileNames;
}
public String GetSuffix(String dataType, String sysType, String Fulltype, String LT) {
public String GetSuffix(String dataType, String Fulltype, String LT) {
String rData = "";
BigDecimal bd = new BigDecimal(LT);
//AUX09_003-20151226_1855 _S_FULL_40184.8.PHD
//将acquisition_live_time保留一位小数 如果保留一位小数后小数点后的值是0则四舍五入保留整数否则按正常条件四舍五入保留小数位
String scale = bd.setScale(1, RoundingMode.HALF_UP).toString();
if(dataType.contains(DataType.SAMPLEPHD.getType())) {

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>3.5.1</version>
</parent>
<artifactId>jeecg-module-BetaGammaAnalyser</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 引入jeecg-boot-starter-cloud依赖 -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.ejml/ejml-simple -->
<dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-simple</artifactId>
<version>0.39</version>
</dependency>
</dependencies>
</project>

View File

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
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.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.ejml.simple.SimpleMatrix;
@ -18,9 +18,7 @@ import org.jeecg.modules.base.entity.rnman.GardsAnalySetting;
import org.jeecg.modules.base.enums.CalName;
import org.jeecg.modules.base.enums.CalType;
import org.jeecg.modules.base.enums.MiddleDataType;
import org.jeecg.modules.entity.*;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
@ -53,8 +51,6 @@ public class GammaFileUtil {
@Autowired
private SpectrumPathProperties spectrumPathProperties;
@Autowired
private SpectrumAnalysisMapper spectrumAnalysisMapper;
@Autowired
private NameStandUtil nameStandUtil;
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
@ -561,301 +557,6 @@ public class GammaFileUtil {
}
}
public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) {
//判断连接的数据库
String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting;
if (dbName.equals("auto")){
T_analy = "RNAUTO.GARDS_ANALYSES";
T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS";
T_peaks = "RNAUTO.GARDS_PEAKS";
T_param = "RNAUTO.GARDS_CALIBRATION";
T_nuc_line = "RNAUTO.GARDS_NUCL_LINES_IDED";
T_nuc_act = "RNAUTO.GARDS_NUCL_IDED";
T_qc = "RNAUTO.GARDS_QC_CHECK";
userName = "RNAUTO";
}else {
T_analy = "RNMAN.GARDS_ANALYSES";
T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS";
T_peaks = "RNMAN.GARDS_PEAKS";
T_param = "RNMAN.GARDS_CALIBRATION";
T_nuc_line = "RNMAN.GARDS_NUCL_LINES_IDED";
T_nuc_act = "RNMAN.GARDS_NUCL_IDED";
T_qc = "RNMAN.GARDS_QC_CHECK";
T_setting = "RNMAN.GARDS_ANALY_SETTING";
}
String status = spectrumAnalysisMapper.getStatus(sampleId);
if (StringUtils.isNotBlank(status)){
phd.setStatus(status);
if (!phd.getStatus().equals("P") && !phd.getStatus().equals("R")){
return false;
}
}else {
return false;
}
// 获取 ananlysis_idBaseLineLcScac峰数量Category谱注释等信息
GardsAnalysesSpectrum analysis = spectrumAnalysisMapper.getAnalysis(T_analy, sampleId, userName);
int peakNum = 0;
if (Objects.nonNull(analysis)){
phd.setId_analysis(analysis.getIdAnalysis().toString());
phd.setBaseline_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getBaselinePath());
phd.setLc_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getLcPath());
phd.setScac_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getScacPath());
peakNum = analysis.getNumberOfPeaks();
phd.setTotalCmt(analysis.getComments());
phd.getBaseCtrls().setRg_low(analysis.getSearchStartChannel());
phd.getBaseCtrls().setRg_high(analysis.getSearchEndChannel());
phd.getUsedSetting().setEnergyTolerance(analysis.getSearchThreshold());
} else {
result.error500("There are 0 records when sample_id is "+sampleId+"!");
return false;
}
if (peakNum>0){
// 获取峰信息列表
List<GardsPeaksSpectrum> peaks = spectrumAnalysisMapper.getPeaks(T_peaks, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(peaks)){
for (GardsPeaksSpectrum peaksSpectrum:peaks) {
PeakInfo peakInfo = new PeakInfo();
peakInfo.index = peaksSpectrum.getIdPeak()==null?0:peaksSpectrum.getIdPeak();
peakInfo.multiIndex = peaksSpectrum.getMulitiIndex()==null?0:peaksSpectrum.getMulitiIndex().intValue();
peakInfo.left = peaksSpectrum.getRoiStart()==null?0:peaksSpectrum.getRoiStart().intValue();
peakInfo.right = peaksSpectrum.getRoiEnd()==null?0:peaksSpectrum.getRoiEnd().intValue();
peakInfo.peakCentroid = peaksSpectrum.getCentroidChannel()==null?0:peaksSpectrum.getCentroidChannel();
peakInfo.energy = peaksSpectrum.getEnergy()==null?0:peaksSpectrum.getEnergy();
peakInfo.fwhmc = peaksSpectrum.getFwtm()==null?0:peaksSpectrum.getFwtm();
peakInfo.fwhm = peaksSpectrum.getFwhm()==null?0:peaksSpectrum.getFwhm();
peakInfo.area = peaksSpectrum.getArea()==null?0:peaksSpectrum.getArea();
peakInfo.areaErr = peaksSpectrum.getUncArea()==null?0:peaksSpectrum.getUncArea();
peakInfo.efficiency = peaksSpectrum.getEfficiency()==null?0:peaksSpectrum.getEfficiency();
peakInfo.lc = peaksSpectrum.getLc()==null?0:peaksSpectrum.getLc();
peakInfo.ld = peaksSpectrum.getLd()==null?0:peaksSpectrum.getLd();
peakInfo.meanBackCount = peaksSpectrum.getMeanbackcount()==null?0:peaksSpectrum.getMeanbackcount();
peakInfo.backgroundArea = peaksSpectrum.getBackgroundarea()==null?0:peaksSpectrum.getBackgroundarea();
peakInfo.significance = peaksSpectrum.getSignificance()==null?0:peaksSpectrum.getSignificance();
peakInfo.sensitivity = peaksSpectrum.getSensitivity()==null?0:peaksSpectrum.getSensitivity();
peakInfo.stepRatio = peaksSpectrum.getStepraio()==null?0:peaksSpectrum.getStepraio();
peakInfo.tail = peaksSpectrum.getTail()==null?0:peaksSpectrum.getTail();
peakInfo.tailAlpha = peaksSpectrum.getTailAlpha()==null?0:peaksSpectrum.getTailAlpha();
peakInfo.upperTail = peaksSpectrum.getUpperTail()==null?0:peaksSpectrum.getUpperTail();
peakInfo.upperTailAlpha = peaksSpectrum.getUpperTailAlpha()==null?0:peaksSpectrum.getUpperTailAlpha();
peakInfo.BWWidthChan = peaksSpectrum.getBwwidthchan()==null?0:peaksSpectrum.getBwwidthchan();
peakInfo.recoilBetaChan = "1";
peakInfo.recoilDeltaChan = peaksSpectrum.getRecoildeltachan()==null?"1":peaksSpectrum.getRecoildeltachan().toString();
peakInfo.comments = StringUtils.isNotBlank(peaksSpectrum.getPeakcomments())?peaksSpectrum.getPeakcomments():"";
phd.getVPeak().add(peakInfo);
}
}
}
// 获取刻度点数据
List<GardsCalibrationPairsSpectrum> calibrationPairs = spectrumAnalysisMapper.getCalibrationPairs(T_calib, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(calibrationPairs)){
GEnergyBlock gEnergyBlock = new GEnergyBlock();
GResolutionBlock gResolutionBlock = new GResolutionBlock();
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
TotaleffBlock totaleffBlock = new TotaleffBlock();
for (GardsCalibrationPairsSpectrum pairsSpectrum:calibrationPairs) {
String calType = pairsSpectrum.getCaltype().trim();
if(calType.equals(CalType.ENERGY_CAL.getType())) {
phd.setUsedEner(pairsSpectrum.getInput());
gEnergyBlock.getCentroid_channel().add(pairsSpectrum.getXValue());
gEnergyBlock.getG_energy().add(pairsSpectrum.getYValue());
gEnergyBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0:Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.RESOLUTION_CAL.getType())) {
phd.setUsedReso(pairsSpectrum.getInput());
gResolutionBlock.getG_energy().add(pairsSpectrum.getXValue());
gResolutionBlock.getFWHM().add(pairsSpectrum.getYValue());
gResolutionBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.EFFICIENCY_CAL.getType())) {
phd.setUsedEffi(pairsSpectrum.getInput());
gEfficiencyBlock.getG_energy().add(pairsSpectrum.getXValue());
gEfficiencyBlock.getEfficiency().add(pairsSpectrum.getYValue());
gEfficiencyBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.TOTALEFFICIENCY_CAL.getType())) {
phd.setUsedTotE(pairsSpectrum.getInput());
totaleffBlock.getG_energy().add(pairsSpectrum.getXValue());
totaleffBlock.getTotal_efficiency().add(pairsSpectrum.getYValue());
totaleffBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
}
}
if (phd.getUsedEner().isEmpty()){
phd.setUsedEner(CalName.CalPHD.getType());
}
if (phd.getUsedReso().isEmpty()){
phd.setUsedReso(CalName.CalPHD.getType());
}
if (phd.getUsedEffi().isEmpty()){
phd.setUsedEffi(CalName.CalPHD.getType());
}
if (phd.getUsedTotE().isEmpty()){
phd.setUsedTotE(CalName.CalPHD.getType());
}
gEnergyBlock.setRecord_count(gEnergyBlock.getG_energy().size());
gResolutionBlock.setRecord_count(gResolutionBlock.getG_energy().size());
gEfficiencyBlock.setRecord_count(gEfficiencyBlock.getG_energy().size());
totaleffBlock.setRecord_count(totaleffBlock.getG_energy().size());
if(gEnergyBlock.getRecord_count() > 0) {
phd.setUsedEnerKD(gEnergyBlock);
phd.getMapEnerKD().put(phd.getUsedEner(), gEnergyBlock);
}
if(gResolutionBlock.getRecord_count() > 0) {
phd.setUsedResoKD(gResolutionBlock);
phd.getMapResoKD().put(phd.getUsedReso(), gResolutionBlock);
}
if(gEfficiencyBlock.getRecord_count() > 0) {
phd.setUsedEffiKD(gEfficiencyBlock);
phd.getMapEffiKD().put(phd.getUsedEffi(), gEfficiencyBlock);
}
if(totaleffBlock.getRecord_count() > 0) {
phd.setUsedTotEKD(totaleffBlock);
phd.getMapTotEKD().put(phd.getUsedTotE(), totaleffBlock);
}
}
// 获取刻度拟合系数
List<GardsCalibrationSpectrum> paras = spectrumAnalysisMapper.getPara(T_param, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(paras)){
for (GardsCalibrationSpectrum calibrationSpectrum:paras) {
ParameterInfo para = new ParameterInfo();
String calType = calibrationSpectrum.getCalType().trim();
para.getP().add(calibrationSpectrum.getFunction().doubleValue());
String[] list_coeff = calibrationSpectrum.getCoeffString().split(StringPool.COMMA);
for (String str:list_coeff) {
para.getP().add(Double.valueOf(str));
para.getPerr().add(0.0);
}
if(calType.equals(CalType.ENERGY_CAL.getType())) {
phd.setUsedEnerPara(para);
phd.getMapEnerPara().put(phd.getUsedEner(), para);
phd.setNewEner(phd.getUsedEner());
} else if(calType.equals(CalType.RESOLUTION_CAL.getType())) {
phd.setUsedResoPara(para);
phd.getMapResoPara().put(phd.getUsedReso(), para);
phd.setNewReso(phd.getUsedReso());
} else if(calType.equals(CalType.EFFICIENCY_CAL.getType())) {
phd.setUsedEffiPara(para);
phd.getMapEffiPara().put(phd.getUsedEffi(), para);
phd.setNewEffi(phd.getUsedEffi());
} else if(calType.equals(CalType.TOTALEFFICIENCY_CAL.getType())) {
phd.setUsedTotEPara(para);
phd.getMapTotEPara().put(phd.getUsedTotE(), para);
phd.setNewTotE(phd.getUsedTotE());
}
}
}
// 获取被识别核素射线信息
List<GardsNuclLinesIdedSpectrum> nuclLinesIdeds = spectrumAnalysisMapper.getNuclLinesIded(T_nuc_line, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(nuclLinesIdeds)){
for (GardsNuclLinesIdedSpectrum nuclLinesIdedSpectrum:nuclLinesIdeds) {
String str_key = nuclLinesIdedSpectrum.getNuclideName();
phd.getMapNucActMda().put(str_key, new NuclideActMda());
if(Objects.nonNull(phd.getMapNucActMda().get(str_key))) {
phd.getMapNucActMda().get(str_key).setActivity(Double.valueOf(nuclLinesIdedSpectrum.getActivity()));
phd.getMapNucActMda().get(str_key).setAct_err(nuclLinesIdedSpectrum.getUncActivity());
phd.getMapNucActMda().get(str_key).setEfficiency(nuclLinesIdedSpectrum.getEffic());
phd.getMapNucActMda().get(str_key).setEffi_err(nuclLinesIdedSpectrum.getUnEffic());
phd.getMapNucActMda().get(str_key).setMda(nuclLinesIdedSpectrum.getMda());
phd.getMapNucActMda().get(str_key).setMdc(Double.valueOf(nuclLinesIdedSpectrum.getMdc()));
phd.getMapNucActMda().get(str_key).setConcentration(Double.valueOf(nuclLinesIdedSpectrum.getConcentration()));
if(phd.getMapNucActMda().get(str_key).getActivity() > 0){
phd.getMapNucActMda().get(str_key).setBCalculateMDA(true);
}
}
if(nuclLinesIdedSpectrum.getKeyFlag().toString().equals("1")){
phd.getMapNucActMda().get(str_key).setKey_flag(phd.getMapNucActMda().get(str_key).getVYield().size());
}
phd.getMapNucActMda().get(str_key).getFullNames().add(nuclLinesIdedSpectrum.getNuclidefullname());
phd.getMapNucActMda().get(str_key).getVEnergy().add(nuclLinesIdedSpectrum.getEnergy());
phd.getMapNucActMda().get(str_key).getVUncertE().add(nuclLinesIdedSpectrum.getUncEnergy());
phd.getMapNucActMda().get(str_key).getVYield().add(nuclLinesIdedSpectrum.getAbundance());
phd.getMapNucActMda().get(str_key).getVUncertY().add(nuclLinesIdedSpectrum.getUncAbundance());
int idx = nuclLinesIdedSpectrum.getIdPeak() - 1;
if(idx >= 0 && idx < peakNum) {
phd.getMapNucActMda().get(str_key).getVPeakIdx().add(idx+1);
if(!phd.getVPeak().get(idx).nuclides.contains(str_key)){
phd.getVPeak().get(idx).nuclides.add(str_key);
}
}
}
}
// 获取被识别核素的活度浓度
List<GardsNuclIdedSpectrum> nuclIdeds = spectrumAnalysisMapper.getNuclIded(T_nuc_act, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(nuclIdeds)){
for (GardsNuclIdedSpectrum nuclIdedSpectrum:nuclIdeds) {
String str_key = nuclIdedSpectrum.getNuclideName();
if(Objects.nonNull(phd.getMapNucActMda().get(str_key))) {
phd.getMapNucActMda().get(str_key).setHalflife(Double.valueOf(nuclIdedSpectrum.getHalflife()));
List<Double> vEner = phd.getMapNucActMda().get(str_key).getVEnergy();
Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy());
for(int i=0; i<vEner.size(); i++) {
if(Math.abs(vEner.get(i) - key_ener) < 1E-6) {
phd.getMapNucActMda().get(str_key).setCalculateIdx(i);
break;
}
}
}
}
}
// 获取 QC 结果
List<GardsQcCheckSpectrum> qcChecks = spectrumAnalysisMapper.getQcCheck(T_qc, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(qcChecks)){
for (GardsQcCheckSpectrum qcCheckSpectrum:qcChecks) {
String str_key = qcCheckSpectrum.getQcName();
QcCheckItem qcCheckItem = new QcCheckItem();
qcCheckItem.setValue(qcCheckSpectrum.getQcValue());
qcCheckItem.setBPass(qcCheckSpectrum.getQcResult() == 1);
qcCheckItem.setStandard(qcCheckSpectrum.getQcStandard());
phd.getQcItems().put(str_key, qcCheckItem);
}
}
// RNMAN.GARDS_ANALY_SETTING 表读分析设置
if (dbName.equals("auto")){
GardsAnalySetting analySetting = spectrumAnalysisMapper.getAnalySetting(analysis.getIdAnalysis());
if (Objects.nonNull(analySetting)){
phd.getUsedSetting().setECutAnalysis_Low(analySetting.getEcutanalysisLow());
double t_d = analySetting.getEcutanalysisHigh();
phd.getUsedSetting().setECutAnalysis_High((t_d <= phd.getUsedSetting().getECutAnalysis_Low() ? 0 : t_d));
phd.getUsedSetting().setEnergyTolerance(analySetting.getEnergytolerance());
phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh());
phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow());
phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss());
phd.getUsedSetting().setPss_low(analySetting.getPssLow());
phd.getUsedSetting().setK_back(analySetting.getKBack());
phd.getUsedSetting().setK_alpha(analySetting.getKAlpha());
phd.getUsedSetting().setK_beta(analySetting.getKBeta());
phd.getUsedSetting().setRiskLevelK(analySetting.getRisklevelk());
phd.getUsedSetting().setBUpdateCal(analySetting.getBupdatecal() == 1);
phd.getUsedSetting().setKeepCalPeakSearchPeaks(analySetting.getKeepcalpeakserchpeaks() == 1);
Date reftimeAct = analySetting.getReftimeAct();
if(Objects.nonNull(reftimeAct)){
phd.getUsedSetting().setRefTime_act(reftimeAct);
}
Date reftimeConc = analySetting.getReftimeConc();
if(Objects.nonNull(reftimeConc)){
phd.getUsedSetting().setRefTime_conc(reftimeConc);
}
}
}
if(!phd.getUsedEnerPara().getP().isEmpty()) {
List<Double> vChan = new LinkedList<>();
double c = 1;
while(c <= phd.getSpec().getNum_g_channel()) {
vChan.add(c);
c += 1;
}
System.loadLibrary("GammaAnaly");
CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP());
phd.setVEnergy(calValuesOut.counts);
phd.setBAnalyed(true);
}
return true;
}
public List<String> Qcstate(PHDFile phd) {
// Collection Time Acq Time Decay Time SampVol Be7-FWHM Ba140-MDC Xe133-MDC
List<String> qcState = new LinkedList<>();
@ -1654,7 +1355,7 @@ public class GammaFileUtil {
return datalist;
}
public int AnalyseData(PHDFile phd, List<String> nuclides) {
public int AnalyseData(PHDFile phd) {
//判断phdFile内容是否有进行改变
int change = SettingChanged(phd);
//change == 0 vPeak的集合大小大于0 说明内容没有变化
@ -1665,13 +1366,8 @@ public class GammaFileUtil {
phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi()));
phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi()));
UpdateEfficiency(phd);
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
NuclidesIdent(phd, nuclideLinesMap);
RunQC(phd);
} else {
change = 1;
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
AnalyseSpectrum(phd, nuclideLinesMap);
}
return change;
}
@ -1911,8 +1607,6 @@ public class GammaFileUtil {
peak.recoilDeltaChan = "1";
}
}
//重新分析各峰值对应的核素信息
NuclidesIdent(phd, mapLines);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
} finally {
@ -2248,36 +1942,6 @@ public class GammaFileUtil {
}
}
public Map<String, NuclideLines> GetNuclideLines(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if(nuclideList.size() < 1){
return mapLines;
}
for(String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergyUncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYieldUncert());
if(Objects.nonNull(nuclideLineList.get(j).getKeyFlag()) && nuclideLineList.get(j).getKeyFlag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
}
mapLines.put(name, nlines);
}
List<HalfData> halfs = spectrumAnalysisMapper.getHalf(nuclideList);
for(int m=0;m<halfs.size();m++) {
NuclideLines nuclideLines = mapLines.get(halfs.get(m).getName());
nuclideLines.setHalflife(halfs.get(m).getHalf()==null? 0 : halfs.get(m).getHalf() * 86400);// 将天转换成秒
mapLines.put(halfs.get(m).getName(), nuclideLines);
}
return mapLines;
}
public ChartData Channel_BaseLine(PHDFile phd, long m_nCount, String color) {
ChartData cData = new ChartData();
int start =0;
@ -2696,103 +2360,6 @@ public class GammaFileUtil {
map.put("AllData", datalist);
}
public List<GardsNuclLinesLib> InitNuclideLine(String editEnergy, double err, String name) {
Double min = null;
Double max = null;
if (StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)){
double editEnergyDou = Double.valueOf(editEnergy);
min = editEnergyDou - err;
max = editEnergyDou + err;
}
List<GardsNuclLinesLib> nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name);
return nuclideLines;
}
public Map<String, String> InitNuclideInfo(String name) {
Map<String, String> map = new HashMap<>();
GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name);
if(Objects.nonNull(nuclideInfo)) {
Long numLines = nuclideInfo.getNumLines();
map.put("lab_lines", numLines.toString());
if(Objects.isNull(nuclideInfo.getHalflife())) {
map.put("lab_halfLife", "");
} else {
String units = "D";
double halflife = nuclideInfo.getHalflife().doubleValue();
if(halflife >= 1000) {
halflife = halflife / 365.25;
units = "A";
} else if(halflife < 0.1 && halflife >= 1.0 / 1440.0) {
halflife = halflife * 1440.0;
units = "M";
} else if(halflife <= 1.0 / 1440.0 && halflife > 0.0) {
halflife = halflife * 86400.0;
units = "S";
}
char flag = 'f';
if(halflife >= 1000){
flag = 'e';
}
if (flag == 'f'){
map.put("lab_halfLife", String.format("%.3f", halflife)+units);
} else if (flag == 'e') {
NumberFormat numberFormat = new DecimalFormat("0.###E0");
String formatNum = numberFormat.format(halflife);
map.put("lab_halfLife", formatNum+units);
}
}
if(Objects.isNull(nuclideInfo.getHalflifeErr())) {
map.put("lab_halfLifeErr", "");
} else {
map.put("lab_halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue())+"%");
}
}
return map;
}
public Map<String, Object> InitParentAndDaughter(String name) {
Map<String, Object> map = new HashMap<>();
GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name);
List<String> parentList = new LinkedList<>();
if(Objects.nonNull(parentAndDaughter)) {
parentList.add(parentAndDaughter.getParents1());
parentList.add(parentAndDaughter.getParents2());
parentList.add(parentAndDaughter.getParents3());
parentList.add(parentAndDaughter.getParents4());
parentList.add(parentAndDaughter.getParents5());
parentList.add(parentAndDaughter.getParents6());
map.put("list_parent", parentList);
List<TableDaughter> daughterList = new LinkedList<>();
TableDaughter tableDaughter1 = new TableDaughter();
tableDaughter1.setDaughters(parentAndDaughter.getDaughters1());
tableDaughter1.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios1().doubleValue())+"%");
tableDaughter1.setDaughtersstable(parentAndDaughter.getDaughtersstable1().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter1);
TableDaughter tableDaughter2 = new TableDaughter();
tableDaughter2.setDaughters(parentAndDaughter.getDaughters2());
tableDaughter2.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios2().doubleValue())+"%");
tableDaughter2.setDaughtersstable(parentAndDaughter.getDaughtersstable2().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter2);
TableDaughter tableDaughter3 = new TableDaughter();
tableDaughter3.setDaughters(parentAndDaughter.getDaughters3());
tableDaughter3.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios3().doubleValue())+"%");
tableDaughter3.setDaughtersstable(parentAndDaughter.getDaughtersstable3().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter3);
TableDaughter tableDaughter4 = new TableDaughter();
tableDaughter4.setDaughters(parentAndDaughter.getDaughters4());
tableDaughter4.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios4().doubleValue())+"%");
tableDaughter4.setDaughtersstable(parentAndDaughter.getDaughtersstable4().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter4);
TableDaughter tableDaughter5 = new TableDaughter();
tableDaughter5.setDaughters(parentAndDaughter.getDaughters5());
tableDaughter5.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios5().doubleValue())+"%");
tableDaughter5.setDaughtersstable(parentAndDaughter.getDaughtersstable5().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter5);
map.put("table_daughter", daughterList);
}
return map;
}
public String GetReportContent(PHDFile phd, boolean bLog) {
GStoreMiddleProcessData middleData = new GStoreMiddleProcessData();
GetInterMiddlData(phd, "", middleData);
@ -3128,14 +2695,6 @@ public class GammaFileUtil {
return strBuffer.toString();
}
public List<Double> DoubleLimit_L(List<Long> data) {
List<Double> rData = new LinkedList<>();
for(int pos=0;pos<data.size();pos++) {
rData.add(Double.valueOf(String.valueOf(data.get(pos))));
}
return rData;
}
public List<String> DoubleLimit(List data) {
List<String> rData = new LinkedList<>();
for(int pos=0;pos<data.size();pos++) {
@ -3144,19 +2703,6 @@ public class GammaFileUtil {
return rData;
}
public List<String> DoubleLimit_I(List<Double> _data) {
List<String> rdata = new LinkedList<>();
for(int pos=0;pos<_data.size();pos++) {
Double value = _data.get(pos);
if(Objects.isNull(value)) {
rdata.add("NULL");
} else {
rdata.add(String.valueOf(value));
}
}
return rdata;
}
public List<String> DoubleLimit_G(List<Double> _data) {
List<String> rdata = new LinkedList<>();
for(int pos=0;pos<_data.size();pos++) {
@ -4057,58 +3603,6 @@ public class GammaFileUtil {
return y;
}
public List<String> InitList(double energy, double tolerance, List<String> nuclides) {
if(nuclides.size() < 1){
return new LinkedList<>();
}
double min = energy - tolerance;
double max = energy + tolerance;
List<String> nuclideList = spectrumAnalysisMapper.findNuclideList(min, max, nuclides);
return nuclideList;
}
public void InitTable(String name, Map<String, Object> map, PHDFile phd, Map<String, String> colorMap) {
InitNuclideInfo(name, map);
long span = phd.getSpec().getG_energy_span();
List<GardsNuclLinesLib> nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span);
if (CollectionUtils.isNotEmpty(nuclideTableList)){
map.put("table", nuclideTableList);
InitChart(nuclideTableList, phd, map, colorMap);
}
}
public void InitNuclideInfo(String name, Map<String, Object> map) {
map.put("name", name);
GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name);
if(Objects.nonNull(nuclideInfo)) {
map.put("lines", nuclideInfo.getNumLines());
if(Objects.isNull(nuclideInfo.getHalflife())) {
map.put("halfLife", "");
} else {
String units = "D";
double halflife = nuclideInfo.getHalflife().doubleValue();
if(halflife >= 1000) {
halflife = halflife / 365.25;
units = "A";
} else if(halflife < 0.1 && halflife >= 1.0 / 1440) {
halflife = halflife * 1440;
units = "M";
} else if(halflife <= 1.0 / 1440 && halflife > 0) {
halflife = halflife * 86400;
units = "S";
}
halflife = halflife + 0.0001;
map.put("halfLife", String.format("%.3f", halflife) + units);
}
if(Objects.isNull(nuclideInfo.getHalflifeErr())) {
map.put("halfLifeErr", "");
} else {
map.put("halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue())+"%");
}
}
}
public void InitChart(List<GardsNuclLinesLib> nuclideTableList, PHDFile phd, Map<String, Object> map, Map<String, String> colorMap) {
List<Map<String, Object>> chartList = new LinkedList<>();
for (int i=0; i < nuclideTableList.size(); i++){
@ -4286,40 +3780,6 @@ public class GammaFileUtil {
return i;
}
public List<TablePeaks> FitPeakBaseLine(PHDFile phd, List<Integer> vIdx) {
List<TablePeaks> tablePeaksList = new LinkedList<>();
int peakNum = vIdx.size();
for (int i=0; i<peakNum; i++) {
int peakIdx = vIdx.get(i);
int row = i+1;
PeakInfo peak = phd.getVPeak().get(peakIdx);
TablePeaks tablePeaks = new TablePeaks();
tablePeaks.setLab(String.valueOf(peakIdx + 1));
String nuclide = "";
for (String peakNuclide:peak.nuclides) {
nuclide+=peakNuclide+";";
}
tablePeaks.setNuclide(StringUtils.isBlank(nuclide)?nuclide:nuclide.substring(0,nuclide.length()-1));
BigDecimal energy = new BigDecimal(peak.energy);
energy = energy.setScale(3, RoundingMode.HALF_UP);
tablePeaks.setEnergy(String.valueOf(energy));
BigDecimal area = new BigDecimal(peak.area);
area = area.setScale(4, RoundingMode.HALF_UP);
tablePeaks.setNetArea(String.valueOf(area));
BigDecimal fwhm = new BigDecimal(peak.fwhm);
fwhm = fwhm.setScale(5, RoundingMode.HALF_UP);
tablePeaks.setFwhm(String.valueOf(fwhm));
tablePeaks.setStep(String.valueOf(peak.area * peak.stepRatio));
double deriva = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP());
tablePeaks.setBwGamma(String.valueOf(peak.BWWidthChan * deriva));
tablePeaks.setNetAreaB(false);
tablePeaks.setCentroid(true);
tablePeaks.setFwhmB(true);
tablePeaksList.add(tablePeaks);
}
return tablePeaksList;
}
public List<PeakInfo> InitPeakTable(List<PeakInfo> vPeak) {
List<PeakInfo> result = new LinkedList<>();
for(int i=0; i<vPeak.size(); i++) {

View File

@ -0,0 +1,71 @@
package org.jeecg.modules.entity.vo;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
public class PeakInfo implements Serializable {
public int index; //峰序号
public int multiIndex; //重峰序号
public int left; //峰的左边界
public int right; //峰的右边界
public double peakCentroid; //峰拟合后加权峰中心道
public double energy;
public double fwhmc; //半高宽
public double fwhm; //以keV为单位的半高宽
public double area; //净面积
public double areaErr; //
public double efficiency;
public double lc;
public double ld;
public double meanBackCount;
public double backgroundArea;
public double significance;
public double sensitivity;
public double stepRatio;
public double tail;
public double tailAlpha;
public double upperTail;
public double upperTailAlpha;
public double BWWidthChan;
public String recoilBetaChan;
public String recoilDeltaChan;
public String comments;
public List<String> nuclides;
public PeakInfo(){
nuclides = new LinkedList<>();
comments = "";
recoilBetaChan = "1";
recoilDeltaChan = "1";
}
}

View File

@ -0,0 +1,60 @@
package org.jeecg.modules.entity.vo;
import java.io.Serializable;
import java.util.List;
public class StructInsertInput implements Serializable {
//-----------------input:------------------
public List<Double> peakCentroid;
public List<Double> fwhmc;
public List<Double> tail;
public List<Double> tailAlpha;
public List<Double> upperTail;
public List<Double> upperTailAlpha;
public List<Double> area;
public List<Double> stepRatio;
public List<Double> usedEnerPara;
public List<Double> usedResoPara;
public List<Double> usedEffiPara;
public long num_g_channel;
public long begin_channel;
public List<Double> XCtrl;
public List<Double> YCtrl;
public List<Double> YSlope;
public int rg_low;
public int rg_high;
public List<Double> para_tail;
public List<Double> para_tailAlpha;
public List<Double> para_tailRight;
public List<Double> para_tailRightAlpha;
public List<Double> para_stepRatio;
public int curChan;
public List<Double> vCount;
}

View File

@ -0,0 +1,48 @@
package org.jeecg.modules.entity.vo;
import java.io.Serializable;
import java.util.List;
public class StructInsertOutput implements Serializable {
//-----------------output:------------------
public List<Double> peakCentroid;
public List<Double> energy;
public List<Double> area;
public List<Double> sensitivity;
public List<Double> fwhm;
public List<Double> fwhmc;
public List<Double> stepRatio;
public List<Double> tail;
public List<Double> tailAlpha;
public List<Double> upperTail;
public List<Double> upperTailAlpha;
public List<Double> efficiency;
public List<Double> BWWidthChan;
public List<Double> recoilBetaChan;
public List<Double> recoilDeltaChan;
public List<Double> vIdx;
public List<Double> vLeft;
public List<Double> vRight;
public List<Double> vCentroid;
}

View File

@ -0,0 +1,30 @@
package org.jeecg.modules.native_jni;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.entity.vo.StructInsertInput;
import org.jeecg.modules.entity.vo.StructInsertOutput;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import java.util.List;
public class CalValuesHandler {
public static native CalValuesOut calFcnEval(List<Double> x, List<Double> para);
public static native CalValuesOut energyToChannel(List<Double> energy, List<Double> para);
public static native CalValuesOut calDerivEval(List<Double> channel, List<Double> para);
public static native double calDerivaOut(double Chan, List<Double> p);
public static native List<Double> interp1(PeakInfo peak, List<Double> t_base, List<Double> regChan);
public static native StructInsertOutput insertPeaks(StructInsertInput structInsertInput);
public static native List<Double> calFitPara(String type, int funcId, List<Double> x, List<Double> y, List<Double> err);
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 String analyseSpectrum(String phd, String mapLines, String phdFilePath);
}

View File

@ -0,0 +1,54 @@
package org.jeecg.modules.native_jni;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.BgBoundary;
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.List;
/**
* 能谱处理本地类
*/
public class EnergySpectrumHandler {
/**
* 获取能谱原始数据
* @param path 能谱文件路径
* @return 能谱原始数据
*/
public static native EnergySpectrumStruct getSourceData(String path);
/**
* 根据不同的拟合方法计算边界值 默认2次拟合 可以继承书写新的拟合
* @param calcBgBoundaryParam
* @return
*/
public static native BgBoundary CalcBgBoundary(CalcBgBoundaryParam calcBgBoundaryParam);
/**
* 获取 Energy
* @param centroid_channel
* @param g_energy
* @return
*/
public static native List<Double> GetFileFittingPara(List<Double> g_energy, List<Double> centroid_channel);
/**
* 根据channel 获取 Energy
* @param centroid_channel
* @param fittingPara
* @return
*/
public static native List<Double> GetFileFittingData(List<Double> centroid_channel, List<Double> fittingPara);
/**
* BetaGamma 分析算法
* @param sampleFile 样品谱文件
* @param gasFile 气体谱文件
* @param detFile 探测器本地谱文件
* @return
*/
public static native BgAnalyseResult bgAnalyse(String sampleFile, String gasFile, String detFile);
}

View File

@ -0,0 +1,89 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
public class AllGenerate {
//BgGasGenerate BgGas;
private List<Integer> g_ROI_B_Boundary_start;
private List<Integer> g_ROI_B_Boundary_stop;
private List<Integer> g_ROI_G_Boundary_start;
private List<Integer> g_ROI_G_Boundary_stop;
private List<Double> g_roi_cts; //气体本底谱感兴趣区计数
private List<Double> g_deduct_d_cts; //气体本底谱扣除探测器本底谱数据
private int g_b_fitting_type;
private int g_g_fitting_type;
private List<Double> g_b_fitting_e_c;
private List<Double> g_g_fitting_e_c;
private List<Double> g_b_fitting_c_e;
private List<Double> g_g_fitting_c_e;
//BgSampleGenerate BgSample;
// private BgBoundary s_boungdary;
private List<Integer> s_ROI_B_Boundary_start;
private List<Integer> s_ROI_B_Boundary_stop;
private List<Integer> s_ROI_G_Boundary_start;
private List<Integer> s_ROI_G_Boundary_stop;
private List<Double> s_roi_cts; //样品普感兴趣区计数
private List<Double> s_deduct_d_cts; //样品谱扣除探测器本底谱数据
private int s_b_fitting_type;
private int s_g_fitting_type;
private List<Double> s_b_fitting_e_c;
private List<Double> s_g_fitting_e_c;
private List<Double> s_b_fitting_c_e;
private List<Double> s_g_fitting_c_e;
private String s_collection_time; //采集时间
//BgOtherGenerate BgOther;
private List<Double> ROI_net_coutns; //感兴趣区净计数
private List<Double> ROI_net_err;
private List<Double> ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度
private List<Double> ROI_con_counts_factor; //感兴趣区浓度计数系数 [n..0]系数
//enum XeType{both,_131m,_133m,none};
private int XeType;
private double LC_Xe135; //LC XE135
private double LC_Xe131m; //LC XE131m
private double LC_Xe133m; //LC XE133m
private double LC_Xe133; //LC XE133
private List<Double> LC;
private List<Double> LC_CTS;
private double MDC_Xe135; //MDC XE135
private double MDC_Xe131m; //MDC XE131m
private double MDC_Xe133m; //MDC XE133m
private double MDC_Xe133; //MDC XE133
private List<Double> MDC;
private List<Double> MDC_CTS;
private double Xe135_con; //135不浓度
private double Xe135_uncer; //135不确定度
private double Xe131m_con;
private double Xe131m_uncer;
private double Xe133m_con;
private double Xe133m_uncer;
private double Xe133_con;
private double Xe133_uncer;
private List<Integer> ROI_B_Boundary_start;
private List<Integer> ROI_B_Boundary_stop;
private List<Integer> ROI_G_Boundary_start;
private List<Integer> ROI_G_Boundary_stop;
private List<Double> d_roi_cts; //探测器本底谱感兴趣区计数
// 拟合后值
private int b_fitting_type;
private int g_fitting_type;
private List<Double> b_fitting_e_c;
private List<Double> g_fitting_e_c;
private List<Double> b_fitting_c_e;
private List<Double> g_fitting_c_e;
//BgDetbgrGenerate BgDetbgr;
private List<Integer> d_ROI_B_Boundary_start;
private List<Integer> d_ROI_B_Boundary_stop;
private List<Integer> d_ROI_G_Boundary_start;
private List<Integer> d_ROI_G_Boundary_stop;
private List<Double> d_d_roi_cts; //探测器本底谱感兴趣区计数
private int d_b_fitting_type;
private int d_g_fitting_type;
private List<Double> d_b_fitting_e_c;
private List<Double> d_g_fitting_e_c;
private List<Double> d_b_fitting_c_e;
private List<Double> d_g_fitting_c_e;
}

View File

@ -0,0 +1,191 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
public class BgAnalyseResult {
/************************** GARDS_XE_RESULTS START**************************/
/************************** XE_131m **************************/
public double Xe131m_con;
public double Xe131m_uncer;
public double MDC_Xe131m;
public double LC_Xe131m;
public int XE_131m_NID_FLAG;
/************************** XE_133 **************************/
public double Xe133_con;
public double Xe133_uncer;
public double MDC_Xe133;
public double LC_Xe133;
public int XE_133_NID_FLAG;
/************************** XE_133m **************************/
public double Xe133m_con;
public double Xe133m_uncer;
public double MDC_Xe133m;
public double LC_Xe133m;
public int XE_133m_NID_FLAG;
/************************** XE_135 **************************/
public double Xe135_con;
public double Xe135_uncer;
public double MDC_Xe135;
public double LC_Xe135;
public int XE_135_NID_FLAG;
/************************** GARDS_XE_RESULTS end **************************/
/************************** GARDS_ROI_RESULTS START**************************/
public List<Integer> ROI;
public List<Double> LC;
public List<Double> s_roi_cts;
public List<Double> g_roi_cts;
public List<Double> d_roi_cts;
public List<Double> s_deduct_d_cts;
public List<Double> g_deduct_d_cts;
public List<Double> ROI_net_coutns;
public List<Double> ROI_net_coutns_err;
public List<Double> ROI_con_uncer;
public List<Double> ROI_con_uncer_err;
public List<Double> MDC;
public List<Integer> dNidFlag;
public List<Double> LC_CTS;
/************************** GARDS_ROI_RESULTS end **************************/
/************************** GARDS_CALIBRATION START**************************/
public List<Double> s_b_fitting_e_c;
public int s_b_fitting_type;
public String s_b_fitting_type_def;
public List<Double> s_g_fitting_e_c;
public int s_g_fitting_type;
public String s_g_fitting_type_def;
public List<Double> s_b_fitting_c_e;
public List<Double> s_g_fitting_c_e;
public List<Double> g_b_fitting_e_c;
public int g_b_fitting_type;
public String g_b_fitting_type_def;
public List<Double> g_g_fitting_e_c;
public int g_g_fitting_type;
public String g_g_fitting_type_def;
public List<Double> g_b_fitting_c_e;
public List<Double> g_g_fitting_c_e;
public List<Double> d_b_fitting_e_c;
public int d_b_fitting_type;
public String d_b_fitting_type_def;
public List<Double> d_g_fitting_e_c;
public int d_g_fitting_type;
public String d_g_fitting_type_def;
public List<Double> d_b_fitting_c_e;
public List<Double> d_g_fitting_c_e;
/************************** GARDS_CALIBRATION end **************************/
/************************** GARDS_ROI_CHANNELS START**************************/
public List<Integer> S_ROI;
public List<Integer> S_ROI_B_Boundary_start;
public List<Integer> S_ROI_B_Boundary_stop;
public List<Integer> S_ROI_G_Boundary_start;
public List<Integer> S_ROI_G_Boundary_stop;
public List<Integer> G_ROI;
public List<Integer> G_ROI_B_Boundary_start;
public List<Integer> G_ROI_B_Boundary_stop;
public List<Integer> G_ROI_G_Boundary_start;
public List<Integer> G_ROI_G_Boundary_stop;
public List<Integer> D_ROI;
public List<Integer> D_ROI_B_Boundary_start;
public List<Integer> D_ROI_B_Boundary_stop;
public List<Integer> D_ROI_G_Boundary_start;
public List<Integer> D_ROI_G_Boundary_stop;
/************************** GARDS_ROI_CHANNELS end **************************/
/**
* 分析结果标记true成功false失败
*/
public boolean analyse_flag;
/**
* 失败原因
*/
public String error_log;
@Override
public String toString() {
return "BgAnalyseResult{" +
"Xe131m_con=" + Xe131m_con +
", Xe131m_uncer=" + Xe131m_uncer +
", MDC_Xe131m=" + MDC_Xe131m +
", LC_Xe131m=" + LC_Xe131m +
", XE_131m_NID_FLAG=" + XE_131m_NID_FLAG +
", Xe133_con=" + Xe133_con +
", Xe133_uncer=" + Xe133_uncer +
", MDC_Xe133=" + MDC_Xe133 +
", LC_Xe133=" + LC_Xe133 +
", XE_133_NID_FLAG=" + XE_133_NID_FLAG +
", Xe133m_con=" + Xe133m_con +
", Xe133m_uncer=" + Xe133m_uncer +
", MDC_Xe133m=" + MDC_Xe133m +
", LC_Xe133m=" + LC_Xe133m +
", XE_133m_NID_FLAG=" + XE_133m_NID_FLAG +
", Xe135_con=" + Xe135_con +
", Xe135_uncer=" + Xe135_uncer +
", MDC_Xe135=" + MDC_Xe135 +
", LC_Xe135=" + LC_Xe135 +
", XE_135_NID_FLAG=" + XE_135_NID_FLAG +
", ROI=" + ROI +
", LC=" + LC +
", s_roi_cts=" + s_roi_cts +
", g_roi_cts=" + g_roi_cts +
", d_roi_cts=" + d_roi_cts +
", s_deduct_d_cts=" + s_deduct_d_cts +
", g_deduct_d_cts=" + g_deduct_d_cts +
", ROI_net_coutns=" + ROI_net_coutns +
", ROI_net_coutns_err=" + ROI_net_coutns_err +
", ROI_con_uncer=" + ROI_con_uncer +
", ROI_con_uncer_err=" + ROI_con_uncer_err +
", MDC=" + MDC +
", dNidFlag=" + dNidFlag +
", LC_CTS=" + LC_CTS +
", s_b_fitting_e_c=" + s_b_fitting_e_c +
", s_b_fitting_type=" + s_b_fitting_type +
", s_b_fitting_type_def='" + s_b_fitting_type_def + '\'' +
", s_g_fitting_e_c=" + s_g_fitting_e_c +
", s_g_fitting_type=" + s_g_fitting_type +
", s_g_fitting_type_def='" + s_g_fitting_type_def + '\'' +
", s_b_fitting_c_e=" + s_b_fitting_c_e +
", s_g_fitting_c_e=" + s_g_fitting_c_e +
", g_b_fitting_e_c=" + g_b_fitting_e_c +
", g_b_fitting_type=" + g_b_fitting_type +
", g_b_fitting_type_def='" + g_b_fitting_type_def + '\'' +
", g_g_fitting_e_c=" + g_g_fitting_e_c +
", g_g_fitting_type=" + g_g_fitting_type +
", g_g_fitting_type_def='" + g_g_fitting_type_def + '\'' +
", g_b_fitting_c_e=" + g_b_fitting_c_e +
", g_g_fitting_c_e=" + g_g_fitting_c_e +
", d_b_fitting_e_c=" + d_b_fitting_e_c +
", d_b_fitting_type=" + d_b_fitting_type +
", d_b_fitting_type_def='" + d_b_fitting_type_def + '\'' +
", d_g_fitting_e_c=" + d_g_fitting_e_c +
", d_g_fitting_type=" + d_g_fitting_type +
", d_g_fitting_type_def='" + d_g_fitting_type_def + '\'' +
", d_b_fitting_c_e=" + d_b_fitting_c_e +
", d_g_fitting_c_e=" + d_g_fitting_c_e +
", S_ROI=" + S_ROI +
", S_ROI_B_Boundary_start=" + S_ROI_B_Boundary_start +
", S_ROI_B_Boundary_stop=" + S_ROI_B_Boundary_stop +
", S_ROI_G_Boundary_start=" + S_ROI_G_Boundary_start +
", S_ROI_G_Boundary_stop=" + S_ROI_G_Boundary_stop +
", G_ROI=" + G_ROI +
", G_ROI_B_Boundary_start=" + G_ROI_B_Boundary_start +
", G_ROI_B_Boundary_stop=" + G_ROI_B_Boundary_stop +
", G_ROI_G_Boundary_start=" + G_ROI_G_Boundary_start +
", G_ROI_G_Boundary_stop=" + G_ROI_G_Boundary_stop +
", D_ROI=" + D_ROI +
", D_ROI_B_Boundary_start=" + D_ROI_B_Boundary_start +
", D_ROI_B_Boundary_stop=" + D_ROI_B_Boundary_stop +
", D_ROI_G_Boundary_start=" + D_ROI_G_Boundary_start +
", D_ROI_G_Boundary_stop=" + D_ROI_G_Boundary_stop +
", analyse_flag=" + analyse_flag +
", error_log='" + error_log + '\'' +
'}';
}
}

View File

@ -0,0 +1,21 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
/**
* 边界值
*/
public class BgBoundary {
/**
*/
public List<Integer> ROI_B_Boundary_start;
/**
*/
public List<Integer> ROI_B_Boundary_stop;
/**
*/
public List<Integer> ROI_G_Boundary_start;
/**
*/
public List<Integer> ROI_G_Boundary_stop;
}

View File

@ -0,0 +1,13 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
public class CalValuesOut {
public int rowNum;
public int colNum;
public List<Double> counts;
}

View File

@ -0,0 +1,75 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
public class CalcBgBoundaryParam {
/************************* BgROILimit ******************/
/**
* 2-D ROI β-range start, x 1 (keV)
*/
public List<Double> ROI_B_start_x1;
/**
* 2-D ROI β-range stop, x 2 (keV)
*/
public List<Double> ROI_B_stop_x2;
/**
* 2-D ROI γ-range start, y 1 (keV)
*/
public List<Double> ROI_G_start_y1;
/**
* 2-D ROI γ-range stop, y 2 (keV)
*/
public List<Double> ROI_G_stop_y2;
/************************* BgEnergyChannel ******************/
/**
* b_Energy:electron_energy kev 能量
*/
public List<Double> b_energy;
/**
* b_Energy channel
*/
public List<Double> b_channel;
/**
* g_Energy:g_energy kev 能量
*/
public List<Double> g_energy;
/**
* g_Energy:centroid_channel
*/
public List<Double> g_channel;
/************************* BgCalibratePara ******************/
/**
* b 能刻度系数
*/
public List<Double> b_e_cal;
/**
* g 能刻度系数
*/
public List<Double> g_e_cal;
/**
* b 自计算刻度系数配置
*/
int b_e_cal_flag = 2;
/**
* g 自计算刻度系数配置
*/
int g_e_cal_flag = 2;
/**
* 界面交互新刻度应用
*/
boolean bApplyNewCalicSample = false;
boolean bApplyNewCalicDetBg = false;
boolean bApplyNewCalicGasBg = false;
boolean bApplyNewCalicQc = false;
}

View File

@ -0,0 +1,552 @@
package org.jeecg.modules.native_jni.struct;
import java.util.List;
/**
* 能谱结构体字段信息
*/
public class EnergySpectrumStruct {
/************************* Infomations ******************/
/**
* 消息类型
*/
public String msg_type;
/**
* 消息id
*/
public String msg_id;
/**
* 数据类型
*/
public String data_type;
/************************* Header Black ******************/
/**
* designator
*/
public String designator;
/**
* site code
*/
public String site_code;
/**
* detector code
*/
public String detector_code;
/**
* system type: P for particulate; B for gas with 3-D β - γ coincidence detection; and
*/
public String system_type;
/**
* sample geometry
*/
public String sample_geometry;
/**
* spectrum qualifier: preliminary ( PREL )or full ( FULL)
*/
public String spectrum_quantity;
/**
* sample reference identification
*/
public String sample_ref_id;
/**
* measurement identification
*/
public String measurement_id;
/**
* detector background measurement identification
*/
public String detector_bk_measurement_id;
/**
* gas background measurement identification (memory effect)
*/
public String gas_bk_measurement_id;
/**
* transmit date (yyyy / mm / dd)
*/
public String transmit_date;
/**
* transmit time (hh : mm : ss . s)
*/
public String transmit_time;
/************************* Sample ******************/
public double dimension_1;
public double dimension_2;
/************************* Comment ******************/
public String comment;
/************************* Acquisition Block ******************/
/**
* acquisition start date (yyyy / mm / dd)
*/
public String acquisition_start_date;
/**
* acquisition start time (hh : mm : ss . s)
*/
public String acquisition_start_time;
/**
* acquisition real time (s)
*/
public double acquisition_real_time;
/**
* acquisition live time (s)
*/
public double acquisition_live_time;
/************************* Collection Block ******************/
/**
* collection start date (yyyy / mm / dd)
*/
public String collection_start_date;
/**
* collection start time (hh : mm : ss . s)
*/
public String collection_start_time;
/**
* collection stop date (yyyy / mm / dd)
*/
public String collection_stop_date;
/**
* collection stop time (hh : mm : ss . s)
*/
public String collection_stop_time;
/**
* total air volume sampled (standard cubic meters [scm])
*/
public double air_volume;
/************************* Processing Block ******************/
/**
* sample volume of Xe (cm 3 )
*/
public double sample_volume_of_Xe;
/**
* uncertainty (cm 3 )
*/
public double uncertainty_1;
/**
* Xe collection yield (Xe gas in sample/total Xe gas sampled)
*/
public double Xe_collection_yield;
/**
* uncertainty (Xe gas in sample/total Xe gas sampled)
*/
public double uncertainty_2;
/**
* archive bottle identification
*/
public String archive_bottle_id;
/************************* Calibration Block ******************/
/**
* date of last calibration (yyyy / mm / dd)
*/
public String date_calibration;
/**
* time of last calibration (hh : mm : ss)
*/
public String time_calibration;
/************************* g_Energy Block ******************/
/**
* γ -energy (keV)
*/
public List<Double> g_energy;
/**
* centroid channel
*/
public List<Double> g_centroid_channel;
/**
* uncertainty (channels)
*/
public List<Double> g_uncertainty;
public int g_record_count;
/************************* b_Energy Block ******************/
/**
* electron energy (keV)
*/
public List<Double> b_electron_energy;
/**
* decay mode descriptor: B for β-particle, C for conversion electron (CE)
*/
public List<String> b_decay_mode;
/**
* maximum channel of β-particle distribution or centroid channel of CE (channels)
*/
public List<Double> b_channel;
/**
* uncertainty (channels)
*/
public List<Double> b_uncertainty;
public int b_record_count;
/************************* g_Resolution Block ******************/
/**
* γ -energy (keV)
*/
public List<Double> g_r_energy;
/**
* FWHM (keV)
*/
public List<Double> g_r_FWHM;
/**
* uncertainty (keV)
*/
public List<Double> g_r_uncertainty;
public int g_r_record_count;
/************************* b_Resolution Block ******************/
/**
* electron energy (keV)
*/
public List<Double> b_r_electron_energy;
/**
* FWHM (keV)
*/
public List<Double> b_r_FWHM;
/**
* uncertainty (keV)
*/
public List<Double> b_r_uncertainty;
public int b_r_record_count;
/************************* g_Efficiency Block ******************/
/**
* γ -energy (keV)
*/
public List<Double> g_e_energy;
/**
* efficiency (counts in peak/photon emitted)
*/
public List<Double> g_e_efficiency;
/**
* uncertainty (counts in peak/photon emitted)
*/
public List<Double> g_e_uncertainty;
public int g_e_record_count;
/************************* ROI_Limits Block ******************/
/**
* ROI number
*/
public List<String> ROI_number;
/**
* 2-D ROI β-range start, x 1 (keV)
*/
public List<Double> POI_B_x1;
/**
* 2-D ROI β-range stop, x 2 (keV)
*/
public List<Double> POI_B_x2;
/**
* 2-D ROI γ-range start, y 1 (keV)
*/
public List<Double> POI_G_y1;
/**
* 2-D ROI γ-range stop, y 2 (keV)
*/
public List<Double> POI_G_y2;
public int roi_record_count;
/************************* b-gEfficiency Block ******************/
/**
* nuclide name
*/
public List<String> bg_nuclide_name;
/**
* ROI number
*/
public List<Double> bg_ROI_number;
/**
* β-γ coincidence efficiency (counts in ROI/β-γ pair emitted)
*/
public List<Double> bg_efficiency;
/**
* uncertainty (counts in ROI/β-γ pair emitted)
*/
public List<Double> bg_uncertainty;
public int bg_record_count;
/************************* Ratios Block ******************/
/**
* ratio identifier
*/
public List<String> ratio_id;
/**
* ROI number for the higher γ -energy ROI
*/
public List<String> ROI_num_highter_G_energy_ROI;
/**
* ROI number for the lower γ -energy ROI
*/
public List<String> ROI_num_lower_G_energy_ROI;
/**
* Q_DECLARE_METATYPE(RMSSOHData::HeaderBlock)count ratio(counts in higher γ -energy ROI/counts in lower γ -energy ROI)
*/
public List<Double> count_ratio;
/**
* count ratio uncertainty (percent)
*/
public List<Double> count_ratio_uncertainty;
public int ratio_record_count;
/************************* g_Spectrum Block ******************/
/**
* number of γ channels
*/
public long num_g_channel;
/**
* γ-energy span (keV)
*/
public long g_energy_span;
/**
* begin of channels
*/
public long g_begin_channel;
/**
* count at channel
*/
public List<Long> g_counts;
/************************* b_Spectrum Block ******************/
/**
* number of β -channels
*/
public long num_b_channel;
/**
* β -energy span (keV)
*/
public long b_energy_span;
/**
* begin of channels
*/
public long b_begin_channel;
/**
* counts at channels
*/
public List<Long> b_counts;
/************************* Histogram Block ******************/
/**
* β-channels
*/
public long b_channels;
/**
* γ-channels
*/
public long g_channels;
/**
* β-energy span
*/
public long b_h_energy_span;
/**
* γ-energy span
*/
public long g_h_energy_span;
/**
* counts at channels
*/
public List<Long> h_counts;
/************************* Certificate_Block ******************/
/**
* total source activity (Bq)
*/
public double total_source_activity;
/**
* assay date (yyyy / mm / dd)
*/
public String assay_date;
/**
* assay time (hh : mm : ss)
*/
public String assay_time;
/**
* units of activity: B, b for Bq or [blank]; if nothing, then B is assigned
*/
public String units_activity;
/**
* nuclide name
*/
public List<String> nuclide_name;
/**
* half-life in seconds, hours, days, or years
*/
public List<String> half_life_time;
/**
* time unit(Y, D, H, S)
*/
public List<String> time_unit;
/**
* activity of nuclide at time of assay
*/
public List<Double> activity_nuclide_time_assay;
/**
* uncertainty (%)
*/
public List<Double> uncertainty;
/**
* γ-energy (keV)
*/
public List<Double> cer_g_energy;
/**
* γ-intensity (percent)
*/
public List<Double> g_intensity;
/**
* electron decay mode descriptor: B for β particle or C for conversion electron (CE), 0 for none (that is, γ-only source)
*/
public List<String> electron_decay_mode;
/**
* maximum β-particle energy or CE energy (keV)
*/
public List<Double> maximum_energy;
/**
* intensity of β-particle (percent)
*/
public List<Double> intensity_b_particle;
public int record_count;
/************************* Totaleff Block ******************/
/**
* γ-energy (keV)
*/
public List<Double> t_g_energy;
/**
* total efficiency (counts/photon emitted)
*/
public List<Double> total_efficiency;
/**
* uncertainty (counts/photon emitted)
*/
public List<Double> t_uncertainty;
public int t_record_count;
public EnergySpectrumStruct() {
super();
}
@Override
public String toString() {
return "EnergySpectrumStruct{" +
"msg_type='" + msg_type + '\'' +
", msg_id='" + msg_id + '\'' +
", data_type='" + data_type + '\'' +
", designator='" + designator + '\'' +
", site_code='" + site_code + '\'' +
", detector_code='" + detector_code + '\'' +
", system_type='" + system_type + '\'' +
", sample_geometry='" + sample_geometry + '\'' +
", spectrum_quantity='" + spectrum_quantity + '\'' +
", sample_ref_id='" + sample_ref_id + '\'' +
", measurement_id='" + measurement_id + '\'' +
", detector_bk_measurement_id='" + detector_bk_measurement_id + '\'' +
", gas_bk_measurement_id='" + gas_bk_measurement_id + '\'' +
", transmit_date='" + transmit_date + '\'' +
", transmit_time='" + transmit_time + '\'' +
", comment='" + comment + '\'' +
", acquisition_start_date='" + acquisition_start_date + '\'' +
", acquisition_start_time='" + acquisition_start_time + '\'' +
", acquisition_real_time=" + acquisition_real_time +
", acquisition_live_time=" + acquisition_live_time +
", collection_start_date='" + collection_start_date + '\'' +
", collection_start_time='" + collection_start_time + '\'' +
", collection_stop_date='" + collection_stop_date + '\'' +
", collection_stop_time='" + collection_stop_time + '\'' +
", air_volume=" + air_volume +
", sample_volume_of_Xe=" + sample_volume_of_Xe +
", uncertainty_1=" + uncertainty_1 +
", Xe_collection_yield=" + Xe_collection_yield +
", uncertainty_2=" + uncertainty_2 +
", archive_bottle_id='" + archive_bottle_id + '\'' +
", date_calibration='" + date_calibration + '\'' +
", time_calibration='" + time_calibration + '\'' +
", g_energy=" + g_energy +
", g_centroid_channel=" + g_centroid_channel +
", g_uncertainty=" + g_uncertainty +
", g_record_count=" + g_record_count +
", b_electron_energy=" + b_electron_energy +
", b_decay_mode=" + b_decay_mode +
", b_channel=" + b_channel +
", b_uncertainty=" + b_uncertainty +
", b_record_count=" + b_record_count +
", g_r_energy=" + g_r_energy +
", g_r_FWHM=" + g_r_FWHM +
", g_r_uncertainty=" + g_r_uncertainty +
", g_r_record_count=" + g_r_record_count +
", b_r_electron_energy=" + b_r_electron_energy +
", b_r_FWHM=" + b_r_FWHM +
", b_r_uncertainty=" + b_r_uncertainty +
", b_r_record_count=" + b_r_record_count +
", g_e_energy=" + g_e_energy +
", g_e_efficiency=" + g_e_efficiency +
", g_e_uncertainty=" + g_e_uncertainty +
", g_e_record_count=" + g_e_record_count +
", ROI_number=" + ROI_number +
", POI_B_x1=" + POI_B_x1 +
", POI_B_x2=" + POI_B_x2 +
", POI_G_y1=" + POI_G_y1 +
", POI_G_y2=" + POI_G_y2 +
", roi_record_count=" + roi_record_count +
", bg_nuclide_name=" + bg_nuclide_name +
", bg_ROI_number=" + bg_ROI_number +
", bg_efficiency=" + bg_efficiency +
", bg_uncertainty=" + bg_uncertainty +
", bg_record_count=" + bg_record_count +
", ratio_id=" + ratio_id +
", ROI_num_highter_G_energy_ROI=" + ROI_num_highter_G_energy_ROI +
", ROI_num_lower_G_energy_ROI=" + ROI_num_lower_G_energy_ROI +
", count_ratio=" + count_ratio +
", count_ratio_uncertainty=" + count_ratio_uncertainty +
", ratio_record_count=" + ratio_record_count +
", num_g_channel=" + num_g_channel +
", g_energy_span=" + g_energy_span +
", g_begin_channel=" + g_begin_channel +
", g_counts=" + g_counts +
", num_b_channel=" + num_b_channel +
", b_energy_span=" + b_energy_span +
", b_begin_channel=" + b_begin_channel +
", b_counts=" + b_counts +
", b_channels=" + b_channels +
", g_channels=" + g_channels +
", b_h_energy_span=" + b_h_energy_span +
", g_h_energy_span=" + g_h_energy_span +
", h_counts=" + h_counts +
", total_source_activity=" + total_source_activity +
", assay_date='" + assay_date + '\'' +
", assay_time='" + assay_time + '\'' +
", units_activity='" + units_activity + '\'' +
", nuclide_name=" + nuclide_name +
", half_life_time=" + half_life_time +
", time_unit=" + time_unit +
", activity_nuclide_time_assay=" + activity_nuclide_time_assay +
", uncertainty=" + uncertainty +
", cer_g_energy=" + cer_g_energy +
", g_intensity=" + g_intensity +
", electron_decay_mode=" + electron_decay_mode +
", maximum_energy=" + maximum_energy +
", intensity_b_particle=" + intensity_b_particle +
", record_count=" + record_count +
'}';
}
public static void main(String[] args) {
EnergySpectrumStruct s = new EnergySpectrumStruct();
System.out.println(s);
System.out.println(s.gas_bk_measurement_id);
}
}

View File

@ -16,17 +16,15 @@
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-BetaGammaAnalyser</artifactId>
</dependency>
<!-- 引入jeecg-boot-starter-cloud依赖 -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-cloud</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.ejml/ejml-simple -->
<dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-simple</artifactId>
<version>0.39</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>

View File

@ -13,11 +13,11 @@ import com.google.common.collect.Maps;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.GammaFileUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.GammaFileUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.bizVo.AttributeItemVo;
import org.jeecg.common.util.MyLogFormatUtil;

View File

@ -23,6 +23,11 @@
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-BetaGammaAnalyser</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.ejml/ejml-simple -->
<dependency>
<groupId>org.ejml</groupId>

View File

@ -500,10 +500,11 @@ public class PHDFileUtil {
String gasBkMeasurementId = struct.gas_bk_measurement_id;
String detectorBkMeasurementId = struct.detector_bk_measurement_id;
//格式化文件名称
String fileSuffix = nameStandUtil.GetSuffix(dataType, systemType, spectrumQuantity, String.valueOf(acquisitionLiveTime));
String fileSuffix = nameStandUtil.GetSuffix(dataType, spectrumQuantity, String.valueOf(acquisitionLiveTime));
String measurementName = nameStandUtil.GetFileNameFromDateTime(measurementId, fileSuffix);
String gasFileName = nameStandUtil.GetFileNameFromDateTime(gasBkMeasurementId, "_G.PHD");
String detaFileName = nameStandUtil.GetFileNameFromDateTime(detectorBkMeasurementId, "_D.PHD");
map.put("sampleFileName", measurementName);
map.put("gasFileName", gasFileName);
map.put("detaFileName", detaFileName);
map.put("sampleSystemType", systemType);

View File

@ -9,7 +9,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
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.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
@ -19,7 +18,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.cache.Cache;
import org.apache.commons.net.ftp.FTPClient;
import org.codehaus.jettison.json.JSONString;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant;
@ -27,16 +25,20 @@ import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
import org.jeecg.modules.base.entity.postgre.SysUser;
import org.jeecg.modules.base.entity.rnman.GardsAnalySetting;
import org.jeecg.modules.base.enums.CalName;
import org.jeecg.modules.base.enums.CalType;
import org.jeecg.modules.base.enums.ExportTemplate;
import org.jeecg.modules.base.enums.RoleType;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.entity.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import org.jeecg.modules.service.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -48,11 +50,14 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.*;
@ -144,7 +149,7 @@ public class GammaServiceImpl implements IGammaService {
//声明基础数组信息
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
if (!bRet){
return result;
}
@ -177,7 +182,7 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", systemType);
}
Map<String, NuclideLines> nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides);
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
result.setSuccess(true);
result.setResult(nuclideLinesMap);
return result;
@ -230,7 +235,7 @@ public class GammaServiceImpl implements IGammaService {
//加载phd数据所需的lcscacbaseline数据
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取phd其他相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
//判断数据库信息是否读取正常
if (!bRet){
return result;
@ -259,6 +264,301 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) {
//判断连接的数据库
String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting;
if (dbName.equals("auto")){
T_analy = "RNAUTO.GARDS_ANALYSES";
T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS";
T_peaks = "RNAUTO.GARDS_PEAKS";
T_param = "RNAUTO.GARDS_CALIBRATION";
T_nuc_line = "RNAUTO.GARDS_NUCL_LINES_IDED";
T_nuc_act = "RNAUTO.GARDS_NUCL_IDED";
T_qc = "RNAUTO.GARDS_QC_CHECK";
userName = "RNAUTO";
}else {
T_analy = "RNMAN.GARDS_ANALYSES";
T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS";
T_peaks = "RNMAN.GARDS_PEAKS";
T_param = "RNMAN.GARDS_CALIBRATION";
T_nuc_line = "RNMAN.GARDS_NUCL_LINES_IDED";
T_nuc_act = "RNMAN.GARDS_NUCL_IDED";
T_qc = "RNMAN.GARDS_QC_CHECK";
T_setting = "RNMAN.GARDS_ANALY_SETTING";
}
String status = spectrumAnalysisMapper.getStatus(sampleId);
if (StringUtils.isNotBlank(status)){
phd.setStatus(status);
if (!phd.getStatus().equals("P") && !phd.getStatus().equals("R")){
return false;
}
}else {
return false;
}
// 获取 ananlysis_idBaseLineLcScac峰数量Category谱注释等信息
GardsAnalysesSpectrum analysis = spectrumAnalysisMapper.getAnalysis(T_analy, sampleId, userName);
int peakNum = 0;
if (Objects.nonNull(analysis)){
phd.setId_analysis(analysis.getIdAnalysis().toString());
phd.setBaseline_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getBaselinePath());
phd.setLc_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getLcPath());
phd.setScac_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getScacPath());
peakNum = analysis.getNumberOfPeaks();
phd.setTotalCmt(analysis.getComments());
phd.getBaseCtrls().setRg_low(analysis.getSearchStartChannel());
phd.getBaseCtrls().setRg_high(analysis.getSearchEndChannel());
phd.getUsedSetting().setEnergyTolerance(analysis.getSearchThreshold());
} else {
result.error500("There are 0 records when sample_id is "+sampleId+"!");
return false;
}
if (peakNum>0){
// 获取峰信息列表
List<GardsPeaksSpectrum> peaks = spectrumAnalysisMapper.getPeaks(T_peaks, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(peaks)){
for (GardsPeaksSpectrum peaksSpectrum:peaks) {
PeakInfo peakInfo = new PeakInfo();
peakInfo.index = peaksSpectrum.getIdPeak()==null?0:peaksSpectrum.getIdPeak();
peakInfo.multiIndex = peaksSpectrum.getMulitiIndex()==null?0:peaksSpectrum.getMulitiIndex().intValue();
peakInfo.left = peaksSpectrum.getRoiStart()==null?0:peaksSpectrum.getRoiStart().intValue();
peakInfo.right = peaksSpectrum.getRoiEnd()==null?0:peaksSpectrum.getRoiEnd().intValue();
peakInfo.peakCentroid = peaksSpectrum.getCentroidChannel()==null?0:peaksSpectrum.getCentroidChannel();
peakInfo.energy = peaksSpectrum.getEnergy()==null?0:peaksSpectrum.getEnergy();
peakInfo.fwhmc = peaksSpectrum.getFwtm()==null?0:peaksSpectrum.getFwtm();
peakInfo.fwhm = peaksSpectrum.getFwhm()==null?0:peaksSpectrum.getFwhm();
peakInfo.area = peaksSpectrum.getArea()==null?0:peaksSpectrum.getArea();
peakInfo.areaErr = peaksSpectrum.getUncArea()==null?0:peaksSpectrum.getUncArea();
peakInfo.efficiency = peaksSpectrum.getEfficiency()==null?0:peaksSpectrum.getEfficiency();
peakInfo.lc = peaksSpectrum.getLc()==null?0:peaksSpectrum.getLc();
peakInfo.ld = peaksSpectrum.getLd()==null?0:peaksSpectrum.getLd();
peakInfo.meanBackCount = peaksSpectrum.getMeanbackcount()==null?0:peaksSpectrum.getMeanbackcount();
peakInfo.backgroundArea = peaksSpectrum.getBackgroundarea()==null?0:peaksSpectrum.getBackgroundarea();
peakInfo.significance = peaksSpectrum.getSignificance()==null?0:peaksSpectrum.getSignificance();
peakInfo.sensitivity = peaksSpectrum.getSensitivity()==null?0:peaksSpectrum.getSensitivity();
peakInfo.stepRatio = peaksSpectrum.getStepraio()==null?0:peaksSpectrum.getStepraio();
peakInfo.tail = peaksSpectrum.getTail()==null?0:peaksSpectrum.getTail();
peakInfo.tailAlpha = peaksSpectrum.getTailAlpha()==null?0:peaksSpectrum.getTailAlpha();
peakInfo.upperTail = peaksSpectrum.getUpperTail()==null?0:peaksSpectrum.getUpperTail();
peakInfo.upperTailAlpha = peaksSpectrum.getUpperTailAlpha()==null?0:peaksSpectrum.getUpperTailAlpha();
peakInfo.BWWidthChan = peaksSpectrum.getBwwidthchan()==null?0:peaksSpectrum.getBwwidthchan();
peakInfo.recoilBetaChan = "1";
peakInfo.recoilDeltaChan = peaksSpectrum.getRecoildeltachan()==null?"1":peaksSpectrum.getRecoildeltachan().toString();
peakInfo.comments = StringUtils.isNotBlank(peaksSpectrum.getPeakcomments())?peaksSpectrum.getPeakcomments():"";
phd.getVPeak().add(peakInfo);
}
}
}
// 获取刻度点数据
List<GardsCalibrationPairsSpectrum> calibrationPairs = spectrumAnalysisMapper.getCalibrationPairs(T_calib, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(calibrationPairs)){
GEnergyBlock gEnergyBlock = new GEnergyBlock();
GResolutionBlock gResolutionBlock = new GResolutionBlock();
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
TotaleffBlock totaleffBlock = new TotaleffBlock();
for (GardsCalibrationPairsSpectrum pairsSpectrum:calibrationPairs) {
String calType = pairsSpectrum.getCaltype().trim();
if(calType.equals(CalType.ENERGY_CAL.getType())) {
phd.setUsedEner(pairsSpectrum.getInput());
gEnergyBlock.getCentroid_channel().add(pairsSpectrum.getXValue());
gEnergyBlock.getG_energy().add(pairsSpectrum.getYValue());
gEnergyBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0:Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.RESOLUTION_CAL.getType())) {
phd.setUsedReso(pairsSpectrum.getInput());
gResolutionBlock.getG_energy().add(pairsSpectrum.getXValue());
gResolutionBlock.getFWHM().add(pairsSpectrum.getYValue());
gResolutionBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.EFFICIENCY_CAL.getType())) {
phd.setUsedEffi(pairsSpectrum.getInput());
gEfficiencyBlock.getG_energy().add(pairsSpectrum.getXValue());
gEfficiencyBlock.getEfficiency().add(pairsSpectrum.getYValue());
gEfficiencyBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
} else if(calType.equals(CalType.TOTALEFFICIENCY_CAL.getType())) {
phd.setUsedTotE(pairsSpectrum.getInput());
totaleffBlock.getG_energy().add(pairsSpectrum.getXValue());
totaleffBlock.getTotal_efficiency().add(pairsSpectrum.getYValue());
totaleffBlock.getUncertainty().add(StringUtils.isBlank(pairsSpectrum.getUncYValue())? 0: Double.valueOf(pairsSpectrum.getUncYValue()));
}
}
if (phd.getUsedEner().isEmpty()){
phd.setUsedEner(CalName.CalPHD.getType());
}
if (phd.getUsedReso().isEmpty()){
phd.setUsedReso(CalName.CalPHD.getType());
}
if (phd.getUsedEffi().isEmpty()){
phd.setUsedEffi(CalName.CalPHD.getType());
}
if (phd.getUsedTotE().isEmpty()){
phd.setUsedTotE(CalName.CalPHD.getType());
}
gEnergyBlock.setRecord_count(gEnergyBlock.getG_energy().size());
gResolutionBlock.setRecord_count(gResolutionBlock.getG_energy().size());
gEfficiencyBlock.setRecord_count(gEfficiencyBlock.getG_energy().size());
totaleffBlock.setRecord_count(totaleffBlock.getG_energy().size());
if(gEnergyBlock.getRecord_count() > 0) {
phd.setUsedEnerKD(gEnergyBlock);
phd.getMapEnerKD().put(phd.getUsedEner(), gEnergyBlock);
}
if(gResolutionBlock.getRecord_count() > 0) {
phd.setUsedResoKD(gResolutionBlock);
phd.getMapResoKD().put(phd.getUsedReso(), gResolutionBlock);
}
if(gEfficiencyBlock.getRecord_count() > 0) {
phd.setUsedEffiKD(gEfficiencyBlock);
phd.getMapEffiKD().put(phd.getUsedEffi(), gEfficiencyBlock);
}
if(totaleffBlock.getRecord_count() > 0) {
phd.setUsedTotEKD(totaleffBlock);
phd.getMapTotEKD().put(phd.getUsedTotE(), totaleffBlock);
}
}
// 获取刻度拟合系数
List<GardsCalibrationSpectrum> paras = spectrumAnalysisMapper.getPara(T_param, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(paras)){
for (GardsCalibrationSpectrum calibrationSpectrum:paras) {
ParameterInfo para = new ParameterInfo();
String calType = calibrationSpectrum.getCalType().trim();
para.getP().add(calibrationSpectrum.getFunction().doubleValue());
String[] list_coeff = calibrationSpectrum.getCoeffString().split(StringPool.COMMA);
for (String str:list_coeff) {
para.getP().add(Double.valueOf(str));
para.getPerr().add(0.0);
}
if(calType.equals(CalType.ENERGY_CAL.getType())) {
phd.setUsedEnerPara(para);
phd.getMapEnerPara().put(phd.getUsedEner(), para);
phd.setNewEner(phd.getUsedEner());
} else if(calType.equals(CalType.RESOLUTION_CAL.getType())) {
phd.setUsedResoPara(para);
phd.getMapResoPara().put(phd.getUsedReso(), para);
phd.setNewReso(phd.getUsedReso());
} else if(calType.equals(CalType.EFFICIENCY_CAL.getType())) {
phd.setUsedEffiPara(para);
phd.getMapEffiPara().put(phd.getUsedEffi(), para);
phd.setNewEffi(phd.getUsedEffi());
} else if(calType.equals(CalType.TOTALEFFICIENCY_CAL.getType())) {
phd.setUsedTotEPara(para);
phd.getMapTotEPara().put(phd.getUsedTotE(), para);
phd.setNewTotE(phd.getUsedTotE());
}
}
}
// 获取被识别核素射线信息
List<GardsNuclLinesIdedSpectrum> nuclLinesIdeds = spectrumAnalysisMapper.getNuclLinesIded(T_nuc_line, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(nuclLinesIdeds)){
for (GardsNuclLinesIdedSpectrum nuclLinesIdedSpectrum:nuclLinesIdeds) {
String str_key = nuclLinesIdedSpectrum.getNuclideName();
phd.getMapNucActMda().put(str_key, new NuclideActMda());
if(Objects.nonNull(phd.getMapNucActMda().get(str_key))) {
phd.getMapNucActMda().get(str_key).setActivity(Double.valueOf(nuclLinesIdedSpectrum.getActivity()));
phd.getMapNucActMda().get(str_key).setAct_err(nuclLinesIdedSpectrum.getUncActivity());
phd.getMapNucActMda().get(str_key).setEfficiency(nuclLinesIdedSpectrum.getEffic());
phd.getMapNucActMda().get(str_key).setEffi_err(nuclLinesIdedSpectrum.getUnEffic());
phd.getMapNucActMda().get(str_key).setMda(nuclLinesIdedSpectrum.getMda());
phd.getMapNucActMda().get(str_key).setMdc(Double.valueOf(nuclLinesIdedSpectrum.getMdc()));
phd.getMapNucActMda().get(str_key).setConcentration(Double.valueOf(nuclLinesIdedSpectrum.getConcentration()));
if(phd.getMapNucActMda().get(str_key).getActivity() > 0){
phd.getMapNucActMda().get(str_key).setBCalculateMDA(true);
}
}
if(nuclLinesIdedSpectrum.getKeyFlag().toString().equals("1")){
phd.getMapNucActMda().get(str_key).setKey_flag(phd.getMapNucActMda().get(str_key).getVYield().size());
}
phd.getMapNucActMda().get(str_key).getFullNames().add(nuclLinesIdedSpectrum.getNuclidefullname());
phd.getMapNucActMda().get(str_key).getVEnergy().add(nuclLinesIdedSpectrum.getEnergy());
phd.getMapNucActMda().get(str_key).getVUncertE().add(nuclLinesIdedSpectrum.getUncEnergy());
phd.getMapNucActMda().get(str_key).getVYield().add(nuclLinesIdedSpectrum.getAbundance());
phd.getMapNucActMda().get(str_key).getVUncertY().add(nuclLinesIdedSpectrum.getUncAbundance());
int idx = nuclLinesIdedSpectrum.getIdPeak() - 1;
if(idx >= 0 && idx < peakNum) {
phd.getMapNucActMda().get(str_key).getVPeakIdx().add(idx+1);
if(!phd.getVPeak().get(idx).nuclides.contains(str_key)){
phd.getVPeak().get(idx).nuclides.add(str_key);
}
}
}
}
// 获取被识别核素的活度浓度
List<GardsNuclIdedSpectrum> nuclIdeds = spectrumAnalysisMapper.getNuclIded(T_nuc_act, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(nuclIdeds)){
for (GardsNuclIdedSpectrum nuclIdedSpectrum:nuclIdeds) {
String str_key = nuclIdedSpectrum.getNuclideName();
if(Objects.nonNull(phd.getMapNucActMda().get(str_key))) {
phd.getMapNucActMda().get(str_key).setHalflife(Double.valueOf(nuclIdedSpectrum.getHalflife()));
List<Double> vEner = phd.getMapNucActMda().get(str_key).getVEnergy();
Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy());
for(int i=0; i<vEner.size(); i++) {
if(Math.abs(vEner.get(i) - key_ener) < 1E-6) {
phd.getMapNucActMda().get(str_key).setCalculateIdx(i);
break;
}
}
}
}
}
// 获取 QC 结果
List<GardsQcCheckSpectrum> qcChecks = spectrumAnalysisMapper.getQcCheck(T_qc, analysis.getIdAnalysis());
if (CollectionUtils.isNotEmpty(qcChecks)){
for (GardsQcCheckSpectrum qcCheckSpectrum:qcChecks) {
String str_key = qcCheckSpectrum.getQcName();
QcCheckItem qcCheckItem = new QcCheckItem();
qcCheckItem.setValue(qcCheckSpectrum.getQcValue());
qcCheckItem.setBPass(qcCheckSpectrum.getQcResult() == 1);
qcCheckItem.setStandard(qcCheckSpectrum.getQcStandard());
phd.getQcItems().put(str_key, qcCheckItem);
}
}
// RNMAN.GARDS_ANALY_SETTING 表读分析设置
if (dbName.equals("auto")){
GardsAnalySetting analySetting = spectrumAnalysisMapper.getAnalySetting(analysis.getIdAnalysis());
if (Objects.nonNull(analySetting)){
phd.getUsedSetting().setECutAnalysis_Low(analySetting.getEcutanalysisLow());
double t_d = analySetting.getEcutanalysisHigh();
phd.getUsedSetting().setECutAnalysis_High((t_d <= phd.getUsedSetting().getECutAnalysis_Low() ? 0 : t_d));
phd.getUsedSetting().setEnergyTolerance(analySetting.getEnergytolerance());
phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh());
phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow());
phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss());
phd.getUsedSetting().setPss_low(analySetting.getPssLow());
phd.getUsedSetting().setK_back(analySetting.getKBack());
phd.getUsedSetting().setK_alpha(analySetting.getKAlpha());
phd.getUsedSetting().setK_beta(analySetting.getKBeta());
phd.getUsedSetting().setRiskLevelK(analySetting.getRisklevelk());
phd.getUsedSetting().setBUpdateCal(analySetting.getBupdatecal() == 1);
phd.getUsedSetting().setKeepCalPeakSearchPeaks(analySetting.getKeepcalpeakserchpeaks() == 1);
Date reftimeAct = analySetting.getReftimeAct();
if(Objects.nonNull(reftimeAct)){
phd.getUsedSetting().setRefTime_act(reftimeAct);
}
Date reftimeConc = analySetting.getReftimeConc();
if(Objects.nonNull(reftimeConc)){
phd.getUsedSetting().setRefTime_conc(reftimeConc);
}
}
}
if(!phd.getUsedEnerPara().getP().isEmpty()) {
List<Double> vChan = new LinkedList<>();
double c = 1;
while(c <= phd.getSpec().getNum_g_channel()) {
vChan.add(c);
c += 1;
}
System.loadLibrary("GammaAnaly");
CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP());
phd.setVEnergy(calValuesOut.counts);
phd.setBAnalyed(true);
}
return true;
}
@Override
public Result gammaByFile(String fileName, HttpServletRequest request) {
Result result = new Result();
@ -440,19 +740,26 @@ public class GammaServiceImpl implements IGammaService {
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
//分析文件数据
int flag = gammaFileUtil.AnalyseData(phd, nuclides);
int flag = gammaFileUtil.AnalyseData(phd);
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){
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
gammaFileUtil.RunQC(phd);
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, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
//重新分析各峰值对应的核素信息
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
Map<String, Object> map = new HashMap<>();
gammaFileUtil.UpdateChart(phd, map, colorMap);
// 更新 QC Flags 状态
@ -464,6 +771,36 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
public Map<String, NuclideLines> GetNuclideLines(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if(nuclideList.size() < 1){
return mapLines;
}
for(String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergyUncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYieldUncert());
if(Objects.nonNull(nuclideLineList.get(j).getKeyFlag()) && nuclideLineList.get(j).getKeyFlag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
}
mapLines.put(name, nlines);
}
List<HalfData> halfs = spectrumAnalysisMapper.getHalf(nuclideList);
for(int m=0;m<halfs.size();m++) {
NuclideLines nuclideLines = mapLines.get(halfs.get(m).getName());
nuclideLines.setHalflife(halfs.get(m).getHalf()==null? 0 : halfs.get(m).getHalf() * 86400);// 将天转换成秒
mapLines.put(halfs.get(m).getName(), nuclideLines);
}
return mapLines;
}
@Override
public Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request) {
Result result = new Result();
@ -642,7 +979,7 @@ public class GammaServiceImpl implements IGammaService {
ii++;
}
List<TablePeaks> tablePeaksList = gammaFileUtil.FitPeakBaseLine(phd, vIdx);
List<TablePeaks> tablePeaksList = FitPeakBaseLine(phd, vIdx);
map.put("tablePeaksList", tablePeaksList);
map.put("oldPeaks", vOriPeaks);
result.setSuccess(true);
@ -650,6 +987,40 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
public List<TablePeaks> FitPeakBaseLine(PHDFile phd, List<Integer> vIdx) {
List<TablePeaks> tablePeaksList = new LinkedList<>();
int peakNum = vIdx.size();
for (int i=0; i<peakNum; i++) {
int peakIdx = vIdx.get(i);
int row = i+1;
PeakInfo peak = phd.getVPeak().get(peakIdx);
TablePeaks tablePeaks = new TablePeaks();
tablePeaks.setLab(String.valueOf(peakIdx + 1));
String nuclide = "";
for (String peakNuclide:peak.nuclides) {
nuclide+=peakNuclide+";";
}
tablePeaks.setNuclide(StringUtils.isBlank(nuclide)?nuclide:nuclide.substring(0,nuclide.length()-1));
BigDecimal energy = new BigDecimal(peak.energy);
energy = energy.setScale(3, RoundingMode.HALF_UP);
tablePeaks.setEnergy(String.valueOf(energy));
BigDecimal area = new BigDecimal(peak.area);
area = area.setScale(4, RoundingMode.HALF_UP);
tablePeaks.setNetArea(String.valueOf(area));
BigDecimal fwhm = new BigDecimal(peak.fwhm);
fwhm = fwhm.setScale(5, RoundingMode.HALF_UP);
tablePeaks.setFwhm(String.valueOf(fwhm));
tablePeaks.setStep(String.valueOf(peak.area * peak.stepRatio));
double deriva = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP());
tablePeaks.setBwGamma(String.valueOf(peak.BWWidthChan * deriva));
tablePeaks.setNetAreaB(false);
tablePeaks.setCentroid(true);
tablePeaks.setFwhmB(true);
tablePeaksList.add(tablePeaks);
}
return tablePeaksList;
}
@Override
public Result acceptResults(String fileName, boolean accept, List<PeakInfo> oldPeak, HttpServletRequest request) {
Result result = new Result();
@ -811,7 +1182,7 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(userLib)){
userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> mapNucLines = gammaFileUtil.GetNuclideLines(userLib);
Map<String, NuclideLines> mapNucLines = GetNuclideLines(userLib);
//查询出核素信息
NuclideLines it_line = mapNucLines.get(nuclideName);
//如果核素信息不存在返回
@ -962,11 +1333,11 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
List<String> nuclideList = gammaFileUtil.InitList(bigDecimal.doubleValue(), 0.5, nuclides);
List<String> nuclideList = InitList(bigDecimal.doubleValue(), 0.5, nuclides);
if(CollectionUtils.isNotEmpty(nuclideList)) {
map.put("list", nuclideList);
String name = nuclideList.get(0);
gammaFileUtil.InitTable(name, map, phd, colorMap);
InitTable(name, map, phd, colorMap);
} else {
map.put("list", nuclideList);
map.put("chart", new LinkedList<>());
@ -980,6 +1351,57 @@ public class GammaServiceImpl implements IGammaService {
result.setResult(map);
return result;
}
public List<String> InitList(double energy, double tolerance, List<String> nuclides) {
if(nuclides.size() < 1){
return new LinkedList<>();
}
double min = energy - tolerance;
double max = energy + tolerance;
List<String> nuclideList = spectrumAnalysisMapper.findNuclideList(min, max, nuclides);
return nuclideList;
}
public void InitTable(String name, Map<String, Object> map, PHDFile phd, Map<String, String> colorMap) {
InitNuclideInfo(name, map);
long span = phd.getSpec().getG_energy_span();
List<GardsNuclLinesLib> nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span);
if (CollectionUtils.isNotEmpty(nuclideTableList)){
map.put("table", nuclideTableList);
gammaFileUtil.InitChart(nuclideTableList, phd, map, colorMap);
}
}
public void InitNuclideInfo(String name, Map<String, Object> map) {
map.put("name", name);
GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name);
if(Objects.nonNull(nuclideInfo)) {
map.put("lines", nuclideInfo.getNumLines());
if(Objects.isNull(nuclideInfo.getHalflife())) {
map.put("halfLife", "");
} else {
String units = "D";
double halflife = nuclideInfo.getHalflife().doubleValue();
if(halflife >= 1000) {
halflife = halflife / 365.25;
units = "A";
} else if(halflife < 0.1 && halflife >= 1.0 / 1440) {
halflife = halflife * 1440;
units = "M";
} else if(halflife <= 1.0 / 1440 && halflife > 0) {
halflife = halflife * 86400;
units = "S";
}
halflife = halflife + 0.0001;
map.put("halfLife", String.format("%.3f", halflife) + units);
}
if(Objects.isNull(nuclideInfo.getHalflifeErr())) {
map.put("halfLifeErr", "");
} else {
map.put("halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue())+"%");
}
}
}
@Override
public Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request) {
@ -993,7 +1415,7 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
Map<String, String> colorMap = sysUserColorService.initColor(userName);
gammaFileUtil.InitTable(nuclideName, map, phd, colorMap);
InitTable(nuclideName, map, phd, colorMap);
result.setSuccess(true);
result.setResult(map);
return result;
@ -1021,11 +1443,11 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
List<String> nuclideList = gammaFileUtil.InitList(bigDecimal.doubleValue(), tolerance, nuclides);
List<String> nuclideList = InitList(bigDecimal.doubleValue(), tolerance, nuclides);
if(CollectionUtils.isNotEmpty(nuclideList)) {
map.put("list", nuclideList);
String name = nuclideList.get(0);
gammaFileUtil.InitTable(name, map, phd, colorMap);
InitTable(name, map, phd, colorMap);
} else {
map.put("list", nuclideList);
map.put("chart", new LinkedList<>());
@ -2173,17 +2595,114 @@ public class GammaServiceImpl implements IGammaService {
if (StringUtils.isBlank(nuclideName)){
nuclideName = nuclides.get(0);
}
List<GardsNuclLinesLib> nuclLinesLibs = gammaFileUtil.InitNuclideLine(editEnergy, err, nuclideName);
List<GardsNuclLinesLib> nuclLinesLibs = InitNuclideLine(editEnergy, err, nuclideName);
map.put("nuclLinesLibs", nuclLinesLibs);
Map<String, String> nuclideInfo = gammaFileUtil.InitNuclideInfo(nuclideName);
Map<String, String> nuclideInfo = InitNuclideInfo(nuclideName);
map.put("nuclideInfo", nuclideInfo);
Map<String, Object> daughter = gammaFileUtil.InitParentAndDaughter(nuclideName);
Map<String, Object> daughter = InitParentAndDaughter(nuclideName);
map.put("daughter", daughter);
result.setSuccess(true);
result.setResult(map);
return result;
}
public List<GardsNuclLinesLib> InitNuclideLine(String editEnergy, double err, String name) {
Double min = null;
Double max = null;
if (StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)){
double editEnergyDou = Double.valueOf(editEnergy);
min = editEnergyDou - err;
max = editEnergyDou + err;
}
List<GardsNuclLinesLib> nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name);
return nuclideLines;
}
public Map<String, String> InitNuclideInfo(String name) {
Map<String, String> map = new HashMap<>();
GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name);
if(Objects.nonNull(nuclideInfo)) {
Long numLines = nuclideInfo.getNumLines();
map.put("lab_lines", numLines.toString());
if(Objects.isNull(nuclideInfo.getHalflife())) {
map.put("lab_halfLife", "");
} else {
String units = "D";
double halflife = nuclideInfo.getHalflife().doubleValue();
if(halflife >= 1000) {
halflife = halflife / 365.25;
units = "A";
} else if(halflife < 0.1 && halflife >= 1.0 / 1440.0) {
halflife = halflife * 1440.0;
units = "M";
} else if(halflife <= 1.0 / 1440.0 && halflife > 0.0) {
halflife = halflife * 86400.0;
units = "S";
}
char flag = 'f';
if(halflife >= 1000){
flag = 'e';
}
if (flag == 'f'){
map.put("lab_halfLife", String.format("%.3f", halflife)+units);
} else if (flag == 'e') {
NumberFormat numberFormat = new DecimalFormat("0.###E0");
String formatNum = numberFormat.format(halflife);
map.put("lab_halfLife", formatNum+units);
}
}
if(Objects.isNull(nuclideInfo.getHalflifeErr())) {
map.put("lab_halfLifeErr", "");
} else {
map.put("lab_halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue())+"%");
}
}
return map;
}
public Map<String, Object> InitParentAndDaughter(String name) {
Map<String, Object> map = new HashMap<>();
GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name);
List<String> parentList = new LinkedList<>();
if(Objects.nonNull(parentAndDaughter)) {
parentList.add(parentAndDaughter.getParents1());
parentList.add(parentAndDaughter.getParents2());
parentList.add(parentAndDaughter.getParents3());
parentList.add(parentAndDaughter.getParents4());
parentList.add(parentAndDaughter.getParents5());
parentList.add(parentAndDaughter.getParents6());
map.put("list_parent", parentList);
List<TableDaughter> daughterList = new LinkedList<>();
TableDaughter tableDaughter1 = new TableDaughter();
tableDaughter1.setDaughters(parentAndDaughter.getDaughters1());
tableDaughter1.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios1().doubleValue())+"%");
tableDaughter1.setDaughtersstable(parentAndDaughter.getDaughtersstable1().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter1);
TableDaughter tableDaughter2 = new TableDaughter();
tableDaughter2.setDaughters(parentAndDaughter.getDaughters2());
tableDaughter2.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios2().doubleValue())+"%");
tableDaughter2.setDaughtersstable(parentAndDaughter.getDaughtersstable2().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter2);
TableDaughter tableDaughter3 = new TableDaughter();
tableDaughter3.setDaughters(parentAndDaughter.getDaughters3());
tableDaughter3.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios3().doubleValue())+"%");
tableDaughter3.setDaughtersstable(parentAndDaughter.getDaughtersstable3().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter3);
TableDaughter tableDaughter4 = new TableDaughter();
tableDaughter4.setDaughters(parentAndDaughter.getDaughters4());
tableDaughter4.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios4().doubleValue())+"%");
tableDaughter4.setDaughtersstable(parentAndDaughter.getDaughtersstable4().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter4);
TableDaughter tableDaughter5 = new TableDaughter();
tableDaughter5.setDaughters(parentAndDaughter.getDaughters5());
tableDaughter5.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios5().doubleValue())+"%");
tableDaughter5.setDaughtersstable(parentAndDaughter.getDaughtersstable5().intValue() == 1? "Stable" : "Unstable");
daughterList.add(tableDaughter5);
map.put("table_daughter", daughterList);
}
return map;
}
@Override
public Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request) {
Result result = new Result();

View File

@ -218,7 +218,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
Result result = new Result();
List<Map<String, Object>> resultList = new LinkedList<>();
String userName = JwtUtil.getUserNameByToken(request);
String filePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName;
String filePath = "/test";//StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName;
String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD";
Pattern regexPattern = Pattern.compile(sampleRx);
String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD";
@ -241,7 +241,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp文件查询失败");
return result;
}
String sampleFileName = matchFileName;
String sampleFileName = fileData.get("sampleFileName");
String sampleSystemType = fileData.get("sampleSystemType");
if (sampleSystemType.equals(SystemType.BETA.getType())) {
//加载并获取当前路径下所有的文件名称并进行名称格式化 仅需要格式化和sample文件同一个台站 名称格式化为最终名称

View File

@ -84,7 +84,8 @@
<module>jeecg-module-abnormal-alarm</module>
<module>jeecg-module-auto-process</module>
<module>jeecg-module-spectrum-analysis</module>
</modules>
<module>jeecg-module-BetaGammaAnalyser</module>
</modules>
<repositories>
<repository>
@ -201,6 +202,12 @@
<artifactId>jeecg-module-spectrum-analysis</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!--jeecg-module-BetaGammaAnalyser-->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-BetaGammaAnalyser</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!-- jeecg tools -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>