From e012393bb11ad18eb004f449cc651e96bef22e79 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Thu, 28 Sep 2023 10:04:30 +0800 Subject: [PATCH] =?UTF-8?q?Beta=E4=BF=9D=E5=AD=98=E6=97=B6qc=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=A9=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SpectrumAnalysisServiceImpl.java | 1589 +++++++++-------- 1 file changed, 844 insertions(+), 745 deletions(-) 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 fa3d112d..86f22c83 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 @@ -1036,94 +1036,111 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String gasFilePath = ""; String detFilePath = ""; List xeDataList = new LinkedList<>(); - //判断是否有sampleId和dbName 如果有则说明数据来源DB - if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) { - Integer analysisID = null; - if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); - }else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + try { + //判断是否有sampleId和dbName 如果有则说明数据来源DB + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) { + Integer analysisID = null; + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); + }else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + } + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + //查询数据库中结果的Xe数据 + xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); + xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); + gardsXeResults = xeDataList.get(0); + } else {//如果没有数据来源就是File + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + sampleFilePath = path; + gasFilePath = path; + detFilePath = path; + sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); + gasTmp = phdFileUtil.analyzeFile(path, gasFileName); + detTmp = phdFileUtil.analyzeFile(path, detFileName); + if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { + result.error500("ftp下文件不存在"); + return result; + } + xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); + xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); + gardsXeResults = xeDataList.get(0); } - dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - gasFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - detFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - //查询数据库中结果的Xe数据 - xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); - xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); - gardsXeResults = xeDataList.get(0); - } else {//如果没有数据来源就是File - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - sampleFilePath = path; - gasFilePath = path; - detFilePath = path; - File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); - File gasTmp = phdFileUtil.analyzeFile(path, gasFileName); - File detTmp = phdFileUtil.analyzeFile(path, detFileName); - if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { - result.error500("ftp下文件不存在"); - return result; + //解析sample,gas,det文件并判断数据状态 + if (StringUtils.isNotBlank(sampleFileName) && StringUtils.isNotBlank(gasFileName) && StringUtils.isNotBlank(detFileName)) { + EnergySpectrumStruct sampleSourceData = phdFileUtil.analyzeFileSourceData(sampleFilePath, sampleFileName); + EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, gasFileName); + EnergySpectrumStruct detSourceData = phdFileUtil.analyzeFileSourceData(detFilePath, detFileName); + try { + Date collectStartDate = DateUtils.parseDate(sampleSourceData.collection_start_date + StringPool.SPACE + sampleSourceData.collection_start_time); + Date collectStopDate = DateUtils.parseDate(sampleSourceData.collection_stop_date + StringPool.SPACE + sampleSourceData.collection_stop_time); + Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); + String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); + qcResult.setCollectTimeValue(collection_time_value); + if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ + qcResult.setCollectTimeStatus("Pass"); + }else { + qcResult.setCollectTimeStatus("Failed"); + } + String acquisition_live_sec = String.format("%.2f",sampleSourceData.acquisition_live_time/3600.0); + qcResult.setAcquisitionTimeValue(acquisition_live_sec); + if (acquisitionTimeSections.get(1) < sampleSourceData.acquisition_live_time/3600.0 && sampleSourceData.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ + qcResult.setAcquisitionTimeStatus("Pass"); + }else { + qcResult.setAcquisitionTimeStatus("Failed"); + } + String s_xe_stable_volume = String.valueOf(sampleSourceData.sample_volume_of_Xe); + qcResult.setXenonVolumeValue(s_xe_stable_volume); + if (xeVolumeSections.get(1) < sampleSourceData.sample_volume_of_Xe){ + qcResult.setXenonVolumeStatus("Pass"); + }else { + qcResult.setXenonVolumeStatus("Failed"); + } + // + String gasMeasurementID = gasSourceData.measurement_id; + if (gasMeasurementID.equals(sampleSourceData.gas_bk_measurement_id)){ + qcResult.setGasBgValueAndStatus(true); + }else { + qcResult.setGasBgValueAndStatus(false); + } + // + String detMeasurementID = detSourceData.measurement_id; + if (detMeasurementID.equals(sampleSourceData.detector_bk_measurement_id)){ + qcResult.setDetBgValueAndStatus(true); + }else { + qcResult.setDetBgValueAndStatus(false); + } + } catch (ParseException e) { + throw new RuntimeException(e); + } } - xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); - xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); - gardsXeResults = xeDataList.get(0); - } - //解析sample,gas,det文件并判断数据状态 - if (StringUtils.isNotBlank(sampleFileName) && StringUtils.isNotBlank(gasFileName) && StringUtils.isNotBlank(detFileName)) { - EnergySpectrumStruct sampleSourceData = phdFileUtil.analyzeFileSourceData(sampleFilePath, sampleFileName); - EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, gasFileName); - EnergySpectrumStruct detSourceData = phdFileUtil.analyzeFileSourceData(detFilePath, detFileName); - try { - Date collectStartDate = DateUtils.parseDate(sampleSourceData.collection_start_date + StringPool.SPACE + sampleSourceData.collection_start_time); - Date collectStopDate = DateUtils.parseDate(sampleSourceData.collection_stop_date + StringPool.SPACE + sampleSourceData.collection_stop_time); - Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); - String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); - qcResult.setCollectTimeValue(collection_time_value); - if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ - qcResult.setCollectTimeStatus("Pass"); + if (Objects.nonNull(gardsXeResults)){ + qcResult.setXe133MDCValue(String.valueOf(gardsXeResults.getMdc())); + if ( 0.001 < gardsXeResults.getMdc() && gardsXeResults.getMdc() < 5.0 ){ + qcResult.setXe133MDCStatus("Pass"); }else { - qcResult.setCollectTimeStatus("Failed"); + qcResult.setXe133MDCStatus("Failed"); } - String acquisition_live_sec = String.format("%.2f",sampleSourceData.acquisition_live_time/3600.0); - qcResult.setAcquisitionTimeValue(acquisition_live_sec); - if (acquisitionTimeSections.get(1) < sampleSourceData.acquisition_live_time/3600.0 && sampleSourceData.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ - qcResult.setAcquisitionTimeStatus("Pass"); - }else { - qcResult.setAcquisitionTimeStatus("Failed"); - } - String s_xe_stable_volume = String.valueOf(sampleSourceData.sample_volume_of_Xe); - qcResult.setXenonVolumeValue(s_xe_stable_volume); - if (xeVolumeSections.get(1) < sampleSourceData.sample_volume_of_Xe){ - qcResult.setXenonVolumeStatus("Pass"); - }else { - qcResult.setXenonVolumeStatus("Failed"); - } - // - String gasMeasurementID = gasSourceData.measurement_id; - if (gasMeasurementID.equals(sampleSourceData.gas_bk_measurement_id)){ - qcResult.setGasBgValueAndStatus(true); - }else { - qcResult.setGasBgValueAndStatus(false); - } - // - String detMeasurementID = detSourceData.measurement_id; - if (detMeasurementID.equals(sampleSourceData.detector_bk_measurement_id)){ - qcResult.setDetBgValueAndStatus(true); - }else { - qcResult.setDetBgValueAndStatus(false); - } - } catch (ParseException e) { - throw new RuntimeException(e); } - } - if (Objects.nonNull(gardsXeResults)){ - qcResult.setXe133MDCValue(String.valueOf(gardsXeResults.getMdc())); - if ( 0.001 < gardsXeResults.getMdc() && gardsXeResults.getMdc() < 5.0 ){ - qcResult.setXe133MDCStatus("Pass"); - }else { - qcResult.setXe133MDCStatus("Failed"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); } } result.setSuccess(true); @@ -1159,28 +1176,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String userName = JwtUtil.getUserNameByToken(request); String sampleFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; List xeDataList = new LinkedList<>(); - if (Objects.nonNull(sampleId)) { - sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - //查询数据库中结果的Xe数据 - xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); - } else { - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); - File gasTmp = phdFileUtil.analyzeFile(path, gasFileName); - File detTmp = phdFileUtil.analyzeFile(path, detFileName); - if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { - result.error500("ftp下文件不存在"); - return result; - } - xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); - } FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); return result; } InputStream inputStream = null; + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; try { //切换被动模式 ftpClient.enterLocalPassiveMode(); @@ -1188,6 +1192,22 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 ftpClient.setControlEncoding("UTF-8"); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + if (Objects.nonNull(sampleId)) { + sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + //查询数据库中结果的Xe数据 + xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); + } else { + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); + gasTmp = phdFileUtil.analyzeFile(path, gasFileName); + detTmp = phdFileUtil.analyzeFile(path, detFileName); + if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { + result.error500("ftp下文件不存在"); + return result; + } + xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); + } if (StringUtils.isNotBlank(sampleFilePath)){ ftpClient.changeWorkingDirectory(sampleFilePath); inputStream = ftpClient.retrieveFileStream(sampleFileName); @@ -1248,6 +1268,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(inputStream)){ inputStream.close(); } + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -2442,114 +2471,42 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String samplePath = ""; String gasPath = ""; String detPath = ""; - //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 - if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ - if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); - } else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + try { + //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); + } else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + } + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); + samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ + result.error500("Data load From DB need to pass in sampleId and dbName"); + return result; + } else {//如果sampleId,dbNamed都为空 就指向ftp上传文件临时路径 + samplePath = path; + gasPath = path; + detPath = path; } - dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ - result.error500("Data load From DB need to pass in sampleId and dbName"); - return result; - } else {//如果sampleId,dbNamed都为空 就指向ftp上传文件临时路径 - samplePath = path; - gasPath = path; - detPath = path; - } - //根据文件路径 文件名称获取对应的临时文件 - File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); - File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); - File detTmp = phdFileUtil.analyzeFile(detPath, detFileName); - if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { - result.error500("ftp文件获取失败!"); - return result; - } - map.put("sampleFileName", sampleFileName); - BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); - if (Objects.nonNull(resultIn)) { - List xeDataList = getXeDataList(resultIn, sampleId, analysisID); - if (CollectionUtils.isNotEmpty(xeDataList)){ - for (GardsXeResultsSpectrum xeData:xeDataList) { - Double conc = xeData.getConc(); - Double mdc = xeData.getMdc(); - if (conc < 0){ - xeData.setColor("red"); - xeData.setNidFlag(0); - } else if (0 mdc) { - xeData.setColor("green"); - xeData.setNidFlag(1); - } - } - map.put("XeData", xeDataList); + //根据文件路径 文件名称获取对应的临时文件 + sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); + gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); + detTmp = phdFileUtil.analyzeFile(detPath, detFileName); + if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { + result.error500("ftp文件获取失败!"); + return result; } - map.put("savedAnalysisResult", true); - } - result.setSuccess(true); - result.setResult(map); - return result; - } - - @Override - public Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request) { - Result result = new Result(); - String userName = JwtUtil.getUserNameByToken(request); - List> mapList = new LinkedList<>(); - if (CollectionUtils.isNotEmpty(sampleFileNames)) { - for (int i=0; i map = new HashMap<>(); - //声明一个实体类获取数据库中文件路径 - SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); - Integer analysisID = null; - //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 - if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ - if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); - } else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN"; - analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); - } - dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId,analysisID); - } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ - result.error500("Data load From DB need to pass in sampleId and dbName"); - return result; - } - //拼接ftp上传临时文件路径 - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; - //判断数据库文件路径是否为空 如果为空 就指向ftp上传文件临时路径 - String samplePath = path; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ - samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - } - String gasPath = path; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { - gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - } - String detPath = path; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { - detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - } - //根据文件路径 文件名称获取对应的临时文件 - File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); - File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); - File detTmp = phdFileUtil.analyzeFile(detPath, detFileName); - map.put("sampleFileName", sampleFileName); - BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); + map.put("sampleFileName", sampleFileName); + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); + if (Objects.nonNull(resultIn)) { List xeDataList = getXeDataList(resultIn, sampleId, analysisID); if (CollectionUtils.isNotEmpty(xeDataList)){ for (GardsXeResultsSpectrum xeData:xeDataList) { @@ -2569,7 +2526,113 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { map.put("XeData", xeDataList); } map.put("savedAnalysisResult", true); - mapList.add(map); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); + } + } + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + List> mapList = new LinkedList<>(); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + try { + if (CollectionUtils.isNotEmpty(sampleFileNames)) { + for (int i=0; i map = new HashMap<>(); + //声明一个实体类获取数据库中文件路径 + SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + Integer analysisID = null; + //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); + } else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + } + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId,analysisID); + } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ + result.error500("Data load From DB need to pass in sampleId and dbName"); + return result; + } + //拼接ftp上传临时文件路径 + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; + //判断数据库文件路径是否为空 如果为空 就指向ftp上传文件临时路径 + String samplePath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ + samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + } + String gasPath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { + gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + } + String detPath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { + detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + } + //根据文件路径 文件名称获取对应的临时文件 + sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); + gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); + detTmp = phdFileUtil.analyzeFile(detPath, detFileName); + map.put("sampleFileName", sampleFileName); + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); + List xeDataList = getXeDataList(resultIn, sampleId, analysisID); + if (CollectionUtils.isNotEmpty(xeDataList)){ + for (GardsXeResultsSpectrum xeData:xeDataList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + xeData.setNidFlag(0); + } else if (0 mdc) { + xeData.setColor("green"); + xeData.setNidFlag(1); + } + } + map.put("XeData", xeDataList); + } + map.put("savedAnalysisResult", true); + mapList.add(map); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); } } result.setSuccess(true); @@ -2642,7 +2705,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) { String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); String qcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); - anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); + if (StringUtils.isNotBlank(qcFilePath)) { + anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); + } } } } else { @@ -2791,16 +2856,23 @@ 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 = null; + File gasTmp = null; + File detTmp = null; + try { + sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + 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); + } finally { + sampleTmp.delete(); + gasTmp.delete(); + detTmp.delete(); + } result.setSuccess(true); return result; } @@ -2836,7 +2908,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } - if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) { Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName()); Integer analysisID = null; @@ -2874,7 +2945,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { getChannelAndEnergy(anlyseResultIn, betaList, gammaList); //分析文件内容 analyzeSavePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi); - // 返回需要Save的数据 return anlyseResultIn; } @@ -2890,7 +2960,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { roiChannels = ObjectUtil.isNotNull(roiChannels) ? roiChannels : new LinkedList<>(); roiResults = ObjectUtil.isNotNull(roiResults) ? roiResults : new LinkedList<>(); xeResults = ObjectUtil.isNotNull(xeResults) ? xeResults : new LinkedList<>(); - // 转换ROIChannels数据 List roiChannelsDtosS = new LinkedList<>(); List roiChannelsDtosD = new LinkedList<>(); @@ -2932,7 +3001,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xeResultsDto.shift(); xeResultsDtos.add(xeResultsDto); } - result.put("gammaCalibrationSCE", anlyseResultIn.getGammaCalibrationSCE()); result.put("gammaCalibrationSEC", anlyseResultIn.getGammaCalibrationSEC()); result.put("gammaCalibrationGCE", anlyseResultIn.getGammaCalibrationGCE()); @@ -2961,10 +3029,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver(); resolver.setPrefix("excelTemplate/"); templateEngine.setTemplateResolver(resolver); - Context context = new Context(); context.setVariables(variables); - return templateEngine.process(SAVETOHTML.getName(), context); } @@ -3008,7 +3074,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) { // 解析文件,生成导出数据 Map analyze = exportData(anlyseResultIn); - // 将Null值替换为"",避免空指针异常(集合为空集合,不能为null) analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); String export = "SaveToExcel.xls"; @@ -3199,560 +3264,594 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } 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()); - File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); - System.loadLibrary("ReadPHDFile"); - //如果勾选了Energy Calibration页面下sample Data - if (Objects.nonNull(sampleTmp)) { - if(anlyseResultIn.isCheckSample()) { - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); - //没有点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮 channel/energy数据读取文件 如果点击过数据来源页面 - if (!anlyseResultIn.isBGammaEnergyValidSample()){ + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + try { + //获取ftp文件路径下临时文件 + sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + System.loadLibrary("ReadPHDFile"); + //如果勾选了Energy Calibration页面下sample Data + if (Objects.nonNull(sampleTmp)) { + if(anlyseResultIn.isCheckSample()) { + EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); + //没有点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮 channel/energy数据读取文件 如果点击过数据来源页面 + if (!anlyseResultIn.isBGammaEnergyValidSample()){ + 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.isBBetaEnergyValidSample()){ + 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()); 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.isBBetaEnergyValidSample()){ 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()); - anlyseResultIn.setG_channel_sample(sourceData.g_centroid_channel); - anlyseResultIn.setG_energy_sample(sourceData.g_energy); - anlyseResultIn.setB_channel_sample(sourceData.b_channel); - anlyseResultIn.setB_energy_sample(sourceData.b_electron_energy); } - } - if (Objects.nonNull(gasTmp)) { - if (anlyseResultIn.isCheckGas()) { - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath()); - if (!anlyseResultIn.isBGammaEnergyValidGas()){ + if (Objects.nonNull(gasTmp)) { + if (anlyseResultIn.isCheckGas()) { + EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath()); + if (!anlyseResultIn.isBGammaEnergyValidGas()){ + 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.isBBetaEnergyValidGas()){ + 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()); 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.isBBetaEnergyValidGas()){ 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()); - anlyseResultIn.setG_channel_gas(sourceData.g_centroid_channel); - anlyseResultIn.setG_energy_gas(sourceData.g_energy); - anlyseResultIn.setB_channel_gas(sourceData.b_channel); - anlyseResultIn.setB_energy_gas(sourceData.b_electron_energy); } - } - if (Objects.nonNull(detTmp)) { - if (anlyseResultIn.isCheckDet()) { - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath()); - if (!anlyseResultIn.isBGammaEnergyValidDet()){ + if (Objects.nonNull(detTmp)) { + if (anlyseResultIn.isCheckDet()) { + EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath()); + if (!anlyseResultIn.isBGammaEnergyValidDet()){ + 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.isBBetaEnergyValidDet()){ + 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()); 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.isBBetaEnergyValidDet()){ 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()); - anlyseResultIn.setG_channel_det(sourceData.g_centroid_channel); - anlyseResultIn.setG_energy_det(sourceData.g_energy); - anlyseResultIn.setB_channel_det(sourceData.b_channel); - anlyseResultIn.setB_energy_det(sourceData.b_electron_energy); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); } } } public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara,List betaFittingParaToUi, List gammaFittingParaToUi) { - //根据文件路径 文件名称获取对应的临时文件 - 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); - - if (anlyseResultIn.isBGammaEnergyValidSample()) { - GardsCalibrationSpectrum gammaCalibrationSCE = new GardsCalibrationSpectrum(); - gammaCalibrationSCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); - gammaCalibrationSCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); - gammaCalibrationSCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); - GardsCalibrationSpectrum gammaCalibrationSEC = new GardsCalibrationSpectrum(); - gammaCalibrationSEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); - gammaCalibrationSEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); - gammaCalibrationSEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); - anlyseResultIn.setGammaCalibrationSCE(gammaCalibrationSCE); - anlyseResultIn.setGammaCalibrationSEC(gammaCalibrationSEC); - } else { - GardsCalibrationSpectrum gammaCalibrationSCE = new GardsCalibrationSpectrum(); - gammaCalibrationSCE.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0)); - gammaCalibrationSCE.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1)); - gammaCalibrationSCE.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2)); - GardsCalibrationSpectrum gammaCalibrationSEC = new GardsCalibrationSpectrum(); - gammaCalibrationSEC.setCoeff1(bgAnalyseResult.s_g_fitting_e_c.get(0)); - gammaCalibrationSEC.setCoeff2(bgAnalyseResult.s_g_fitting_e_c.get(1)); - gammaCalibrationSEC.setCoeff3(bgAnalyseResult.s_g_fitting_e_c.get(2)); - anlyseResultIn.setGammaCalibrationSCE(gammaCalibrationSCE); - anlyseResultIn.setGammaCalibrationSEC(gammaCalibrationSEC); - } - if (anlyseResultIn.isBGammaEnergyValidGas()) { - GardsCalibrationSpectrum gammaCalibrationGCE = new GardsCalibrationSpectrum(); - gammaCalibrationGCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); - gammaCalibrationGCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); - gammaCalibrationGCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); - GardsCalibrationSpectrum gammaCalibrationGEC = new GardsCalibrationSpectrum(); - gammaCalibrationGEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); - gammaCalibrationGEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); - gammaCalibrationGEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); - anlyseResultIn.setGammaCalibrationGCE(gammaCalibrationGCE); - anlyseResultIn.setGammaCalibrationGEC(gammaCalibrationGEC); - } else { - GardsCalibrationSpectrum gammaCalibrationGCE = new GardsCalibrationSpectrum(); - gammaCalibrationGCE.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0)); - gammaCalibrationGCE.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1)); - gammaCalibrationGCE.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2)); - GardsCalibrationSpectrum gammaCalibrationGEC = new GardsCalibrationSpectrum(); - gammaCalibrationGEC.setCoeff1(bgAnalyseResult.g_g_fitting_e_c.get(0)); - gammaCalibrationGEC.setCoeff2(bgAnalyseResult.g_g_fitting_e_c.get(1)); - gammaCalibrationGEC.setCoeff3(bgAnalyseResult.g_g_fitting_e_c.get(2)); - anlyseResultIn.setGammaCalibrationGCE(gammaCalibrationGCE); - anlyseResultIn.setGammaCalibrationGEC(gammaCalibrationGEC); - } - if (anlyseResultIn.isBGammaEnergyValidDet()) { - GardsCalibrationSpectrum gammaCalibrationDCE = new GardsCalibrationSpectrum(); - gammaCalibrationDCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); - gammaCalibrationDCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); - gammaCalibrationDCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); - GardsCalibrationSpectrum gammaCalibrationDEC = new GardsCalibrationSpectrum(); - gammaCalibrationDEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); - gammaCalibrationDEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); - gammaCalibrationDEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); - anlyseResultIn.setGammaCalibrationDCE(gammaCalibrationDCE); - anlyseResultIn.setGammaCalibrationDEC(gammaCalibrationDEC); - } else { - GardsCalibrationSpectrum gammaCalibrationDCE = new GardsCalibrationSpectrum(); - gammaCalibrationDCE.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0)); - gammaCalibrationDCE.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1)); - gammaCalibrationDCE.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2)); - GardsCalibrationSpectrum gammaCalibrationDEC = new GardsCalibrationSpectrum(); - gammaCalibrationDEC.setCoeff1(bgAnalyseResult.d_g_fitting_e_c.get(0)); - gammaCalibrationDEC.setCoeff2(bgAnalyseResult.d_g_fitting_e_c.get(1)); - gammaCalibrationDEC.setCoeff3(bgAnalyseResult.d_g_fitting_e_c.get(2)); - anlyseResultIn.setGammaCalibrationDCE(gammaCalibrationDCE); - anlyseResultIn.setGammaCalibrationDEC(gammaCalibrationDEC); - } - - if (anlyseResultIn.isBBetaEnergyValidSample()) { - GardsCalibrationSpectrum betaCalibrationSCE = new GardsCalibrationSpectrum(); - betaCalibrationSCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); - betaCalibrationSCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); - betaCalibrationSCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); - GardsCalibrationSpectrum betaCalibrationSEC = new GardsCalibrationSpectrum(); - betaCalibrationSEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); - betaCalibrationSEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); - betaCalibrationSEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); - anlyseResultIn.setBetaCalibrationSCE(betaCalibrationSCE); - anlyseResultIn.setBetaCalibrationSEC(betaCalibrationSEC); - } else { - GardsCalibrationSpectrum betaCalibrationSCE = new GardsCalibrationSpectrum(); - betaCalibrationSCE.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); - betaCalibrationSCE.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); - betaCalibrationSCE.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); - GardsCalibrationSpectrum betaCalibrationSEC = new GardsCalibrationSpectrum(); - betaCalibrationSEC.setCoeff1(bgAnalyseResult.s_b_fitting_e_c.get(0)); - betaCalibrationSEC.setCoeff2(bgAnalyseResult.s_b_fitting_e_c.get(1)); - betaCalibrationSEC.setCoeff3(bgAnalyseResult.s_b_fitting_e_c.get(2)); - anlyseResultIn.setBetaCalibrationSCE(betaCalibrationSCE); - anlyseResultIn.setBetaCalibrationSEC(betaCalibrationSEC); - } - if (anlyseResultIn.isBBetaEnergyValidGas()) { - GardsCalibrationSpectrum betaCalibrationGCE = new GardsCalibrationSpectrum(); - betaCalibrationGCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); - betaCalibrationGCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); - betaCalibrationGCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); - GardsCalibrationSpectrum betaCalibrationGEC = new GardsCalibrationSpectrum(); - betaCalibrationGEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); - betaCalibrationGEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); - betaCalibrationGEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); - anlyseResultIn.setBetaCalibrationGCE(betaCalibrationGCE); - anlyseResultIn.setBetaCalibrationGEC(betaCalibrationGEC); - } else { - GardsCalibrationSpectrum betaCalibrationGCE = new GardsCalibrationSpectrum(); - betaCalibrationGCE.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); - betaCalibrationGCE.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); - betaCalibrationGCE.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); - GardsCalibrationSpectrum betaCalibrationGEC = new GardsCalibrationSpectrum(); - betaCalibrationGEC.setCoeff1(bgAnalyseResult.g_b_fitting_e_c.get(0)); - betaCalibrationGEC.setCoeff2(bgAnalyseResult.g_b_fitting_e_c.get(1)); - betaCalibrationGEC.setCoeff3(bgAnalyseResult.g_b_fitting_e_c.get(2)); - anlyseResultIn.setBetaCalibrationGCE(betaCalibrationGCE); - anlyseResultIn.setBetaCalibrationGEC(betaCalibrationGEC); - } - if (anlyseResultIn.isBBetaEnergyValidDet()) { - GardsCalibrationSpectrum betaCalibrationDCE = new GardsCalibrationSpectrum(); - betaCalibrationDCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); - betaCalibrationDCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); - betaCalibrationDCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); - GardsCalibrationSpectrum betaCalibrationDEC = new GardsCalibrationSpectrum(); - betaCalibrationDEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); - betaCalibrationDEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); - betaCalibrationDEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); - anlyseResultIn.setBetaCalibrationDCE(betaCalibrationDCE); - anlyseResultIn.setBetaCalibrationDEC(betaCalibrationDEC); - } else { - GardsCalibrationSpectrum betaCalibrationDCE = new GardsCalibrationSpectrum(); - betaCalibrationDCE.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); - betaCalibrationDCE.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); - betaCalibrationDCE.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); - GardsCalibrationSpectrum betaCalibrationDEC = new GardsCalibrationSpectrum(); - betaCalibrationDEC.setCoeff1(bgAnalyseResult.d_b_fitting_e_c.get(0)); - betaCalibrationDEC.setCoeff2(bgAnalyseResult.d_b_fitting_e_c.get(1)); - betaCalibrationDEC.setCoeff3(bgAnalyseResult.d_b_fitting_e_c.get(2)); - anlyseResultIn.setBetaCalibrationDCE(betaCalibrationDCE); - anlyseResultIn.setBetaCalibrationDEC(betaCalibrationDEC); - } - - List roiChannelsSpectrumList = new LinkedList<>(); - for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); - for (int i=0; ibgAnalyseResult.MDC.get(i)) { - roiResults.setNidFlag(1); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + try { + //根据文件路径 文件名称获取对应的临时文件 + sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + 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 { - roiResults.setNidFlag(0); + 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); + if (anlyseResultIn.isBGammaEnergyValidSample()) { + GardsCalibrationSpectrum gammaCalibrationSCE = new GardsCalibrationSpectrum(); + gammaCalibrationSCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationSCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationSCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + GardsCalibrationSpectrum gammaCalibrationSEC = new GardsCalibrationSpectrum(); + gammaCalibrationSEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); + gammaCalibrationSEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); + gammaCalibrationSEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); + anlyseResultIn.setGammaCalibrationSCE(gammaCalibrationSCE); + anlyseResultIn.setGammaCalibrationSEC(gammaCalibrationSEC); + } else { + GardsCalibrationSpectrum gammaCalibrationSCE = new GardsCalibrationSpectrum(); + gammaCalibrationSCE.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0)); + gammaCalibrationSCE.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1)); + gammaCalibrationSCE.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2)); + GardsCalibrationSpectrum gammaCalibrationSEC = new GardsCalibrationSpectrum(); + gammaCalibrationSEC.setCoeff1(bgAnalyseResult.s_g_fitting_e_c.get(0)); + gammaCalibrationSEC.setCoeff2(bgAnalyseResult.s_g_fitting_e_c.get(1)); + gammaCalibrationSEC.setCoeff3(bgAnalyseResult.s_g_fitting_e_c.get(2)); + anlyseResultIn.setGammaCalibrationSCE(gammaCalibrationSCE); + anlyseResultIn.setGammaCalibrationSEC(gammaCalibrationSEC); + } + if (anlyseResultIn.isBGammaEnergyValidGas()) { + GardsCalibrationSpectrum gammaCalibrationGCE = new GardsCalibrationSpectrum(); + gammaCalibrationGCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationGCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationGCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + GardsCalibrationSpectrum gammaCalibrationGEC = new GardsCalibrationSpectrum(); + gammaCalibrationGEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); + gammaCalibrationGEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); + gammaCalibrationGEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); + anlyseResultIn.setGammaCalibrationGCE(gammaCalibrationGCE); + anlyseResultIn.setGammaCalibrationGEC(gammaCalibrationGEC); + } else { + GardsCalibrationSpectrum gammaCalibrationGCE = new GardsCalibrationSpectrum(); + gammaCalibrationGCE.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0)); + gammaCalibrationGCE.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1)); + gammaCalibrationGCE.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2)); + GardsCalibrationSpectrum gammaCalibrationGEC = new GardsCalibrationSpectrum(); + gammaCalibrationGEC.setCoeff1(bgAnalyseResult.g_g_fitting_e_c.get(0)); + gammaCalibrationGEC.setCoeff2(bgAnalyseResult.g_g_fitting_e_c.get(1)); + gammaCalibrationGEC.setCoeff3(bgAnalyseResult.g_g_fitting_e_c.get(2)); + anlyseResultIn.setGammaCalibrationGCE(gammaCalibrationGCE); + anlyseResultIn.setGammaCalibrationGEC(gammaCalibrationGEC); + } + if (anlyseResultIn.isBGammaEnergyValidDet()) { + GardsCalibrationSpectrum gammaCalibrationDCE = new GardsCalibrationSpectrum(); + gammaCalibrationDCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0))); + gammaCalibrationDCE.setCoeff2(Double.valueOf(gammaFittingPara.get(1))); + gammaCalibrationDCE.setCoeff3(Double.valueOf(gammaFittingPara.get(2))); + GardsCalibrationSpectrum gammaCalibrationDEC = new GardsCalibrationSpectrum(); + gammaCalibrationDEC.setCoeff1(Double.valueOf(gammaFittingParaToUi.get(0))); + gammaCalibrationDEC.setCoeff2(Double.valueOf(gammaFittingParaToUi.get(1))); + gammaCalibrationDEC.setCoeff3(Double.valueOf(gammaFittingParaToUi.get(2))); + anlyseResultIn.setGammaCalibrationDCE(gammaCalibrationDCE); + anlyseResultIn.setGammaCalibrationDEC(gammaCalibrationDEC); + } else { + GardsCalibrationSpectrum gammaCalibrationDCE = new GardsCalibrationSpectrum(); + gammaCalibrationDCE.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0)); + gammaCalibrationDCE.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1)); + gammaCalibrationDCE.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2)); + GardsCalibrationSpectrum gammaCalibrationDEC = new GardsCalibrationSpectrum(); + gammaCalibrationDEC.setCoeff1(bgAnalyseResult.d_g_fitting_e_c.get(0)); + gammaCalibrationDEC.setCoeff2(bgAnalyseResult.d_g_fitting_e_c.get(1)); + gammaCalibrationDEC.setCoeff3(bgAnalyseResult.d_g_fitting_e_c.get(2)); + anlyseResultIn.setGammaCalibrationDCE(gammaCalibrationDCE); + anlyseResultIn.setGammaCalibrationDEC(gammaCalibrationDEC); + } + if (anlyseResultIn.isBBetaEnergyValidSample()) { + GardsCalibrationSpectrum betaCalibrationSCE = new GardsCalibrationSpectrum(); + betaCalibrationSCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationSCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationSCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + GardsCalibrationSpectrum betaCalibrationSEC = new GardsCalibrationSpectrum(); + betaCalibrationSEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); + betaCalibrationSEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); + betaCalibrationSEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); + anlyseResultIn.setBetaCalibrationSCE(betaCalibrationSCE); + anlyseResultIn.setBetaCalibrationSEC(betaCalibrationSEC); + } else { + GardsCalibrationSpectrum betaCalibrationSCE = new GardsCalibrationSpectrum(); + betaCalibrationSCE.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); + betaCalibrationSCE.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); + betaCalibrationSCE.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); + GardsCalibrationSpectrum betaCalibrationSEC = new GardsCalibrationSpectrum(); + betaCalibrationSEC.setCoeff1(bgAnalyseResult.s_b_fitting_e_c.get(0)); + betaCalibrationSEC.setCoeff2(bgAnalyseResult.s_b_fitting_e_c.get(1)); + betaCalibrationSEC.setCoeff3(bgAnalyseResult.s_b_fitting_e_c.get(2)); + anlyseResultIn.setBetaCalibrationSCE(betaCalibrationSCE); + anlyseResultIn.setBetaCalibrationSEC(betaCalibrationSEC); + } + if (anlyseResultIn.isBBetaEnergyValidGas()) { + GardsCalibrationSpectrum betaCalibrationGCE = new GardsCalibrationSpectrum(); + betaCalibrationGCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationGCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationGCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + GardsCalibrationSpectrum betaCalibrationGEC = new GardsCalibrationSpectrum(); + betaCalibrationGEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); + betaCalibrationGEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); + betaCalibrationGEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); + anlyseResultIn.setBetaCalibrationGCE(betaCalibrationGCE); + anlyseResultIn.setBetaCalibrationGEC(betaCalibrationGEC); + } else { + GardsCalibrationSpectrum betaCalibrationGCE = new GardsCalibrationSpectrum(); + betaCalibrationGCE.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); + betaCalibrationGCE.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); + betaCalibrationGCE.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); + GardsCalibrationSpectrum betaCalibrationGEC = new GardsCalibrationSpectrum(); + betaCalibrationGEC.setCoeff1(bgAnalyseResult.g_b_fitting_e_c.get(0)); + betaCalibrationGEC.setCoeff2(bgAnalyseResult.g_b_fitting_e_c.get(1)); + betaCalibrationGEC.setCoeff3(bgAnalyseResult.g_b_fitting_e_c.get(2)); + anlyseResultIn.setBetaCalibrationGCE(betaCalibrationGCE); + anlyseResultIn.setBetaCalibrationGEC(betaCalibrationGEC); + } + if (anlyseResultIn.isBBetaEnergyValidDet()) { + GardsCalibrationSpectrum betaCalibrationDCE = new GardsCalibrationSpectrum(); + betaCalibrationDCE.setCoeff1(Double.valueOf(betaFittingPara.get(0))); + betaCalibrationDCE.setCoeff2(Double.valueOf(betaFittingPara.get(1))); + betaCalibrationDCE.setCoeff3(Double.valueOf(betaFittingPara.get(2))); + GardsCalibrationSpectrum betaCalibrationDEC = new GardsCalibrationSpectrum(); + betaCalibrationDEC.setCoeff1(Double.valueOf(betaFittingParaToUi.get(0))); + betaCalibrationDEC.setCoeff2(Double.valueOf(betaFittingParaToUi.get(1))); + betaCalibrationDEC.setCoeff3(Double.valueOf(betaFittingParaToUi.get(2))); + anlyseResultIn.setBetaCalibrationDCE(betaCalibrationDCE); + anlyseResultIn.setBetaCalibrationDEC(betaCalibrationDEC); + } else { + GardsCalibrationSpectrum betaCalibrationDCE = new GardsCalibrationSpectrum(); + betaCalibrationDCE.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); + betaCalibrationDCE.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); + betaCalibrationDCE.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); + GardsCalibrationSpectrum betaCalibrationDEC = new GardsCalibrationSpectrum(); + betaCalibrationDEC.setCoeff1(bgAnalyseResult.d_b_fitting_e_c.get(0)); + betaCalibrationDEC.setCoeff2(bgAnalyseResult.d_b_fitting_e_c.get(1)); + betaCalibrationDEC.setCoeff3(bgAnalyseResult.d_b_fitting_e_c.get(2)); + anlyseResultIn.setBetaCalibrationDCE(betaCalibrationDCE); + anlyseResultIn.setBetaCalibrationDEC(betaCalibrationDEC); + } + 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); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (Objects.nonNull(sampleTmp)) { + sampleTmp.delete(); + } + if (Objects.nonNull(gasTmp)) { + gasTmp.delete(); + } + if (Objects.nonNull(detTmp)) { + detTmp.delete(); } - roiResultsSpectrumList.add(roiResults); } - anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList); } public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn,List betaFittingPara, List gammaFittingPara) { - //根据文件路径 文件名称获取对应的临时文件 - 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.isBGammaEnergyValidSample()) { - 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); - } 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); - } - if (anlyseResultIn.isBGammaEnergyValidGas()) { - 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); - } else { - 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); - } - if (anlyseResultIn.isBGammaEnergyValidDet()) { - 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); - } else { - 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.isBBetaEnergyValidSample()) { - 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); - } 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); - } - if (anlyseResultIn.isBBetaEnergyValidGas()) { - 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); - } else { - 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); - } - if (anlyseResultIn.isBBetaEnergyValidDet()) { - 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 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); + try { + //根据文件路径 文件名称获取对应的临时文件 + 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 { - roiResults.setNidFlag(0); + bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); } - roiResultsSpectrumList.add(roiResults); + 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.isBGammaEnergyValidSample()) { + 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); + } 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); + } + if (anlyseResultIn.isBGammaEnergyValidGas()) { + 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); + } else { + 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); + } + if (anlyseResultIn.isBGammaEnergyValidDet()) { + 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); + } else { + 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.isBBetaEnergyValidSample()) { + 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); + } 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); + } + if (anlyseResultIn.isBBetaEnergyValidGas()) { + 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); + } else { + 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); + } + if (anlyseResultIn.isBBetaEnergyValidDet()) { + 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 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); + } catch (Exception e) { + e.printStackTrace(); + } finally { + } - 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++){