diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java index 58d2fb24..202e4da2 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/FittingBody.java @@ -18,4 +18,8 @@ public class FittingBody implements Serializable { private Integer count; + private String qcFileName; + + private String tabName; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java new file mode 100644 index 00000000..be2ac261 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java @@ -0,0 +1,36 @@ +package org.jeecg.common.cache; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.jeecg.modules.entity.vo.PHDFile; +import org.jeecg.modules.entity.vo.SeriseData; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Component +public class BetaCache { + private Cache> betaCache = CacheBuilder.newBuilder() + //设置缓存初始大小,应该合理设置,后续会扩容 + .initialCapacity(10) + //最大值 + .maximumSize(100) + //并发数设置 + .concurrencyLevel(5) + //缓存过期时间,写入后5秒钟过期 + .expireAfterWrite(5, TimeUnit.HOURS) + //统计缓存命中率 + .recordStats() + .build(); + + public Cache> getBetaCache() { + return betaCache; + } + + public void setBetaCache(Cache> betaCache) { + this.betaCache = betaCache; + } + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 7254da77..dff6063e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -2,7 +2,7 @@ package org.jeecg.common.util; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; @@ -2717,14 +2717,37 @@ public class GammaFileUtil { return data; } - List DoubleLimit_G(List _data) { - NumberFormat numberFormat = new DecimalFormat("0.##########E0"); + public List DoubleLimit_I(List _data) { List rdata = new LinkedList<>(); for(int pos=0;pos<_data.size();pos++) { if(Objects.isNull(_data.get(pos))) { rdata.add("NULL"); } else { - rdata.add(numberFormat.format(_data.get(pos))); + rdata.add(String.valueOf(_data.get(pos).intValue())); + } + } + return rdata; + } + + public List DoubleLimit_G(List _data) { + NumberFormat numberFormat = new DecimalFormat("0.##########E0"); + List rdata = new LinkedList<>(); + for(int pos=0;pos<_data.size();pos++) { + Double value = _data.get(pos); + if (String.valueOf(value).indexOf("e")>0) { + if(Objects.isNull(value)) { + rdata.add("NULL"); + } else { + rdata.add(numberFormat.format(value)); + } + } else { + if (String.format("%.1f", value).indexOf(".0")>0) { + rdata.addAll(DoubleLimit_I(_data)); + break; + } else { + rdata.addAll(DoubleLimit(_data)); + break; + } } } return rdata; @@ -3120,7 +3143,7 @@ public class GammaFileUtil { List dvctLD = new LinkedList<>(); List dvctNuclide_name = new LinkedList<>(); List dvctComments = new LinkedList<>(); - for(int m=0;m 1024){ t_comment = t_comment.substring(0, 1025); } dvctComments.add(t_comment); - - String qsName = ""; - for(int n=0;n svctNUCLIDEFULLNAME = new LinkedList<>(); - List dvctIDPEAK = new LinkedList<>(); - List dvctENERGY = new LinkedList<>(); - List dvctUNCENERGY = new LinkedList<>(); - List dvctABUNDANCE = new LinkedList<>(); - List dvctUNCABUNDANCE = new LinkedList<>(); - List dvctACTIVITY = new LinkedList<>(); - List dvctUNCACTIVITY = new LinkedList<>(); - List dvctEFFIC = new LinkedList<>(); - List dvctUNEFFIC = new LinkedList<>(); - List dvctMDA = new LinkedList<>(); - List dvctKEY_FLAG = new LinkedList<>(); - List dvctCSC_RATIO = new LinkedList<>(); - List dvctCSC_RATIO_ERR = new LinkedList<>(); - List dvctCSC_MOD_FLAG = new LinkedList<>(); - List dvctMDC = new LinkedList<>(); - List dvctCONCENTRATION = new LinkedList<>(); for(Map.Entry itor:fileAnlyse.getMapNucActMda().entrySet()) { + List svctNUCLIDEFULLNAME = new LinkedList<>(); + List dvctIDPEAK = new LinkedList<>(); + List dvctENERGY = new LinkedList<>(); + List dvctUNCENERGY = new LinkedList<>(); + List dvctABUNDANCE = new LinkedList<>(); + List dvctUNCABUNDANCE = new LinkedList<>(); + List dvctACTIVITY = new LinkedList<>(); + List dvctUNCACTIVITY = new LinkedList<>(); + List dvctEFFIC = new LinkedList<>(); + List dvctUNEFFIC = new LinkedList<>(); + List dvctMDA = new LinkedList<>(); + List dvctKEY_FLAG = new LinkedList<>(); + List dvctCSC_RATIO = new LinkedList<>(); + List dvctCSC_RATIO_ERR = new LinkedList<>(); + List dvctCSC_MOD_FLAG = new LinkedList<>(); + List dvctMDC = new LinkedList<>(); + List dvctCONCENTRATION = new LinkedList<>(); int first=itor.getValue().getFullNames().size(); int second=itor.getValue().getVPeakIdx().size(); first = first svctNUCLIDEFULLNAME1 = new LinkedList<>(); - List svctTYPE = new LinkedList<>(); - List dvctHALFLIFE = new LinkedList<>(); - List dvctAVE_ACTIV = new LinkedList<>(); - List dvctAVE_ACTIV_ERR = new LinkedList<>(); - List dvctACTIV_KEY = new LinkedList<>(); - List dvctACTIV_KEY_ERR = new LinkedList<>(); - List dvctMDA1 = new LinkedList<>(); - List dvctMDA_ERR = new LinkedList<>(); - List dvctNID_FLAG = new LinkedList<>(); - List dvctCSC_RATIO1 = new LinkedList<>(); - List dvctCSC_RATIO_ERR1 = new LinkedList<>(); - List dvctCSC_MOD_FLAG1 = new LinkedList<>(); - List dvctMDC1 = new LinkedList<>(); - List dvctCONCENTRATION1 = new LinkedList<>(); - List dvctKey_Energy = new LinkedList<>(); - List dvctKey_Yield = new LinkedList<>(); - if( fileAnlyse.getMapNucActMda().size() != 0) { + List svctNUCLIDEFULLNAME1 = new LinkedList<>(); + List svctTYPE = new LinkedList<>(); + List dvctHALFLIFE = new LinkedList<>(); + List dvctAVE_ACTIV = new LinkedList<>(); + List dvctAVE_ACTIV_ERR = new LinkedList<>(); + List dvctACTIV_KEY = new LinkedList<>(); + List dvctACTIV_KEY_ERR = new LinkedList<>(); + List dvctMDA1 = new LinkedList<>(); + List dvctMDA_ERR = new LinkedList<>(); + List dvctNID_FLAG = new LinkedList<>(); + List dvctCSC_RATIO1 = new LinkedList<>(); + List dvctCSC_RATIO_ERR1 = new LinkedList<>(); + List dvctCSC_MOD_FLAG1 = new LinkedList<>(); + List dvctMDC1 = new LinkedList<>(); + List dvctCONCENTRATION1 = new LinkedList<>(); + List dvctKey_Energy = new LinkedList<>(); + List dvctKey_Yield = new LinkedList<>(); for(Map.Entry itor_v: fileAnlyse.getMapNucActMda().entrySet()) { String nuclideName = itor_v.getKey(); svctNUCLIDEFULLNAME1.add(nuclideName); @@ -3307,7 +3321,6 @@ public class GammaFileUtil { dvctKey_Yield.add(itor_v.getValue().getVYield().get(itor_v.getValue().getCalculateIdx())); } } - middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME1; middleData.nucl_ided_Type= svctTYPE; middleData.nucl_ided_Halflife =DoubleLimit_G(dvctHALFLIFE); @@ -3322,17 +3335,16 @@ public class GammaFileUtil { middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR1); middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG1); middleData.nucl_ided_MDC = dvctMDC1; - middleData.nucl_ided_Concentration = dvctCONCENTRATION; + middleData.nucl_ided_Concentration = dvctCONCENTRATION1; middleData.nucl_ided_Key_Energy = DoubleLimit_G(dvctKey_Energy); middleData.nucl_ided_Key_Yield = DoubleLimit_G(dvctKey_Yield); - } // GARDS_QC_CHECK数据表 - List qvctQC_NAME = new LinkedList<>(); - List dvctQC_VALUE = new LinkedList<>(); - List qvctQC_STANDARD = new LinkedList<>(); - List dvctQC_RESULT = new LinkedList<>(); if( fileAnlyse.getQcItems().size() != 0) { + List qvctQC_NAME = new LinkedList<>(); + List dvctQC_VALUE = new LinkedList<>(); + List qvctQC_STANDARD = new LinkedList<>(); + List dvctQC_RESULT = new LinkedList<>(); for(Map.Entry itor_q:fileAnlyse.getQcItems().entrySet()) { String nuclideName = itor_q.getKey(); qvctQC_NAME.add(nuclideName); @@ -3345,11 +3357,9 @@ public class GammaFileUtil { middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD; middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE); } - //sample info middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time(); middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time(); - if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) { middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) { @@ -3365,16 +3375,14 @@ public class GammaFileUtil { middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume()); middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time(); String acquisition_start = middleData.sample_acquisiton_start; - Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss"); - middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss"); + Date dataTime = DateUtils.parseDate(acquisition_start); + middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss"); middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ; middleData.sample_stationID = fileAnlyse.getHeader().getSite_code(); middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code(); middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry(); middleData.sample_Type = fileAnlyse.getHeader().getSystem_type(); middleData.setting_specSetup = fileAnlyse.getUsedSetting(); - middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt(); middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt(); return bRet; 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 6185b705..a382b127 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 @@ -588,11 +588,11 @@ public class PHDFileUtil { String dataType = sourceData.data_type; StringBuffer path = new StringBuffer(); if(systemType.contains("B")) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Sauna"); } else if(systemType.contains("G")) { - path.append(StringPool.SLASH+"Spectrum"); + path.append("Spectrum"); path.append(StringPool.SLASH+"Xenon"); path.append(StringPool.SLASH+"Spalax"); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index d4b7c751..35c7fd5b 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -181,6 +181,7 @@ public class GammaController { } @PostMapping("saveDataEnergy") + @ApiOperation(value = "保存Energy Calibration数据", notes = "保存Energy Calibration数据") public void saveDataEnergy(@RequestBody ChangeData changeData, HttpServletResponse response) { gammaService.saveDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response); } @@ -203,6 +204,12 @@ public class GammaController { return gammaService.applyDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName()); } + @PostMapping("saveDataResolution") + @ApiOperation(value = "保存Resolution Calibration数据", notes = "保存Resolution Calibration数据") + public void saveDataResolution(@RequestBody ChangeData changeData, HttpServletResponse response) { + gammaService.saveDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response); + } + @GetMapping("EfficiencyCalibration") @ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据") public Result EfficiencyCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { @@ -221,6 +228,12 @@ public class GammaController { return gammaService.applyDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName()); } + @PostMapping("saveDataEfficiency") + @ApiOperation(value = "保存Efficiency Calibration数据", notes = "保存Efficiency Calibration数据") + public void saveDataEfficiency(@RequestBody ChangeData changeData, HttpServletResponse response) { + gammaService.saveDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getFuncId(), response); + } + @GetMapping("NuclideLibrary") @ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据") public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { @@ -263,12 +276,22 @@ public class GammaController { gammaService.viewARR(sampleId, response); } + @GetMapping("exportARR") + public void exportARR(Integer sampleId, HttpServletResponse response) { + gammaService.exportARR(sampleId, response); + } + @GetMapping("viewRRR") @ApiOperation(value = "查看RRR页面数据", notes = "查看RRR页面数据") public Result viewRRR(Integer sampleId, String fileName) { return gammaService.viewRRR(sampleId, fileName); } + @GetMapping("exportRRR") + public void exportRRR(Integer sampleId, String fileName, HttpServletResponse response) { + gammaService.exportRRR(sampleId, fileName, response); + } + @GetMapping("radionuclideActivity") @ApiOperation(value = "查看Radionuclide Activity页面数据", notes = "查看Radionuclide Activity页面数据") public Result radionuclideActivity(Integer sampleId, String fileName) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index 826f8636..20239e31 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -179,8 +179,8 @@ public class SpectrumAnalysesController { @PostMapping("fitting") @ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线") - public Result fitting(@RequestBody FittingBody fittingBody) { - return spectrumAnalysisService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount()); + public Result fitting(@RequestBody FittingBody fittingBody, HttpServletRequest request) { + return spectrumAnalysisService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount(), fittingBody.getQcFileName(), fittingBody.getTabName(), request); } @GetMapping("getGammaGated") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java index 51ed7a7d..22128005 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java @@ -1,6 +1,7 @@ package org.jeecg.modules.entity.vo; import lombok.Data; +import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.entity.GardsCalibrationSpectrum; import org.jeecg.modules.entity.GardsROIChannelsSpectrum; import org.jeecg.modules.entity.GardsROIResultsSpectrum; @@ -177,15 +178,9 @@ public class BgDataAnlyseResultIn implements Serializable { /** * Beta Detector Calibration公式参数 */ - private String param_a_c2e_b_sample; - private String param_b_c2e_b_sample; - private String param_c_c2e_b_sample; - private String param_a_c2e_b_gas; - private String param_b_c2e_b_gas; - private String param_c_c2e_b_gas; - private String param_a_c2e_b_det; - private String param_b_c2e_b_det; - private String param_c_c2e_b_det; + private String param_a_c2e_b; + private String param_b_c2e_b; + private String param_c_c2e_b; private double mdc_Xe135; //MDC XE135 private double mdc_Xe131m; //MDC XE131m @@ -222,6 +217,6 @@ public class BgDataAnlyseResultIn implements Serializable { List roiResultsSpectrumList; - List XeData; + List XeData; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index abffbb44..cac084cc 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -71,12 +71,16 @@ public interface IGammaService{ Result applyDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); + void saveDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); + Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText); Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName); Result applyDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); + void saveDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, Integer funId, HttpServletResponse response); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); @@ -91,8 +95,12 @@ public interface IGammaService{ void viewARR(Integer sampleId, HttpServletResponse response); + void exportARR(Integer sampleId, HttpServletResponse response); + Result viewRRR(Integer sampleId, String fileName); + void exportRRR(Integer sampleId, String fileName, HttpServletResponse response); + Result radionuclideActivity(Integer sampleId, String fileName); void exportRadionuclideActivity(Integer sampleId, String fileName, HttpServletResponse response); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index 72ed5eb2..6e5a7ef1 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -62,7 +62,7 @@ public interface ISpectrumAnalysisService { Result statisticsQueryBtn(Integer detectorId, String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime); - Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count); + Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count, String qcFileName, String tabName, HttpServletRequest request); Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index da9bfc23..9de64459 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -39,6 +39,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; +import java.net.URLEncoder; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -1224,6 +1225,10 @@ public class GammaServiceImpl implements IGammaService { } OutputStream fos = null; try { + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("EnergyCalibration.Ent","UTF-8")); fos = response.getOutputStream(); fos.write(strBuffer.toString().getBytes()); } catch (FileNotFoundException e) { @@ -1365,6 +1370,34 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void saveDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response) { + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("#g_Resolution").append("\n"); + for (int i=0; i m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, Integer funId, HttpServletResponse response) { + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("#g_Efficiency").append("\n"); + for (int i=0; i ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ftpFiles)){ + throw new RuntimeException("ftp下对应的报告文件不存在"); + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)){ + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("ARR.txt","UTF-8")); + outputStream = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int bytesRead; + // 将文件输出流写入到输出流中 + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (ObjectUtil.isNotNull(inputStream)){ + inputStream.close(); + } + if (ObjectUtil.isNotNull(outputStream)){ + outputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + @Override public Result viewRRR(Integer sampleId, String fileName) { Result result = new Result(); @@ -1753,6 +1882,35 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void exportRRR(Integer sampleId, String fileName, HttpServletResponse response) { + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)) { + return; + } + String reportContent = gammaFileUtil.GetReportContent(phd, false); + OutputStream fos = null; + try { + //设置响应类型 + response.setContentType("application/octet-stream"); + //解决中文不能生成文件 + response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode("RRR.txt","UTF-8")); + fos = response.getOutputStream(); + fos.write(reportContent.getBytes()); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + fos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + @Override public Result> radionuclideActivity(Integer sampleId, String fileName) { Result> result = new Result(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 650d87c3..dd6375f0 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -9,12 +9,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.cache.Cache; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.cache.BetaCache; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; @@ -28,6 +30,7 @@ import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.EnergySpectrumHandler; +import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; @@ -64,6 +67,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private PHDFileUtil phdFileUtil; @Autowired + private BetaCache betaCache; + @Autowired private IGardsSampleDataSpectrumService sampleDataSpectrumService; @Autowired private IGardsSampleAuxSpectrumService sampleAuxSpectrumService; @@ -74,16 +79,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private IGardsSampleCertLineSpectrumService sampleCertLineSpectrumService; @Autowired - private IGardsCalibrationSpectrumService calibrationSpectrumService; - @Autowired - private IGardsROIChannelsSpectrumService roiChannelsSpectrumService; - @Autowired - private IGardsXeResultsSpectrumService xeResultsSpectrumService; - @Autowired - private IGardsROIResultsSpectrumService roiResultsSpectrumService; - @Autowired - private IGardsCalibrationPairsSpectrumService calibrationPairsSpectrumService; - @Autowired private IGardsCalibrationPairsOrigSpectrumService calibrationPairsOrigSpectrumService; @Autowired private IGardsBgEfficiencyPairsSpectrumService bgEfficiencyPairsSpectrumService; @@ -1345,6 +1340,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Result result = new Result(); Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; //如果sampleId不为空 if (Objects.nonNull(sampleId)) { @@ -1463,6 +1460,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { map.put("min", min); map.put("max", max); map.put("gammaSpectrum", seriseDataList); + + cacheMap.put("Series", oldScatterSeries); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-gamma", cacheMap); + betaCache.setBetaCache(cache); } } } catch (IOException e) { @@ -1489,6 +1491,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Result result = new Result(); Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; if (Objects.nonNull(sampleId)) { GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); @@ -1609,6 +1613,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { fittingParaToUiStr.add(String.valueOf(para)); } map.put("EToC", fittingParaToUiStr); + + cacheMap.put("Series", oldScatterSeries); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-beta", cacheMap); + betaCache.setBetaCache(cache); } } } catch (IOException e) { @@ -2181,8 +2190,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count) { + public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count, String qcFileName, String tabName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Cache> cache = betaCache.getBetaCache(); + Map cacheMap = new HashMap<>(); Map map = new HashMap<>(); //加载dll工具库 System.loadLibrary("ReadPHDFile"); @@ -2222,11 +2234,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { fittingParaToUiStr.add(String.valueOf(para)); } map.put("EToC", fittingParaToUiStr); - }else { + + cacheMap.put("Series", tempPoints); + cacheMap.put("fittingPara", fittingParaStr); + cache.put(qcFileName+"-"+userName+"-"+tabName, cacheMap); + betaCache.setBetaCache(cache); + } else { List fittingPara = new LinkedList<>(); fittingPara.add(paramA); fittingPara.add(paramB); fittingPara.add(paramC); + List fittingParaStr = new LinkedList<>(); + fittingParaStr.add(String.valueOf(paramA)); + fittingParaStr.add(String.valueOf(paramB)); + fittingParaStr.add(String.valueOf(paramC)); List xs = new LinkedList<>(); for (int i=0; i> cache = betaCache.getBetaCache(); + //根据qc文件名称-用户名-beta的方式获取beta的内容 + Map betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); + List betaFittingPara = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); + betaFittingPara = (List) betaMap.get("fittingPara"); + } + //根据qc文件名称-用户名-gamma的方式获取gamma的内容 + Map gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); + List gammaFittingPara = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); + gammaFittingPara = (List) gammaMap.get("fittingPara"); + } + //获取当前时间作为人工分析开始时间 String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); + //获取当前时间作为人工分析结束时间 String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //判断当前分析员是否有过排班任务 Integer stationId = spectrumAnalysisMapper.getStationId(anlyseResultIn.getStationName()); + //判断当前分析员是否有过当前台站的排班任务 boolean bAnalysisResultWriteAuthority = userTaskUtil.CheckUserWriteAuthorityForStation(anlyseResultIn.getUserName(), stationId); if ( !bAnalysisResultWriteAuthority ){ result.error500("This user has no right to store the results of the analysis to the database."); return result; } - //处理数据 获取对应的channel/energy值 - getChannelAndEnergy(anlyseResultIn); //获取ROI Limit数据 // getROILimit(anlyseResultIn); //根据sample文件名称模糊查询sampleId @@ -2694,7 +2741,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName); } - + //处理数据 获取对应的channel/energy值 + getChannelAndEnergy(anlyseResultIn, betaList, gammaList); + //分析文件内容 + Map map = new HashMap<>(); + analyzePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara, map); //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2782,9 +2833,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } //gards_roi_channels数据表 List roiChannelsList = new LinkedList<>(); - getROIChannel(sampleId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); - getROIChannel(gasId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); - getROIChannel(detId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList); + getROIChannel(sampleId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.SAMPLEPHD.getType()); + getROIChannel(gasId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.GASBKPHD.getType()); + getROIChannel(detId, idAnalysis, anlyseResultIn.getRoiChannelsSpectrumList(), roiChannelsList, DataTypeAbbr.DETBKPHD.getType()); //如果分析过数据 if (Objects.nonNull(isExist)){ //删除gards_roi_channels数据表数据 @@ -2815,7 +2866,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } //gards_roi_results数据表 - List roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis, isExist); + List roiResultsSpectrumList = getROIResult(anlyseResultIn.getRoiResultsSpectrumList(), sampleId, idAnalysis); if(Objects.nonNull(isExist)) { //删除gards_roi_results数据表数据 spectrumAnalysisMapper.deleteROIResults(idAnalysis); @@ -2830,21 +2881,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } //上传本次文件到ftp人工交互存储路径下 - File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); - File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); - try { - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } +// File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); +// File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); +// File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); +// try { +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); +// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); +// } catch (FileNotFoundException e) { +// throw new RuntimeException(e); +// } result.setSuccess(true); return result; } - public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn) { + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List betaList, List gammaList) { //获取ftp文件路径下临时文件 File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2858,11 +2909,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_sample(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_sample(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_sample(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_sample(energys); } //没有点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮 channel/energy数据读取文件 如果点击过数据来源页面 if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_sample(sourceData.b_channel); anlyseResultIn.setB_energy_sample(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_sample(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_sample(energys); } } else {//如果没有勾选Energy Calibration页面下sample Data EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); @@ -2878,10 +2939,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_gas(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_gas(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_gas(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_gas(energys); } if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_gas(sourceData.b_channel); anlyseResultIn.setB_energy_gas(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_gas(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_gas(energys); } } else { EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath()); @@ -2897,10 +2968,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setG_channel_det(sourceData.g_centroid_channel); anlyseResultIn.setG_energy_det(sourceData.g_energy); + } else { + List channels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setG_channel_det(channels); + List energys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setG_energy_det(energys); } if (!anlyseResultIn.isBGammaEnergyValid()){ anlyseResultIn.setB_channel_det(sourceData.b_channel); anlyseResultIn.setB_energy_det(sourceData.b_electron_energy); + } else { + List channels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + anlyseResultIn.setB_channel_det(channels); + List energys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + anlyseResultIn.setB_energy_det(energys); } } else { EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath()); @@ -2912,6 +2993,203 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } + public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara, Map map) { + //根据文件路径 文件名称获取对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + //调用动态库解析文件 + + //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 + //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 + BgAnalyseResult bgAnalyseResult = null; + if (anlyseResultIn.isCheckSample() && anlyseResultIn.isCheckGas() && anlyseResultIn.isCheckDet()) { + bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + } else { + bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + } + List xeResultsSpectrumList = new LinkedList<>(); + GardsXeResults xe131m = new GardsXeResults(); + xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + xe131m.setConc(bgAnalyseResult.Xe131m_con); + xe131m.setConcErr(bgAnalyseResult.Xe131m_uncer); + xe131m.setLc(bgAnalyseResult.LC_Xe131m); + xe131m.setMdc(bgAnalyseResult.MDC_Xe131m); + xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); + xeResultsSpectrumList.add(xe131m); + GardsXeResults xe133 = new GardsXeResults(); + xe133.setNuclideName(XeNuclideName.XE_133.getType()); + xe133.setConc(bgAnalyseResult.Xe133_con); + xe133.setConcErr(bgAnalyseResult.Xe133_uncer); + xe133.setLc(bgAnalyseResult.LC_Xe133); + xe133.setMdc(bgAnalyseResult.MDC_Xe133); + xe133.setNidFlag(anlyseResultIn.getXe133Flag()); + xeResultsSpectrumList.add(xe133); + GardsXeResults xe133m = new GardsXeResults(); + xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + xe133m.setConc(bgAnalyseResult.Xe133m_con); + xe133m.setConcErr(bgAnalyseResult.Xe133m_uncer); + xe133m.setLc(bgAnalyseResult.LC_Xe133m); + xe133m.setMdc(bgAnalyseResult.MDC_Xe133m); + xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); + xeResultsSpectrumList.add(xe133m); + GardsXeResults xe135 = new GardsXeResults(); + xe135.setNuclideName(XeNuclideName.XE_135.getType()); + xe135.setConc(bgAnalyseResult.Xe135_con); + xe135.setConcErr(bgAnalyseResult.Xe135_uncer); + xe135.setLc(bgAnalyseResult.LC_Xe135); + xe135.setMdc(bgAnalyseResult.MDC_Xe135); + xe135.setNidFlag(anlyseResultIn.getXe135Flag()); + xeResultsSpectrumList.add(xe135); + anlyseResultIn.setXeData(xeResultsSpectrumList); + + List gammaCalibrationSpectrumList = new LinkedList<>(); + if (anlyseResultIn.isBGammaEnergyValid()) { + GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); + gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationS.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationS.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationS); + GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); + gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + gammaCalibrationG.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationG.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationG.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationG); + GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); + gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + gammaCalibrationD.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationD.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationD.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + gammaCalibrationSpectrumList.add(gammaCalibrationD); + anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList); + } else { + GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); + gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0)); + gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1)); + gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationS); + GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); + gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0)); + gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1)); + gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationG); + GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); + gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0)); + gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1)); + gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationD); + anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList); + } + + + List betaCalibrationSpectrumList = new LinkedList<>(); + if (anlyseResultIn.isBBetaEnergyValid()) { + GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); + betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + betaCalibrationS.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationS.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationS.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationS); + GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); + betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + betaCalibrationG.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationG.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationG.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationG); + GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); + betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + betaCalibrationD.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationD.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationD.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + betaCalibrationSpectrumList.add(betaCalibrationD); + } else { + GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); + betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + betaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); + betaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); + betaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationS); + GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); + betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); + betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); + betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationG); + GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); + betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); + betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); + betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationD); + } + + anlyseResultIn.setBetaCalibrationSpectrumList(betaCalibrationSpectrumList); + List roiChannelsSpectrumList = new LinkedList<>(); + for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); + for (int i=0; ibgAnalyseResult.MDC.get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); + } + roiResultsSpectrumList.add(roiResults); + } + anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList); + } + public List getCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { List calibrationPairsList = new LinkedList<>(); for (int i=0; i< anlyseResultIn.getB_channel_sample().size(); i++){ @@ -3066,10 +3344,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_sample())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_sample())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_sample())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); + GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(sampleId); calibrationG.setIdAnalysis(idAnalysis); @@ -3079,13 +3360,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_sample())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_sample())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_sample())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.SAMPLEPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } if (Objects.nonNull(gasId)) { + //gas文件 Beta部分 GardsCalibration calibrationB = new GardsCalibration(); calibrationB.setSampleId(gasId); calibrationB.setIdAnalysis(idAnalysis); @@ -3095,10 +3379,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_gas())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_gas())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_gas())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); + //gas文件 gamma部分 GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(gasId); calibrationG.setIdAnalysis(idAnalysis); @@ -3108,9 +3395,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_gas())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_gas())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_gas())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.GASBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } @@ -3124,9 +3413,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationB.setFunctionDef(FittingType.POLY2.getDescription()); calibrationB.setStartOfRange(0); calibrationB.setEndOfRange(1); - calibrationB.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_b_det())); - calibrationB.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_b_det())); - calibrationB.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_b_det())); + List betaCollect = anlyseResultIn.getBetaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum betaCalibrationSpectrum = betaCollect.get(0); + calibrationB.setCoeff1(Double.valueOf(betaCalibrationSpectrum.getCoeff1())); + calibrationB.setCoeff2(Double.valueOf(betaCalibrationSpectrum.getCoeff2())); + calibrationB.setCoeff3(Double.valueOf(betaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationB); GardsCalibration calibrationG = new GardsCalibration(); calibrationG.setSampleId(detId); @@ -3137,15 +3428,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { calibrationG.setFunctionDef(FittingType.POLY2.getDescription()); calibrationG.setStartOfRange(0); calibrationG.setEndOfRange(1); - calibrationG.setCoeff1(Double.valueOf(anlyseResultIn.getParam_a_c2e_g_det())); - calibrationG.setCoeff2(Double.valueOf(anlyseResultIn.getParam_b_c2e_g_det())); - calibrationG.setCoeff3(Double.valueOf(anlyseResultIn.getParam_c_c2e_g_det())); + List gammaCollect = anlyseResultIn.getGammaCalibrationSpectrumList().stream().filter(item -> item.getDataType().equals(DataTypeAbbr.DETBKPHD.getType())).collect(Collectors.toList()); + GardsCalibrationSpectrum gammaCalibrationSpectrum = gammaCollect.get(0); + calibrationG.setCoeff1(Double.valueOf(gammaCalibrationSpectrum.getCoeff1())); + calibrationG.setCoeff2(Double.valueOf(gammaCalibrationSpectrum.getCoeff2())); + calibrationG.setCoeff3(Double.valueOf(gammaCalibrationSpectrum.getCoeff3())); calibrationSpectrumList.add(calibrationG); } return calibrationSpectrumList; } - public void getROIChannel(Integer sampleId, Integer idAnalysis, List roiChannelsSpectrumList, List roiChannelsList) { + public void getROIChannel(Integer sampleId, Integer idAnalysis, List roiChannelsSpectrumList, List roiChannelsList, String dataType) { + roiChannelsSpectrumList = roiChannelsSpectrumList.stream().filter(item-> item.getDataType().equals(dataType)).collect(Collectors.toList()); for (int i=0; i getXeResults(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis) { - List xeResultsList = new LinkedList<>(); - //Xe131m - GardsXeResults xe131m = new GardsXeResults(); - xe131m.setSampleId(sampleId); - xe131m.setIdAnalysis(idAnalysis); - xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); - xe131m.setConc(anlyseResultIn.getXe131m_con()); - xe131m.setConcErr(anlyseResultIn.getXe131m_uncer()); - xe131m.setMdc(anlyseResultIn.getMdc_Xe131m()); - xe131m.setLc(anlyseResultIn.getLc_Xe131m()); - xe131m.setNidFlag(anlyseResultIn.getXe131mFlag()); - xeResultsList.add(xe131m); - //Xe133 - GardsXeResults xe133 = new GardsXeResults(); - xe133.setSampleId(sampleId); - xe133.setIdAnalysis(idAnalysis); - xe133.setNuclideName(XeNuclideName.XE_133.getType()); - xe133.setConc(anlyseResultIn.getXe133_con()); - xe133.setConcErr(anlyseResultIn.getXe133_uncer()); - xe133.setMdc(anlyseResultIn.getMdc_Xe133()); - xe133.setLc(anlyseResultIn.getLc_Xe133()); - xe133.setNidFlag(anlyseResultIn.getXe133Flag()); - xeResultsList.add(xe133); - //Xe133m - GardsXeResults xe133m = new GardsXeResults(); - xe133m.setSampleId(sampleId); - xe133m.setIdAnalysis(idAnalysis); - xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); - xe133m.setConc(anlyseResultIn.getXe133m_con()); - xe133m.setConcErr(anlyseResultIn.getXe133m_uncer()); - xe133m.setMdc(anlyseResultIn.getMdc_Xe133m()); - xe133m.setLc(anlyseResultIn.getLc_Xe133m()); - xe133m.setNidFlag(anlyseResultIn.getXe133mFlag()); - xeResultsList.add(xe133m); - //Xe135 - GardsXeResults xe135 = new GardsXeResults(); - xe135.setSampleId(sampleId); - xe135.setIdAnalysis(idAnalysis); - xe135.setNuclideName(XeNuclideName.XE_135.getType()); - xe135.setConc(anlyseResultIn.getXe135_con()); - xe135.setConcErr(anlyseResultIn.getXe135_uncer()); - xe135.setMdc(anlyseResultIn.getMdc_Xe135()); - xe135.setLc(anlyseResultIn.getLc_Xe135()); - xe135.setNidFlag(anlyseResultIn.getXe135Flag()); - xeResultsList.add(xe135); + List xeResultsList = anlyseResultIn.getXeData(); + for (GardsXeResults xeResults:xeResultsList) { + xeResults.setIdAnalysis(idAnalysis); + xeResults.setSampleId(sampleId); + } return xeResultsList; } @@ -3377,7 +3631,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return readLines; } - public List getROIResult(List roiResultsSpectrumList, Integer sampleId, Integer idAnalysis, Integer isExist) { + public List getROIResult(List roiResultsSpectrumList, Integer sampleId, Integer idAnalysis) { List roiResultsList = new LinkedList<>(); for (int i=0; i