From 950407d6da3aea9cb62421623a606284105e7644 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Sat, 7 Oct 2023 16:48:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B4=E5=90=88GammaFileUtil=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=20=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97jeecg-?= =?UTF-8?q?module-BetaGammaAnalyser=20=E7=A7=BB=E5=8A=A8=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=88=B0jeecg-module-BetaGammaAnaly?= =?UTF-8?q?ser=E6=A8=A1=E5=9D=97=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/NameStandUtil.java | 5 +- jeecg-module-BetaGammaAnalyser/pom.xml | 40 + .../org/jeecg/common/util/GammaFileUtil.java | 544 +-- .../org/jeecg/modules/entity/vo/PeakInfo.java | 71 + .../modules/entity/vo/StructInsertInput.java | 60 + .../modules/entity/vo/StructInsertOutput.java | 48 + .../modules/native_jni/CalValuesHandler.java | 30 + .../native_jni/EnergySpectrumHandler.java | 54 + .../native_jni/struct/AllGenerate.java | 89 + .../native_jni/struct/BgAnalyseResult.java | 191 + .../modules/native_jni/struct/BgBoundary.java | 21 + .../native_jni/struct/CalValuesOut.java | 13 + .../struct/CalcBgBoundaryParam.java | 75 + .../struct/EnergySpectrumStruct.java | 552 +++ jeecg-module-auto-process/pom.xml | 10 +- .../java/org/jeecg/common/GammaFileUtil.java | 4314 ----------------- .../modules/spectrum/Sample_G_Analysis.java | 2 +- jeecg-module-spectrum-analysis/pom.xml | 5 + .../org/jeecg/common/util/PHDFileUtil.java | 3 +- .../service/impl/GammaServiceImpl.java | 553 ++- .../impl/SpectrumAnalysisServiceImpl.java | 4 +- pom.xml | 9 +- 22 files changed, 1807 insertions(+), 4886 deletions(-) create mode 100644 jeecg-module-BetaGammaAnalyser/pom.xml rename {jeecg-module-spectrum-analysis => jeecg-module-BetaGammaAnalyser}/src/main/java/org/jeecg/common/util/GammaFileUtil.java (87%) create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertInput.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertOutput.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/AllGenerate.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgBoundary.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalValuesOut.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalcBgBoundaryParam.java create mode 100644 jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java delete mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java index 22729bb4..dd4e9302 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NameStandUtil.java @@ -79,14 +79,15 @@ public class NameStandUtil { } public Map 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 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())) { diff --git a/jeecg-module-BetaGammaAnalyser/pom.xml b/jeecg-module-BetaGammaAnalyser/pom.xml new file mode 100644 index 00000000..442068a5 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + org.jeecgframework.boot + jeecg-boot-parent + 3.5.1 + + + jeecg-module-BetaGammaAnalyser + + + 8 + 8 + UTF-8 + + + + + + org.jeecgframework.boot + jeecg-boot-starter-cloud + + + + org.jeecgframework.boot + jeecg-boot-base-core + + + + + org.ejml + ejml-simple + 0.39 + + + + \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java similarity index 87% rename from jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java rename to jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index ca881e55..622a2274 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -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_id、BaseLine、Lc、Scac、峰数量、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 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 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 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 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 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 vEner = phd.getMapNucActMda().get(str_key).getVEnergy(); - Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy()); - for(int i=0; i 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 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 Qcstate(PHDFile phd) { // Collection Time、 Acq Time、 Decay Time、 SampVol、 Be7-FWHM、 Ba140-MDC、 Xe133-MDC List qcState = new LinkedList<>(); @@ -1654,7 +1355,7 @@ public class GammaFileUtil { return datalist; } - public int AnalyseData(PHDFile phd, List 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 nuclideLinesMap = GetNuclideLines(nuclides); - NuclidesIdent(phd, nuclideLinesMap); - RunQC(phd); } else { change = 1; - Map 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 GetNuclideLines(List nuclideList) { - Map mapLines = new HashMap<>(); - if(nuclideList.size() < 1){ - return mapLines; - } - for(String name : nuclideList) { - NuclideLines nlines = new NuclideLines(); - List nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); - for(int j=0;j 0) { - nlines.key_flag = j; - nlines.maxYeildIdx = j; - } - } - mapLines.put(name, nlines); - } - List halfs = spectrumAnalysisMapper.getHalf(nuclideList); - for(int m=0;m 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 nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name); - return nuclideLines; - } - - public Map InitNuclideInfo(String name) { - Map 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 InitParentAndDaughter(String name) { - Map map = new HashMap<>(); - GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name); - List 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 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 DoubleLimit_L(List data) { - List rData = new LinkedList<>(); - for(int pos=0;pos DoubleLimit(List data) { List rData = new LinkedList<>(); for(int pos=0;pos DoubleLimit_I(List _data) { - List 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 DoubleLimit_G(List _data) { List rdata = new LinkedList<>(); for(int pos=0;pos<_data.size();pos++) { @@ -4057,58 +3603,6 @@ public class GammaFileUtil { return y; } - public List InitList(double energy, double tolerance, List nuclides) { - if(nuclides.size() < 1){ - return new LinkedList<>(); - } - double min = energy - tolerance; - double max = energy + tolerance; - List nuclideList = spectrumAnalysisMapper.findNuclideList(min, max, nuclides); - return nuclideList; - } - - public void InitTable(String name, Map map, PHDFile phd, Map colorMap) { - InitNuclideInfo(name, map); - long span = phd.getSpec().getG_energy_span(); - List nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span); - if (CollectionUtils.isNotEmpty(nuclideTableList)){ - map.put("table", nuclideTableList); - InitChart(nuclideTableList, phd, map, colorMap); - } - } - - public void InitNuclideInfo(String name, Map 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 nuclideTableList, PHDFile phd, Map map, Map colorMap) { List> chartList = new LinkedList<>(); for (int i=0; i < nuclideTableList.size(); i++){ @@ -4286,40 +3780,6 @@ public class GammaFileUtil { return i; } - public List FitPeakBaseLine(PHDFile phd, List vIdx) { - List tablePeaksList = new LinkedList<>(); - int peakNum = vIdx.size(); - for (int i=0; i InitPeakTable(List vPeak) { List result = new LinkedList<>(); for(int i=0; i nuclides; + + public PeakInfo(){ + nuclides = new LinkedList<>(); + comments = ""; + recoilBetaChan = "1"; + recoilDeltaChan = "1"; + } + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertInput.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertInput.java new file mode 100644 index 00000000..f747ff79 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertInput.java @@ -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 peakCentroid; + + public List fwhmc; + + public List tail; + + public List tailAlpha; + + public List upperTail; + + public List upperTailAlpha; + + public List area; + + public List stepRatio; + + public List usedEnerPara; + + public List usedResoPara; + + public List usedEffiPara; + + public long num_g_channel; + + public long begin_channel; + + public List XCtrl; + + public List YCtrl; + + public List YSlope; + + public int rg_low; + + public int rg_high; + + public List para_tail; + + public List para_tailAlpha; + + public List para_tailRight; + + public List para_tailRightAlpha; + + public List para_stepRatio; + + public int curChan; + + public List vCount; + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertOutput.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertOutput.java new file mode 100644 index 00000000..307523bf --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/entity/vo/StructInsertOutput.java @@ -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 peakCentroid; + + public List energy; + + public List area; + + public List sensitivity; + + public List fwhm; + + public List fwhmc; + + public List stepRatio; + + public List tail; + + public List tailAlpha; + + public List upperTail; + + public List upperTailAlpha; + + public List efficiency; + + public List BWWidthChan; + + public List recoilBetaChan; + + public List recoilDeltaChan; + + public List vIdx; + + public List vLeft; + + public List vRight; + + public List vCentroid; + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java new file mode 100644 index 00000000..d08cf789 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java @@ -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 x, List para); + + public static native CalValuesOut energyToChannel(List energy, List para); + + public static native CalValuesOut calDerivEval(List channel, List para); + + public static native double calDerivaOut(double Chan, List p); + + public static native List interp1(PeakInfo peak, List t_base, List regChan); + + public static native StructInsertOutput insertPeaks(StructInsertInput structInsertInput); + + public static native List calFitPara(String type, int funcId, List x, List y, List err); + + public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List vCentroid, List vFwhmCh, List vTail, List vUpperTail); + + public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath); + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java new file mode 100644 index 00000000..acf974c2 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java @@ -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 GetFileFittingPara(List g_energy, List centroid_channel); + + /** + * 根据channel 获取 Energy + * @param centroid_channel + * @param fittingPara + * @return + */ + public static native List GetFileFittingData(List centroid_channel, List fittingPara); + + /** + * BetaGamma 分析算法 + * @param sampleFile 样品谱文件 + * @param gasFile 气体谱文件 + * @param detFile 探测器本地谱文件 + * @return + */ + public static native BgAnalyseResult bgAnalyse(String sampleFile, String gasFile, String detFile); + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/AllGenerate.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/AllGenerate.java new file mode 100644 index 00000000..6205e4b7 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/AllGenerate.java @@ -0,0 +1,89 @@ +package org.jeecg.modules.native_jni.struct; + +import java.util.List; + +public class AllGenerate { + + //BgGasGenerate BgGas; + private List g_ROI_B_Boundary_start; + private List g_ROI_B_Boundary_stop; + private List g_ROI_G_Boundary_start; + private List g_ROI_G_Boundary_stop; + private List g_roi_cts; //气体本底谱感兴趣区计数 + private List g_deduct_d_cts; //气体本底谱扣除探测器本底谱数据 + private int g_b_fitting_type; + private int g_g_fitting_type; + private List g_b_fitting_e_c; + private List g_g_fitting_e_c; + private List g_b_fitting_c_e; + private List g_g_fitting_c_e; + + //BgSampleGenerate BgSample; +// private BgBoundary s_boungdary; + private List s_ROI_B_Boundary_start; + private List s_ROI_B_Boundary_stop; + private List s_ROI_G_Boundary_start; + private List s_ROI_G_Boundary_stop; + private List s_roi_cts; //样品普感兴趣区计数 + private List s_deduct_d_cts; //样品谱扣除探测器本底谱数据 + private int s_b_fitting_type; + private int s_g_fitting_type; + private List s_b_fitting_e_c; + private List s_g_fitting_e_c; + private List s_b_fitting_c_e; + private List s_g_fitting_c_e; + private String s_collection_time; //采集时间 + + //BgOtherGenerate BgOther; + private List ROI_net_coutns; //感兴趣区净计数 + private List ROI_net_err; + private List ROI_con_uncer; //感兴趣区浓度和不确定度 [n..0]浓度 [n..1]不确定度 + private List 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 LC; + private List 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 MDC; + private List 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 ROI_B_Boundary_start; + private List ROI_B_Boundary_stop; + private List ROI_G_Boundary_start; + private List ROI_G_Boundary_stop; + private List d_roi_cts; //探测器本底谱感兴趣区计数 + // 拟合后值 + private int b_fitting_type; + private int g_fitting_type; + private List b_fitting_e_c; + private List g_fitting_e_c; + private List b_fitting_c_e; + private List g_fitting_c_e; + //BgDetbgrGenerate BgDetbgr; + private List d_ROI_B_Boundary_start; + private List d_ROI_B_Boundary_stop; + private List d_ROI_G_Boundary_start; + private List d_ROI_G_Boundary_stop; + private List d_d_roi_cts; //探测器本底谱感兴趣区计数 + private int d_b_fitting_type; + private int d_g_fitting_type; + private List d_b_fitting_e_c; + private List d_g_fitting_e_c; + private List d_b_fitting_c_e; + private List d_g_fitting_c_e; + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java new file mode 100644 index 00000000..c06585dd --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java @@ -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 ROI; + public List LC; + public List s_roi_cts; + public List g_roi_cts; + public List d_roi_cts; + public List s_deduct_d_cts; + public List g_deduct_d_cts; + public List ROI_net_coutns; + public List ROI_net_coutns_err; + public List ROI_con_uncer; + public List ROI_con_uncer_err; + public List MDC; + public List dNidFlag; + public List LC_CTS; + + /************************** GARDS_ROI_RESULTS end **************************/ + + /************************** GARDS_CALIBRATION START**************************/ + public List s_b_fitting_e_c; + public int s_b_fitting_type; + public String s_b_fitting_type_def; + public List s_g_fitting_e_c; + public int s_g_fitting_type; + public String s_g_fitting_type_def; + public List s_b_fitting_c_e; + public List s_g_fitting_c_e; + + public List g_b_fitting_e_c; + public int g_b_fitting_type; + public String g_b_fitting_type_def; + public List g_g_fitting_e_c; + public int g_g_fitting_type; + public String g_g_fitting_type_def; + public List g_b_fitting_c_e; + public List g_g_fitting_c_e; + + public List d_b_fitting_e_c; + public int d_b_fitting_type; + public String d_b_fitting_type_def; + public List d_g_fitting_e_c; + public int d_g_fitting_type; + public String d_g_fitting_type_def; + public List d_b_fitting_c_e; + public List d_g_fitting_c_e; + + /************************** GARDS_CALIBRATION end **************************/ + + /************************** GARDS_ROI_CHANNELS START**************************/ + public List S_ROI; + public List S_ROI_B_Boundary_start; + public List S_ROI_B_Boundary_stop; + public List S_ROI_G_Boundary_start; + public List S_ROI_G_Boundary_stop; + public List G_ROI; + public List G_ROI_B_Boundary_start; + public List G_ROI_B_Boundary_stop; + public List G_ROI_G_Boundary_start; + public List G_ROI_G_Boundary_stop; + public List D_ROI; + public List D_ROI_B_Boundary_start; + public List D_ROI_B_Boundary_stop; + public List D_ROI_G_Boundary_start; + public List 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 + '\'' + + '}'; + } +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgBoundary.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgBoundary.java new file mode 100644 index 00000000..e4354a79 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/BgBoundary.java @@ -0,0 +1,21 @@ +package org.jeecg.modules.native_jni.struct; + +import java.util.List; + +/** + * 边界值 + */ +public class BgBoundary { + /** + */ + public List ROI_B_Boundary_start; + /** + */ + public List ROI_B_Boundary_stop; + /** + */ + public List ROI_G_Boundary_start; + /** + */ + public List ROI_G_Boundary_stop; +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalValuesOut.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalValuesOut.java new file mode 100644 index 00000000..1846200f --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalValuesOut.java @@ -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 counts; + +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalcBgBoundaryParam.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalcBgBoundaryParam.java new file mode 100644 index 00000000..77a84ea7 --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/CalcBgBoundaryParam.java @@ -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 ROI_B_start_x1; + + /** + * 2-D ROI β-range stop, x 2 (keV) + */ + public List ROI_B_stop_x2; + + /** + * 2-D ROI γ-range start, y 1 (keV) + */ + public List ROI_G_start_y1; + + /** + * 2-D ROI γ-range stop, y 2 (keV) + */ + public List ROI_G_stop_y2; + + /************************* BgEnergyChannel ******************/ + /** + * b_Energy:electron_energy kev 能量 + */ + public List b_energy; + + /** + * b_Energy channel 道 + */ + public List b_channel; + + /** + * g_Energy:g_energy kev 能量 + */ + public List g_energy; + + /** + * g_Energy:centroid_channel 道 + */ + public List g_channel; + + /************************* BgCalibratePara ******************/ + /** + * b 能刻度系数 + */ + public List b_e_cal; + + /** + * g 能刻度系数 + */ + public List 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; +} diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java new file mode 100644 index 00000000..b02d240d --- /dev/null +++ b/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java @@ -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 g_energy; + /** + * centroid channel + */ + public List g_centroid_channel; + /** + * uncertainty (channels) + */ + public List g_uncertainty; + + public int g_record_count; + + /************************* b_Energy Block ******************/ + /** + * electron energy (keV) + */ + public List b_electron_energy; + /** + * decay mode descriptor: B for β-particle, C for conversion electron (CE) + */ + public List b_decay_mode; + /** + * maximum channel of β-particle distribution or centroid channel of CE (channels) + */ + public List b_channel; + /** + * uncertainty (channels) + */ + public List b_uncertainty; + + public int b_record_count; + + /************************* g_Resolution Block ******************/ + /** + * γ -energy (keV) + */ + public List g_r_energy; + /** + * FWHM (keV) + */ + public List g_r_FWHM; + /** + * uncertainty (keV) + */ + public List g_r_uncertainty; + + public int g_r_record_count; + + /************************* b_Resolution Block ******************/ + /** + * electron energy (keV) + */ + public List b_r_electron_energy; + /** + * FWHM (keV) + */ + public List b_r_FWHM; + /** + * uncertainty (keV) + */ + public List b_r_uncertainty; + + public int b_r_record_count; + + /************************* g_Efficiency Block ******************/ + /** + * γ -energy (keV) + */ + public List g_e_energy; + /** + * efficiency (counts in peak/photon emitted) + */ + public List g_e_efficiency; + /** + * uncertainty (counts in peak/photon emitted) + */ + public List g_e_uncertainty; + + public int g_e_record_count; + + /************************* ROI_Limits Block ******************/ + /** + * ROI number + */ + public List ROI_number; + /** + * 2-D ROI β-range start, x 1 (keV) + */ + public List POI_B_x1; + /** + * 2-D ROI β-range stop, x 2 (keV) + */ + public List POI_B_x2; + /** + * 2-D ROI γ-range start, y 1 (keV) + */ + public List POI_G_y1; + /** + * 2-D ROI γ-range stop, y 2 (keV) + */ + public List POI_G_y2; + + public int roi_record_count; + + /************************* b-gEfficiency Block ******************/ + /** + * nuclide name + */ + public List bg_nuclide_name; + /** + * ROI number + */ + public List bg_ROI_number; + /** + * β-γ coincidence efficiency (counts in ROI/β-γ pair emitted) + */ + public List bg_efficiency; + /** + * uncertainty (counts in ROI/β-γ pair emitted) + */ + public List bg_uncertainty; + + public int bg_record_count; + + /************************* Ratios Block ******************/ + /** + * ratio identifier + */ + public List ratio_id; + /** + * ROI number for the higher γ -energy ROI + */ + public List ROI_num_highter_G_energy_ROI; + /** + * ROI number for the lower γ -energy ROI + */ + public List 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 count_ratio; + /** + * count ratio uncertainty (percent) + */ + public List 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 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 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 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 nuclide_name; + /** + * half-life in seconds, hours, days, or years + */ + public List half_life_time; + /** + * time unit(Y, D, H, S) + */ + public List time_unit; + /** + * activity of nuclide at time of assay + */ + public List activity_nuclide_time_assay; + /** + * uncertainty (%) + */ + public List uncertainty; + /** + * γ-energy (keV) + */ + public List cer_g_energy; + /** + * γ-intensity (percent) + */ + public List g_intensity; + /** + * electron decay mode descriptor: B for β particle or C for conversion electron (CE), 0 for none (that is, γ-only source) + */ + public List electron_decay_mode; + /** + * maximum β-particle energy or CE energy (keV) + */ + public List maximum_energy; + /** + * intensity of β-particle (percent) + */ + public List intensity_b_particle; + + public int record_count; + + /************************* Totaleff Block ******************/ + /** + * γ-energy (keV) + */ + public List t_g_energy; + /** + * total efficiency (counts/photon emitted) + */ + public List total_efficiency; + /** + * uncertainty (counts/photon emitted) + */ + public List 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); + } +} diff --git a/jeecg-module-auto-process/pom.xml b/jeecg-module-auto-process/pom.xml index 9df7bbc9..2d2dbd37 100644 --- a/jeecg-module-auto-process/pom.xml +++ b/jeecg-module-auto-process/pom.xml @@ -16,17 +16,15 @@ org.jeecgframework.boot jeecg-boot-base-core + + org.jeecgframework.boot + jeecg-module-BetaGammaAnalyser + org.jeecgframework.boot jeecg-boot-starter-cloud - - - org.ejml - ejml-simple - 0.39 - org.springframework.boot spring-boot-configuration-processor diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java deleted file mode 100644 index 55e6cbf5..00000000 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java +++ /dev/null @@ -1,4314 +0,0 @@ -package org.jeecg.common; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.lang.Console; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.io.FileUtils; -import org.apache.commons.net.ftp.FTP; -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; -import org.ejml.simple.SimpleMatrix; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.properties.SpectrumPathProperties; -import org.jeecg.common.util.DateUtils; -import org.jeecg.common.util.FTPUtil; -import org.jeecg.common.util.GammaReportUtil; -import org.jeecg.common.util.NameStandUtil; -import org.jeecg.modules.base.entity.configuration.GardsNuclLib; -import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; -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.eneity.*; -import org.jeecg.modules.eneity.vo.StructInsertOutput; -import org.jeecg.modules.entity.vo.*; -import org.jeecg.modules.eneity.vo.TablePeaks; -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; -import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; -import org.jeecgframework.core.util.ApplicationContextUtil; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.w3c.dom.*; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.*; -import java.util.stream.Collectors; - -@Component -public class GammaFileUtil { - - @Value("${parameter.filePath}") - private String parameterFilePath; - @Autowired - private FTPUtil ftpUtil; - @Autowired - private SpectrumPathProperties spectrumPathProperties; - @Autowired - private SpectrumAnalysisMapper spectrumAnalysisMapper; - @Autowired - private NameStandUtil nameStandUtil; - - public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) { - phd.setFilepath(pathName); - phd.setFilename(fileName); - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return false; - } - InputStream inputStream = null; - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)) { - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - //读取文件信息 - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - //MsgInfo - phd.getMsgInfo().setMsg_id(struct.msg_id); - phd.getMsgInfo().setMsg_type(struct.msg_type); - phd.getMsgInfo().setData_type(struct.data_type); - //Header - phd.getHeader().setDesignator(struct.designator); - phd.getHeader().setSite_code(struct.site_code); - phd.getHeader().setDetector_code(struct.detector_code); - phd.getHeader().setSystem_type(struct.system_type); - phd.getHeader().setSample_geometry(struct.sample_geometry); - phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity); - phd.getHeader().setSample_ref_id(struct.sample_ref_id); - phd.getHeader().setMeasurement_id(struct.measurement_id); - phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id); - phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id); - phd.getHeader().setTransmit_date(struct.transmit_date); - phd.getHeader().setTransmit_time(struct.transmit_time); - //Comment - phd.setOriTotalCmt(struct.comment); - //Collection - if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) { - phd.getCollect().setCollection_start_date(struct.collection_start_date); - phd.getCollect().setCollection_start_time(struct.collection_start_time); - phd.getCollect().setCollection_stop_date(struct.collection_stop_date); - phd.getCollect().setCollection_stop_time(struct.collection_stop_time); - phd.getCollect().setAir_volume(struct.air_volume); - if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) { - phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0"); - } - if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) { - phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0"); - } - } else { - phd.getCollect().setAir_volume(0.0); - } - //Acquisition - if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) { - phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date); - phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time); - phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time); - phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time); - if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) { - phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0"); - } - } else { - phd.getAcq().setAcquisition_live_time(0.0); - phd.getAcq().setAcquisition_real_time(0.0); - } - //Processing - if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.archive_bottle_id)) { - phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe); - phd.getProcess().setUncertainty_1(struct.uncertainty_1); - phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield); - phd.getProcess().setUncertainty_2(struct.uncertainty_2); - phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id); - } else { - phd.getProcess().setSample_volume_of_Xe(0.0); - phd.getProcess().setXe_collection_yield(0.0); - phd.getProcess().setUncertainty_1(0.0); - phd.getProcess().setUncertainty_2(0.0); - } - //Sample - if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) { - phd.getSampleBlock().setDimension_1(struct.dimension_1); - phd.getSampleBlock().setDimension_2(struct.dimension_2); - } else { - phd.getSampleBlock().setDimension_1(0.0); - phd.getSampleBlock().setDimension_2(0.0); - } - //Calibration - if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.date_calibration) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.time_calibration)) { - phd.getCalibration().setDate_calibration(struct.date_calibration); - phd.getCalibration().setTime_calibration(struct.time_calibration); - } - //Certificate - if (Objects.nonNull(struct.total_source_activity) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name) - && CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty) - && CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) { - phd.getCertificate().setTotal_source_activity(struct.total_source_activity); - phd.getCertificate().setAssay_date(struct.assay_date); - phd.getCertificate().setAssay_time(struct.assay_time); - phd.getCertificate().setUnits_activity(struct.units_activity); - phd.getCertificate().setNuclide_name(struct.nuclide_name); - phd.getCertificate().setHalf_life_time(struct.half_life_time); - phd.getCertificate().setTime_unit(struct.time_unit); - phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay); - phd.getCertificate().setUncertainty(struct.uncertainty); - phd.getCertificate().setG_energy(struct.cer_g_energy); - phd.getCertificate().setG_intensity(struct.g_intensity); - phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode); - phd.getCertificate().setMaximum_energy(struct.maximum_energy); - phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle); - phd.getCertificate().setRecord_count(struct.record_count); - } - //g_Spectrum - if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) { - phd.getSpec().setNum_g_channel(struct.num_g_channel); - phd.getSpec().setG_energy_span(struct.g_energy_span); - phd.getSpec().setBegin_channel(struct.g_begin_channel); - phd.getSpec().setCounts(struct.g_counts); - int i = 0; - for (; i < phd.getSpec().getNum_g_channel(); ++i) { - if (phd.getSpec().getCounts().get(i) > 0) { - break; - } - } - if (i == phd.getSpec().getNum_g_channel()) { - phd.setValid(false); - } - } - //g_Energy - if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) { - GEnergyBlock gEnergyBlock = new GEnergyBlock(); - gEnergyBlock.setG_energy(struct.g_energy); - gEnergyBlock.setCentroid_channel(struct.g_centroid_channel); - gEnergyBlock.setUncertainty(struct.g_uncertainty); - gEnergyBlock.setRecord_count(struct.g_record_count); - phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock); - } - //g_Resolution - if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) { - GResolutionBlock gResolutionBlock = new GResolutionBlock(); - gResolutionBlock.setG_energy(struct.g_r_energy); - gResolutionBlock.setFWHM(struct.g_r_FWHM); - gResolutionBlock.setUncertainty(struct.g_r_uncertainty); - gResolutionBlock.setRecord_count(struct.g_r_record_count); - phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock); - } - //g_Efficiency - if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) { - GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); - gEfficiencyBlock.setG_energy(struct.g_e_energy); - gEfficiencyBlock.setEfficiency(struct.g_e_efficiency); - gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty); - gEfficiencyBlock.setRecord_count(struct.g_e_record_count); - phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock); - } - //TotalEff - if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) { - TotaleffBlock totaleffBlock = new TotaleffBlock(); - totaleffBlock.setG_energy(struct.t_g_energy); - totaleffBlock.setTotal_efficiency(struct.total_efficiency); - totaleffBlock.setUncertainty(struct.t_uncertainty); - totaleffBlock.setRecord_count(struct.t_record_count); - phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock); - } - - // 初始化默认分析设置 - if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - phd.getSetting().setECutAnalysis_Low(35.0); - phd.getSetting().setBUpdateCal(true); - } - phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - SpecSetup usedSetting = new SpecSetup(); - BeanUtils.copyProperties(phd.getSetting(), usedSetting); - phd.setUsedSetting(usedSetting); - - phd.setBAnalyed(false); - phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss")); - - } - }catch (IOException e) { - throw new RuntimeException(e); - } catch (ParseException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return true; - } - - public void SetBaseInfo(PHDFile phd){ - String pathName = phd.getFilepath(); - String fileName = phd.getFilename(); - //文件名称需要加上自动处理的前缀以及修改不同的文件后缀名 - String subFileName = fileName.substring(0, fileName.lastIndexOf(StringPool.DOT)); - pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; - if(StringUtils.isNotBlank(subFileName)){ - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - String warning = "ftp连接失败"; - } - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - String lcFileName = "RNAUTO_"+subFileName + ".lc"; - List lcFiles = ftpFiles.stream().filter(item -> item.getName().equals(lcFileName)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(lcFiles)){ - FTPFile lcFile = lcFiles.get(0); - if (Objects.nonNull(lcFile)){ - InputStream inputStream = ftpClient.retrieveFileStream(lcFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - List readLines = FileUtils.readLines(file, "UTF-8"); - List vData = ReadLcScacInfo(readLines); - phd.setVLc(vData); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - ftpClient.disconnect(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - if(StringUtils.isNotBlank(subFileName)){ - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - String warning = "ftp连接失败"; - } - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - String scacFileName = "RNAUTO_"+subFileName + ".scac"; - List scacFiles = ftpFiles.stream().filter(item -> item.getName().equals(scacFileName)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(scacFiles)){ - FTPFile scacFile = scacFiles.get(0); - if (Objects.nonNull(scacFile)){ - InputStream inputStream = ftpClient.retrieveFileStream(scacFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - List readLines = FileUtils.readLines(file, "UTF-8"); - List vData = ReadLcScacInfo(readLines); - phd.setVScac(vData); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - ftpClient.disconnect(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - if(StringUtils.isNotBlank(subFileName)){ - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - String warning = "ftp连接失败"; - } - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; - List baselineFiles = ftpFiles.stream().filter(item -> item.getName().equals(baselineFileName)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(baselineFiles)){ - FTPFile baselineFile = baselineFiles.get(0); - if (Objects.nonNull(baselineFile)){ - InputStream inputStream = ftpClient.retrieveFileStream(baselineFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - List readLines = FileUtils.readLines(file, "UTF-8"); - ReadBaseCtrlInfo(phd,readLines); - phd.setVBase(phd.getBaseCtrls().getBaseline()); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - ftpClient.disconnect(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - } - - public List ReadLcScacInfo(List readLines){ - List vData = new LinkedList<>(); - for (int i=0; i< readLines.size(); i++){ - String line = readLines.get(i); - if (line.contains("#")){ - int j=i+1; - line = readLines.get(j); - String line1 = line; - while (j != readLines.size()-1 && StringUtils.isNotBlank(line) ){ - j++; - line = readLines.get(j); - if (!line.contains("#")){ - line1 += " " + line; - }else { - break; - } - } - line1 = line1.trim(); - List strList = Arrays.asList(line1.split("\\s+")); - if(strList.size() < 2){ - continue; - } - for(int k=1; k readLines){ - for (int i=0; i< readLines.size(); i++){ - String line = readLines.get(i); - if (line.contains("#")){ - String block_name = line.trim(); - int j=i+1; - line = readLines.get(j); - String block_data = line; - while(j!= readLines.size()-1 && StringUtils.isNotBlank(line)) { - j++; - line = readLines.get(j); - if (!line.contains("#")){ - block_data += " " + line; - }else { - break; - } - } - i=j-1; - block_data = block_data.trim(); - List str_list = Arrays.asList(block_data.split("\\s+")); - if(str_list.size() < 1){ - continue; - } - List vTemp = new LinkedList<>(); - for(String str:str_list) { - if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ - double d = Double.valueOf(str); - vTemp.add(d); - } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { - vTemp.add(0.0); - } - } - if(block_name.contains("#AnalyseRange")) { - if(vTemp.size() == 2) { - phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); - phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); - } - } else if(block_name.contains("#XCtrl")) { - phd.getBaseCtrls().setXCtrl(vTemp); - } else if(block_name.contains("#YCtrl")) { - phd.getBaseCtrls().setYCtrl(vTemp); - } else if(block_name.contains("#YSlope")) { - phd.getBaseCtrls().setYSlope(vTemp); - } else if(block_name.contains("#Baseline")) { - List list = vTemp.subList(1, vTemp.size()); - phd.getBaseCtrls().setBaseline(list); - } else if(block_name.contains("#StepCounts")) { - List list = vTemp.subList(1, vTemp.size()); - phd.getBaseCtrls().setStepCounts(list); - } - } - } - } - - public boolean getResultFromDB(String dbName, 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"; - }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_id、BaseLine、Lc、Scac、峰数量、Category、谱注释等信息 - GardsAnalysesSpectrum analysis = spectrumAnalysisMapper.getAnalysis(T_analy, sampleId); - 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 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 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 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 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 nuclIdeds = spectrumAnalysisMapper.getNuclIded(T_nuc_act, analysis.getIdAnalysis()); - if (CollectionUtils.isNotEmpty(nuclIdeds)){ - for (GardsNuclIdedSpectrum nuclIdedSpectrum:nuclIdeds) { - String str_key = nuclIdedSpectrum.getNuclideName(); - if(Objects.isNull(phd.getMapNucActMda().get(str_key))) { - phd.getMapNucActMda().get(str_key).setHalflife(Double.valueOf(nuclIdedSpectrum.getHalflife())); - List vEner = phd.getMapNucActMda().get(str_key).getVEnergy(); - Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy()); - for(int i=0; i 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 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 Qcstate(PHDFile phd){ - // Collection Time、 Acq Time、 Decay Time、 SampVol、 Be7-FWHM、 Ba140-MDC、 Xe133-MDC - List qcState = new LinkedList<>(); - for (int i=0;i<7; i++){ - qcState.add("GRAY"); - } - if(phd.getQcItems().size() <= 5) { - this.RunQC(phd); - } - qcState.set(0, phd.getQcItems().get("col_time").isBPass()?"BLUE":"RED"); - qcState.set(1, phd.getQcItems().get("acq_time").isBPass()?"BLUE":"RED"); - qcState.set(2, phd.getQcItems().get("decay_time").isBPass()?"BLUE":"RED"); - qcState.set(3, phd.getQcItems().get("samp_vol").isBPass()?"BLUE":"RED"); - - if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - if(Objects.isNull(phd.getQcItems().get("Be7-FWHM"))) { - qcState.set(4, phd.getQcItems().get("Be7-FWHM").isBPass()?"BLUE":"RED"); - qcState.set(5, phd.getQcItems().get("Ba140-MDC").isBPass()?"BLUE":"RED"); - } - } else if(phd.getHeader().getSystem_type().equalsIgnoreCase("G")) { - if(Objects.isNull(phd.getQcItems().get("Xe133-MDC"))) { - qcState.set(6, phd.getQcItems().get("Xe133-MDC").isBPass()?"BLUE":"RED"); - } - } - return qcState; - } - - public void RunQC(PHDFile phd){ - System.loadLibrary("GammaAnaly"); - try { - Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - - double collect_hour = (start.getTime()/1000 - end.getTime()/1000) / 3600.0; - double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0; - double Decay_hour = (end.getTime()/1000 - acq.getTime()/1000) / 3600.0; - - Double ener_Be7 = 0.0; - Map vMdcInfoMap = new HashMap<>(); - List vMdcInfo = new LinkedList<>(); - Map qcItems = new LinkedHashMap<>(); - if(!this.ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { - String WARNING = "Read QC Flags from SystemManager.xml Failed!"; - } - if (CollectionUtils.isNotEmpty(vMdcInfoMap)) { - vMdcInfo.add(vMdcInfoMap.get("0")); - vMdcInfo.add(vMdcInfoMap.get("1")); - vMdcInfo.add(vMdcInfoMap.get("2")); - } - - QcCheckItem colTime = qcItems.get("col_time"); - colTime.setValue(collect_hour); - qcItems.put("col_time", colTime); - - QcCheckItem acqTime = qcItems.get("acq_time"); - acqTime.setValue(acq_hour); - qcItems.put("acq_time", acqTime); - - QcCheckItem decayTime = qcItems.get("decay_time"); - decayTime.setValue(Decay_hour); - qcItems.put("decay_time", decayTime); - - QcCheckItem sampVol = qcItems.get("samp_vol"); - sampVol.setValue(phd.getCollect().getAir_volume()); - qcItems.put("samp_vol", sampVol); - - QcCheckItem airFlow = qcItems.get("airFlow"); - airFlow.setValue(phd.getCollect().getAir_volume() / collect_hour); - qcItems.put("airFlow", airFlow); - - if(phd.isValid() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { - if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - List energy = new LinkedList<>(); - energy.add(ener_Be7); - CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); - List fwhm = calValuesOut.counts; - QcCheckItem be7 = qcItems.get("Be7-FWHM"); - be7.setValue(fwhm.get(0)); - qcItems.put("Be7-FWHM", be7); - QcCheckItem Ba140 = qcItems.get("Ba140-MDC"); - Ba140.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); - qcItems.put("Ba140-MDC", Ba140); - } else { - QcCheckItem Xe133 = qcItems.get("Xe133-MDC"); - Xe133.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); - qcItems.put("Xe133-MDC", Xe133); - } - } - - for(Map.Entry iter:qcItems.entrySet()){ - if(iter.getValue().getStandard().isEmpty()){ - continue; - } - String[] lists = iter.getValue().getStandard().split(StringPool.COMMA); - boolean bSatisfy = true; - for(String str : lists) { - if(str.contains(StringPool.DASH)){ - continue; - } else if(str.contains(StringPool.LEFT_BRACKET)) { - if(iter.getValue().getValue() <= Double.valueOf(str.replace(StringPool.LEFT_BRACKET,""))) { - bSatisfy = false; - break; - } - } else if(str.contains(StringPool.RIGHT_BRACKET)) { - if(iter.getValue().getValue() >= Double.valueOf(str.replace(StringPool.RIGHT_BRACKET,""))) { - bSatisfy = false; - break; - } - } else if(str.contains(StringPool.LEFT_SQ_BRACKET)) { - if(iter.getValue().getValue() < Double.valueOf(str.replace(StringPool.LEFT_SQ_BRACKET,""))) { - bSatisfy = false; - break; - } - } else if(str.contains(StringPool.RIGHT_SQ_BRACKET)) { - if(iter.getValue().getValue() > Double.valueOf(str.replace(StringPool.RIGHT_SQ_BRACKET,""))) { - bSatisfy = false; - break; - } - } - } - iter.getValue().setBPass(bSatisfy); - } - phd.setQcItems(qcItems); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public Double CalculateMDC(PHDFile phd, List vMdcInfo, Double CCF){ - try { - System.loadLibrary("GammaAnaly"); - if(vMdcInfo.size() < 3 || vMdcInfo.get(2) == 0) { - return 0.0; - } - Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000); // 采样时间 - double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); // 衰变时间 - double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间 - double Tl = phd.getAcq().getAcquisition_live_time(); // 能谱获取活时间 - double Svol = phd.getCollect().getAir_volume(); // 样品采样体积 - double DCF1, DCF2, DCF3; - - double lambda = Math.log(2.0) / (vMdcInfo.get(2) * 86400); - if ( Ts == 0 ) DCF1 = 1; - else DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts)); - if ( Td == 0 ) DCF2 = 1; - else DCF2 = Math.exp(lambda*Td); - if ( Ta == 0 ) DCF3 = 1; - else DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta)); - - double DCF_conc = Math.exp(lambda * (phd.getUsedSetting().getRefTime_conc().getTime()/1000 - collectStart.getTime()/1000)); - - List energy = new LinkedList<>(); - energy.add(vMdcInfo.get(0)); - //使用energyToChannel方法计算 - CalValuesOut energyToChannel = CalValuesHandler.energyToChannel(energy, phd.getUsedEnerPara().getP()); - List channel = energyToChannel.counts; - //使用calDerivEval方法计算dE矩阵 - CalValuesOut calDerivEval = CalValuesHandler.calDerivEval(channel, phd.getUsedEnerPara().getP()); - List dE = calDerivEval.counts; - double[] array = dE.stream().mapToDouble(Double::doubleValue).toArray(); - SimpleMatrix dEMatrix = new SimpleMatrix(calDerivEval.rowNum, calDerivEval.colNum, true, array); - //calFcnEval计算得到矩阵数据 - CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEnerPara().getP()); - List counts = calFcnEval.counts; - //计算后的矩阵的集合转换成数组 - double[] array2 = counts.stream().mapToDouble(Double::doubleValue).toArray(); - //按照行数 列数 实际数据 生成矩阵 - SimpleMatrix calMatrix = new SimpleMatrix(calFcnEval.rowNum, calFcnEval.colNum, true, array2); - //计算后的矩阵 / dE矩阵 得到除后的矩阵 - SimpleMatrix matrixC = calMatrix.elementDiv(dEMatrix); - //声明一个集合接收除后的矩阵数据 - List values = new LinkedList<>(); - //遍历相除后的矩阵 行数 - for (int i=0; i= vMdcInfo.get(0)) { - index = i; - if(phd.getVEnergy().get(i) - vMdcInfo.get(0) > vMdcInfo.get(0) - phd.getVEnergy().get(i-1)){ - index = i-1; - } - break; - } - } - double lcc = phd.getVLc().get(index); - double baseline = phd.getVBase().get(index); - double mdc = (2 * fwhmc * (lcc - baseline) / 0.8591 ) * CCF*DCF1*DCF2*DCF3*DCF_conc / ( vMdcInfo.get(1) * effi * Tl ) *1e6 / Svol; - return mdc; - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public boolean ReadQCLimit(Map qcItems, Map vMdcInfoMap, Double ener_Be7, String systemType){ - try { - String filePath = parameterFilePath+ File.separator +"SystemManager.xml"; - //创建一个文档解析器工厂 - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - //创建文档解析器 - DocumentBuilder documentBuilder = factory.newDocumentBuilder(); - //读取xml文件生成一个文档 - Document document = documentBuilder.parse(filePath); - if (Objects.isNull(document)){ - return false; - } - //获取文档的根元素 - Element element = document.getDocumentElement(); - //获取根元素的子节点 - NodeList docChildNodes = element.getChildNodes(); - if (Objects.nonNull(docChildNodes) && docChildNodes.getLength()>0){ - //遍历子节点信息 - for(int i = 0; i < docChildNodes.getLength(); i++) { - //根据下标获取对应的节点信息 - Node n = docChildNodes.item(i); - //判断节点名称是否是 QCFlags-P 并且当前解析文件的系统类型是否是 P - if(n.getNodeName().equals("QCFlags-P") && systemType.equalsIgnoreCase("P")) { - // 获取节点的第一个子节点 - Node childNode = n.getFirstChild(); - //如果节点信息不为空 - while(Objects.nonNull(childNode)) { - String nodeName = childNode.getNodeName(); - //判断节点名称是否是 item - if(nodeName.equals("col_time") || nodeName.equals("acq_time") || nodeName.equals("decay_time") || nodeName.equals("samp_vol") - || nodeName.equals("airFlow") || nodeName.equals("Be7-FWHM") || nodeName.equals("Ba140-MDC")) { - QcCheckItem qcCheckItem = new QcCheckItem(); - // 获取节点的属性信息 - NamedNodeMap attributes = childNode.getAttributes(); - // 如果属性信息不为空 - if (Objects.nonNull(attributes)){ - // 遍历获取属性值 - for (int j=0; j< attributes.getLength(); j++){ - // 获取属性 - Node item = attributes.item(j); - //判断属性名称是否是 number - if(item.getNodeName().equals("green")) { - qcCheckItem.setStandard(item.getNodeValue()); - qcItems.put(nodeName, qcCheckItem); - } - } - } - }else if(nodeName.equals("Be7")) { - // 获取节点的属性信息 - NamedNodeMap attributes = childNode.getAttributes(); - // 如果属性信息不为空 - if (Objects.nonNull(attributes)){ - // 遍历获取属性值 - for (int j=0; j< attributes.getLength(); j++){ - // 获取属性 - Node item = attributes.item(j); - //判断属性名称是否是 number - if(item.getNodeName().equals(CalType.ENERGY_CAL.getType())) { - ener_Be7 = Double.valueOf(item.getNodeValue()); - } - } - } - } else if(nodeName.equals("Ba140")) { - // 获取节点的属性信息 - NamedNodeMap attributes = childNode.getAttributes(); - // 如果属性信息不为空 - if (Objects.nonNull(attributes)){ - // 遍历获取属性值 - for (int j=0; j< attributes.getLength(); j++){ - // 获取属性 - Node item = attributes.item(j); - //判断属性名称是否是 number - if(item.getNodeName().equals(CalType.ENERGY_CAL.getType())) { - vMdcInfoMap.put("0", Double.valueOf(item.getNodeValue())); - }else if (item.getNodeName().equals("yield")){ - vMdcInfoMap.put("1", Double.valueOf(item.getNodeValue())); - }else if (item.getNodeName().equals("halflife")){ - vMdcInfoMap.put("2", Double.valueOf(item.getNodeValue())); - } - } - } - } - // 获取下一个节点 - childNode = childNode.getNextSibling(); - } - }else if(n.getNodeName().equals("QCFlags-G") && systemType.equalsIgnoreCase("G")) { - // 获取节点的第一个子节点 - Node childNode = n.getFirstChild(); - //如果节点信息不为空 - while(Objects.nonNull(childNode)) { - String nodeName = childNode.getNodeName(); - //判断节点名称是否是 item - if(nodeName.equals("col_time") || nodeName.equals("acq_time") || nodeName.equals("decay_time") || nodeName.equals("samp_vol") - || nodeName.equals("airFlow") || nodeName.equals("Xe133-MDC")) { - QcCheckItem qcCheckItem = new QcCheckItem(); - // 获取节点的属性信息 - NamedNodeMap attributes = childNode.getAttributes(); - // 如果属性信息不为空 - if (Objects.nonNull(attributes)){ - // 遍历获取属性值 - for (int j=0; j< attributes.getLength(); j++){ - // 获取属性 - Node item = attributes.item(j); - //判断属性名称是否是 number - if(item.getNodeName().equals("green")) { - qcCheckItem.setStandard(item.getNodeValue()); - qcItems.put(nodeName, qcCheckItem); - } - } - } - }else if(nodeName.equals("Xe133")) { - // 获取节点的属性信息 - NamedNodeMap attributes = childNode.getAttributes(); - // 如果属性信息不为空 - if (Objects.nonNull(attributes)){ - // 遍历获取属性值 - for (int j=0; j< attributes.getLength(); j++){ - // 获取属性 - Node item = attributes.item(j); - //判断属性名称是否是 number - if(item.getNodeName().equals(CalType.ENERGY_CAL.getType())) { - vMdcInfoMap.put("0", Double.valueOf(item.getNodeValue())); - }else if (item.getNodeName().equals("yield")){ - vMdcInfoMap.put("1", Double.valueOf(item.getNodeValue())); - }else if (item.getNodeName().equals("halflife")){ - vMdcInfoMap.put("2", Double.valueOf(item.getNodeValue())); - } - } - } - } - // 获取下一个节点 - childNode = childNode.getNextSibling(); - } - } - } - } - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - return true; - } - - public List DetailedInfo(Integer sampleId, PHDFile phd) { - try { - // Sample_Id, Station_Code, Detector_Code, System_Type, Data_Type, Spectral_Qualifier, - // SRID, Sample_Status, Collect_Start, Sampling_Time, Quantity, Flow_Rate, - // Acq_Start, Acq_Real, Acq_Live, Decay_Time, Auto_Cat, Category - List detailInfo = new LinkedList<>(); - for (int i=0; i<18; i++){ - detailInfo.add(""); - } - detailInfo.set(0, Objects.nonNull(sampleId)?sampleId.toString():""); // Sample_Id - detailInfo.set(1, phd.getHeader().getSite_code()); // Station_Code - detailInfo.set(2, phd.getHeader().getDetector_code()); // Detector_Code - detailInfo.set(3, phd.getHeader().getSystem_type().toUpperCase()); // System_Type - detailInfo.set(4, phd.getMsgInfo().getData_type()); // Data_Type - detailInfo.set(5, phd.getHeader().getSpectrum_quantity()); // Spectral_Qualifier - detailInfo.set(6, phd.getHeader().getSample_ref_id()); // SRID - detailInfo.set(7, phd.getStatus()); // Sample_Status - String collect_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)); - Date collect_stop_dt = DateUtils.parseDate(collect_stop,"yyyy/MM/dd HH:mm:ss"); - detailInfo.set(8, phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time()); - Date date = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - double timeSpan = (collect_stop_dt.getTime()/1000 - date.getTime()/1000) / 3600.0; - detailInfo.set(9, String.format("%.2f", timeSpan));// Sampling_Time - detailInfo.set(10, String.format("%.2f", phd.getCollect().getAir_volume())); - if(timeSpan != 0){ - detailInfo.set(11, String.format("%.2f", phd.getCollect().getAir_volume()/timeSpan)); - } - detailInfo.set(12, phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); - String start_time = phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)); - Date start_date = DateUtils.parseDate(start_time, "yyyy/MM/dd HH:mm:ss"); - detailInfo.set(13, String.format("%.2f", phd.getAcq().getAcquisition_real_time())); - detailInfo.set(14, String.format("%.2f", phd.getAcq().getAcquisition_live_time())); - double timespan = (start_date.getTime()/1000 - collect_stop_dt.getTime()/1000); - detailInfo.set(15, String.format("%.2f", timespan / 3600.0)); - detailInfo.set(17, phd.getCategory()); - return detailInfo; - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public void UpdateChart(PHDFile phd, Map map){ - List m_vCount = new LinkedList<>(); - long m_nCount = phd.getSpec().getNum_g_channel(); - long m_nSChan = phd.getSpec().getBegin_channel(); - - // 确保绘制曲线时所有谱都是从1道开始 - int i = 0; - if(m_nSChan == 0){ - i = 1; - } - for(; i allData = AllData(false, phd, m_vCount, m_nCount); - map.put("allData", allData); - List shapeEnergyData = Energy_BaseCP(phd); - map.put("shapeEnergyData", shapeEnergyData); - List shapeChannelData = Channel_BaseCP(phd); - map.put("shapeChannelData", shapeChannelData); - } - - public ChartData Energy_Count(PHDFile phd, List m_vCount, long m_nCount){ - int start = 0; - long end = -1; - //Energy - ChartData data1 = new ChartData(); - if(m_nCount > 1 && phd.getVEnergy().size() == m_nCount) { - if(start < 1) { - start = 1; - } - if(end < 1 || end > m_nCount){ - end = m_nCount; - } - for(int i=start-1; i m_vCount, long m_nCount){ - int start = 1; - long end = -1; - ChartData data1 = new ChartData(); - if(m_nCount > 1) { - if(start < 1){ - start = 1; - } - if(end < 1 || end > m_nCount){ - end = m_nCount; - } - for(int i=start-1; i Lc_Scac_base(boolean showLc, PHDFile phd, long m_nCount){ - List datalist = new LinkedList<>(); - int start = 0; - long end = -1; - if(m_nCount > 1 && phd.getVEnergy().size() == m_nCount && phd.getVLc().size() == m_nCount - && phd.getVScac().size() == m_nCount && phd.getVBase().size() == m_nCount) { - if(start < 1) { - start = 1; - } - if(end < 1 || end > m_nCount) { - end = m_nCount; - } - - ChartData data2 = new ChartData(); - ChartData data3 = new ChartData(); - ChartData data4 = new ChartData(); - ChartData data6 = new ChartData(); - ChartData data7 = new ChartData(); - ChartData data8 = new ChartData(); - for(int i=start-1; iSpectrum.counts[i] == 0) continue; - SeriseData data2Point = new SeriseData(); - data2Point.setX(i+1); - data2Point.setY(phd.getVLc().get(i)); - data2.getPointlist().add(data2Point); - - SeriseData data3Point = new SeriseData(); - data3Point.setX(i+1); - data3Point.setY(phd.getVScac().get(i)); - data3.getPointlist().add(data3Point); - - SeriseData data4Point = new SeriseData(); - data4Point.setX(i+1); - data4Point.setY(phd.getVBase().get(i)); - data4.getPointlist().add(data4Point); - - SeriseData data6Point = new SeriseData(); - data6Point.setX(phd.getVEnergy().get(i)); - data6Point.setY(phd.getVLc().get(i)); - data6.getPointlist().add(data6Point); - - SeriseData data7Point = new SeriseData(); - data7Point.setX(phd.getVEnergy().get(i)); - data7Point.setY(phd.getVScac().get(i)); - data7.getPointlist().add(data7Point); - - SeriseData data8Point = new SeriseData(); - data8Point.setX(phd.getVEnergy().get(i)); - data8Point.setY(phd.getVBase().get(i)); - data8.getPointlist().add(data8Point); - } - // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; - data2.setGroup("channel"); - data2.setName("Lc"); - data2.setColor("255,0,0"); - data2.setShow(showLc); - data3.setGroup("channel"); - data3.setName("Scac"); - data3.setColor("244,112,247"); - data3.setShow(showLc); - data4.setGroup("channel"); - data4.setName("BaseLine"); - data4.setColor("0,246,255"); - data6.setGroup("energy"); - data6.setName("Lc"); - data6.setColor("255,0,0"); - data6.setShow(showLc); - data7.setGroup("energy"); - data7.setName("Scac"); - data7.setColor("244,112,247"); - data7.setShow(showLc); - data8.setGroup("energy"); - data8.setName("BaseLine"); - data8.setColor("0,246,255"); - data2.setType("Line"); - data3.setType("Line"); - data4.setType("Line"); - data6.setType("Line"); - data7.setType("Line"); - data8.setType("Line"); - datalist.add(data2); - datalist.add(data3); - datalist.add(data4); - datalist.add(data6); - datalist.add(data7); - datalist.add(data8); - } - return datalist; - } - - public List Channel_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, null, false); - } - - public List Energy_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, phd.getUsedEnerPara().getP(), true); - } - - public List PeakSet(List vPeak, List vBase, long m_nCount, List p, boolean bEnergy){ - System.loadLibrary("GammaAnaly"); - List datalist = new LinkedList<>(); - int peakNum = vPeak.size(); - if(peakNum < 1 || vBase.size() != m_nCount){ - return datalist; - } - int start = 0; - long end = -1; - if(start < 1){ - start = 1; - } - if(end > m_nCount || end < 1){ - end = m_nCount; - } - - // 找出在所给范围的第一道拟合峰和最后一道拟合峰的索引下标 - int index = 0, startPeak = -1, endPeak = peakNum-1; - while(index < peakNum && start > vPeak.get(index).right){ - ++index; - } - if(index < peakNum) { - startPeak = index; - while(index < peakNum && vPeak.get(index).left < end){ - ++index; - } - endPeak = index-1; - } - if(startPeak < 0 || startPeak > endPeak){ - return datalist; - } - - for(int i=startPeak; i<=endPeak; ++i) { - PeakInfo peak = vPeak.get(i); - - ChartData cData = new ChartData(); - cData.setColor("255,127,39"); - cData.setName("Peak"); - - List regChan = new LinkedList<>(); - double d = peak.left; - while(d <= peak.right) { - regChan.add(d); - d += 0.25; - } - List t_base = vBase.subList(peak.left, peak.right + 1); - List regPeak = CalValuesHandler.interp1(peak, t_base, regChan); - - if(bEnergy) { - cData.setGroup("energy"); - CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(regChan, p); - List regEnergy = calValuesOut.counts; - for(int ii=0; ii end){ - continue; - } - SeriseData seriseData = new SeriseData(); - seriseData.setX(regEnergy.get(ii)); - seriseData.setY(regPeak.get(ii)); - cData.getPointlist().add(seriseData); - } - } else { - cData.setGroup("channel"); - for(int ii=0; ii end){ - continue; - } - SeriseData seriseData = new SeriseData(); - seriseData.setX(regChan.get(ii)); - seriseData.setY(regPeak.get(ii)); - cData.getPointlist().add(seriseData); - } - } - datalist.add(cData); - } - return datalist; - } - - public List Energy_BaseCP(PHDFile phd){ - System.loadLibrary("GammaAnaly"); - List shapes = new LinkedList<>(); - CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(phd.getBaseCtrls().getXCtrl(), phd.getUsedEnerPara().getP()); - List vEner = calValuesOut.counts; - if(phd.getBaseCtrls().getXCtrl().size() == phd.getBaseCtrls().getYCtrl().size()) { - for(int i=0; i Channel_BaseCP(PHDFile phd){ - List shapes = new LinkedList<>(); - int num = phd.getBaseCtrls().getXCtrl().size(); - if(num == phd.getBaseCtrls().getYCtrl().size()) { - for(int i=0; i AllData(boolean showLc, PHDFile phd, List m_vCount, long m_nCount){ - List datalist = new LinkedList<>(); - datalist.add(Channel_Count(m_vCount, m_nCount)); - datalist.add(Energy_Count(phd, m_vCount, m_nCount)); - datalist.addAll(Lc_Scac_base(showLc, phd, m_nCount)); - datalist.addAll(Channel_Peak(phd, m_nCount)); - datalist.addAll(Energy_Peak(phd, m_nCount)); - return datalist; - } - - public boolean AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, boolean bSingle){ - //调用方法判断是否修改了参数 - if (Objects.nonNull(configureData)){ - SpecSetup phdSetting = phd.getSetting(); - phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); - phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); - phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); - phdSetting.setPss_low(configureData.getPss_low()); - phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); - phdSetting.setK_back(configureData.getK_back()); - phdSetting.setK_alpha(configureData.getK_alpha()); - phdSetting.setK_beta(configureData.getK_beta()); - phdSetting.setRiskLevelK(configureData.getRiskLevelK()); - phdSetting.setRefTime_act(configureData.getRefTime_act()); - phdSetting.setRefTime_conc(configureData.getRefTime_conc()); - } - - int change = SettingChanged(phd); - if(change == 0 && phd.getVPeak().size() > 0) return false; - else if(change == -1) { - phd.setUsedEffi(phd.getNewEffi()); - phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi())); - phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi())); - UpdateEfficiency(phd); - Map nuclideLinesMap = GetNuclideLines(nuclides); - NuclidesIdent(phd, nuclideLinesMap); - RunQC(phd); - String Warning = "Finish three tasks:\n"+ - "\t1.Update efficiencies of all peaks;\n"+ - "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."; - } else { - if(bSingle) { -// AnalyseFlowChart flow_dlg(this); -// flow_dlg.exec(); - } else { - Map nuclideLinesMap = GetNuclideLines(nuclides); -// AnalyseSpectrum(phd, nuclideLinesMap); - } - } - return true; - } - - public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ - System.loadLibrary("GammaAnaly"); - //解析获取临时文件信息 - File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename()); - ObjectMapper mapper = new ObjectMapper(); - try { - String phdStr = mapper.writeValueAsString(phd); - String nuclideLinesMap = mapper.writeValueAsString(mapLines); - String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath()); - Map parseMap = JSON.parseObject(strValue, Map.class); - for (Map.Entry entry:parseMap.entrySet()) { - if (entry.getKey().equalsIgnoreCase("bAnalyed")) { - boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class); - phd.setBAnalyed(value); - } - if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); - value.put(key, entryValue); - } - phd.setMapEnerPara(value); - } - if (entry.getKey().equalsIgnoreCase("mapResoPara")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); - value.put(key, entryValue); - } - phd.setMapResoPara(value); - } - if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); - value.put(key, entryValue); - } - phd.setMapEffiPara(value); - } - if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); - value.put(key, entryValue); - } - phd.setMapTotEPara(value); - } - if (entry.getKey().equalsIgnoreCase("para_stepRatio")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setPara_stepRatio(value); - } - if (entry.getKey().equalsIgnoreCase("para_tail")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setPara_tail(value); - } - if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setPara_tailAlpha(value); - } - if (entry.getKey().equalsIgnoreCase("para_tailRight")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setPara_tailRight(value); - } - if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setPara_tailRightAlpha(value); - } - if (entry.getKey().equalsIgnoreCase("newEner")) { - String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); - phd.setNewEner(value); - } - if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class); - value.put(key, entryValue); - } - phd.setMapEnerKD(value); - } - if (entry.getKey().equalsIgnoreCase("mapResoKD")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); - for (Map.Entry objectEntry:jsonMap.entrySet()) { - String key = objectEntry.getKey(); - GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class); - value.put(key, entryValue); - } - phd.setMapResoKD(value); - } - if (entry.getKey().equalsIgnoreCase("vEnergy")) { - List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); - phd.setVEnergy(value); - } - if (entry.getKey().equalsIgnoreCase("vBase")) { - List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); - phd.setVBase(value); - } - if (entry.getKey().equalsIgnoreCase("vLc")) { - List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); - phd.setVLc(value); - } - if (entry.getKey().equalsIgnoreCase("vScac")) { - List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); - phd.setVScac(value); - } - if (entry.getKey().equalsIgnoreCase("vPeak")) { - List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class); - phd.setVPeak(value); - } - if (entry.getKey().equalsIgnoreCase("baseCtrls")) { - BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class); - phd.setBaseCtrls(value); - } - if (entry.getKey().equalsIgnoreCase("usedEner")) { - String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); - phd.setUsedEner(value); - } - if (entry.getKey().equalsIgnoreCase("usedEnerKD")) { - GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class); - phd.setUsedEnerKD(value); - } - if (entry.getKey().equalsIgnoreCase("usedEnerPara")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setUsedEnerPara(value); - } - if (entry.getKey().equalsIgnoreCase("usedReso")) { - String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); - phd.setUsedReso(value); - } - if (entry.getKey().equalsIgnoreCase("usedResoKD")) { - GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class); - phd.setUsedResoKD(value); - } - if (entry.getKey().equalsIgnoreCase("usedResoPara")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setUsedResoPara(value); - } - if (entry.getKey().equalsIgnoreCase("usedEffi")) { - String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); - phd.setUsedEffi(value); - } - if (entry.getKey().equalsIgnoreCase("usedEffiKD")) { - GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class); - phd.setUsedEffiKD(value); - } - if (entry.getKey().equalsIgnoreCase("usedEffiPara")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setUsedEffiPara(value); - } - if (entry.getKey().equalsIgnoreCase("usedTotE")) { - String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); - phd.setUsedTotE(value); - } - if (entry.getKey().equalsIgnoreCase("usedTotEKD")) { - TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class); - phd.setUsedTotEKD(value); - } - if (entry.getKey().equalsIgnoreCase("usedTotEPara")) { - ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); - phd.setUsedTotEPara(value); - } - } - BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); - if(CollectionUtils.isNotEmpty(phd.getMapEnerKD())) { - String key = ""; - key = phd.getNewEner(); - phd.setUsedEner(key); - GEnergyBlock source = new GEnergyBlock(); - GEnergyBlock gEnergyBlock = phd.getMapEnerKD().get(phd.getNewEner()); - BeanUtils.copyProperties(gEnergyBlock, source); - phd.setUsedEnerKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = phd.getMapEnerPara().get(phd.getNewEner()); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedEnerPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapResoKD())) { - String key = ""; - key = phd.getNewReso(); - phd.setUsedReso(key); - GResolutionBlock source = new GResolutionBlock(); - GResolutionBlock gResolutionBlock = phd.getMapResoKD().get(phd.getNewReso()); - BeanUtils.copyProperties(gResolutionBlock, source); - phd.setUsedResoKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = phd.getMapResoPara().get(phd.getNewReso()); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedResoPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapEffiKD())) { - String key = ""; - key = phd.getNewEffi(); - phd.setUsedEffi(key); - GEfficiencyBlock source = new GEfficiencyBlock(); - GEfficiencyBlock gEfficiencyBlock = phd.getMapEffiKD().get(phd.getNewEffi()); - BeanUtils.copyProperties(gEfficiencyBlock, source); - phd.setUsedEffiKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = Objects.nonNull(phd.getMapEffiPara().get(phd.getNewEffi()))?phd.getMapEffiPara().get(phd.getNewEffi()):new ParameterInfo(); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedEffiPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapTotEKD())) { - String key = ""; - key = phd.getNewTotE(); - phd.setUsedTotE(key); - TotaleffBlock source = new TotaleffBlock(); - TotaleffBlock totaleffBlock = phd.getMapTotEKD().get(phd.getNewTotE()); - BeanUtils.copyProperties(totaleffBlock, source); - phd.setUsedTotEKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = Objects.nonNull(phd.getMapTotEPara().get(phd.getNewTotE()))?phd.getMapTotEPara().get(phd.getNewTotE()):new ParameterInfo(); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedTotEPara(info); - } - - for (PeakInfo peak:phd.getVPeak()) { - if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilBetaChan)) { - peak.recoilBetaChan = "1"; - } - if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilDeltaChan)) { - peak.recoilDeltaChan = "1"; - } - } - //重新分析各峰值对应的核素信息 - NuclidesIdent(phd, mapLines); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } finally { - if (Objects.nonNull(tmpFile)) { - tmpFile.delete(); - } - } - return true; - } - - public int SettingChanged(PHDFile phd) { - SpecSetup newSets = phd.getSetting(); - SpecSetup oldSets = phd.getUsedSetting(); - - if(newSets.getECutAnalysis_Low() != oldSets.getECutAnalysis_Low() - || newSets.getECutAnalysis_High() != oldSets.getECutAnalysis_High() - || newSets.getEnergyTolerance() != oldSets.getEnergyTolerance() - || newSets.getPss_low() != oldSets.getCalibrationPSS_low() - || newSets.getBaseImprovePSS() != oldSets.getBaseImprovePSS() - || newSets.getK_back() != oldSets.getK_back() - || newSets.getK_alpha() != oldSets.getK_alpha() - || newSets.getK_beta() != oldSets.getK_beta() - || newSets.getRiskLevelK() != oldSets.getRiskLevelK() - || newSets.getRefTime_act() != oldSets.getRefTime_act() - || newSets.getRefTime_conc() != oldSets.getRefTime_conc()) - { - return 1; - } - - List old_ener = phd.getUsedEnerPara().getP(); - List new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP(); - if(old_ener.size() != new_ener.size()) return 1; - for(int i=0; i 1E-6){ - return 1; - } - } - - List old_reso = phd.getUsedResoPara().getP(); - List new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP(); - if(old_reso.size() != new_reso.size()) return 1; - for(int i=0; i 1E-6){ - return 1; - } - } - - List old_effi = phd.getUsedEffiPara().getP(); - List new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP(); - if(old_effi.size() != new_effi.size()) return -1; - for(int i=0; i 1E-6){ - return -1; - } - } - return 0; - } - - public void UpdateEfficiency(PHDFile phd) { - int peakNum = phd.getVPeak().size(); - List vEner = new LinkedList<>(); - for (int i=0; i vEffi = calValuesOut.counts; - for (int i=0; i map){ - // 当重新分析时先清除上一次的分析结果 - phd.getMapNucActMda().clear(); - for(int i=0; i mapHalflife = new HashMap<>(); // 用其他核素半衰期计算活度/浓度的核素 - List vNuclides = new LinkedList<>(); // 只识别不计算活度/浓度的核素 - ReadSpecialNuclides(mapHalflife, vNuclides); - - double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - int peakNum = phd.getVPeak().size(); - for (Map.Entry iter: map.entrySet()){ - if(iter.getValue().halflife <= 0){ - continue; - } - FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 - - List vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量 - List vYield = iter.getValue().vyield; - List vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 - List vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 - for (int i=0; i= 510 && phd.getVPeak().get(j).energy <= 512) { - continue; // 峰中心道能量为511的峰不进行核素识别 - } - if(vEnergy.get(i) < phd.getVPeak().get(j).energy - energyWidth){ - break; - } else if(vEnergy.get(i) <= phd.getVPeak().get(j).energy + energyWidth) { - sum_found += vEffi.get(i) * vYield.get(i); - vFit.set(i, j); - if(iter.getValue().maxYeildIdx == i){ - mainPeakIdx = j; - } - break; - } - } - sum_total += vEffi.get(i) * vYield.get(i); - } - - // 核素匹配到峰 - if(sum_total > 0) { - // 如果该核素属特殊核素,则用“特殊核素配置文件”中指明的其他核素的半衰期 - double halflife = (Objects.nonNull(mapHalflife.get(iter.getKey()))? iter.getValue().halflife : mapHalflife.get(iter.getKey())); - double lambda = Math.log(2.0) / halflife; - double rate = sum_found / sum_total; - if(rate > 0.5) { - // 获取用于计算Activity、MDC的主γ峰和最大分支比 - double maxFoundYield = vYield.get(iter.getValue().maxYeildIdx); - if(mainPeakIdx < 0) - { - maxFoundYield = 0; - for(int ii=0; ii= 0 && vYield.get(ii) > maxFoundYield) { - mainPeakIdx = vFit.get(ii); - maxFoundYield = vYield.get(ii); - } - } - if(mainPeakIdx < 0) continue; - } - - NuclideActMda ActMda = phd.getMapNucActMda().get(iter.getKey()); - boolean bActBigger = CalculateMDCs(phd, ActMda, mainPeakIdx, lambda, maxFoundYield, 1.0); - - if(rate > 0.8 || bActBigger) { - ActMda.setHalflife(halflife); - ActMda.setKey_flag(-1); - if(!vNuclides.contains(iter.getKey())) // 需要计算活度浓度的核素 - { - ActMda.setBCalculateMDA(true); - } else { - ActMda.setActivity(0); - ActMda.setAct_err(0); - ActMda.setEfficiency(0); - ActMda.setEffi_err(0); - ActMda.setMda(0); - ActMda.setMdc(0); - ActMda.setConcentration(0); - } - - int fitLineNum = 0, peakIdx = -1; - for(int ii=0; ii= 0) { - // 向峰信息表中添加识别到的核素 - if(vFit.get(ii) != peakIdx) { - phd.getVPeak().get(vFit.get(ii)).nuclides.add(iter.getKey()); - peakIdx = vFit.get(ii); - } - // 添加匹配的γ射线的信息 - if(vFit.get(ii) == mainPeakIdx){ - ActMda.setCalculateIdx(fitLineNum); - } - if(iter.getValue().maxYeildIdx == ii && iter.getValue().key_flag >= 0){ - ActMda.setKey_flag(fitLineNum); - } - ActMda.getVPeakIdx().add(peakIdx+1); - ActMda.getFullNames().add(iter.getValue().fullNames.get(ii)); - ActMda.getVEnergy().add(vEnergy.get(ii)); - ActMda.getVUncertE().add(iter.getValue().vuncertE.get(ii)); - ActMda.getVYield().add(vYield.get(ii)); - ActMda.getVUncertY().add(iter.getValue().vuncertY.get(ii)); - ++fitLineNum; - } - } - phd.getMapNucActMda().put(iter.getKey(), ActMda); - } - } - } - } - } - - private void ReadSpecialNuclides(Map mapHalflife, List vNuclides) { - try { - String fileName = parameterFilePath+"/nuclide_ActMdc.txt"; - File t_file = new File(fileName); - List readLines = FileUtils.readLines(t_file, "UTF-8"); - for (int i=0;i< readLines.size();i++){ - String line = readLines.get(i); - if(line.contains("#MDA")) { - for (int j=i+1; j strList = Arrays.asList(line.split("\\s")); - if(strList.size() == 3) { - mapHalflife.put(strList.get(0), Double.valueOf(strList.get(2)) * 86400); - } - }else { - i=j; - break; - } - } - break; - } - if(line.contains("#Identify")) { - for (int j=i+1; j strList = Arrays.asList(line.split("\\s")); - vNuclides.addAll(strList); - } - } - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private void FilterNuclideLine(NuclideLines lines, double lowE) { - List vE = lines.venergy; - for(int i=0, j=0; i 0) { - List vY = lines.vyield; - lines.maxYeildIdx = 0; - double maxYield = vY.get(0); - for(int ii=1; ii maxYield) { - maxYield = vY.get(ii); - lines.maxYeildIdx = ii; - } - } - } else{ - lines.maxYeildIdx = lines.key_flag; - } - } - - private boolean CalculateMDCs(PHDFile phd, NuclideActMda nucActMda, int mainPeakIdx, double lambda, double keyLineYield, double CCF){ - // 计算衰变校正因子——DCF - try { - Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - double Ts = collectStart.getTime()/1000 - collectStop.getTime()/1000; // 采样时间 - double Td = collectStop.getTime()/1000 - acqStart.getTime()/1000; // 衰变时间 - double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间 - double Tl = phd.getAcq().getAcquisition_live_time(); // 能谱获取活时间 - double Svol = phd.getCollect().getAir_volume(); // 样品采样体积 - double DCF1, DCF2, DCF3; - - if ( Ts == 0 ) DCF1 = 1; - else DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts)); - if ( Td == 0 ) DCF2 = 1; - else DCF2 = Math.exp(lambda*Td); - if ( Ta == 0 ) DCF3 = 1; - else DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta)); - - double DCF_act = Math.exp(lambda * (phd.getUsedSetting().getRefTime_act().getTime()/1000 - acqStart.getTime()/1000)); - double DCF_conc = Math.exp(lambda * (phd.getUsedSetting().getRefTime_conc().getTime()/1000 - collectStart.getTime()/1000)); - - PeakInfo peak = phd.getVPeak().get(mainPeakIdx); - double netKeyPeakArea = peak.area; - double linePeakAreaErr = peak.areaErr; - - double detectorEfficiency = peak.efficiency; - double detectorEfficiencyError = 0.01 * peak.efficiency; - double fwhmc = peak.fwhmc; - int index = (int)(peak.peakCentroid + 0.5) - 1; - double lcc = phd.getVLc().get(index); - double baseline = phd.getVBase().get(index); - - double activity, mda; - if ( keyLineYield == 0 ) { - activity = 0; - mda = 0; - } else { - activity = ( netKeyPeakArea * CCF * DCF3*DCF_act ) / ( keyLineYield * detectorEfficiency * Tl ) ;//Bq,参考时间为referenceTimeActivity - mda = (2 * fwhmc * (lcc - baseline) / 0.8591 ) * CCF * DCF3*DCF_act / ( keyLineYield * detectorEfficiency * Tl ) ;//Bq,参考时间为referenceTimeActivity - } - double concentration = ( netKeyPeakArea * CCF*DCF1*DCF2*DCF3*DCF_conc ) / ( keyLineYield * detectorEfficiency * Tl ) *1e6/ Svol;//mBq/m3,参考时间为referenceTimeConc - double mdc = (2 * fwhmc * (lcc - baseline) / 0.8591 ) * CCF*DCF1*DCF2*DCF3*DCF_conc / ( keyLineYield * detectorEfficiency * Tl ) *1e6 / Svol; - double activityErr = Math.sqrt( Math.pow(linePeakAreaErr/netKeyPeakArea, 2) + Math.pow(detectorEfficiencyError/detectorEfficiency, 2) ) * activity; - - nucActMda.setActivity(activity); - nucActMda.setAct_err(activityErr); - nucActMda.setMda(mda); - nucActMda.setMdc(mdc); - nucActMda.setEfficiency(peak.efficiency); - nucActMda.setEffi_err(detectorEfficiencyError); - nucActMda.setConcentration(concentration); - - return (activity > mda); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - public Map GetNuclideLines(List nuclideList) { - Map mapLines = new HashMap<>(); - if(nuclideList.size() < 1){ - return mapLines; - } - for(String name : nuclideList) { - NuclideLines nlines = new NuclideLines(); - List nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); - for(int j=0;j 0) { - nlines.key_flag = j; - nlines.maxYeildIdx = j; - } - } - mapLines.put(name, nlines); - } - long start = System.currentTimeMillis(); - List halfs = spectrumAnalysisMapper.getHalf(nuclideList); - for(int m=0;m 1 && phd.getVBase().size() == m_nCount) { - if(start < 1){ - start = 1; - } - if(end > m_nCount || end < 1){ - end = m_nCount; - } - - for(int i=start-1; i Differance(PHDFile phd, List vecPeak, List m_vCount, long m_nCount){ - System.loadLibrary("GammaAnaly"); - List pointlist = new LinkedList<>(); - int start =0; - long end = -1; - int peakNum = vecPeak.size(); - if(peakNum < 1 || phd.getVBase().size() != m_nCount){ - return pointlist; - } - - if(start < 1){ - start = 1; - } - if(end > m_nCount || end < 1){ - end = m_nCount; - } - - // 找出在所给范围的第一道拟合峰和最后一道拟合峰的索引下标 - int index = 0; - int startPeak = -1; - int endPeak = peakNum-1; - while(index < peakNum && start > vecPeak.get(index).right){ - ++index; - } - if(index < peakNum) { - startPeak = index; - while(index < peakNum && vecPeak.get(index).left < end){ - ++index; - } - endPeak = index-1; - } - if(startPeak < 0 || startPeak > endPeak){ - return pointlist; - } - - List regPeak = new LinkedList<>(); - int channel = 1; - for(int i=start-1; i= peak.left && channel <= peak.right) { - if(CollectionUtils.isEmpty(regPeak)) { - List regChan = new LinkedList<>(); - for(double d=peak.left; d<=peak.right; d+=1.0){ - regChan.add(d); - } - List vBase = phd.getVBase(); - List t_base = vBase.subList(peak.left-1, peak.right); - regPeak = CalValuesHandler.interp1(peak, t_base, regChan); - } - // 差值 = 原谱值 - 峰面积 - SeriseData seriseData = new SeriseData(); - seriseData.setX(channel); - seriseData.setY(m_vCount.get(i) - regPeak.get(channel-peak.left)); - pointlist.add(seriseData); - } else if(m_vCount.get(i) > 0 && phd.getVBase().get(i) > 0) { - SeriseData seriseData = new SeriseData(); - seriseData.setX(channel); - seriseData.setY(m_vCount.get(i) - phd.getVBase().get(i)); - pointlist.add(seriseData); - } else{ - SeriseData seriseData = new SeriseData(); - seriseData.setX(channel); - seriseData.setY(0); - pointlist.add(seriseData); - } - - if(vecPeak.get(startPeak).right < channel) { - ++startPeak; regPeak.clear(); - } - if(startPeak > endPeak){ - break; - } - } - for(int i=channel; i 0 && phd.getVBase().get(i) > 0) { - SeriseData seriseData = new SeriseData(); - seriseData.setX(i+1); - seriseData.setY(m_vCount.get(i) - phd.getVBase().get(i)); - pointlist.add(seriseData); - } else { - SeriseData seriseData = new SeriseData(); - seriseData.setX(i+1); - seriseData.setY(0); - pointlist.add(seriseData); - } - } - - return pointlist; - } - - public void ReadData(List m_vEnergy, List m_vNuclide){ - try { - String filePath = parameterFilePath+File.separator+"Energy_Nuclide.txt"; - File file = new File(filePath); - List readLines = FileUtils.readLines(file, "UTF-8"); - for (int i=0; i= 2 && m_curParam.getP().get(2) > 0) { - // Polynomial: y=a0+a1*x+a2*x^2+a3*x^3 - equation +="Energy = "+m_curParam.getP().get(1)+" + C * "+m_curParam.getP().get(2); - for(int i=3; i<=p_size; ++i) { - equation += " + C" + (i-1) +" * "+m_curParam.getP().get(i)+""; - } - } else if(p_size == 1) { - equation = "Energy = "+m_curParam.getP().get(1)+" * C"; - } - return equation; - } - - public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Map map) { - System.loadLibrary("GammaAnaly"); - int num = m_vCurEnergy.size(); - if(num < 1){ - return; - } - List datalist = new LinkedList<>(); - if(CollectionUtils.isNotEmpty(m_curParam.getP())) { - // 拟合曲线 - ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); - lData.setType("Line"); - - List vChan = new LinkedList<>(); - double MaxChan = Double.valueOf(phd.getSpec().getNum_g_channel()); - double d = 1; - double dStep = MaxChan / 30 * 2; - while(d < MaxChan) { - vChan.add(d); - d+= dStep; - } - vChan.add(MaxChan); - - List vFit = CalValuesHandler.calFcnEval(vChan, m_curParam.getP()).counts; - for(int i=0; i 0){ - SeriseData seriseData = new SeriseData(); - seriseData.setX(vChan.get(i)); - seriseData.setY(vFit.get(i)); - lData.getPointlist().add(seriseData); - } - } - if(lData.getPointlist().size() > 1){ - datalist.add(lData); - } - } - - // Channel——Energy 点集 - ChartData pData = new ChartData(); - pData.setColor("red"); - pData.setType("Scatter"); - for(int i=0; i= 2 && m_curParam.getP().get(1) > 0 && m_curParam.getP().get(2) > 0) { - // Square root of polynomial: y = sqrt(a0+a1*x+a2*x^2+a3*x^3 ) - equation += "FWHM = ("+m_curParam.getP().get(1)+" + E * "+m_curParam.getP().get(2); - for(int i=3; i<=p_size; ++i) { - equation += " + E"+(i-1)+" * "+m_curParam.getP().get(i); - } - equation += ")"+1+"/"+2+""; - } - return equation; - } - - public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Map map) { - System.loadLibrary("GammaAnaly"); - int num = m_vCurEnergy.size(); - if(num < 1) return; - - List datalist = new LinkedList<>(); - if(CollectionUtils.isNotEmpty(m_curParam.getP())) { - // 拟合曲线 - ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); - lData.setType("Line"); - - List vChan = new LinkedList<>(); - vChan.add(1.0); - vChan.add(Double.valueOf(phd.getSpec().getNum_g_channel())); - - List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; - double d = vEner.get(0), maxE = vEner.get(1); - double dStep = maxE / 30 * 2; - - vEner.remove(vEner.size()-1); - while(d < maxE) { - vEner.add(d); - d += dStep; - } - vEner.add(maxE); - - List vFit = CalValuesHandler.calFcnEval(vEner, m_curParam.getP()).counts; - for(int i=0; i 0){ - SeriseData seriseData = new SeriseData(); - seriseData.setX(vEner.get(i)); - seriseData.setY(vFit.get(i)); - lData.getPointlist().add(seriseData); - } - } - if(lData.getPointlist().size() > 1){ - datalist.add(lData); - } - } - - // Channel——Energy 点集 - ChartData pData = new ChartData(); - pData.setColor("red"); - pData.setType("Scatter"); - for(int i=0; i m_vCurEnergy, ParameterInfo m_curParam) { - String equation = ""; - if(m_curParam.getP().size() > 2) { - int p_size = m_curParam.getP().size()-1; - int e_size = m_vCurEnergy.size(); - int funId = m_curParam.getP().get(0).intValue(); - switch(funId) { - case 1: // Interpolation: y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x= 4) { - int i = 0; - if(i < 0 || i >= e_size) break; - - double y1, y0, x1, x0; - if(i < e_size - 1) - { - y1 = m_curParam.getP().get(i*2+3); - y0 = m_curParam.getP().get(i*2+1); - x1 = m_curParam.getP().get(i*2+2); - x0 = m_curParam.getP().get(i*2); - } - else { - y1 = m_curParam.getP().get(i*2+1); - y0 = m_curParam.getP().get(i*2-1); - x1 = m_curParam.getP().get(i*2); - x0 = m_curParam.getP().get(i*2-2); - } - equation += "Efficiency = "+y0+" + ("+y1+"-"+y0+") * (E - "+x0+") / ("+x1+" - "+x0+")"; - } - break; - case 5: // HT Efficiency: y = A*exp(-(E1/x)^k)*(1-exp(-(E2/x)^n)) - if(p_size == 5) { - for(int i=1; i<=p_size; ++i) { - if(m_curParam.getP().get(i) <= 0) break; - } - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1-exp(-("+m_curParam.getP().get(4)+" / E)"+m_curParam.getP().get(5)+"))"; - } - break; - case 6: // Polynomial in log(y) against log(x): log(y) = a0 + a1*log(x) +a2*log(x)^2+ a3*log(x)^3 - if(p_size >= 2) { - equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(E)"; - for(int i=3; i<=p_size; ++i) { - equation += " + "+m_curParam.getP().get(i)+" * log(E)"+(i-1)+""; - } - } - break; - case 8: // Polynomial in log(y) against log(1/x): log(y) = a0 + a1*log(c/x) + a2*log(c/x)^2 + a3*log(c/x)^3 + a4*log(c/x)^4 - if(p_size >= 3) { - equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(C/E)"; - for(int i=3; i<=p_size; ++i) { - equation += " + "+m_curParam.getP().get(i)+" * log(C/E)"+(i-1)+""; - } - } - break; - case 93: // HAE Efficiency (1-3): y=S*exp(-(E1/x)^k)*(1- exp(-(2*E3/(x-E3))^n)) - if(p_size == 5) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-(2 * "+m_curParam.getP().get(4)+" / (E - "+m_curParam.getP().get(4)+"))"+m_curParam.getP().get(5)+"))"; - } - break; - case 94: // HAE Efficiency (1-2): y=S*exp(-(E1/x)^k)*(1- exp(-b*(1/(x-E2))^m)) - if(p_size == 6) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+"))"; - } - break; - case 95: // HAE Efficiency (1-2-3): y = S * exp(-(E1/x)^k) * (1- exp(-b*(1/(x-E2))^m)) *(1 - exp(-(2*E3/(E-E3))^n)) - if(p_size == 8) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+")) * "+ - "(1 - exp(-(2 * "+m_curParam.getP().get(7)+" / (E - "+m_curParam.getP().get(7)+"))"+m_curParam.getP().get(8)+"))"; - } - break; - } - } - return equation; - } - - public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Map map) { - System.loadLibrary("GammaAnaly"); - int num = m_vCurEnergy.size(); - if(num < 1) return; - - List datalist = new LinkedList<>(); - if(CollectionUtils.isNotEmpty(m_curParam.getP())) { - // 拟合曲线 - ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); - lData.setType("Line"); - - List vChan = new LinkedList<>(); - vChan.add(1.0); - vChan.add(Double.valueOf(phd.getSpec().getNum_g_channel())); - - List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; - double d = vEner.get(0); - double maxE = vEner.get(1); - double dStep = maxE / 30 * 2; - - vEner.remove(vEner.size()-1); - while(d < maxE) { - vEner.add(d); - d += dStep; - } - vEner.add(maxE); - - List vFit = CalValuesHandler.calFcnEval(vEner, m_curParam.getP()).counts; - for(int i=0; i 0){ - SeriseData seriseData = new SeriseData(); - seriseData.setX(vEner.get(i)); - seriseData.setY(vFit.get(i)); - lData.getPointlist().add(seriseData); - } - } - if(lData.getPointlist().size() > 1){ - datalist.add(lData); - } - } - - // Channel——Energy 点集 - ChartData pData = new ChartData(); - pData.setColor("red"); - pData.setType("Scatter"); - for(int i=0; i 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 nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name); - return nuclideLines; - } - - public Map InitNuclideInfo(String name) { - Map 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 InitParentAndDaughter(String name) { - Map map = new HashMap<>(); - GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name); - List 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 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(); - this.GetInterMiddlData(phd, "", middleData); - if(bLog) { - return this.GetLogContent(middleData); - } else { - return this.GetReportContent(middleData); - } - } - - public boolean GetInterMiddlData(PHDFile phd, String userName, GStoreMiddleProcessData middleData){ - boolean bRet = true; - Map temp = new HashMap<>(); - try { - bRet = GetMiddleData(phd, userName, temp,middleData, MiddleDataType.InterAction.getType()); - middleData.analyses_type ="Interactive"; - } catch (ParseException e) { - throw new RuntimeException(e); - } - return bRet; - } - - public String GetLogContent(GStoreMiddleProcessData middleData){ - StringBuffer strBuffer = new StringBuffer(); - strBuffer.append("-------------------------- Sample Analyse Beginning at "+DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss")+" ---------------------------\n"); - strBuffer.append("\n"); - strBuffer.append("....................................... Read calibration data ........................................\n"); - strBuffer.append("\n"); - strBuffer.append("Reading gamma energy pairs(sampleID: "+middleData.sample_id+").....\n"); - strBuffer.append("\n"); - for (int i=0;i0) { - strBuffer.append("Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_E_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_E_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_E_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_E_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_E_Input+"\n"); - } - if(middleData.calibration_pairs_R_idCalPoint.size()>0) { - strBuffer.append("Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_R_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_R_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_R_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_R_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_R_Input+"\n"); - } - if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { - strBuffer.append("Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_EF_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_EF_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_EF_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_EF_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_EF_Input+"\n"); - } - if(middleData.calibration_pairs_T_idCalPoint.size()>0) { - strBuffer.append("Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); - strBuffer.append("Function: "+middleData.calibration_T_functionTypeDef+"\n"); - strBuffer.append("E: "+middleData.calibration_T_functionDef+"\n"); - strBuffer.append("P: "+middleData.calibration_T_coeff_string+"\n"); - strBuffer.append("Err: "+middleData.calibration_T_uncoeff_string+"\n"); - strBuffer.append("Data: "+middleData.calibration_pairs_T_Input+"\n"); - } - strBuffer.append("\n"); - strBuffer.append("........................................ Calibration Finished ........................................"); - strBuffer.append("\n"); - strBuffer.append("..................................... Starting Spectrum Analysis ....................................."); - strBuffer.append("\n"); - strBuffer.append("PROCESSING PARAMETERS.....\n"); - strBuffer.append("ECutAnalysis_Low : "+middleData.setting_specSetup.getECutAnalysis_Low()+"\n"); - strBuffer.append("ECutAnalysis_High : "+middleData.setting_specSetup.getECutAnalysis_High()+"\n"); - strBuffer.append("EnergyTolerance : "+middleData.setting_specSetup.getEnergyTolerance()+"\n"); - strBuffer.append("BaseImprovePSS : "+middleData.setting_specSetup.getBaseImprovePSS()+"\n"); - strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPss_low()+"\n"); - strBuffer.append("k_back : "+middleData.setting_specSetup.getK_back()+"\n"); - strBuffer.append("k_alpha : "+middleData.setting_specSetup.getK_alpha()+"\n"); - strBuffer.append("k_beta : "+middleData.setting_specSetup.getK_beta()+"\n"); - strBuffer.append("RiskLevelK : "+middleData.setting_specSetup.getRiskLevelK()+"\n"); - strBuffer.append("refTime_act : "+middleData.setting_specSetup.getRefTime_act()+"\n"); - strBuffer.append("refTime_conc : "+middleData.setting_specSetup.getRefTime_conc()+"\n"); - strBuffer.append("\n"); - strBuffer.append("CALIBRATION PARAMETERS.....\n"); - strBuffer.append("\n"); - strBuffer.append("CalibrationPSS_low : "+middleData.setting_specSetup.getCalibrationPSS_low()+"\n"); - strBuffer.append("CalibrationPSS_high : "+middleData.setting_specSetup.getCalibrationPSS_high()+"\n"); - strBuffer.append("bUpdateCal : "+(middleData.setting_specSetup.isBUpdateCal()?"1":"0")+"\n"); - strBuffer.append("KeepCalPeakSearchPeaks : "+(middleData.setting_specSetup.isKeepCalPeakSearchPeaks()?"1":"0")+"\n"); - strBuffer.append("\n"); - double peaksUsed = 0; - for(int m=0;m1) - { - qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); - } - strBuffer.append("Nuclide Identified.....\n"); - strBuffer.append("\n"); - strBuffer.append("Nuclides Identified : "+qsNuclidesName+"\n"); - strBuffer.append("Keyline Activities for Nuclides with defined Reference Line : \n"); - strBuffer.append("Activity Reference Time : "+middleData.sample_acquisiton_start+"\n"); - strBuffer.append("Concentration Reference Time : "+middleData.sample_collection_start+"\n"); - strBuffer.append("\n"); - for (int i=0;i1) { - qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); - } - strBuffer.append("#ACTIVITY SUMMARY\n"); - strBuffer.append(" Nuclides Identified: "+qsNuclidesName+"\n"); - strBuffer.append(" Keyline Activities for Nuclides: \n"); - strBuffer.append(" with defined Reference Line: \n"); - strBuffer.append(" Activity Reference Time: "+middleData.sample_acquisiton_start+"\n"); - strBuffer.append(" Concentration Reference Time: "+middleData.sample_collection_start+"\n"); - strBuffer.append(" \n"); - strBuffer.append(" \n"); - strBuffer.append(" \n"); - strBuffer.append(" Nuclide Halflife(s) Activity(Bq) RelErr% MDA(Bq) Conc(uBq/m^3) MDC\n"); - for (int i=0; i0) { - strBuffer.append("#Calibration\n"); - strBuffer.append(" Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_E_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_E_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_E_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_E_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_E_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - } - if(middleData.calibration_pairs_R_idCalPoint.size()>0) { - strBuffer.append(" Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_R_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_R_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_R_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_R_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_R_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - } - if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { - strBuffer.append(" Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_EF_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_EF_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_EF_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_EF_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_EF_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - } - if(middleData.calibration_pairs_T_idCalPoint.size()>0) { - strBuffer.append(" Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); - strBuffer.append(" Function: "+middleData.calibration_T_functionTypeDef+"\n"); - strBuffer.append(" E: "+middleData.calibration_T_functionDef+"\n"); - strBuffer.append(" P: "+middleData.calibration_T_coeff_string+"\n"); - strBuffer.append(" Err: "+middleData.calibration_T_uncoeff_string+"\n"); - strBuffer.append(" Data: "+middleData.calibration_pairs_T_Input+"\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - strBuffer.append("\n"); - } - strBuffer.append("#DATA QUALITY FLAGS\n"); - strBuffer.append(" Name Pass/Fail Value Test\n"); - for (int i=0;i DoubleLimit(List data){ - List rData = new LinkedList<>(); - for(int pos=0;pos DoubleLimit_G(List _data) { - NumberFormat numberFormat = new DecimalFormat("0.##########E0"); - List rdata = new LinkedList<>(); - for(int pos=0;pos<_data.size();pos++) { - if(Objects.isNull(_data.get(pos))) { - rdata.add("NULL"); - } else { - rdata.add(numberFormat.format(_data.get(pos))); - } - } - return rdata; - } - - public String EquationDescription(int funcId) { - String desc = ""; - switch (funcId) - { - case 1: desc = "y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x nucline,GStoreMiddleProcessData middleData, String type) throws ParseException { - boolean bRet=true; - //标准名称规范化 - String dataType = fileAnlyse.getMsgInfo().getData_type(); - String subDirSavePath = ""; - subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type()); - subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType); - Map fileNames = nameStandUtil.NameStandard(fileAnlyse); - String lcName = fileNames.get("lc"); - String scacName = fileNames.get("scac"); - String baselineName = fileNames.get("baseline"); - String logName = fileNames.get("log"); - String rptName = fileNames.get("rpt"); - String saveFileName = fileNames.get("saveFile"); - String path = nameStandUtil.SetFileDir(subDirSavePath, saveFileName); - middleData.analyses_analyst=userName; - String qsSaveFile = path+StringPool.SLASH+saveFileName; - qsSaveFile = qsSaveFile.replace(StringPool.BACK_SLASH, StringPool.SLASH); - String qsLogPath= path+StringPool.SLASH+middleData.analyses_analyst+"_"+logName; - qsLogPath = qsLogPath.replace(StringPool.BACK_SLASH, StringPool.SLASH); - String qsReportPath="Arr"+StringPool.SLASH+path+StringPool.SLASH+middleData.analyses_analyst+"_"+rptName; - qsReportPath = qsReportPath.replace(StringPool.BACK_SLASH, StringPool.SLASH); - - middleData.analyses_save_filePath = qsSaveFile; - middleData.analyses_LogPath = qsLogPath; - middleData.analyses_ReportPath = qsReportPath; - //获取算法数据 - if(type.equals(MiddleDataType.Auto.getType())) { - String anylseBegin; - String anylseEnd; - anylseBegin = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"); - bRet = AnalyseSpectrum(fileAnlyse,nucline); - anylseEnd = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"); - middleData.analyses_analysisBegin = anylseBegin; - middleData.analyses_analysisEnd = anylseEnd; - } - - - //gards_analyses - String qsBaseLinePath = path+StringPool.SLASH+middleData.analyses_analyst+"_"+baselineName; - qsBaseLinePath = qsBaseLinePath.replace(StringPool.BACK_SLASH, StringPool.SLASH); - // m_baseLineFileName; - String qsLcPath= path+StringPool.SLASH+middleData.analyses_analyst+"_"+lcName; - qsLcPath = qsLcPath.replace(StringPool.BACK_SLASH, StringPool.SLASH); - String qsScacPath= path+StringPool.SLASH+middleData.analyses_analyst+"_"+scacName; - qsScacPath = qsScacPath.replace(StringPool.BACK_SLASH, StringPool.SLASH); - - - - String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath; - String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath; - String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath; - - GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), qsSaveBaseLine); - GammaReportUtil.writeFile(fileAnlyse.getVLc(), "LC", qsSaveLc); - GammaReportUtil.writeFile(fileAnlyse.getVScac(), "SCSC", qsSaveScac); -// ftpUtil.saveFile(org.apache.commons.lang3.StringUtils.substringBeforeLast(qsSaveBaseLine, StringPool.SLASH), baselineName, new FileInputStream(fileAnlyse.getBaseCtrls())); -// WriteBaseInfo(fileAnlyse.getBaseCtrls(),qsSaveBaseLine); -// WriteLcScac(fileAnlyse.getVLc(),"Lc",qsSaveLc); -// WriteLcScac(fileAnlyse.getVScac(),"Scac",qsSaveScac); - - double totalNumber = 0.0; - for(int m=0;m temp = new LinkedList<>(); - for(int pos=0;pos temp = new LinkedList<>(); - for(int pos=0;pos temp = new LinkedList<>(); - for(int pos=0;pos temp = new LinkedList<>(); - for(int pos=0;pos0) { - funcType = fileAnlyse.getUsedEnerPara().getP().get(0).intValue(); - } - for(int m=1;m0) { - coeffEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1)); - } - - uncerNumber = fileAnlyse.getUsedEnerPara().getPerr().size(); - for(int m=0;m0) { - uncerEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1)); - } - funcDefEnergy = EquationDescription(funcType); - funcTypeDefEnergy = EquationName(funcType); - middleData.calibration_E_Caltype = CalType.ENERGY_CAL.getType(); - middleData.calibration_E_function = funcType; - middleData.calibration_E_functionDef = funcDefEnergy; - middleData.calibration_E_functionTypeDef = funcTypeDefEnergy; - middleData.calibration_E_startOfRange = 0; - middleData.calibration_E_endOfRange = 1; - middleData.calibration_E_coeff_string = coeffEnergy; - - - String coeffEffi = ""; - String uncerEffi = ""; - String funcDefEffi = ""; - String funcTypeDefEffi = ""; - coeffNumber = fileAnlyse.getUsedEffiPara().getP().size(); - if(coeffNumber>0) { - funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue(); - } - for(int m=1;m0) { - coeffEffi+=String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1)); - } - - uncerNumber = fileAnlyse.getUsedEffiPara().getPerr().size(); - for(int m=0;m0) { - uncerEffi+= String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1)); - } - funcDefEffi = EquationDescription(funcType); - funcTypeDefEffi = EquationName(funcType); - middleData.calibration_EF_Caltype = "efficiency"; - middleData.calibration_EF_function = funcType; - middleData.calibration_EF_functionDef = funcDefEffi; - middleData.calibration_EF_functionTypeDef = funcTypeDefEffi; - middleData.calibration_EF_startOfRange = 0; - middleData.calibration_EF_endOfRange = 1; - middleData.calibration_EF_coeff_string = coeffEffi; - - String coeffReso = ""; - String uncerReso = ""; - String funcDefReso = ""; - String funcTypeDefReso = ""; - coeffNumber = fileAnlyse.getUsedResoPara().getP().size(); - if(coeffNumber>0) { - funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue(); - } - for(int m=1;m0) { - coeffReso+= String.format("%e", fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1)); - } - - uncerNumber = fileAnlyse.getUsedResoPara().getPerr().size(); - for(int m=0;m0) { - uncerReso+= String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1)); - } - funcDefReso = EquationDescription(funcType); - funcTypeDefReso = EquationName(funcType); - middleData.calibration_R_Caltype = "Resolution"; - middleData.calibration_R_function = funcType; - middleData.calibration_R_functionDef = funcDefReso; - middleData.calibration_R_functionTypeDef = funcTypeDefReso; - middleData.calibration_R_startOfRange = 0; - middleData.calibration_R_endOfRange = 1; - middleData.calibration_R_coeff_string = coeffReso; - - String coeffTotE = ""; - String uncerTotE = ""; - String funcDefTotE = ""; - String funcTypeDefTotE = ""; - coeffNumber = fileAnlyse.getUsedTotEPara().getP().size(); - if(coeffNumber>0) { - funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue(); - } - for(int m=1;m0) { - coeffTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1)); - } - - uncerNumber = fileAnlyse.getUsedTotEPara().getPerr().size(); - for(int m=0;m0) { - uncerTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1)); - } - funcDefTotE = EquationDescription(funcType); - funcTypeDefTotE = EquationName(funcType); - middleData.calibration_T_Caltype = "TotalEfficiency"; - middleData.calibration_T_function = funcType; - middleData.calibration_T_functionDef = funcDefTotE; - middleData.calibration_T_functionTypeDef = funcTypeDefTotE; - middleData.calibration_T_startOfRange = 0; - middleData.calibration_T_endOfRange = 1; - middleData.calibration_T_coeff_string = coeffTotE; - - //gards_ peaks数据表 - - if(fileAnlyse.getVPeak().size() != 0) { - List dvctIDPEAK = new LinkedList<>(); - List dvctCENTROIDCHANNEL = new LinkedList<>(); - List dvctUNCCENTROIDCHANNEL = new LinkedList<>(); - List dvctENERGY = new LinkedList<>(); - List dvctUNCENERGY = new LinkedList<>(); - List dvctAREA = new LinkedList<>(); - List dvctnetCountRate = new LinkedList<>(); - List dvctuncNetCountRate = new LinkedList<>(); - List dvctUNCAREA = new LinkedList<>(); - List dvctEFFICIENCY = new LinkedList<>(); - List dvctUNCEFFICIENCY = new LinkedList<>(); - List dvctFWHM = new LinkedList<>(); - List dvctFWTM = new LinkedList<>(); - List dvctSIGNIFICANCE = new LinkedList<>(); - List dvctSENSITIVITY = new LinkedList<>(); - List dvctMULTIINDEX = new LinkedList<>(); - List dvctROISTART = new LinkedList<>(); - List dvctROIEND = new LinkedList<>(); - List dvctTAIL = new LinkedList<>(); - List dvctTAILALPHA = new LinkedList<>(); - List dvctUPPERTAIL = new LinkedList<>(); - List dvctUPPERTAILALPHA = new LinkedList<>(); - List dvctBWWIDTHCHAN = new LinkedList<>(); - List dvctRECOILBETACHAN = new LinkedList<>(); - List dvctRECOILDELTACHAN = new LinkedList<>(); - List dvctSTEPRAIO = new LinkedList<>(); - List dvctBACKGROUNDAREA = new LinkedList<>(); - List dvctMEANBACKCOUNT = new LinkedList<>(); - List dvctLC = new LinkedList<>(); - List dvctLD = new LinkedList<>(); - List dvctNuclide_name = new LinkedList<>(); - List dvctComments = new LinkedList<>(); - for(int m=0; m 1024){ - t_comment = t_comment.substring(0, 1025); - } - dvctComments.add(t_comment); - dvctNuclide_name.add(org.apache.commons.lang3.StringUtils.join(fileAnlyse.getVPeak().get(m).nuclides, ";")); - } - middleData.peaks_idPeak =dvctIDPEAK; - middleData.peaks_peakCentroid =DoubleLimit_G(dvctCENTROIDCHANNEL); - middleData.peaks_uncpeakCentroid =DoubleLimit_G(dvctUNCCENTROIDCHANNEL); - middleData.peaks_Energy =DoubleLimit_G(dvctENERGY); - middleData.peaks_uncEnergy =DoubleLimit_G(dvctUNCENERGY); - middleData.peaks_Area =DoubleLimit_G(dvctAREA); - middleData.peaks_areaErr =DoubleLimit_G(dvctUNCAREA); - middleData.peaks_Efficiency =DoubleLimit_G(dvctEFFICIENCY); - middleData.peaks_Uncefficiency =DoubleLimit_G(dvctUNCEFFICIENCY); - middleData.peaks_Fwhm =DoubleLimit_G(dvctFWHM); - middleData.peaks_Fwhmc = DoubleLimit_G(dvctFWTM); - middleData.peaks_Significance =DoubleLimit_G(dvctSIGNIFICANCE); - middleData.peaks_Sensitivity =DoubleLimit_G(dvctSENSITIVITY); - middleData.peaks_multiIndex =DoubleLimit_G(dvctMULTIINDEX); - middleData.peaks_ROIstart =DoubleLimit_G(dvctROISTART); - middleData.peaks_ROIend =DoubleLimit_G(dvctROIEND); - middleData.peaks_tail =DoubleLimit_G(dvctTAIL); - middleData.peaks_tailAlpha =DoubleLimit_G(dvctTAILALPHA); - middleData.peaks_upperTail =DoubleLimit_G(dvctUPPERTAIL); - middleData.peaks_upperTailAlpha =DoubleLimit_G(dvctUPPERTAILALPHA); - middleData.peaks_BWWidthChan =DoubleLimit_G(dvctBWWIDTHCHAN); - middleData.peaks_recoilBetaChan = DoubleLimit_G(dvctRECOILBETACHAN); - middleData.peaks_recoilDeltaChan =DoubleLimit_G(dvctRECOILDELTACHAN); - middleData.peaks_stepRatio =DoubleLimit_G(dvctSTEPRAIO); - middleData.peaks_backgroundArea =DoubleLimit_G(dvctBACKGROUNDAREA); - middleData.peaks_meanBackCount =DoubleLimit_G(dvctMEANBACKCOUNT); - middleData.peaks_Lc =DoubleLimit_G(dvctLC); - middleData.peaks_Ld =DoubleLimit_G(dvctLD); - middleData.peaks_comments = dvctComments; - middleData.peaks_Nuclide_name = dvctNuclide_name; - } - // gards_ nucl_lines_ided数据表 - GStoreMiddleProcessDataNuclLinesIded nucl_lines_ided_data = new GStoreMiddleProcessDataNuclLinesIded(); - for(Map.Entry itor:fileAnlyse.getMapNucActMda().entrySet()) { - List svctNUCLIDEFULLNAME = new LinkedList<>(); - List dvctIDPEAK = new LinkedList<>(); - List dvctENERGY = new LinkedList<>(); - List dvctUNCENERGY = new LinkedList<>(); - List dvctABUNDANCE = new LinkedList<>(); - List dvctUNCABUNDANCE = new LinkedList<>(); - List dvctACTIVITY = new LinkedList<>(); - List dvctUNCACTIVITY = new LinkedList<>(); - List dvctEFFIC = new LinkedList<>(); - List dvctUNEFFIC = new LinkedList<>(); - List dvctMDA = new LinkedList<>(); - List dvctKEY_FLAG = new LinkedList<>(); - List dvctCSC_RATIO = new LinkedList<>(); - List dvctCSC_RATIO_ERR = new LinkedList<>(); - List dvctCSC_MOD_FLAG = new LinkedList<>(); - List dvctMDC = new LinkedList<>(); - List dvctCONCENTRATION = new LinkedList<>(); - int first=itor.getValue().getFullNames().size(); - int second=itor.getValue().getVPeakIdx().size(); - first = first0?String.format("%e", itor.getValue().getMda()):"0.0"); - // dvctKEY_FLAG.add(itor.value().vYield.get(m)); - dvctCSC_RATIO.add(1.0); - dvctCSC_RATIO_ERR.add(0.0); - dvctCSC_MOD_FLAG.add(0.0); - if(itor.getValue().getKey_flag() == m) { - dvctKEY_FLAG.add(1.0); - } else { - dvctKEY_FLAG.add(0.0); - } - dvctMDC.add(String.format("%e", itor.getValue().getMdc())); - dvctCONCENTRATION.add(String.format("%e", itor.getValue().getConcentration())); - } - nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME; - nucl_lines_ided_data.idPeak =dvctIDPEAK; - nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY); - nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY); - nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE); - nucl_lines_ided_data.uncAbundance =DoubleLimit_G(dvctUNCABUNDANCE); - nucl_lines_ided_data.Activity = dvctACTIVITY; - nucl_lines_ided_data.uncActivity =DoubleLimit_G(dvctUNCACTIVITY); - nucl_lines_ided_data.Effic =DoubleLimit_G(dvctEFFIC); - nucl_lines_ided_data.uncEffic =DoubleLimit_G(dvctUNEFFIC); - nucl_lines_ided_data.Mda = dvctMDA; - nucl_lines_ided_data.key_flag =DoubleLimit_G(dvctKEY_FLAG); - nucl_lines_ided_data.csc_ratio =DoubleLimit_G(dvctCSC_RATIO); - nucl_lines_ided_data.csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR); - nucl_lines_ided_data.csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG); - nucl_lines_ided_data.MDC = dvctMDC; - nucl_lines_ided_data.Concentration = dvctCONCENTRATION; - middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data); - } - // gards_ nucl_ided数据表 - if( fileAnlyse.getMapNucActMda().size() != 0) { - List svctNUCLIDEFULLNAME = new LinkedList<>(); - List svctTYPE = new LinkedList<>(); - List dvctHALFLIFE = new LinkedList<>(); - List dvctAVE_ACTIV = new LinkedList<>(); - List dvctAVE_ACTIV_ERR = new LinkedList<>(); - List dvctACTIV_KEY = new LinkedList<>(); - List dvctACTIV_KEY_ERR = new LinkedList<>(); - List dvctMDA = new LinkedList<>(); - List dvctMDA_ERR = new LinkedList<>(); - List dvctNID_FLAG = new LinkedList<>(); - List dvctCSC_RATIO = new LinkedList<>(); - List dvctCSC_RATIO_ERR = new LinkedList<>(); - List dvctCSC_MOD_FLAG = new LinkedList<>(); - List dvctMDC = new LinkedList<>(); - List dvctCONCENTRATION = new LinkedList<>(); - List dvctKey_Energy = new LinkedList<>(); - List dvctKey_Yield = new LinkedList<>(); - for(Map.Entry itor_v: fileAnlyse.getMapNucActMda().entrySet()) { - String nuclideName = itor_v.getKey(); - svctNUCLIDEFULLNAME.add(nuclideName); - dvctHALFLIFE.add(itor_v.getValue().getHalflife()); - dvctACTIV_KEY.add(itor_v.getValue().getActivity()); - dvctACTIV_KEY_ERR.add(itor_v.getValue().getAct_err()); - dvctMDA.add(String.format("%e", itor_v.getValue().getMda())); - dvctMDC.add(itor_v.getValue().getMdc()>0?String.format("%e", itor_v.getValue().getMdc()):"0.0"); - dvctCONCENTRATION.add(String.format("%e", itor_v.getValue().getConcentration())); - dvctCSC_RATIO.add(1.0); - dvctCSC_RATIO_ERR.add(0.0); - if(itor_v.getValue().getCalculateIdx() >= 0 && itor_v.getValue().getCalculateIdx()= 0 && itor_v.getValue().getCalculateIdx() qvctQC_NAME = new LinkedList<>(); - List dvctQC_VALUE = new LinkedList<>(); - List qvctQC_STANDARD = new LinkedList<>(); - List dvctQC_RESULT = new LinkedList<>(); - for(Map.Entry itor_q:fileAnlyse.getQcItems().entrySet()) { - String nuclideName = itor_q.getKey(); - qvctQC_NAME.add(nuclideName); - dvctQC_VALUE.add(itor_q.getValue().getValue()); - qvctQC_STANDARD.add(itor_q.getValue().getStandard()); - dvctQC_RESULT.add(itor_q.getValue().isBPass()?1.0:0.0); - } - middleData.QC_CHECK_QC_NAME=qvctQC_NAME; - middleData.QC_CHECK_QC_RESULT=DoubleLimit_G(dvctQC_RESULT); - middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD; - middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE); - } - //sample info - middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time(); - middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time(); - if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) { - middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); - if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) { - middleData.sample_Avg_Flow_Rate = String.format("%.5f", fileAnlyse.getCollect().getAir_volume()/fileAnlyse.getQcItems().get("col_time").getValue()); - } - } - if(Objects.nonNull(fileAnlyse.getQcItems().get("decay_time"))) { - middleData.sample_decay_time = String.format("%.5f", fileAnlyse.getQcItems().get("decay_time").getValue()); - } - if(Objects.nonNull(fileAnlyse.getQcItems().get("acq_time"))) { - middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue()); - } - middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume()); - middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time(); - String acquisition_start = middleData.sample_acquisiton_start; - Date dataTime = DateUtils.parseDate(acquisition_start); - middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss"); - middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ; - middleData.sample_stationID = fileAnlyse.getHeader().getSite_code(); - middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code(); - middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry(); - middleData.sample_Type = fileAnlyse.getHeader().getSystem_type(); - middleData.setting_specSetup = fileAnlyse.getUsedSetting(); - middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt(); - middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt(); - return bRet; - } - - public Map UpdateDatasNuclideActivity(Map mapNucAct, Date act_ref, Date con_ref) { - Map map = new HashMap<>(); - map.put("dateTime_act_ref", act_ref); - map.put("dateTime_con_ref", con_ref); - - //m_mapAct = mapNucAct; - int size_map = mapNucAct.size(); - if(size_map < 1){ - return map; - } - List nuclideActivityList = new LinkedList<>(); - for(Map.Entry iter:mapNucAct.entrySet()){ - TableNuclideActivity tableNuclideActivity = new TableNuclideActivity(); - NuclideActMda nuc = iter.getValue(); - tableNuclideActivity.setNuclide(iter.getKey()); - char units = 'S'; - double halflife = nuc.getHalflife(); - if(halflife >= 31556736) // 1年 = 365.24 * 24 * 60 * 60 = 31556736s - { - halflife /= 31556736; - units = 'A'; - } - else if(halflife >= 86400) // 1天 = 24 * 60 * 60 = 86400s - { - halflife /= 86400; - units = 'D'; - } - else if(halflife >= 3600) - { - halflife /= 3600; - units = 'H'; - } - tableNuclideActivity.setHalfLife(halflife+" "+units); - tableNuclideActivity.setEnergy(nuc.getVEnergy().get(nuc.getCalculateIdx()).toString()); - tableNuclideActivity.setYield(String.valueOf(nuc.getVYield().get(nuc.getCalculateIdx())*100)); - - String str_effi = (nuc.getEfficiency() <= 0 ? "null" : String.valueOf(nuc.getEfficiency())); - tableNuclideActivity.setEfficiency(str_effi); - - String str_act = (nuc.getActivity() <= 0 ? "null" : String.valueOf(nuc.getActivity())); - tableNuclideActivity.setActivity(str_act); - - String str_act_err = (nuc.getActivity() <= 0 ? "null" : String.valueOf(nuc.getAct_err() / nuc.getActivity() * 100)); - tableNuclideActivity.setActErr(str_act_err); - - String str_mda = (nuc.getMda() <= 0 ? "null" : String.valueOf(nuc.getMda())); - tableNuclideActivity.setMda(str_mda); - - String str_con = (nuc.getConcentration() <= 0 ? "null" : String.valueOf(nuc.getConcentration())); - tableNuclideActivity.setConc(str_con); - - String str_mdc = (nuc.getMdc() <= 0 ? "null" : String.valueOf(nuc.getMdc())); - tableNuclideActivity.setMdc(str_mdc); - nuclideActivityList.add(tableNuclideActivity); - } - map.put("table", nuclideActivityList); - return map; - } - - public String RightFill(String str, int fieldWidth) { - String fillChar = " "; - int fillNum = fieldWidth - str.length(); - while(fillNum > 0) { - str+=fillChar; - --fillNum; - } - return str; - } - - public String MakeUpSpectrum(PHDFile phd) { - StringBuffer spectrum = new StringBuffer(); - - spectrum.append("BEGIN IMS2.0\r\n"); - spectrum.append("MSG_TYPE "+phd.getMsgInfo().getMsg_type()+"\r\n"); - spectrum.append("MSG_ID "+phd.getMsgInfo().getMsg_id()+" "+phd.getMsgInfo().getMsg_src_code()+"\r\n"); - if(phd.getMsgInfo().isVerify_srid()) { - spectrum.append("REF_ID\r\n"); - spectrum.append(phd.getMsgInfo().getRef_id_str()+" "+phd.getMsgInfo().getRef_src_code()+" "+phd.getMsgInfo().getSeq_num()+" "+phd.getMsgInfo().getTot_num()+"\r\n"); - spectrum.append("PROD_ID "+phd.getMsgInfo().getProduct_id()+" "+phd.getMsgInfo().getDelivery_id()+"\r\n"); - } - spectrum.append("DATA_TYPE "+phd.getMsgInfo().getData_type()+"\r\n"); - - List data_types = new LinkedList<>(); - data_types.add("SAMPLEPHD"); - data_types.add("SPHDF"); - data_types.add("SPHDP"); - data_types.add("GASBKPHD"); - data_types.add("BLANKPHD"); - data_types.add("DETBKPHD"); - data_types.add("QCPHD"); - data_types.add("CALIBPHD"); - - if(!data_types.contains(phd.getMsgInfo().getData_type())){ - return spectrum.toString(); - } - - // #Header - spectrum.append("#Header "+phd.getHeader().getDesignator()+"\r\n"); - spectrum.append(RightFill(phd.getHeader().getSite_code(), 5)+ - " "+RightFill(phd.getHeader().getDetector_code(), 9)+ - " "+RightFill(phd.getHeader().getSystem_type().toUpperCase(), 1)+ - " "+RightFill(phd.getHeader().getSample_geometry(), 17)+ - " "+RightFill(phd.getHeader().getSpectrum_quantity(), 4)+"\r\n"); - spectrum.append(phd.getHeader().getSample_ref_id() + "\r\n"); - spectrum.append(RightFill(phd.getHeader().getMeasurement_id(), 31)+" "+RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31)+" "+phd.getHeader().getGas_bk_measurement_id()+"\r\n"); - spectrum.append(phd.getHeader().getTransmit_date()+" "+phd.getHeader().getTransmit_time()+"\r\n"); - - // #Comment - if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { - String comment = phd.getOriTotalCmt().replace("\r\n", "\n"); - comment.replace("\n", "\r\n"); - spectrum.append("#Comment\r\n"); - spectrum.append(comment + "\r\n"); - } - - // #Collection - spectrum.append("#Collection\r\n"); - spectrum.append(phd.getCollect().getCollection_start_date()+" "+phd.getCollect().getCollection_start_time()+ - " "+phd.getCollect().getCollection_stop_date()+" "+phd.getCollect().getCollection_stop_time()+" "+phd.getCollect().getAir_volume()+"\r\n"); - - // #Acquisition - spectrum.append("#Acquisition\r\n"); - spectrum.append(phd.getAcq().getAcquisition_start_date()+" "+phd.getAcq().getAcquisition_start_time()+ - " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ - " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); - - // #Processing - if(phd.getProcess().getSample_volume_of_Xe() > 0) { - spectrum.append("#Processing\r\n"); - spectrum.append(RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8)+"\r\n"+ - " "+RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8)+"\r\n"+ - " "+phd.getProcess().getArchive_bottle_id()+"\r\n"); - } - - // #Sample - if(phd.getSampleBlock().getDimension_1() > 0) { - spectrum.append("#Sample\r\n"); - spectrum.append(phd.getSampleBlock().getDimension_1()+" "+phd.getSampleBlock().getDimension_2()+"\r\n"); - } - - // Certificate - if(CollectionUtils.isNotEmpty(phd.getCertificate().getG_energy())) { - spectrum.append("#Certificate\r\n"); - spectrum.append(phd.getCertificate().getTotal_source_activity()+""+ phd.getCertificate().getAssay_date()+"" - + phd.getCertificate().getAssay_time()+""+phd.getCertificate().getUnits_activity() + "\r\n"); - - int fieldWidth = 12; - for(int i=0; i 0) { - spectrum.append("#TotalEff\r\n"); - TotaleffBlock g_totE = phd.getUsedTotEKD(); - for(int i=0; i 0 ? channel-1 : channel; // 确保索引大于等于0 - if(phd.getVEnergy().size() == m_nCount && index < m_nCount) // 确保索引有效 - { - int index2 = (index < m_nCount-1 ? index + 1 : index - 1); - double y1 = phd.getVEnergy().get(index); - double y2 = phd.getVEnergy().get(index2); - y = y1 + (y2 - y1) / (index2 - index) * (channel - index); - } - return y; - } - - public List InitList(double energy, double tolerance, List nuclides){ - if(nuclides.size() < 1){ - return new LinkedList<>(); - } - double min = energy - tolerance; - double max = energy + tolerance; - List nuclideList = spectrumAnalysisMapper.findNuclideList(min, max, nuclides); - return nuclideList; - } - - public void InitTable(String name, Map map, PHDFile phd){ - InitNuclideInfo(name, map); - long span = phd.getSpec().getG_energy_span(); - List nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span); - if (CollectionUtils.isNotEmpty(nuclideTableList)){ - map.put("table", nuclideTableList); - InitChart(nuclideTableList, phd, map); - } - } - - public void InitNuclideInfo(String name, Map 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 nuclideTableList, PHDFile phd, Map map){ - List> chartList = new LinkedList<>(); - for (int i=0; i < nuclideTableList.size(); i++){ - Map chartMap = new HashMap<>(); - GardsNuclLinesLib item = nuclideTableList.get(i); - double energy = item.getEnergy(); - List chartData = Energy_Count_Base(energy, 30, phd); - String title = "Line" + (i+1); - String bottom = "Abundance:" + item.getYield(); - String selPos = energy+""; - String cursorText = energy + " keV"; - chartMap.put("chartData", chartData); - chartMap.put("title", title); - chartMap.put("bottom", bottom); - chartMap.put("selPos", selPos); - chartMap.put("cursorText", cursorText); - chartList.add(chartMap); - } - map.put("chart", chartList); - } - - public List Energy_Count_Base(double energy, int chanNum, PHDFile phd) { - List datalist = new LinkedList<>(); - int channel = GetChannelByEnergy(energy, 0, phd); - int start = channel-chanNum/2, end = channel+chanNum/2; - if(start < 1) { - start = 1; - end = start + chanNum; - } else if(end > phd.getSpec().getNum_g_channel()) { - end = (int) phd.getSpec().getNum_g_channel(); - start = end - chanNum; - } - datalist.add(Energy_CountCahrt(start, end, phd)); - datalist.add(Energy_BaseLine(start, end, phd)); - return datalist; - } - - public ChartData Energy_CountCahrt(int start, int end, PHDFile phd) { - ChartData data1 = new ChartData(); - if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel()) { - if(start < 1){ - start = 1; - } - if(end < 1 || end > phd.getSpec().getNum_g_channel()){ - end = (int) phd.getSpec().getNum_g_channel(); - } - for(int i=start-1; iSpectrum.counts[i] == 0) continue; - data1.getPointlist().add(seriseData); - } - data1.setName("Energy"); - data1.setGroup("energy"); - data1.setColor("255,255,0"); // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; - } - return data1; - } - - public ChartData Energy_BaseLine(int start, int end, PHDFile phd) { - ChartData cData = new ChartData(); - if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { - if(start < 1){ - start = 1; - } - if(end > phd.getSpec().getNum_g_channel() || end < 1){ - end = (int) phd.getSpec().getNum_g_channel(); - } - - for(int i=start-1; i= energy) { - if(phd.getVEnergy().get(i) - energy > energy - phd.getVEnergy().get(i-1)){ - channel = i; // 道在索引(i-1)处 - } else{ - channel = i+1; // 道在索引(i)处 - } - break; - } - } - return channel; - } - - public void InitPara(PHDFile phd){ - List Acal_tail_para = new LinkedList<>(); - Acal_tail_para.add(99.0); - Acal_tail_para.add(0.0); - Acal_tail_para.add(0.0); - Acal_tail_para.add(0.0); - phd.getPara_tail().setP(Acal_tail_para); - List Acal_tail_alpha_para = new LinkedList<>(); - Acal_tail_alpha_para.add(98.0); - Acal_tail_alpha_para.add(1.0); - phd.getPara_tailAlpha().setP(Acal_tail_alpha_para); - List Acal_tail_right_para = new LinkedList<>(); - Acal_tail_right_para.add(98.0); - Acal_tail_right_para.add(0.35); - phd.getPara_tailRight().setP(Acal_tail_right_para); - List Acal_tail_right_alpha_para = new LinkedList<>(); - Acal_tail_right_alpha_para.add(98.0); - Acal_tail_right_alpha_para.add(1.0); - phd.getPara_tailRightAlpha().setP(Acal_tail_right_alpha_para); - List Acal_step_ratio_para = new LinkedList<>(); - Acal_step_ratio_para.add(98.0); - Acal_step_ratio_para.add(0.0); - phd.getPara_stepRatio().setP(Acal_step_ratio_para); - } - - public void PeaksChanged(PHDFile phd) { - System.loadLibrary("GammaAnaly"); - List vCentroid = new LinkedList<>(); - List vFwhmCh = new LinkedList<>(); - List vTail = new LinkedList<>(); - List vUpperTail = new LinkedList<>(); - for (PeakInfo peak: phd.getVPeak()) { - vCentroid.add(peak.peakCentroid); - vFwhmCh.add(peak.fwhmc); - vTail.add(peak.tail); - vUpperTail.add(peak.upperTail); - } - //重新计算各个peak的左值 右值 multiIndex - StructInsertOutput structInsertOutput = CalValuesHandler.ComputePeakRange(phd.getVPeak().size(), (int) phd.getSpec().getNum_g_channel(), vCentroid, vFwhmCh, vTail, vUpperTail); - System.out.println(structInsertOutput.vLeft.size()); - } - - public int FindNearPeak(List vPeak, int channel, boolean bFind) { - boolean t_bFind = false; - int i=0, peakNum = vPeak.size(); - for(; i= peak.left && channel <= peak.right) { - // 如果 channel 在峰的左右边界内 - if(peak.multiIndex > 0 && channel > peak.peakCentroid) { - // 如果是重峰,且 channel 在重峰的第一个峰的中心道右侧 - int j = i; - double temp = channel - peak.peakCentroid; - while(++j < peakNum && vPeak.get(j).multiIndex == peak.multiIndex) { - if(Math.abs(vPeak.get(j).peakCentroid - channel) < temp) // 找出重峰中峰中心道离 channel 最近的峰 - { - temp = Math.abs(vPeak.get(j).peakCentroid - channel); - i = j; - } - } - } - // channel 在索引(i)对应的峰内 - t_bFind = true; - break; - } else if(peak.left > channel) { - // channel 不在任何峰内,找离它最近的峰 - if(i>0 && channel-vPeak.get(i-1).peakCentroid < peak.peakCentroid-channel) i -= 1; - break; - } - } - if(i >= peakNum) i -= 1; - if(bFind) bFind = t_bFind; - return i; - } - - public List FitPeakBaseLine(PHDFile phd, List vIdx){ - List tablePeaksList = new LinkedList<>(); - int peakNum = vIdx.size(); - for (int i=0; i InitPeakTable(List vPeak) { - List result = new LinkedList<>(); - for(int i=0; i vPeakIdx) { - if(lines.halflife <= 0) { - return; - } - // 过滤核素能量小于ECutAnalysis_Low的射线 - FilterNuclideLine(lines, phd.getUsedSetting().getECutAnalysis_Low()); - - // 获取需特殊处理的核素 - Map mapHalflife = new HashMap<>(); // 用其他核素半衰期计算活度/浓度的核素 - List vNuclides = new LinkedList<>(); // 只识别不计算活度/浓度的核素 - ReadSpecialNuclides(mapHalflife, vNuclides); - - double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - List vEnergy = lines.venergy; // 该核素的所有γ射线能量 - double maxYield = 0; - int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 - - NuclideActMda ActMda = new NuclideActMda(); - ActMda.setHalflife(Objects.isNull(mapHalflife.get(nucName))?lines.halflife : mapHalflife.get(nucName)); - for (int i=0, j=0; i maxYield) { - maxYield = ActMda.getVYield().get(i); - mainPeakIdx = ActMda.getVPeakIdx().get(i)-1; - ActMda.setCalculateIdx(i); - } - } - if(mainPeakIdx < 0) { - return; - } - - // 如果该核素属特殊核素,则用“特殊核素配置文件”中指明的其他核素的半衰期 - double halflife = Objects.isNull(mapHalflife.get(nucName))?lines.halflife : mapHalflife.get(nucName); - double lambda = Math.log(2.0) / halflife; - - CalculateMDCs(phd, ActMda, mainPeakIdx, lambda, maxYield, 1.0); - - ActMda.setBCalculateMDA(true); - phd.getMapNucActMda().put(nucName, ActMda); - } - - public void ReCalcMdaMdc(PHDFile phd, String nuclide, int removePeakIdx) { - NuclideActMda it = phd.getMapNucActMda().get(nuclide); - if(Objects.isNull(it)) { - return; - } - NuclideActMda nuc = it; - // 如果该核素只与一个峰对应则直接删除该核素的 MDA 信息 - if(nuc.getVPeakIdx().size() == 1) { - phd.getMapNucActMda().remove(nuclide); - return; - } - // 否则删除该核素与该峰所有关联的射线信息 - boolean needReCalc = false; - for(int i=nuc.getVPeakIdx().size()-1; i>=0; i--) { - if(nuc.getVPeakIdx().get(i) == removePeakIdx) { - nuc.getVEnergy().remove(i); - nuc.getVUncertE().remove(i); - nuc.getVYield().remove(i); - nuc.getVUncertY().remove(i); - nuc.getFullNames().remove(i); - if(nuc.getCalculateIdx() == i && nuc.isBCalculateMDA()) { - needReCalc = true; - } - } - } - nuc.getVPeakIdx().remove(removePeakIdx); - // 如果该核素只与一个峰对应则直接删除该核素的 MDA 信息 - if(nuc.getVPeakIdx().size() < 1) { - phd.getMapNucActMda().remove(nuclide); - return; - } - - if(needReCalc) { - double maxYield = 0; - int mainPeakIdx = -1; - for(int j=0; j maxYield) { - nuc.setCalculateIdx(j); - maxYield = nuc.getVYield().get(j); - mainPeakIdx = nuc.getVPeakIdx().get(j)-1; - } - } - if(mainPeakIdx < 0) { - return; - } - CalculateMDCs(phd, nuc, mainPeakIdx, Math.log(2.0)/nuc.getHalflife(), maxYield, 1.0); - } - } - - public File analyzeFile(String path, String fileName) { - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; - File file = null; - try { - //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - //切换文件路径 - ftpClient.changeWorkingDirectory(path); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)){ - file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return file; - } -} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index cd2d4251..9dad3679 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -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; diff --git a/jeecg-module-spectrum-analysis/pom.xml b/jeecg-module-spectrum-analysis/pom.xml index 1496c748..3e973fc7 100644 --- a/jeecg-module-spectrum-analysis/pom.xml +++ b/jeecg-module-spectrum-analysis/pom.xml @@ -23,6 +23,11 @@ jeecg-boot-base-core + + org.jeecgframework.boot + jeecg-module-BetaGammaAnalyser + + org.ejml diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index 855bfbf3..fd97a2d7 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -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); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index e3c6d1b8..6823300e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -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 nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); + Map nuclideLinesMap = GetNuclideLines(nuclides); result.setSuccess(true); result.setResult(nuclideLinesMap); return result; @@ -230,7 +235,7 @@ public class GammaServiceImpl implements IGammaService { //加载phd数据所需的lc,scac,baseline数据 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_id、BaseLine、Lc、Scac、峰数量、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 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 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 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 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 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 vEner = phd.getMapNucActMda().get(str_key).getVEnergy(); + Double key_ener = Double.valueOf(nuclIdedSpectrum.getKeyEnergy()); + for(int i=0; i 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 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 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 nuclideLinesMap = GetNuclideLines(nuclides); + gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap); + //重新分析各峰值对应的核素信息 + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); Map map = new HashMap<>(); gammaFileUtil.UpdateChart(phd, map, colorMap); // 更新 ‘QC Flags’ 状态 @@ -464,6 +771,36 @@ public class GammaServiceImpl implements IGammaService { return result; } + public Map GetNuclideLines(List nuclideList) { + Map mapLines = new HashMap<>(); + if(nuclideList.size() < 1){ + return mapLines; + } + for(String name : nuclideList) { + NuclideLines nlines = new NuclideLines(); + List nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); + for(int j=0;j 0) { + nlines.key_flag = j; + nlines.maxYeildIdx = j; + } + } + mapLines.put(name, nlines); + } + List halfs = spectrumAnalysisMapper.getHalf(nuclideList); + for(int m=0;m tablePeaksList = gammaFileUtil.FitPeakBaseLine(phd, vIdx); + List 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 FitPeakBaseLine(PHDFile phd, List vIdx) { + List tablePeaksList = new LinkedList<>(); + int peakNum = vIdx.size(); + for (int i=0; i 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 mapNucLines = gammaFileUtil.GetNuclideLines(userLib); + Map 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 nuclideList = gammaFileUtil.InitList(bigDecimal.doubleValue(), 0.5, nuclides); + List 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 InitList(double energy, double tolerance, List nuclides) { + if(nuclides.size() < 1){ + return new LinkedList<>(); + } + double min = energy - tolerance; + double max = energy + tolerance; + List nuclideList = spectrumAnalysisMapper.findNuclideList(min, max, nuclides); + return nuclideList; + } + + public void InitTable(String name, Map map, PHDFile phd, Map colorMap) { + InitNuclideInfo(name, map); + long span = phd.getSpec().getG_energy_span(); + List 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 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 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 nuclideList = gammaFileUtil.InitList(bigDecimal.doubleValue(), tolerance, nuclides); + List 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 nuclLinesLibs = gammaFileUtil.InitNuclideLine(editEnergy, err, nuclideName); + List nuclLinesLibs = InitNuclideLine(editEnergy, err, nuclideName); map.put("nuclLinesLibs", nuclLinesLibs); - Map nuclideInfo = gammaFileUtil.InitNuclideInfo(nuclideName); + Map nuclideInfo = InitNuclideInfo(nuclideName); map.put("nuclideInfo", nuclideInfo); - Map daughter = gammaFileUtil.InitParentAndDaughter(nuclideName); + Map daughter = InitParentAndDaughter(nuclideName); map.put("daughter", daughter); result.setSuccess(true); result.setResult(map); return result; } + public List 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 nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name); + return nuclideLines; + } + + public Map InitNuclideInfo(String name) { + Map 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 InitParentAndDaughter(String name) { + Map map = new HashMap<>(); + GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name); + List 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 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(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 58cad01f..bcbab448 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -218,7 +218,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Result result = new Result(); List> 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文件同一个台站 名称格式化为最终名称 diff --git a/pom.xml b/pom.xml index 688fd618..371400cc 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,8 @@ jeecg-module-abnormal-alarm jeecg-module-auto-process jeecg-module-spectrum-analysis - + jeecg-module-BetaGammaAnalyser + @@ -201,6 +202,12 @@ jeecg-module-spectrum-analysis ${jeecgboot.version} + + + org.jeecgframework.boot + jeecg-module-BetaGammaAnalyser + ${jeecgboot.version} + org.jeecgframework.boot From 32ebf4915c7b6a3a914978b9381df6f43fe8d15c Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Sat, 7 Oct 2023 18:42:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:1.=E5=AE=8C=E6=88=90=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=88=86=E6=9E=90=E6=88=90=E5=8A=9F=E5=8F=91=E9=80=81=E7=BB=99?= =?UTF-8?q?redis=202.=E8=A7=A3=E5=86=B3=E8=8E=B7=E5=8F=96=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E6=8C=89=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/email/EmailServiceManager.java | 4 +-- .../java/org/jeecg/modules/ftp/FTPUtils.java | 2 +- .../modules/spectrum/Sample_B_Analysis.java | 36 ++++++++++++++++--- .../modules/spectrum/SamplephdSpectrum.java | 2 +- .../spectrum/SpectrumServiceQuotes.java | 3 ++ 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java index 7c6cec83..b7ca04b3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java @@ -126,7 +126,7 @@ public class EmailServiceManager { //如果邮箱邮件数量 > 0 final int messageCount = folder.getMessageCount(); if(messageCount > 0){ - SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GT,this.systemStartupTime); + SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE,this.systemStartupTime); Message[] messages = folder.search(searchTerm); Arrays.sort(messages, (o1, o2) -> { try { @@ -296,7 +296,7 @@ public class EmailServiceManager { public void close(){ try { if(null != folder){ - folder.close(); + folder.close(true); } if(null != store){ store.close(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java index aa44cb15..8a14d548 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ftp/FTPUtils.java @@ -300,7 +300,7 @@ public class FTPUtils { public void close(){ try{ if (client != null){ - client.logout(); +// client.logout(); client.disconnect(); } }catch (IOException e){ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java index 232c92fe..d4db2a98 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java @@ -2,17 +2,17 @@ package org.jeecg.modules.spectrum; import cn.hutool.core.io.FileUtil; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.base.dto.Info; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; -import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.DataTypeAbbr; -import org.jeecg.modules.base.enums.SampleStatus; +import org.jeecg.modules.base.enums.*; import org.jeecg.modules.config.datasource.DataSourceSwitcher; import org.jeecg.modules.exception.BAnalyseException; import org.jeecg.modules.exception.FileNotExistException; @@ -25,6 +25,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.transaction.TransactionStatus; import java.io.*; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; @@ -148,7 +151,7 @@ public class Sample_B_Analysis implements BlockConstant { /** * 执行解析过程 */ - public void start() throws BAnalyseException { + public void analysis() throws BAnalyseException { //标记整个分析过程是否分析失败 boolean analyseFail = false; try{ @@ -168,6 +171,8 @@ public class Sample_B_Analysis implements BlockConstant { //生成报告 Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport(); report.start(); + //发送数据到redis + pushToRedis(); }catch (Exception e){ analyseFail = true; e.printStackTrace(); @@ -332,6 +337,29 @@ public class Sample_B_Analysis implements BlockConstant { } } + /** + * 分析成功数据发送到Redis + */ + private void pushToRedis(){ + Info info = new Info(); + info.setStationId(this.sampleData.getStationId().toString()); + info.setSampleId(this.sampleData.getSampleId().toString()); + info.setSampleName(this.phdFileName); + final Instant instant = this.sampleData.getCollectStart().toInstant(); + final LocalDateTime collectTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); + info.setCollectionDate(collectTime); + info.setDatasource(DSType.ARMDARR.getType()); + info.setFullOrPrel(this.sampleData.getSpectralQualifie()); + info.setBetaOrGamma(SpectrumType.BETA.getType()); + Map nuclides = Maps.newHashMap(); + nuclides.put(XE_131m,String.valueOf(analyseResult.Xe131m_con)); + nuclides.put(XE_133,String.valueOf(analyseResult.Xe133_con)); + nuclides.put(XE_133m,String.valueOf(analyseResult.Xe133m_con)); + nuclides.put(XE_135,String.valueOf(analyseResult.Xe135_con)); + info.setNuclides(nuclides); + spectrumServiceQuotes.getRedisStreamUtil().pushAnalysis(info); + } + public Sample_B_Analysis.B_AnalysisReport getReport(){ return new Sample_B_Analysis.B_AnalysisReport(); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java index 9379e202..32e527df 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java @@ -76,7 +76,7 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ protected void autoAnalysis() throws Exception { if(this.sourceData.system_type.equals(SystemType.BETA.getType())){ Sample_B_Analysis bAnalysis = new Sample_B_Analysis(this); - bAnalysis.start(); + bAnalysis.analysis(); } if (this.sourceData.system_type.equals(SystemType.PARTICULATE.getType()) || this.sourceData.system_type.equals(SystemType.GAMMA.getType())) { Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData,super.ftpUtil); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java index 621d6a67..e4961f44 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import org.jeecg.common.properties.SoftwareProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.properties.TaskProperties; +import org.jeecg.common.util.RedisStreamUtil; import org.jeecg.modules.datasource.OraDataSourceProperties; import org.jeecg.modules.ftp.FTPProperties; import org.jeecg.modules.service.*; @@ -70,4 +71,6 @@ public class SpectrumServiceQuotes { private final SoftwareProperties softwareProperties; + private final RedisStreamUtil redisStreamUtil; + }