diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java index 96695ad7..8f9f85c1 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java @@ -554,7 +554,7 @@ public class Sample_C_Analysis { // 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA // serviceQuotes.getSampleDataService().updateStatus(null,null); /* GARDS_CALIBRATION_PAIRS_ROI 数据表保存 */ - saveCalibrationPairsROI(sampleId, idAnalysis); + saveCalibrationPairs(sampleId, idAnalysis); /* GARDS_CALIBRATION_ROI 数据表保存 */ saveCalibrationROI(sampleId, idAnalysis); /* Gards_Peaks_ROI 数据表保存 */ @@ -919,22 +919,21 @@ public class Sample_C_Analysis { this.middleDataMap = middleDataMap; } - public List saveCalibrationPairsROI(Integer sampleId, Integer IdAnalysis, - Integer roiId, GStoreMiddleProcessData middleData){ + public List saveCalibrationPairs(Integer sampleId, Integer IdAnalysis, + Integer roiId, GStoreMiddleProcessData middleData){ String pairsSampleType = middleData.getCalibration_pairs_sample_type(); - GardsCalibrationPairsRoi pairs = new GardsCalibrationPairsRoi(); + GardsCalibrationPairs pairs = new GardsCalibrationPairs(); // GARDS_CALIBRATION_PAIRS (Energy) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS String base_E_Paris = "calibration_pairs_E_idCalPoint"; PairsEDto pairsEDto = new PairsEDto(); BeanUtil.copyProperties(middleData, pairsEDto); - List pairsE = Lists.newArrayList(); + List pairsE = Lists.newArrayList(); if (!pairsEDto.getCalibration_pairs_E_idCalPoint().isEmpty()) { pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap); String pairsECaltype = middleData.getCalibration_pairs_E_Caltype(); String pairsEInput = middleData.getCalibration_pairs_E_Input(); - for (GardsCalibrationPairsRoi onePairs : pairsE) { + for (GardsCalibrationPairs onePairs : pairsE) { onePairs.setSampleId(sampleId); - onePairs.setRoiId(roiId); onePairs.setIdAnalysis(IdAnalysis); onePairs.setSampleType(pairsSampleType); onePairs.setCaltype(pairsECaltype); @@ -945,14 +944,13 @@ public class Sample_C_Analysis { String base_EF_Paris = "calibration_pairs_EF_idCalPoint"; PairsEFDto pairsEFDto = new PairsEFDto(); BeanUtil.copyProperties(middleData, pairsEFDto); - List pairsEF = Lists.newArrayList(); + List pairsEF = Lists.newArrayList(); if (!pairsEFDto.getCalibration_pairs_EF_idCalPoint().isEmpty()) { pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap); String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype(); String pairsEFInput = middleData.getCalibration_pairs_EF_Input(); - for (GardsCalibrationPairsRoi onePairs : pairsEF) { + for (GardsCalibrationPairs onePairs : pairsEF) { onePairs.setSampleId(sampleId); - onePairs.setRoiId(roiId); onePairs.setIdAnalysis(IdAnalysis); onePairs.setSampleType(pairsSampleType); onePairs.setCaltype(pairsEFCaltype); @@ -963,14 +961,13 @@ public class Sample_C_Analysis { String base_R_Paris = "calibration_pairs_R_idCalPoint"; PairsRDto pairsRDto = new PairsRDto(); BeanUtil.copyProperties(middleData,pairsRDto); - List pairsR = Lists.newArrayList(); + List pairsR = Lists.newArrayList(); if (!pairsRDto.getCalibration_pairs_R_idCalPoint().isEmpty()) { pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap); String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype(); String pairsRInput = middleData.getCalibration_pairs_R_Input(); - for (GardsCalibrationPairsRoi onePairs : pairsR) { + for (GardsCalibrationPairs onePairs : pairsR) { onePairs.setSampleId(sampleId); - onePairs.setRoiId(roiId); onePairs.setIdAnalysis(IdAnalysis); onePairs.setSampleType(pairsSampleType); onePairs.setCaltype(pairsRCaltype); @@ -981,14 +978,13 @@ public class Sample_C_Analysis { String base_T_Paris = "calibration_pairs_T_idCalPoint"; PairsTDto pairsTDto = new PairsTDto(); BeanUtil.copyProperties(middleData,pairsTDto); - List pairsT = Lists.newArrayList(); + List pairsT = Lists.newArrayList(); if (!pairsTDto.getCalibration_pairs_T_idCalPoint().isEmpty()) { pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap); String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype(); String pairsTInput = middleData.getCalibration_pairs_T_Input(); - for (GardsCalibrationPairsRoi onePairs : pairsT) { + for (GardsCalibrationPairs onePairs : pairsT) { onePairs.setSampleId(sampleId); - onePairs.setRoiId(roiId); onePairs.setIdAnalysis(IdAnalysis); onePairs.setSampleType(pairsSampleType); onePairs.setCaltype(pairsTCaltype); @@ -996,21 +992,21 @@ public class Sample_C_Analysis { } } // GARDS_CALIBRATION_PAIRS 汇总保存 - List allPairs = new ArrayList<>(); + List allPairs = new ArrayList<>(); allPairs.addAll(pairsE);allPairs.addAll(pairsEF); allPairs.addAll(pairsR);allPairs.addAll(pairsT); return allPairs; } - public void saveCalibrationPairsROI(Integer sampleId, Integer IdAnalysis){ - List pairsRois = new ArrayList<>(); + public void saveCalibrationPairs(Integer sampleId, Integer IdAnalysis){ + List pairsRois = new ArrayList<>(); Set> entries = this.middleDataMap.entrySet(); for (Map.Entry entry : entries) { Integer roiId = entry.getKey(); GStoreMiddleProcessData middleData = entry.getValue(); - pairsRois.addAll(saveCalibrationPairsROI(sampleId, IdAnalysis, roiId, middleData)); + pairsRois.addAll(saveCalibrationPairs(sampleId, IdAnalysis, roiId, middleData)); } - this.serviceQuotes.getCalibrationPairsRoiAutoService().saveBatch(pairsRois); + this.serviceQuotes.getGardsCalibrationPairsService().saveBatch(pairsRois); } public List saveCalibrationROI(Integer sampleId, Integer IdAnalysis, Integer roiId, @@ -1106,16 +1102,105 @@ public class Sample_C_Analysis { return calibrations; } + public List saveCalibration(Integer sampleId, Integer IdAnalysis, Integer roiId, + GStoreMiddleProcessData middleData){ + String calibrationSampleType = middleData.getCalibration_sample_type(); + List pairsEIdCalPoint = middleData.getCalibration_pairs_E_idCalPoint(); + List pairsEFIdCalPoint = middleData.getCalibration_pairs_EF_idCalPoint(); + List pairsRIdCalPoint = middleData.getCalibration_pairs_R_idCalPoint(); + List pairsTIdCalPoint = middleData.getCalibration_pairs_T_idCalPoint(); + List calibrations = new ArrayList<>(); + // GARDS_CALIBRATION (E) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsEIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + calibration.setCalType(middleData.getCalibration_E_Caltype()); + calibration.setFunction((int)middleData.getCalibration_E_function()); + calibration.setFunctionDef(middleData.getCalibration_E_functionDef()); + calibration.setStartOfRange((int)middleData.getCalibration_E_startOfRange()); + calibration.setEndOfRange((int)middleData.getCalibration_E_endOfRange()); + calibration.setCoeffString(middleData.getCalibration_E_coeff_string()); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (EF) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsEFIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String efCaltype = middleData.getCalibration_EF_Caltype(); + double efFunction = middleData.getCalibration_EF_function(); + String efFunctionDef = middleData.getCalibration_EF_functionDef(); + double efStartOfRange = middleData.getCalibration_EF_startOfRange(); + double efEndOfRange = middleData.getCalibration_EF_endOfRange(); + String efCoeffString = middleData.getCalibration_EF_coeff_string(); + calibration.setCalType(efCaltype); + calibration.setFunction((int)efFunction); + calibration.setFunctionDef(efFunctionDef); + calibration.setStartOfRange((int)efStartOfRange); + calibration.setEndOfRange((int)efEndOfRange); + calibration.setCoeffString(efCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (R) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsRIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String rCaltype = middleData.getCalibration_R_Caltype(); + double rFunction = middleData.getCalibration_R_function(); + String rFunctionDef = middleData.getCalibration_R_functionDef(); + double rStartOfRange = middleData.getCalibration_R_startOfRange(); + double rEndOfRange = middleData.getCalibration_R_endOfRange(); + String rCoeffString = middleData.getCalibration_R_coeff_string(); + calibration.setCalType(rCaltype); + calibration.setFunction((int)rFunction); + calibration.setFunctionDef(rFunctionDef); + calibration.setStartOfRange((int)rStartOfRange); + calibration.setEndOfRange((int)rEndOfRange); + calibration.setCoeffString(rCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (T) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsTIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String tCaltype = middleData.getCalibration_T_Caltype(); + double tFunction = middleData.getCalibration_T_function(); + String tFunctionDef = middleData.getCalibration_T_functionDef(); + double tStartOfRange = middleData.getCalibration_T_startOfRange(); + double tEndOfRange = middleData.getCalibration_T_endOfRange(); + String tCoeffString = middleData.getCalibration_T_coeff_string(); + calibration.setCalType(tCaltype); + calibration.setFunction((int)middleData.getCalibration_T_function()); + calibration.setFunctionDef(tFunctionDef); + calibration.setStartOfRange((int)tStartOfRange); + calibration.setEndOfRange((int)tEndOfRange); + calibration.setCoeffString(tCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + return calibrations; + } + public void saveCalibrationROI(Integer sampleId, Integer IdAnalysis){ - List calibrationRois = new ArrayList<>(); + List calibrationRois = new ArrayList<>(); Set> entries = this.middleDataMap.entrySet(); for (Map.Entry entry : entries) { Integer roiId = entry.getKey(); GStoreMiddleProcessData middleData = entry.getValue(); - calibrationRois.addAll(saveCalibrationROI(sampleId, IdAnalysis, roiId, middleData)); + calibrationRois.addAll(saveCalibration(sampleId, IdAnalysis, roiId, middleData)); } if (CollUtil.isNotEmpty(calibrationRois)) - this.serviceQuotes.getCalibrationRoiAutoService().createBatch(calibrationRois); + this.serviceQuotes.getGardsCalibrationService().createBatch(calibrationRois); } public List savePeaksROI(Integer sampleId, Integer IdAnalysis, diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java index 9164fab0..864f5e3c 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java @@ -336,83 +336,6 @@ public class SelfBaseUtil extends AbstractLogOrReport { return equation; } - /** - * 根据ROI卡出来的Gamma数据生成新的GammaPHD文件 - * @param pathName 文件存储路径 - * @param fileName GammaPHD名称 - * @param struct BetaPHD内容 - * @param g_counts ROI卡出来的Gamma数据 - */ - public static void createGammaFile(String pathName,String fileName, EnergySpectrumStruct struct, List g_counts) { - File file = new File(pathName + "\\" + fileName); - // 创建PrintWriter对象 - PrintWriter out = null; - DecimalFormat decimalFormat = new DecimalFormat("0.000000"); - try { - out = new PrintWriter(file); - out.println("BEGIN IMS2.0"); - out.println("MSG_TYPE DATA"); - // todo msg_type用的不对,dll没解析出这个字段 - out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type); - out.println("#Header 3"); - // 解析出的Gamma谱 系统类型暂时使用G - out.println(struct.site_code + " " + struct.detector_code + " G " + - struct.sample_geometry + " " + struct.spectrum_quantity); - out.println(struct.sample_ref_id); - out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0"); - out.println(struct.transmit_date + " " + struct.transmit_time); - out.println("#Collection"); - out.println(struct.collection_start_date + " " + struct.collection_start_time + " " + - struct.collection_stop_date + " " + struct.collection_stop_time + " " - + decimalFormat.format(struct.air_volume)); - out.println("#Acquisition"); - out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " + - decimalFormat.format(struct.acquisition_real_time) + " " + - decimalFormat.format(struct.acquisition_live_time)); - out.println("#g_Energy"); - - - format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out); - out.println("#g_Resolution"); - format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out); - out.println("#g_Efficiency"); - format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out); - out.println("#g_Spectrum"); - // num_g_channel 根据g_counts数量得来和PHD写的数字没有关系;g_energy_span是PHD写的值 - out.println(struct.num_g_channel + " " + struct.g_energy_span); - // 存储前一个数字 - String beforeStr = ""; - for (int i = 0; i < g_counts.size(); i++) { - String str = g_counts.get(i).toString(); - if(i % 5 == 0) { - if (i == 0) { - out.printf((i+1)+""); - } else { - out.printf("\n" + (i+1) ); - } - beforeStr = i+""; - } - - if(StrUtil.isEmpty(beforeStr)){ - beforeStr = str; - } - // 根据前一个字符长度计算需要的空格 - out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i)); - if(i == g_counts.size() - 1) { - out.println(); - } - beforeStr = str; - } - out.print("STOP"); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } finally { - if (null != out) { - out.close(); - } - } - } - /** * 根据DLL解析GammaPHD内容 得到PHDFile实体 * @param struct dll解析后的实体 @@ -618,6 +541,83 @@ public class SelfBaseUtil extends AbstractLogOrReport { return phd; } + /** + * 根据ROI卡出来的Gamma数据生成新的GammaPHD文件 + * @param pathName 文件存储路径 + * @param fileName GammaPHD名称 + * @param struct BetaPHD内容 + * @param g_counts ROI卡出来的Gamma数据 + */ + public static void createGammaFile(String pathName,String fileName, EnergySpectrumStruct struct, List g_counts) { + File file = new File(pathName + "\\" + fileName); + // 创建PrintWriter对象 + PrintWriter out = null; + DecimalFormat decimalFormat = new DecimalFormat("0.000000"); + try { + out = new PrintWriter(file); + out.println("BEGIN IMS2.0"); + out.println("MSG_TYPE DATA"); + // todo msg_type用的不对,dll没解析出这个字段 + out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type); + out.println("#Header 3"); + // 解析出的Gamma谱 系统类型暂时使用G + out.println(struct.site_code + " " + struct.detector_code + " G " + + struct.sample_geometry + " " + struct.spectrum_quantity); + out.println(struct.sample_ref_id); + out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0"); + out.println(struct.transmit_date + " " + struct.transmit_time); + out.println("#Collection"); + out.println(struct.collection_start_date + " " + struct.collection_start_time + " " + + struct.collection_stop_date + " " + struct.collection_stop_time + " " + + decimalFormat.format(struct.air_volume)); + out.println("#Acquisition"); + out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " + + decimalFormat.format(struct.acquisition_real_time) + " " + + decimalFormat.format(struct.acquisition_live_time)); + out.println("#g_Energy"); + + + format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out); + out.println("#g_Resolution"); + format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out); + out.println("#g_Efficiency"); + format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out); + out.println("#g_Spectrum"); + // num_g_channel 根据g_counts数量得来和PHD写的数字没有关系;g_energy_span是PHD写的值 + out.println(struct.num_g_channel + " " + struct.g_energy_span); + // 存储前一个数字 + String beforeStr = ""; + for (int i = 0; i < g_counts.size(); i++) { + String str = g_counts.get(i).toString(); + if(i % 5 == 0) { + if (i == 0) { + out.printf((i+1)+""); + } else { + out.printf("\n" + (i+1) ); + } + beforeStr = i+""; + } + + if(StrUtil.isEmpty(beforeStr)){ + beforeStr = str; + } + // 根据前一个字符长度计算需要的空格 + out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i)); + if(i == g_counts.size() - 1) { + out.println(); + } + beforeStr = str; + } + out.print("STOP"); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } finally { + if (null != out) { + out.close(); + } + } + } + /** * 数据格式化 * @param aList 第一列数据 diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/AnalysisManService.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/AnalysisManService.java index 89462b83..56db402b 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/AnalysisManService.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/AnalysisManService.java @@ -1,11 +1,10 @@ package org.jeecg.modules.service; -import org.jeecg.modules.base.entity.rnman.GardsAnalyses; +import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.entity.vo.CalMDCInfo; import org.jeecg.modules.entity.vo.GStoreMiddleProcessData; import org.jeecg.modules.entity.vo.PHDFile; import org.jeecg.modules.entity.vo.QcCheckItem; -import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import java.util.List; import java.util.Map; @@ -40,6 +39,10 @@ public interface AnalysisManService { void saveCalibrationROI(Integer sampleId, Integer idAnalysis); + void saveCalibrationPairs(Integer sampleId, Integer idAnalysis); + + void saveCalibration(Integer sampleId, Integer idAnalysis); + void savePeaksROI(Integer sampleId, Integer idAnalysis); void saveNuclLinesIdedROI(Integer sampleId, Integer idAnalysis); @@ -51,4 +54,6 @@ public interface AnalysisManService { void saveMDCROI(Integer sampleId, List> mdcInfoMaps, Integer idAnalysis); void saveAnalySettingROI(Integer sampleId, Integer idAnalysis, List phdFiles); + + void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List xeResultsList); } 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 e2700a9a..439fe821 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 @@ -402,6 +402,17 @@ public class PHDFileUtil extends AbstractLogOrReport { } } + public List readLine(String filePath) { + List allLines = new ArrayList<>(); + try { + File file = new File(filePath); + return FileUtils.readLines(file, "UTF-8"); + }catch (IOException e){ + e.printStackTrace(); + return allLines; + } + } + public void createBgCalPara(BetaDataFile betaDataFile, List gammaCalibrationSpectrumList,List betaCalibrationSpectrumList, List gammaCalibrationPairsList,List betaCalibrationPairsList) { SpectrumGroup spectrum_group = new SpectrumGroup(); @@ -663,17 +674,6 @@ public class PHDFileUtil extends AbstractLogOrReport { } } - public List readLine(String filePath) { - List allLines = new ArrayList<>(); - try { - File file = new File(filePath); - return FileUtils.readLines(file, "UTF-8"); - }catch (IOException e){ - e.printStackTrace(); - return allLines; - } - } - public void getLightColor(Map sampleMap, Map gasBgMap, Map detBgMap, Map qcMap) { SpectrumData sampleSpectrumData = (SpectrumData)sampleMap.get("spectrumData"); SpectrumData gasBgSpectrumData = (SpectrumData)gasBgMap.get("spectrumData"); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java index e39c8019..fede0794 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java @@ -18,10 +18,7 @@ import org.jeecg.modules.base.abstracts.AbstractLogOrReport; import org.jeecg.modules.base.enums.CalName; import org.jeecg.modules.base.enums.DataTypeAbbr; import org.jeecg.modules.base.enums.SampleFileHeader; -import org.jeecg.modules.entity.GardsCalibrationSpectrum; -import org.jeecg.modules.entity.GardsROIChannelsSpectrum; -import org.jeecg.modules.entity.GardsROIResultsSpectrum; -import org.jeecg.modules.entity.GardsXeResultsSpectrum; +import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; @@ -1421,4 +1418,56 @@ public class SelfStationUtil extends SelfBaseUtil { return baseLineCount; } + public void updateEnergyData(BetaDataFile betaDataFile, String type, int channel, + List gammaCalibrationPairs, + List betaCalibrationPairs, Map map) { + List channels = new LinkedList<>(); + List> gammaNewEnergyList = new LinkedList<>(); + List> betaNewEnergyList = new LinkedList<>(); + //填充道值数组的数据 + for (int i = 0; i < channel; i++) { + channels.add(Double.valueOf(i)); + } + //过滤出Gamma对应的表单数据 + List gammaChannelList = gammaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList()); + List gammaEnergyList = gammaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList()); + //计算gamma对应的数据 + List gammaFittingPara = EnergySpectrumHandler.GetFileFittingPara(gammaChannelList, gammaEnergyList); + //计算道值的能量 + List gammaEnergys = EnergySpectrumHandler.GetFileFittingData(channels,gammaFittingPara); + //将新计算的能量封装到数组 + for (Double calEnergy:gammaEnergys) { + List newEnergy = new LinkedList<>(); + newEnergy.add(calEnergy); + gammaNewEnergyList.add(newEnergy); + } + map.put("gammaEnergyData", gammaNewEnergyList); + + //过滤出Beta对应的表单数据 + List betaChannelList = betaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getXValue).collect(Collectors.toList()); + List betaEnergyList = betaCalibrationPairs.stream().map(GardsCalibrationPairsSpectrum::getYValue).collect(Collectors.toList()); + //计算beta对应的数据 + List betaFittingPara = EnergySpectrumHandler.GetFileFittingPara(betaChannelList, betaEnergyList); + + //计算道值的能量 + List betaEnergys = EnergySpectrumHandler.GetFileFittingData(channels,betaFittingPara); + //将新计算的能量封装到数组 + for (Double calEnergy:betaEnergys) { + List newEnergy = new LinkedList<>(); + newEnergy.add(calEnergy); + betaNewEnergyList.add(newEnergy); + } + map.put("betaEnergyData", betaNewEnergyList); + if (type.equalsIgnoreCase("sample")) { + betaDataFile.setSampleGammaEnergyList(gammaNewEnergyList); + betaDataFile.setSampleBetaEnergyList(betaNewEnergyList); + } else if (type.equalsIgnoreCase("gas")) { + betaDataFile.setGasGammaEnergyList(gammaNewEnergyList); + betaDataFile.setGasBetaEnergyList(betaNewEnergyList); + } else if (type.equalsIgnoreCase("det")) { + betaDataFile.setDetGammaEnergyList(gammaNewEnergyList); + betaDataFile.setDetBetaEnergyList(betaNewEnergyList); + } + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java index ada56e86..6a5e6758 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java @@ -1,59 +1,17 @@ package org.jeecg.modules.entity; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; +import org.jeecg.modules.base.entity.rnman.GardsXeResults; import java.io.Serializable; -import java.util.Date; @Data -public class GardsXeResultsSpectrum implements Serializable { - - /** - * 样品id - */ - private Integer sampleId; - - /** - * 分析ID号 - */ - private Integer idAnalysis; - - /** - * 核素名称 - */ - private String nuclideName; - /** - * 感兴趣区活度浓度 - */ - private Double conc; - - /** - * 感兴趣区活度浓度不确定度 - */ - private Double concErr; - /** - * 感兴趣区MDC - */ - private Double mdc; +public class GardsXeResultsSpectrum extends GardsXeResults implements Serializable { /** * 感兴趣区MDC */ private Double mda; - /** - * 感兴趣区LC - */ - private Double lc; - /** - * 感兴趣区识别标示;1:识别到,0,未识别到 - */ - private Integer nidFlag; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date moddate; private String color; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java index 2de9f6e2..525bd313 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java @@ -61,14 +61,18 @@ public class BetaDataFile implements Serializable { private List betaList; + /** e2c */ private List betaFittingPara; + /** c2e*/ private List betaFittingParaToUi; private List gammaList; + /** e2c */ private List gammaFittingPara; + /** c2e*/ private List gammaFittingParaToUi; private List betaListNow; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index b3b9122f..c76f898b 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -70,23 +70,29 @@ public interface SpectrumAnalysisMapper { List getPeaks(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getPeaksROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getPeaksROI(@Param(value = "dbName") String dbName, @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); List getCalibrationPairs(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getCalibrationPairsROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getCalibrationPairsROI(@Param(value = "dbName") String dbName, + @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); List getPara(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getParaROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getParaROI(@Param(value = "dbName") String dbName, @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); List getNuclLinesIded(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getNuclLinesIdedROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getNuclLinesIdedROI(@Param(value = "dbName") String dbName, @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); List getNuclIded(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getNuclIdedROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getNuclIdedROI(@Param(value = "dbName") String dbName, @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); List getQcCheck(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); @@ -94,7 +100,8 @@ public interface SpectrumAnalysisMapper { List getMDC(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); - List getMDCROI(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis); + List getMDCROI(@Param(value = "dbName") String dbName, @Param(value = "dbAnalyRoi") String dbAnalyRoi, + @Param(value = "idAnalysis") Integer idAnalysis); GardsAnalySetting getAnalySetting(@Param(value = "idAnalysis") Integer idAnalysis); diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/AnalysisManServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/AnalysisManServiceImpl.java similarity index 73% rename from jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/AnalysisManServiceImpl.java rename to jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/AnalysisManServiceImpl.java index 30fedf80..1e7d1e13 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/AnalysisManServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/AnalysisManServiceImpl.java @@ -1,4 +1,4 @@ -package org.jeecg.modules.service.impl; +package org.jeecg.modules.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; @@ -7,17 +7,13 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.google.common.collect.HashBasedTable; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.google.common.collect.Lists; -import com.google.common.collect.Table; import org.jeecg.modules.base.dto.*; import org.jeecg.modules.base.entity.rnman.*; import org.jeecg.modules.entity.vo.*; -import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; -import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Field; @@ -46,6 +42,12 @@ public class AnalysisManServiceImpl implements AnalysisManService { private IGardsQcCheckRoiManService qcCheckRoiManService; @Autowired private IGardsAnalySettingRoiService analySettingRoiService; + @Autowired + private IGardsCalibrationSpectrumService calibrationSpectrumService; + @Autowired + private IGardsCalibrationPairsSpectrumService calibrationPairsSpectrumService; + @Autowired + private IGardsXeResultsSpectrumService xeResultsSpectrumService; private Map middleDataMap; @@ -101,16 +103,22 @@ public class AnalysisManServiceImpl implements AnalysisManService { @Override public void deleteCalibrationPairs(Integer idAnalysis) { - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + /*LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(GardsCalibrationPairsRoi::getIdAnalysis, idAnalysis); - calibrationPairsRoiManService.remove(wrapper); + calibrationPairsRoiManService.remove(wrapper);*/ + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(GardsCalibrationPairs::getIdAnalysis, idAnalysis); + calibrationPairsSpectrumService.remove(wrapper); } @Override public void deleteCalibration(Integer idAnalysis) { - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + /*LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(GardsCalibrationRoi::getIdAnalysis, idAnalysis); - calibrationRoiManService.remove(wrapper); + calibrationRoiManService.remove(wrapper);*/ + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(GardsCalibration::getIdAnalysis, idAnalysis); + calibrationSpectrumService.remove(wrapper); } @Override @@ -263,6 +271,110 @@ public class AnalysisManServiceImpl implements AnalysisManService { calibrationRoiManService.createBatch(calibrationRois); } + @Override + public void saveCalibrationPairs(Integer sampleId, Integer idAnalysis) { + Set> entries = this.middleDataMap.entrySet(); + for (Map.Entry entry : entries) { + Integer roiId = entry.getKey(); + GStoreMiddleProcessData middleData = entry.getValue(); + List gardsCalibrationPairs = saveCalibrationPairs(sampleId, idAnalysis, roiId, middleData); + calibrationPairsSpectrumService.saveBatch(gardsCalibrationPairs); + return; + } + } + + public List saveCalibrationPairs(Integer sampleId, Integer IdAnalysis, + Integer roiId, GStoreMiddleProcessData middleData){ + String pairsSampleType = middleData.getCalibration_pairs_sample_type(); + GardsCalibrationPairs pairs = new GardsCalibrationPairs(); + // GARDS_CALIBRATION_PAIRS (Energy) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS + String base_E_Paris = "calibration_pairs_E_idCalPoint"; + PairsEDto pairsEDto = new PairsEDto(); + BeanUtil.copyProperties(middleData, pairsEDto); + List pairsE = Lists.newArrayList(); + if (pairsEDto.getCalibration_pairs_E_idCalPoint().size() > 0) { + pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap); + String pairsECaltype = middleData.getCalibration_pairs_E_Caltype(); + String pairsEInput = middleData.getCalibration_pairs_E_Input(); + for (GardsCalibrationPairs onePairs : pairsE) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsECaltype); + onePairs.setInput(pairsEInput); + } + } + // GARDS_CALIBRATION_PAIRS (Efficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS + String base_EF_Paris = "calibration_pairs_EF_idCalPoint"; + PairsEFDto pairsEFDto = new PairsEFDto(); + BeanUtil.copyProperties(middleData, pairsEFDto); + List pairsEF = Lists.newArrayList(); + if (pairsEFDto.getCalibration_pairs_EF_idCalPoint().size() > 0) { + pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap); + String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype(); + String pairsEFInput = middleData.getCalibration_pairs_EF_Input(); + for (GardsCalibrationPairs onePairs : pairsEF) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsEFCaltype); + onePairs.setInput(pairsEFInput); + } + } + // GARDS_CALIBRATION_PAIRS (Resolution) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS + String base_R_Paris = "calibration_pairs_R_idCalPoint"; + PairsRDto pairsRDto = new PairsRDto(); + BeanUtil.copyProperties(middleData,pairsRDto); + List pairsR = Lists.newArrayList(); + if (pairsRDto.getCalibration_pairs_R_idCalPoint().size() > 0) { + pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap); + String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype(); + String pairsRInput = middleData.getCalibration_pairs_R_Input(); + for (GardsCalibrationPairs onePairs : pairsR) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsRCaltype); + onePairs.setInput(pairsRInput); + } + } + // GARDS_CALIBRATION_PAIRS (TotalEfficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS + String base_T_Paris = "calibration_pairs_T_idCalPoint"; + PairsTDto pairsTDto = new PairsTDto(); + BeanUtil.copyProperties(middleData,pairsTDto); + List pairsT = Lists.newArrayList(); + if (pairsTDto.getCalibration_pairs_T_idCalPoint().size() > 0) { + pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap); + String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype(); + String pairsTInput = middleData.getCalibration_pairs_T_Input(); + for (GardsCalibrationPairs onePairs : pairsT) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsTCaltype); + onePairs.setInput(pairsTInput); + } + } + // GARDS_CALIBRATION_PAIRS 汇总保存 + List allPairs = new ArrayList<>(); + allPairs.addAll(pairsE); + allPairs.addAll(pairsEF); + allPairs.addAll(pairsR); + allPairs.addAll(pairsT); + return allPairs; + } + + @Override + public void saveCalibration(Integer sampleId, Integer idAnalysis) { + Set> entries = this.middleDataMap.entrySet(); + for (Map.Entry entry : entries) { + Integer roiId = entry.getKey(); + GStoreMiddleProcessData middleData = entry.getValue(); + List gardsCalibrations = saveCalibration(sampleId, idAnalysis, roiId, middleData); + return; + } + } + public List saveCalibrationROI(Integer sampleId, Integer IdAnalysis, Integer roiId, GStoreMiddleProcessData middleData){ String calibrationSampleType = middleData.getCalibration_sample_type(); @@ -356,6 +468,100 @@ public class AnalysisManServiceImpl implements AnalysisManService { return calibrations; } + public List saveCalibration(Integer sampleId, Integer IdAnalysis, Integer roiId, + GStoreMiddleProcessData middleData){ + String calibrationSampleType = middleData.getCalibration_sample_type(); + List pairsEIdCalPoint = middleData.getCalibration_pairs_E_idCalPoint(); + List pairsEFIdCalPoint = middleData.getCalibration_pairs_EF_idCalPoint(); + List pairsRIdCalPoint = middleData.getCalibration_pairs_R_idCalPoint(); + List pairsTIdCalPoint = middleData.getCalibration_pairs_T_idCalPoint(); + List calibrations = new ArrayList<>(); + // GARDS_CALIBRATION (E) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsEIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + calibration.setCalType(middleData.getCalibration_E_Caltype()); + calibration.setFunction((int)middleData.getCalibration_E_function()); + calibration.setFunctionDef(middleData.getCalibration_E_functionDef()); + calibration.setStartOfRange((int)middleData.getCalibration_E_startOfRange()); + calibration.setEndOfRange((int)middleData.getCalibration_E_endOfRange()); + calibration.setCoeffString(middleData.getCalibration_E_coeff_string()); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (EF) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsEFIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String efCaltype = middleData.getCalibration_EF_Caltype(); + double efFunction = middleData.getCalibration_EF_function(); + String efFunctionDef = middleData.getCalibration_EF_functionDef(); + double efStartOfRange = middleData.getCalibration_EF_startOfRange(); + double efEndOfRange = middleData.getCalibration_EF_endOfRange(); + String efCoeffString = middleData.getCalibration_EF_coeff_string(); + calibration.setCalType(efCaltype); + calibration.setFunction((int)efFunction); + calibration.setFunctionDef(efFunctionDef); + calibration.setStartOfRange((int)efStartOfRange); + calibration.setEndOfRange((int)efEndOfRange); + calibration.setCoeffString(efCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (R) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsRIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String rCaltype = middleData.getCalibration_R_Caltype(); + double rFunction = middleData.getCalibration_R_function(); + String rFunctionDef = middleData.getCalibration_R_functionDef(); + double rStartOfRange = middleData.getCalibration_R_startOfRange(); + double rEndOfRange = middleData.getCalibration_R_endOfRange(); + String rCoeffString = middleData.getCalibration_R_coeff_string(); + calibration.setCalType(rCaltype); + calibration.setFunction((int)rFunction); + calibration.setFunctionDef(rFunctionDef); + calibration.setStartOfRange((int)rStartOfRange); + calibration.setEndOfRange((int)rEndOfRange); + calibration.setCoeffString(rCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + // GARDS_CALIBRATION (T) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION + if (CollUtil.isNotEmpty(pairsTIdCalPoint)){ + GardsCalibration calibration = new GardsCalibration(); + calibration.setSampleId(sampleId); + calibration.setIdAnalysis(IdAnalysis); + calibration.setSampleType(calibrationSampleType); + String tCaltype = middleData.getCalibration_T_Caltype(); + double tFunction = middleData.getCalibration_T_function(); + String tFunctionDef = middleData.getCalibration_T_functionDef(); + double tStartOfRange = middleData.getCalibration_T_startOfRange(); + double tEndOfRange = middleData.getCalibration_T_endOfRange(); + String tCoeffString = middleData.getCalibration_T_coeff_string(); + calibration.setCalType(tCaltype); + calibration.setFunction((int)middleData.getCalibration_T_function()); + calibration.setFunctionDef(tFunctionDef); + calibration.setStartOfRange((int)tStartOfRange); + calibration.setEndOfRange((int)tEndOfRange); + calibration.setCoeffString(tCoeffString); + calibration.setModdate(new Date()); + calibrations.add(calibration); + } + if (CollectionUtils.isNotEmpty(calibrations)) { + for (GardsCalibration calibration:calibrations) { + calibrationSpectrumService.insertCalibration(calibration); + } + } + return calibrations; + } + @Override public void savePeaksROI(Integer sampleId, Integer idAnalysis) { List peaksRois = new ArrayList<>(); @@ -536,6 +742,18 @@ public class AnalysisManServiceImpl implements AnalysisManService { analySettingRoiService.saveBatch(analySettingRois); } + @Override + @Transactional + public void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List xeResultsList) { + for (GardsXeResults xeResults:xeResultsList) { + xeResults.setIdAnalysis(idAnalysis); + xeResults.setSampleId(sampleId); + } + if (CollectionUtils.isNotEmpty(xeResultsList)) { + xeResultsSpectrumService.saveBatch(xeResultsList); + } + } + public Map fieldMap(){ Map fieldMap = new HashMap<>(); // Gards_Nucl_Lines_Ided diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsCalibrationSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsCalibrationSpectrumService.java index f4e2a2f7..efb6d196 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsCalibrationSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGardsCalibrationSpectrumService.java @@ -1,6 +1,7 @@ package org.jeecg.modules.service; import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.ibatis.annotations.Param; import org.jeecg.modules.base.entity.rnman.GardsCalibration; import org.jeecg.modules.entity.vo.BgDataAnlyseResultIn; import org.jeecg.modules.entity.vo.GStoreMiddleProcessData; @@ -9,6 +10,8 @@ import java.util.List; public interface IGardsCalibrationSpectrumService extends IService { + void insertCalibration(GardsCalibration calibration); + int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis); int saveCalibrationGamma(GStoreMiddleProcessData middleData, Integer sampleId, String idAnalysis); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationSpectrumServiceImpl.java index dd4f6f30..07d22ae7 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationSpectrumServiceImpl.java @@ -26,6 +26,16 @@ import java.util.stream.Collectors; public class GardsCalibrationSpectrumServiceImpl extends ServiceImpl implements IGardsCalibrationSpectrumService { + @Override + public void insertCalibration(GardsCalibration calibration) { + this.baseMapper.insertCalibration(calibration); + } + + @Override + public void insertCalibrationGamma(GardsCalibration calibration) { + this.baseMapper.insertCalibrationGamma(calibration); + } + @Override @Transactional public int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index 02a96286..28926df1 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -39,8 +39,10 @@ import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; import org.jeecg.modules.base.entity.rnman.GardsAnalySettingRoi; import org.jeecg.modules.base.entity.rnman.GardsAnalysisRoi; import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; +import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.base.enums.CalName; import org.jeecg.modules.base.enums.CalType; +import org.jeecg.modules.base.enums.DataTypeAbbr; import org.jeecg.modules.base.enums.SampleFileHeader; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; @@ -148,7 +150,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf @Override public Result loadFromDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) { Result result = new Result(); - Map> resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); //页面展示结果数组 List xeResultsSpectrumList = new LinkedList<>(); List gammaCalibrationSpectrumList= new LinkedList<>(); @@ -171,6 +173,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //查询分析id,相关的分析结果 Integer analysisID = null; List roiPaths = new ArrayList<>(); + // 配置查询数据库 if (dbName.equalsIgnoreCase("auto")){ dbName = "RNAUTO"; analyst = "RNAUTO"; @@ -186,257 +189,303 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf // 获取当前角色配置的颜色信息 Map colorMap = sysUserColorService.initColor(userName); try { - if (Objects.nonNull(analysisID)) { - //查询数据库文件信息 - SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - //判断数据库分析结果基础信息是否为空 - if (Objects.nonNull(dbSpectrumFilePath)) { - //获取sample相关信息 - GardsSampleData sample = null; - String sampleFileName = ""; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())) { - sample = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getSampleFilePath()); - sampleFileName = dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH) + 1); - } - //获取det相关信息 - GardsSampleData detBg = null; - String detFileName = ""; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { - detBg = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getDetBgFilePath()); - detFileName = dbSpectrumFilePath.getDetBgFilePath().substring(dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)+1); - } - //获取qc相关信息 - String dbQcFilePath = ""; - GardsSampleData qc = null; - String qcFileName = ""; - if (Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode())) { - String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); - if (StringUtils.isNotBlank(dbQcFilePath)) { - qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); - qcFileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); - } - } - - //从缓存中获取公用变量的数据 - SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); - if (Objects.isNull(selfStationData)) { - //初始化自建台站数据对象 - selfStationData = new SelfStationData(); - if (dbName.equalsIgnoreCase("RNAUTO")) { - xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); - gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNAUTO", analysisID); - betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNAUTO", analysisID); - roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNAUTO", analysisID, sampleId); - roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNAUTO", analysisID, sampleId); - } else { - gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(analysisID); - betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(analysisID); - xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); - gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNMAN", analysisID); - betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNMAN", analysisID); - roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNMAN", analysisID, sampleId); - roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNMAN", analysisID, sampleId); - } - //判断sample文件名是否为空 - if (Objects.nonNull(sample)) { - //拼接sample文件路径 - String sampleFilePath = prefix + dbSpectrumFilePath.getSampleFilePath(); - //返回结果map - Map map = new HashMap<>(); - //获取sample分析后的对象 - EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(sampleFilePath); - if (Objects.nonNull(struct)) { - selfStationData.setSampleStruct(struct); - selfStationData.setSampleTmpPath(sampleFilePath); - selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map); - // 交互库需要获取最新的ROI数据 - if (dbName.equalsIgnoreCase("RNMAN")) { - List roiList = analysisRoiManService.analysisRoi(analysisID); - LinkedList start = Lists.newLinkedList(); - LinkedList stop = Lists.newLinkedList(); - for (GardsAnalysisRoi f : roiList) { - start.add(f.getRoiNum() -1, f.getMinX().intValue()); - stop.add(f.getRoiNum() -1, f.getMaxX().intValue()); - } - Map gammaByROI = selfStationUtil.getGammaByROI("", start, stop, selfStationData); - map.putAll(gammaByROI); - } - - // 将四个Gamma ROI文件对象放到缓存中 - SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); - - // 用于下次分析判断是否更新 - sampleVueData.setUsedROIOneBetaStart(sampleVueData.getROIOneBetaStart()); - sampleVueData.setUsedROIOneBetaStop(sampleVueData.getROIOneBetaStop()); - sampleVueData.setUsedROITwoBetaStart(sampleVueData.getROITwoBetaStart()); - sampleVueData.setUsedROITwoBetaStop(sampleVueData.getROITwoBetaStop()); - sampleVueData.setUsedROIThreeBetaStart(sampleVueData.getROIThreeBetaStart()); - sampleVueData.setUsedROIThreeBetaStop(sampleVueData.getROIThreeBetaStop()); - sampleVueData.setUsedROIFourBetaStart(sampleVueData.getROIFourBetaStart()); - sampleVueData.setUsedROIFourBetaStop(sampleVueData.getROIFourBetaStop()); - - Map roiPathMap = roiPaths.stream() - .collect(Collectors.toMap(RoiDto::getRoiNum, RoiDto::getPhdPath)); - - String fullPath1 = prefix + roiPathMap.get(1); - String fullPath2 = prefix + roiPathMap.get(2); - String fullPath3 = prefix + roiPathMap.get(3); - String fullPath4 = prefix + roiPathMap.get(4); - - String name1 = FileUtil.getName(fullPath1); - String name2 = FileUtil.getName(fullPath2); - String name3 = FileUtil.getName(fullPath3); - String name4 = FileUtil.getName(fullPath4); - - String path = fullPath1.substring(0, fullPath1.lastIndexOf(StrUtil.SLASH)); - - PHDFile phd1 = selfStationUtil.createGammaPHD(struct, name1, path, sampleVueData.getROIOneCounts()); - PHDFile phd2 = selfStationUtil.createGammaPHD(struct, name2, path, sampleVueData.getROITwoCounts()); - PHDFile phd3 = selfStationUtil.createGammaPHD(struct, name3, path, sampleVueData.getROIThreeCounts()); - PHDFile phd4 = selfStationUtil.createGammaPHD(struct, name4, path, sampleVueData.getROIFourCounts()); - - // 从数据库加载 ROI信息 - List phdFiles = ListUtil.toList(phd1, phd2, phd3, phd4); - getROIResultFromDB(dbName, sampleId, phdFiles, analysisID); - - map.put("ROI1", loadROI(phd1, analyst, colorMap)); - map.put("ROI2", loadROI(phd2, analyst, colorMap)); - map.put("ROI3", loadROI(phd3, analyst, colorMap)); - map.put("ROI4", loadROI(phd4, analyst, colorMap)); - - sampleVueData.setROIOneFileName(name1); - sampleVueData.setROIOnePHDFile(phd1); - sampleVueData.setROITwoFileName(name2); - sampleVueData.setROITwoPHDFile(phd2); - sampleVueData.setROIThreeFileName(name3); - sampleVueData.setROIThreePHDFile(phd3); - sampleVueData.setROIFourFileName(name4); - sampleVueData.setROIFourPHDFile(phd4); - - resultMap.put("sample", map); - - // 返回Beta和Gamma的数据 - bGSpectrum(struct, map); - } - } - //判断det文件名是否为空 - if (Objects.nonNull(detBg)) { - //拼接det文件路径 - String detFilePath = prefix + dbSpectrumFilePath.getDetBgFilePath(); - //返回结果map - Map map = new HashMap<>(); - //获取sample分析后的对象 - EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(detFilePath); - if (Objects.nonNull(struct)) { - selfStationData.setDetStruct(struct); - selfStationData.setDetTmpPath(detFilePath); - selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map); - - resultMap.put("det", map); - - // 返回Beta和Gamma的数据 - bGSpectrum(struct, map); - } - } - //判断qc文件名是否为空 - if (Objects.nonNull(qc)) { - //拼接det文件路径 - String qcFilePath = prefix + qc.getInputFileName(); - //返回结果map - Map map = new HashMap<>(); - //获取sample分析后的对象 - EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(qcFilePath); - if (Objects.nonNull(struct)) { - selfStationData.setQcStruct(struct); - selfStationData.setQcTmpPath(qcFilePath); - selfStationUtil.loadFile(selfStationData, qc.getSampleId(), qc.getStatus(), "qc", map); - - resultMap.put("qc", map); - - // 返回Beta和Gamma的数据 - bGSpectrum(struct, map); - } - } - // 初始化自建台站Configure信息 - if (!StrUtil.equals(dbName, "RNAUTO")) initConfigure(analysisID, selfStationData); - - // 初始化自建台站用户核素库信息 - String systemType = selfStationData.getSampleStruct().getSystem_type(); - if (!redisUtil.hasKey(userName+StringPool.DASH+systemType + "-self") - || !redisUtil.hasKey(userName+StringPool.DASH+systemType+"-list-self")) { - //读取缓存的全部核素信息 - Map allNuclideMap = (Map) redisUtil.get("AllNuclideMap"); - // 查询当前用户关联的核素信息 - // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 - List userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, systemType, 5); - Map nuclideMap = new HashMap<>(); - for (Map.Entry entry:allNuclideMap.entrySet()) { - if (userLib.contains(entry.getKey())) { - nuclideMap.put(entry.getKey(), entry.getValue()); - } - } - redisUtil.set(userName+StringPool.DASH+systemType+"-list-self", userLib); - redisUtil.set(userName+StringPool.DASH+systemType+"-self", nuclideMap); - } - - //将自建台站的数据封装到缓存对象中 - selfCache.put(sampleFileName + StringPool.DASH + userName, selfStationData); - //将缓存对象存入到缓存中 - selfStationCache.setSelfCache(selfCache); - } else { - if (Objects.nonNull(sample)) { - //返回结果map - Map map = new HashMap<>(); - selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map); - // 交互库需要获取最新的ROI数据 - if (dbName.equalsIgnoreCase("RNMAN")) { - List roiList = analysisRoiManService.analysisRoi(analysisID); - LinkedList start = Lists.newLinkedList(); - LinkedList stop = Lists.newLinkedList(); - for (GardsAnalysisRoi f : roiList) { - start.add(f.getRoiNum() -1, f.getMinX().intValue()); - stop.add(f.getRoiNum() -1, f.getMinY().intValue()); - } - Map gammaByROI = selfStationUtil.getGammaByROI("", start, stop, selfStationData); - map.putAll(gammaByROI); - } - - SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); - PHDFile phd1 = sampleVueData.getROIOnePHDFile(); - PHDFile phd2 = sampleVueData.getROITwoPHDFile(); - PHDFile phd3 = sampleVueData.getROIThreePHDFile(); - PHDFile phd4 = sampleVueData.getROIFourPHDFile(); - map.put("ROI1", loadROI(phd1, analyst, colorMap)); - map.put("ROI2", loadROI(phd2, analyst, colorMap)); - map.put("ROI3", loadROI(phd3, analyst, colorMap)); - map.put("ROI4", loadROI(phd4, analyst, colorMap)); - - resultMap.put("sample", map); - // 返回Beta和Gamma的数据 - bGSpectrum(selfStationData.getSampleStruct(), map); - } - if (Objects.nonNull(detBg)) { - //返回结果map - Map map = new HashMap<>(); - selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map); - - resultMap.put("det", map); - // 返回Beta和Gamma的数据 - bGSpectrum(selfStationData.getDetStruct(), map); - } - if (Objects.nonNull(qc)) { - //返回结果map - Map map = new HashMap<>(); - selfStationUtil.loadFile(selfStationData, qc.getSampleId(), qc.getStatus(), "qc", map); - - resultMap.put("qc", map); - // 返回Beta和Gamma的数据 - bGSpectrum(selfStationData.getQcStruct(), map); - } - } + //查询数据库文件信息 + SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); + //判断数据库分析结果基础信息是否为空 + if (Objects.isNull(dbSpectrumFilePath)) { + result.error500("No data found, please contact the administrator!"); + return result; + } + //获取sample相关信息 + GardsSampleData sample = null; + String sampleFileName = ""; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())) { + sample = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getSampleFilePath()); + sampleFileName = dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH) + 1); + } + //获取det相关信息 + GardsSampleData detBg = null; + String detFileName = ""; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { + detBg = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getDetBgFilePath()); + detFileName = dbSpectrumFilePath.getDetBgFilePath().substring(dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)+1); + } + //获取qc相关信息 + String dbQcFilePath = ""; + GardsSampleData qc = null; + String qcFileName = ""; + if (Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode())) { + String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); + if (StringUtils.isNotBlank(dbQcFilePath)) { + qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); + qcFileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); } } + + //从缓存中获取公用变量的数据 + SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); + BetaDataFile betaDataFile = new BetaDataFile(); + if (Objects.isNull(selfStationData)) { + //初始化自建台站数据对象 + selfStationData = new SelfStationData(); + betaDataFile = selfStationData.getBetaDataFile(); + + if (dbName.equalsIgnoreCase("RNMAN")) { + gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(analysisID); + betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(analysisID); + } + xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); + gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam(dbName, analysisID); + betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam(dbName, analysisID); + //判断sample文件名是否为空 + if (Objects.nonNull(sample)) { + //拼接sample文件路径 + String sampleFilePath = prefix + dbSpectrumFilePath.getSampleFilePath(); + //返回结果map + Map map = new HashMap<>(); + //获取sample分析后的对象 + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(sampleFilePath); + if (Objects.nonNull(struct)) { + selfStationData.setSampleStruct(struct); + selfStationData.setSampleTmpPath(sampleFilePath); + selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map); + // 交互库需要获取最新的ROI数据 + if (dbName.equalsIgnoreCase("RNMAN")) { + List roiList = analysisRoiManService.analysisRoi(analysisID); + LinkedList start = Lists.newLinkedList(); + LinkedList stop = Lists.newLinkedList(); + for (GardsAnalysisRoi f : roiList) { + start.add(f.getRoiNum() -1, f.getMinX().intValue()); + stop.add(f.getRoiNum() -1, f.getMaxX().intValue()); + } + Map gammaByROI = selfStationUtil.getGammaByROI("", start, stop, selfStationData); + map.putAll(gammaByROI); + } + + //更新gamma道值-能量折线图 + if (CollectionUtils.isNotEmpty(gammaCalibrationPairsList) && CollectionUtils.isNotEmpty(betaCalibrationPairsList)) { + //过滤出sample的gamma的参数 + List sampleGammaCalibrationPairs = + gammaCalibrationPairsList.stream() + .filter(item -> item.getDataType().equalsIgnoreCase(DataTypeAbbr.SAMPLEPHD.getType())) + .collect(Collectors.toList()); + //过滤出sample的beta的参数 + List sampleBetaCalibrationPairs = + betaCalibrationPairsList.stream() + .filter(item -> item.getDataType().equalsIgnoreCase(DataTypeAbbr.SAMPLEPHD.getType())) + .collect(Collectors.toList()); + //更新道值-能量折线图 + if (CollectionUtils.isNotEmpty(sampleGammaCalibrationPairs) && CollectionUtils.isNotEmpty(sampleBetaCalibrationPairs)) { + phdFileUtil.updateEnergyData(betaDataFile, "sample", sampleGammaCalibrationPairs, sampleBetaCalibrationPairs, map); + } + } + + //更新缓存数据对应的缓存数据 + phdFileUtil.createBgCalPara(betaDataFile, gammaCalibrationSpectrumList, + betaCalibrationSpectrumList, gammaCalibrationPairsList, betaCalibrationPairsList); + //第一次加载时初始化数据库数据 + betaDataFile.setGammaCalibrationSpectrumEList(gammaCalibrationSpectrumList); + betaDataFile.setBetaCalibrationSpectrumEList(betaCalibrationSpectrumList); + + // 将四个Gamma ROI文件对象放到缓存中 + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + + // 用于下次分析判断是否更新 + sampleVueData.setUsedROIOneBetaStart(sampleVueData.getROIOneBetaStart()); + sampleVueData.setUsedROIOneBetaStop(sampleVueData.getROIOneBetaStop()); + sampleVueData.setUsedROITwoBetaStart(sampleVueData.getROITwoBetaStart()); + sampleVueData.setUsedROITwoBetaStop(sampleVueData.getROITwoBetaStop()); + sampleVueData.setUsedROIThreeBetaStart(sampleVueData.getROIThreeBetaStart()); + sampleVueData.setUsedROIThreeBetaStop(sampleVueData.getROIThreeBetaStop()); + sampleVueData.setUsedROIFourBetaStart(sampleVueData.getROIFourBetaStart()); + sampleVueData.setUsedROIFourBetaStop(sampleVueData.getROIFourBetaStop()); + + Map roiPathMap = roiPaths.stream() + .collect(Collectors.toMap(RoiDto::getRoiNum, RoiDto::getPhdPath)); + + String fullPath1 = prefix + roiPathMap.get(1); + String fullPath2 = prefix + roiPathMap.get(2); + String fullPath3 = prefix + roiPathMap.get(3); + String fullPath4 = prefix + roiPathMap.get(4); + + String name1 = FileUtil.getName(fullPath1); + String name2 = FileUtil.getName(fullPath2); + String name3 = FileUtil.getName(fullPath3); + String name4 = FileUtil.getName(fullPath4); + + String path = fullPath1.substring(0, fullPath1.lastIndexOf(StrUtil.SLASH)); + + PHDFile phd1 = SelfStationUtil.createGammaPHD(struct, name1, path, sampleVueData.getROIOneCounts()); + PHDFile phd2 = SelfStationUtil.createGammaPHD(struct, name2, path, sampleVueData.getROITwoCounts()); + PHDFile phd3 = SelfStationUtil.createGammaPHD(struct, name3, path, sampleVueData.getROIThreeCounts()); + PHDFile phd4 = SelfStationUtil.createGammaPHD(struct, name4, path, sampleVueData.getROIFourCounts()); + sampleVueData.setROIOnePHDFile(phd1); + sampleVueData.setROITwoPHDFile(phd2); + sampleVueData.setROIThreePHDFile(phd3); + sampleVueData.setROIFourPHDFile(phd4); + + // 从数据库加载 Gamma ROI信息 + this.getROIResultFromDB(dbName, sampleId, sampleVueData, analysisID); + + + map.put("ROI1", loadROI(phd1, analyst, colorMap)); + map.put("ROI2", loadROI(phd2, analyst, colorMap)); + map.put("ROI3", loadROI(phd3, analyst, colorMap)); + map.put("ROI4", loadROI(phd4, analyst, colorMap)); + + sampleVueData.setROIOneFileName(name1); + sampleVueData.setROIOnePHDFile(phd1); + sampleVueData.setROITwoFileName(name2); + sampleVueData.setROITwoPHDFile(phd2); + sampleVueData.setROIThreeFileName(name3); + sampleVueData.setROIThreePHDFile(phd3); + sampleVueData.setROIFourFileName(name4); + sampleVueData.setROIFourPHDFile(phd4); + + resultMap.put("sample", map); + + // 返回Beta和Gamma的数据 + bGSpectrum(struct, map); + } + } + //判断det文件名是否为空 + if (Objects.nonNull(detBg)) { + //拼接det文件路径 + String detFilePath = prefix + dbSpectrumFilePath.getDetBgFilePath(); + //返回结果map + Map map = new HashMap<>(); + //获取sample分析后的对象 + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(detFilePath); + if (Objects.nonNull(struct)) { + selfStationData.setDetStruct(struct); + selfStationData.setDetTmpPath(detFilePath); + selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map); + + resultMap.put("det", map); + + // 返回Beta和Gamma的数据 + bGSpectrum(struct, map); + } + } + //判断qc文件名是否为空 + if (Objects.nonNull(qc)) { + //拼接det文件路径 + String qcFilePath = prefix + qc.getInputFileName(); + //返回结果map + Map map = new HashMap<>(); + //获取sample分析后的对象 + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(qcFilePath); + if (Objects.nonNull(struct)) { + selfStationData.setQcStruct(struct); + selfStationData.setQcTmpPath(qcFilePath); + selfStationUtil.loadFile(selfStationData, qc.getSampleId(), qc.getStatus(), "qc", map); + + resultMap.put("qc", map); + + // 返回Beta和Gamma的数据 + bGSpectrum(struct, map); + } + } + // 初始化自建台站Configure信息 + if (!StrUtil.equals(dbName, "RNAUTO")) initConfigure(analysisID, selfStationData); + + // 初始化自建台站用户核素库信息 + String systemType = selfStationData.getSampleStruct().getSystem_type(); + if (!redisUtil.hasKey(userName+StringPool.DASH+systemType + "-self") + || !redisUtil.hasKey(userName+StringPool.DASH+systemType+"-list-self")) { + //读取缓存的全部核素信息 + Map allNuclideMap = (Map) redisUtil.get("AllNuclideMap"); + // 查询当前用户关联的核素信息 + // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + List userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, systemType, 5); + Map nuclideMap = new HashMap<>(); + for (Map.Entry entry:allNuclideMap.entrySet()) { + if (userLib.contains(entry.getKey())) { + nuclideMap.put(entry.getKey(), entry.getValue()); + } + } + redisUtil.set(userName+StringPool.DASH+systemType+"-list-self", userLib); + redisUtil.set(userName+StringPool.DASH+systemType+"-self", nuclideMap); + } + + } else { + if (Objects.nonNull(sample)) { + //返回结果map + Map map = new HashMap<>(); + selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map); + // 交互库需要获取最新的ROI数据 + if (dbName.equalsIgnoreCase("RNMAN")) { + List roiList = analysisRoiManService.analysisRoi(analysisID); + LinkedList start = Lists.newLinkedList(); + LinkedList stop = Lists.newLinkedList(); + for (GardsAnalysisRoi f : roiList) { + start.add(f.getRoiNum() -1, f.getMinX().intValue()); + stop.add(f.getRoiNum() -1, f.getMinY().intValue()); + } + Map gammaByROI = selfStationUtil.getGammaByROI("", start, stop, selfStationData); + map.putAll(gammaByROI); + } + + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + PHDFile phd1 = sampleVueData.getROIOnePHDFile(); + PHDFile phd2 = sampleVueData.getROITwoPHDFile(); + PHDFile phd3 = sampleVueData.getROIThreePHDFile(); + PHDFile phd4 = sampleVueData.getROIFourPHDFile(); + map.put("ROI1", loadROI(phd1, analyst, colorMap)); + map.put("ROI2", loadROI(phd2, analyst, colorMap)); + map.put("ROI3", loadROI(phd3, analyst, colorMap)); + map.put("ROI4", loadROI(phd4, analyst, colorMap)); + + resultMap.put("sample", map); + // 返回Beta和Gamma的数据 + bGSpectrum(selfStationData.getSampleStruct(), map); + } + if (Objects.nonNull(detBg)) { + //返回结果map + Map map = new HashMap<>(); + selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map); + + resultMap.put("det", map); + // 返回Beta和Gamma的数据 + bGSpectrum(selfStationData.getDetStruct(), map); + } + if (Objects.nonNull(qc)) { + //返回结果map + Map map = new HashMap<>(); + selfStationUtil.loadFile(selfStationData, qc.getSampleId(), qc.getStatus(), "qc", map); + + resultMap.put("qc", map); + // 返回Beta和Gamma的数据 + bGSpectrum(selfStationData.getQcStruct(), map); + } + } + //Xe + if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){ + for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + } else if (0 mdc) { + xeData.setColor("green"); + } + xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc())))); + xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc())))); + xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr())))); + } + } + betaDataFile.setXeResultsSpectrumList(xeResultsSpectrumList); + betaDataFile.setSaveAnalysisResult(true); + resultMap.put("XeData", phdFileUtil.viewXeData(xeResultsSpectrumList)); + resultMap.put("bProcessed", betaDataFile.isBProcessed()); + resultMap.put("savedAnalysisResult", betaDataFile.isSaveAnalysisResult()); + //将自建台站的数据封装到缓存对象中 + selfCache.put(sampleFileName + StringPool.DASH + userName, selfStationData); + //将缓存对象存入到缓存中 + selfStationCache.setSelfCache(selfCache); } catch (Exception e) { e.printStackTrace(); } @@ -608,7 +657,11 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf return map; } - public boolean getROIResultFromDB(String dbName, Integer sampleId, List phdFiles, Integer idAnalysis) { + public boolean getROIResultFromDB(String dbName, Integer sampleId, SelfStationVueData selfStationVueData, Integer idAnalysis) { + + List phdFiles = ListUtil.toList(selfStationVueData.getROIOnePHDFile(), selfStationVueData.getROITwoPHDFile(), + selfStationVueData.getROIThreePHDFile(), selfStationVueData.getROIFourPHDFile()); + // 判断连接的数据库 String T_analy = ""; String T_calib = ""; @@ -620,18 +673,18 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf String T_mdc = ""; if (dbName.equals("RNAUTO")) { T_analy = "RNAUTO.GARDS_ANALYSIS_ROI"; - T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS_ROI"; + T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS"; T_peaks = "RNAUTO.GARDS_PEAKS_ROI"; - T_param = "RNAUTO.GARDS_CALIBRATION_ROI"; + T_param = "RNAUTO.GARDS_CALIBRATION"; T_nuc_line = "RNAUTO.GARDS_NUCL_LINES_IDED_ROI"; T_nuc_act = "RNAUTO.GARDS_NUCL_IDED_ROI"; T_qc = "RNAUTO.GARDS_QC_CHECK_ROI"; T_mdc = "RNAUTO.GARDS_MDC_ROI"; } else if (dbName.equals("RNMAN")) { T_analy = "RNMAN.GARDS_ANALYSIS_ROI"; - T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS_ROI"; + T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS"; T_peaks = "RNMAN.GARDS_PEAKS_ROI"; - T_param = "RNMAN.GARDS_CALIBRATION_ROI"; + T_param = "RNMAN.GARDS_CALIBRATION"; T_nuc_line = "RNMAN.GARDS_NUCL_LINES_IDED_ROI"; T_nuc_act = "RNMAN.GARDS_NUCL_IDED_ROI"; T_qc = "RNMAN.GARDS_QC_CHECK_ROI"; @@ -651,7 +704,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf List roiIds = spectrumAnalysisMapper.roiIds(T_analy, idAnalysis); // 获取峰信息列表 - List peaks = spectrumAnalysisMapper.getPeaksROI(T_peaks, idAnalysis); + List peaks = spectrumAnalysisMapper.getPeaksROI(T_peaks, T_analy, idAnalysis); Map> peaksMap = peaks.stream() .collect(Collectors.groupingBy(GardsPeaksSpectrum::getRoiId)); for (int i = 0; i < roiIds.size(); i++) { @@ -692,19 +745,16 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } // 获取刻度点数据 - List calibrationPairs = spectrumAnalysisMapper.getCalibrationPairsROI(T_calib, idAnalysis); - Map> calibrationPairsMap = calibrationPairs.stream() - .collect(Collectors.groupingBy(GardsCalibrationPairsSpectrum::getRoiId)); + List calibrationPairs = spectrumAnalysisMapper.getCalibrationPairs(T_calib, idAnalysis); for (int i = 0; i < roiIds.size(); i++) { Integer roiId = roiIds.get(i); PHDFile phd = phdFiles.get(i); - List calibrationPaireList = calibrationPairsMap.get(roiId); - if (CollUtil.isEmpty(calibrationPaireList)) continue; + if (CollUtil.isEmpty(calibrationPairs)) continue; GEnergyBlock gEnergyBlock = new GEnergyBlock(); GResolutionBlock gResolutionBlock = new GResolutionBlock(); GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); TotaleffBlock totaleffBlock = new TotaleffBlock(); - for (GardsCalibrationPairsSpectrum pairsSpectrum : calibrationPaireList) { + for (GardsCalibrationPairsSpectrum pairsSpectrum : calibrationPairs) { String calType = pairsSpectrum.getCaltype().trim(); if (calType.equals(CalType.ENERGY_CAL.getType())) { phd.setUsedEner(pairsSpectrum.getInput()); @@ -766,18 +816,18 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } // 获取刻度拟合系数 - List paras = spectrumAnalysisMapper.getParaROI(T_param, idAnalysis); - Map> parasMap = paras.stream() - .collect(Collectors.groupingBy(GardsCalibrationSpectrum::getRoiId)); + List paras = spectrumAnalysisMapper.getPara(T_param, idAnalysis); for (int i = 0; i < roiIds.size(); i++) { Integer roiId = roiIds.get(i); PHDFile phd = phdFiles.get(i); - List parasList = parasMap.get(roiId); - if (CollUtil.isEmpty(parasList)) continue; - for (GardsCalibrationSpectrum calibrationSpectrum : parasList) { + if (CollUtil.isEmpty(paras)) continue; + for (GardsCalibrationSpectrum calibrationSpectrum : paras) { ParameterInfo para = new ParameterInfo(); String calType = calibrationSpectrum.getCalType().trim(); para.getP().add(calibrationSpectrum.getFunction().doubleValue()); + if (StrUtil.isEmpty(calibrationSpectrum.getCoeffString())) { + continue; + } String[] list_coeff = calibrationSpectrum.getCoeffString().split(StringPool.COMMA); for (String str : list_coeff) { para.getP().add(Double.valueOf(str)); @@ -804,7 +854,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } // 获取被识别核素射线信息 - List nuclLinesIdeds = spectrumAnalysisMapper.getNuclLinesIdedROI(T_nuc_line, idAnalysis); + List nuclLinesIdeds = spectrumAnalysisMapper.getNuclLinesIdedROI(T_nuc_line, T_analy, idAnalysis); Map> nuclLinesIdedsMap = nuclLinesIdeds.stream() .collect(Collectors.groupingBy(GardsNuclLinesIdedSpectrum::getRoiId)); for (int i = 0; i < roiIds.size(); i++) { @@ -849,7 +899,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } // 获取被识别核素的活度浓度 - List nuclIdeds = spectrumAnalysisMapper.getNuclIdedROI(T_nuc_act, idAnalysis); + List nuclIdeds = spectrumAnalysisMapper.getNuclIdedROI(T_nuc_act, T_analy, idAnalysis); Map> nuclIdedsMap = nuclIdeds.stream() .collect(Collectors.groupingBy(GardsNuclIdedSpectrum::getRoiId)); for (int i = 0; i < roiIds.size(); i++) { @@ -873,27 +923,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } } - // 获取 QC 结果 - List qcChecks = spectrumAnalysisMapper.getQcCheckROI(T_qc, idAnalysis); - Map> qcChecksMap = qcChecks.stream() - .collect(Collectors.groupingBy(GardsQcCheckSpectrum::getRoiId)); - for (int i = 0; i < roiIds.size(); i++) { - Integer roiId = roiIds.get(i); - PHDFile phd = phdFiles.get(i); - List qcChecksList = qcChecksMap.get(roiId); - if (CollUtil.isEmpty(qcChecksList)) continue; - for (GardsQcCheckSpectrum qcCheckSpectrum : qcChecksList) { - String str_key = qcCheckSpectrum.getQcName(); - QcCheckItem qcCheckItem = new QcCheckItem(); - qcCheckItem.setValue(qcCheckSpectrum.getQcValue() == null?0.0:qcCheckSpectrum.getQcValue()); - qcCheckItem.setBPass(qcCheckSpectrum.getQcResult() == 1); - qcCheckItem.setStandard(qcCheckSpectrum.getQcStandard()); - phd.getQcItems().put(str_key, qcCheckItem); - } - } - // 获取 MDC 结果 - List calMDCInfo = spectrumAnalysisMapper.getMDCROI(T_mdc, idAnalysis); + List calMDCInfo = spectrumAnalysisMapper.getMDCROI(T_mdc, T_analy, idAnalysis); Map> calMDCInfoMap = calMDCInfo.stream() .collect(Collectors.groupingBy(CalMDCInfo::getRoiId)); for (int i = 0; i < roiIds.size(); i++) { @@ -1167,18 +1198,19 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (StringUtils.isBlank(currentText)) { - currentText = selfStationData.getSampleVueData().getUsedEner(); + currentText = phd.getUsedEner(); } - List dataSourceList = selfStationData.getSampleVueData().getMapEnerKD().keySet().stream().collect(Collectors.toList()); + List dataSourceList = phd.getMapEnerKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); if (StringUtils.isNotBlank(currentText)) { map.put("currentText", currentText); - List m_vCurCentroid = selfStationData.getSampleVueData().getMapEnerKD().get(currentText).getCentroid_channel(); - List m_vCurEnergy = selfStationData.getSampleVueData().getMapEnerKD().get(currentText).getG_energy(); - List m_vCurUncert = selfStationData.getSampleVueData().getMapEnerKD().get(currentText).getUncertainty(); + List m_vCurCentroid = phd.getMapEnerKD().get(currentText).getCentroid_channel(); + List m_vCurEnergy = phd.getMapEnerKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapEnerKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = selfStationData.getSampleVueData().getMapEnerPara().get(currentText); + ParameterInfo m_curParam = phd.getMapEnerPara().get(currentText); if (Objects.isNull(m_curParam)) { m_curParam = new ParameterInfo(); } @@ -1284,8 +1316,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (!curCalName.contains("Input")) { - List list_cal = selfStationData.getSampleVueData().getMapEnerKD().keySet().stream().collect(Collectors.toList()); + List list_cal = phd.getMapEnerKD().keySet().stream().collect(Collectors.toList()); curCalName = "Input " + (list_cal.stream().filter(item -> item.contains("Input")).collect(Collectors.toList()).size() + 1); list_cal.add(curCalName); result.setSuccess(true); @@ -1296,8 +1329,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf gEnergyBlock.setG_energy(m_vCurEnergy); gEnergyBlock.setUncertainty(m_vCurUncert); gEnergyBlock.setRecord_count(m_vCurCentroid.size()); - selfStationData.getSampleVueData().getMapEnerKD().put(curCalName, gEnergyBlock); - selfStationData.getSampleVueData().getMapEnerPara().put(curCalName, m_curParam); + phd.getMapEnerKD().put(curCalName, gEnergyBlock); + phd.getMapEnerPara().put(curCalName, m_curParam); return result; } @@ -1342,6 +1375,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (Objects.nonNull(file)) { String fileName = file.getOriginalFilename(); // 从最后一个。切割文件名称 获取文件名称后缀 @@ -1381,7 +1415,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf map.put("uncert", m_vCurUncert); ParameterInfo m_curParam = new ParameterInfo(); if (StringUtils.isNotBlank(currentText)) { - m_curParam = selfStationData.getSampleVueData().getMapEnerPara().get(currentText); + m_curParam = phd.getMapEnerPara().get(currentText); } map.put("param", m_curParam); int num = m_vCurEnergy.size(); @@ -1436,8 +1470,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (StringUtils.isNotBlank(currentName)) { - selfStationData.getSampleVueData().setNewEner(currentName); + phd.setNewEner(currentName); } selfCache.put(fileName, selfStationData); selfStationCache.setSelfCache(selfCache); @@ -1458,18 +1493,19 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (StringUtils.isBlank(currentText)) { - currentText = selfStationData.getSampleVueData().getUsedReso(); + currentText = phd.getUsedReso(); } - List dataSourceList = selfStationData.getSampleVueData().getMapResoKD().keySet().stream().collect(Collectors.toList()); + List dataSourceList = phd.getMapResoKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); if (StringUtils.isNotBlank(currentText)) { map.put("currentText", currentText); - List m_vCurReso = selfStationData.getSampleVueData().getMapResoKD().get(currentText).getFWHM(); - List m_vCurEnergy = selfStationData.getSampleVueData().getMapResoKD().get(currentText).getG_energy(); - List m_vCurUncert = selfStationData.getSampleVueData().getMapResoKD().get(currentText).getUncertainty(); + List m_vCurReso = phd.getMapResoKD().get(currentText).getFWHM(); + List m_vCurEnergy = phd.getMapResoKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapResoKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = selfStationData.getSampleVueData().getMapResoPara().get(currentText); + ParameterInfo m_curParam = phd.getMapResoPara().get(currentText); if (Objects.isNull(m_curParam)) { m_curParam = new ParameterInfo(); } @@ -1564,8 +1600,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (!curCalName.contains("Input")) { - List list_cal = selfStationData.getSampleVueData().getMapResoKD().keySet().stream().collect(Collectors.toList()); + List list_cal = phd.getMapResoKD().keySet().stream().collect(Collectors.toList()); curCalName = "Input " + (list_cal.stream().filter(item -> item.contains("Input")).collect(Collectors.toList()).size() + 1); list_cal.add(curCalName); result.setSuccess(true); @@ -1576,8 +1613,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf gResolutionBlock.setG_energy(m_vCurEnergy); gResolutionBlock.setUncertainty(m_vCurUncert); gResolutionBlock.setRecord_count(m_vCurEnergy.size()); - selfStationData.getSampleVueData().getMapResoKD().put(curCalName, gResolutionBlock); - selfStationData.getSampleVueData().getMapResoPara().put(curCalName, m_curParam); + phd.getMapResoKD().put(curCalName, gResolutionBlock); + phd.getMapResoPara().put(curCalName, m_curParam); return result; } @@ -1622,6 +1659,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (Objects.nonNull(file)) { String fileName = file.getOriginalFilename(); // 从最后一个。切割文件名称 获取文件名称后缀 @@ -1661,7 +1699,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf map.put("uncert", m_vCurUncert); ParameterInfo m_curParam = new ParameterInfo(); if (StringUtils.isNotBlank(currentText)) { - m_curParam = selfStationData.getSampleVueData().getMapResoPara().get(currentText); + m_curParam = phd.getMapResoPara().get(currentText); } map.put("param", m_curParam); int num = m_vCurEnergy.size(); @@ -1716,8 +1754,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (StringUtils.isNotBlank(currentName)) { - selfStationData.getSampleVueData().setNewReso(currentName); + phd.setNewReso(currentName); } selfCache.put(fileName, selfStationData); selfStationCache.setSelfCache(selfCache); @@ -1746,18 +1785,19 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (StringUtils.isBlank(currentText)) { - currentText = selfStationData.getSampleVueData().getUsedEffi(); + currentText = phd.getUsedEffi(); } - List dataSourceList = selfStationData.getSampleVueData().getMapEffiKD().keySet().stream().collect(Collectors.toList()); + List dataSourceList = phd.getMapEffiKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); if (StringUtils.isNotBlank(currentText)) { map.put("currentText", currentText); - List m_vCurEffi = selfStationData.getSampleVueData().getMapEffiKD().get(currentText).getEfficiency(); - List m_vCurEnergy = selfStationData.getSampleVueData().getMapEffiKD().get(currentText).getG_energy(); - List m_vCurUncert = selfStationData.getSampleVueData().getMapEffiKD().get(currentText).getUncertainty(); + List m_vCurEffi = phd.getMapEffiKD().get(currentText).getEfficiency(); + List m_vCurEnergy = phd.getMapEffiKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapEffiKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = selfStationData.getSampleVueData().getMapEffiPara().get(currentText); + ParameterInfo m_curParam = phd.getMapEffiPara().get(currentText); if (Objects.isNull(m_curParam)) { m_curParam = new ParameterInfo(); } @@ -1852,8 +1892,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first!"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (!curCalName.contains("Input")) { - List list_cal = selfStationData.getSampleVueData().getMapEffiKD().keySet().stream().collect(Collectors.toList()); + List list_cal = phd.getMapEffiKD().keySet().stream().collect(Collectors.toList()); curCalName = "Input " + (list_cal.stream().filter(item -> item.contains("Input")).collect(Collectors.toList()).size() + 1); list_cal.add(curCalName); result.setSuccess(true); @@ -1864,8 +1905,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf gEfficiencyBlock.setG_energy(m_vCurEnergy); gEfficiencyBlock.setUncertainty(m_vCurUncert); gEfficiencyBlock.setRecord_count(m_vCurEnergy.size()); - selfStationData.getSampleVueData().getMapEffiKD().put(curCalName, gEfficiencyBlock); - selfStationData.getSampleVueData().getMapEffiPara().put(curCalName, m_curParam); + phd.getMapEffiKD().put(curCalName, gEfficiencyBlock); + phd.getMapEffiPara().put(curCalName, m_curParam); return result; } @@ -1911,6 +1952,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf result.error500("Please select the parse file first"); return result; } + PHDFile phd = selfStationData.getSampleVueData().getROIOnePHDFile(); if (Objects.nonNull(file)) { String fileName = file.getOriginalFilename(); // 从最后一个。切割文件名称 获取文件名称后缀 @@ -1957,7 +1999,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf map.put("uncert", m_vCurUncert); ParameterInfo m_curParam = new ParameterInfo(); if (StringUtils.isNotBlank(currentText)) { - m_curParam = selfStationData.getSampleVueData().getMapEffiPara().get(currentText); + m_curParam = phd.getMapEffiPara().get(currentText); } if (m_curParam.getP().size() > 0) { m_curParam.getP().set(0, m_nFunId); @@ -2017,7 +2059,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf return result; } if (StringUtils.isNotBlank(currentName)) { - selfStationData.getSampleVueData().setNewEffi(currentName); + selfStationData.getSampleVueData().getROIOnePHDFile().setNewEffi(currentName); } selfCache.put(fileName, selfStationData); selfStationCache.setSelfCache(selfCache); @@ -2532,6 +2574,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf this.updateROI(roiParamList, selfStationData); } + BetaDataFile betaDataFile = selfStationData.getBetaDataFile(); + // Gamma文件内容转换为PHD实体 SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); PHDFile phdOne = sampleVueData.getROIOnePHDFile(); @@ -2596,6 +2640,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf List betaResult = this.betaAnalyse(selfStationData, nuclideLinesMap); resultMap.put("XeData", betaResult); + List xeResults = Lists.newArrayList(betaResult); + betaDataFile.setXeDataList(xeResults); + result.setSuccess(true); result.setResult(resultMap); selfStationData.setBAnalyed(true); @@ -4060,26 +4107,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf xeMap.put("sampleGammaEnergyData", betaDataFile.getGammaNewEnergyList()); } } - if (analyseData.isGasBgData()) { - betaDataFile.setBGammaEnergyValidGas(true); - if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) { - betaDataFile.setGasGammaEnergyList(betaDataFile.getGammaNewEnergyList()); - xeMap.put("gasGammaEnergyData", betaDataFile.getGammaNewEnergyList()); - } - } - if (analyseData.isDetBgData()) { - betaDataFile.setBGammaEnergyValidDet(true); - if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) { - betaDataFile.setDetGammaEnergyList(betaDataFile.getGammaNewEnergyList()); - xeMap.put("detGammaEnergyData", betaDataFile.getGammaNewEnergyList()); - } - } - if (analyseData.isQcData()) { - if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) { - betaDataFile.setQcGammaEnergyList(betaDataFile.getGammaNewEnergyList()); - xeMap.put("qcGammaEnergyData", betaDataFile.getGammaNewEnergyList()); - } - } } //判断是否勾选了sample spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); @@ -4087,6 +4114,25 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { sampleTmp = new File(betaDataFile.getSampleTmpPath()); } + + // 根据公式更新对应#energy道址数据 fix:20240918 +// CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam(); +// calcBgBoundaryParam.g_e_cal = spectrum_group.BgCalPara.g_e_cal; +// calcBgBoundaryParam.b_e_cal = spectrum_group.BgCalPara.b_e_cal; +// calcBgBoundaryParam.b_energy = struct.b_electron_energy; +// calcBgBoundaryParam.b_channel = struct.b_channel; +// calcBgBoundaryParam.g_channel = struct.g_centroid_channel; +// calcBgBoundaryParam.g_energy = struct.g_energy; +// calcBgBoundaryParam.ROI_B_start_x1 = struct.POI_B_x1; +// calcBgBoundaryParam.ROI_B_stop_x2 = struct.POI_B_x2; +// calcBgBoundaryParam.ROI_G_start_y1 = struct.POI_G_y1; +// calcBgBoundaryParam.ROI_G_stop_y2 = struct.POI_G_y2; +// BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam); + + + + + // if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) { // //调用分析方法进行分析操作 // boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, betaDataFile); @@ -5547,8 +5593,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf // 获取Map IdAnalysis:RoiId:GStoreMiddleProcessData analysisManService.middleDataTable(idAnalysis, middleDatas); // 向 RNMAN.GARDS_CALIBRATION_PAIRS 表写入 Energy 刻度数据对 - analysisManService.saveCalibrationPairsROI(sampleId, idAnalysis); - analysisManService.saveCalibrationROI(sampleId, idAnalysis); + analysisManService.saveCalibrationPairs(sampleId, idAnalysis); + analysisManService.saveCalibration(sampleId, idAnalysis); // 向 RNMAN.GARDS_PEAKS 表写入峰信息 analysisManService.savePeaksROI(sampleId, idAnalysis); // 向 RNMAN.GARDS_NUCL_LINES_IDED 表写入被识别核素的射线信息 @@ -5561,6 +5607,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf analysisManService.saveAnalySettingROI(sampleId, idAnalysis, phdFiles); // 向 RNMAN.GARDS_MDC 表写入 MDC计算结果 analysisManService.saveMDCROI(sampleId, mdcInfoMaps, idAnalysis); + + //新增gards_Xe_results数据表数据 + analysisManService.saveGardsXeResults(sampleId, idAnalysis, betaDataFile.getXeDataList()); try { // 存储PHD文件 if (StringUtils.isNotBlank(sampleFilePathName)){