diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java index 2f3cf40c..7c6cec83 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java @@ -78,10 +78,10 @@ public class EmailServiceManager { boolean flag = false; try { socket.connect(new InetSocketAddress(email.getEmailServerAddress(),email.getPort()),5000); - log.info("{}邮件服务连接测试成功",email.getEmailServerAddress()); + log.info("{}邮件服务连接测试成功",email.getName()); flag = true; } catch (IOException e) { - log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因{}",email.getEmailServerAddress(),e.getMessage()); + log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因{}",email.getName(),e.getMessage()); }finally { try { if(null != socket){ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java index f879f7e0..d18418b8 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -19,7 +19,7 @@ public class GammaReportUtil { // 获取系统的临时目录 String tempDir = System.getProperty("java.io.tmpdir"); // 创建文件 - File file = new File(tempDir += System.currentTimeMillis()); + File file = new File(tempDir + System.currentTimeMillis()); // 创建PrintWriter对象 PrintWriter out = null; try { @@ -54,6 +54,7 @@ public class GammaReportUtil { if (null != out) { out.close(); } + file.delete(); } } public static void writeFile(List data, String fileType, String path){ @@ -79,6 +80,7 @@ public class GammaReportUtil { if (null != out) { out.close(); } + file.delete(); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java index 2b51fa6b..27e04bbe 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyLogFormatUtil.java @@ -127,7 +127,7 @@ public class MyLogFormatUtil { List channels = Arrays.asList("59.541", "88.034", "122.061", "165.857", "391.698", "661.657", "834.838", "898.036", "1115.540", "1173.230", "1332.490", "1836.050"); List energies = Arrays.asList("0.168", "0.176", "0.174", "0.155", "0.092", "0.059", "0.051", "0.040", "0.040", "0.031", "0.028", "0.022"); - List errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001", "0.000"); + List errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001"); List energys = new ArrayList<>(); AttributeItemVo attributeItemVo = new AttributeItemVo(); @@ -142,7 +142,7 @@ public class MyLogFormatUtil { attributeItemVo.setAttribute("Error"); attributeItemVo.setContext(errors); energys.add(attributeItemVo); -// MyLogFormatUtil.getBlock(MyLogFormatUtil.SetSampleGEnergyChannel, "sampleId", energys); + MyLogFormatUtil.getBlock(MyLogFormatUtil.SetSampleGEnergyChannel, "sampleId", energys); Console.log(getTitleFormat("Read calibration finished",".")); @@ -294,25 +294,21 @@ public class MyLogFormatUtil { return result; } // 计算每列数据中最长的字符串长度 + StringBuilder sb = new StringBuilder(); int[] columnWidths = new int[data.get(0).size()]; for (List row : data) { for (int i = 0; i < row.size(); i++) { + // 获取长度 columnWidths[i] = Math.max(columnWidths[i], row.get(i).length()); + // 构造格式化字符串 + sb.append("%-").append(columnWidths[i] + 4).append("s"); } + // 构造格式化字符串 + result.add(String.format(sb.toString(), row.toArray())); + result.add(STRING_END); + Console.log(String.format(sb.toString(), row.toArray())); + sb = new StringBuilder(); } - - // 构造格式化字符串 - StringBuilder formatBuilder = new StringBuilder(); - for (int i = 0; i < columnWidths.length; i++) { - formatBuilder.append("%-").append(columnWidths[i] + 4).append("s"); - } - String format = formatBuilder.toString(); - // 格式化输出日志 - for (List row : data) { - result.add(String.format(format, row.toArray())); - Console.log(String.format(format, row.toArray())); - } - result.add(STRING_END); return result; } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java index d56d59d1..232c92fe 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_B_Analysis.java @@ -214,8 +214,8 @@ public class Sample_B_Analysis implements BlockConstant { this.arrFilePath = ftpPath.toString(); String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX; this.arrFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail); - //构造日志文件路径 - this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.ftpSavePath; + //构造日志文件路径,不包括log前缀 + this.logFilePath = this.ftpSavePath; this.logFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX); } @@ -223,10 +223,6 @@ public class Sample_B_Analysis implements BlockConstant { * 调用dll库的分析B谱结果 */ private void autoAnalyse() throws BAnalyseException, FileNotExistException { - System.out.println("sam:"+this.sampleTempFilePath); - System.out.println("gas:"+this.gasTempFilePath); - System.out.println("det:"+this.detTempFilePath); - BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath); System.out.println(analyseResult); if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index 8616658e..cd2d4251 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -32,6 +32,9 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecgframework.core.util.ApplicationContextUtil; import org.springframework.transaction.TransactionStatus; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.lang.reflect.Field; import java.util.*; @@ -122,7 +125,7 @@ public class Sample_G_Analysis { String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result()); - // 获取数据库 Gamma 默认参数 + // todo 测试阶段暂时注释掉,获取数据库 Gamma 默认参数 // getSettingFromDB(phdFile); // 文件路径 middleData.setAnalyses_save_filePath(this.sampleInputFilename); @@ -142,7 +145,7 @@ public class Sample_G_Analysis { this.storageDataToDatabase(middleData, phdFile.getQcItems()); // 生成日志文件 -// writeLog(middleData.getAnalyses_LogPath(), middleData); + writeLog(middleData.getAnalyses_LogPath(), middleData); // todo 报告文件 }catch (Exception e){ e.printStackTrace(); @@ -199,6 +202,7 @@ public class Sample_G_Analysis { * @param middleData */ private void writeLog(String logFilePath, GStoreMiddleProcessData middleData) { + logFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + logFilePath; String sampleId = middleData.getSample_id(); MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil(); List writes = new LinkedList<>(); @@ -458,7 +462,21 @@ public class Sample_G_Analysis { String analyseEnd = MyLogFormatUtil.analyseResultsEnd.replace("%1", "date"); writes.add(MyLogFormatUtil.getTitleFormat(analyseEnd)); - FileUtil.writeLines(writes, logFilePath, "utf8"); + // 保存文件 + // 获取系统的临时目录 + String tempDir = System.getProperty("java.io.tmpdir"); + // 创建文件 + File file = FileUtil.writeLines(writes, tempDir + System.currentTimeMillis(), "utf8"); + String targetPath = StringUtils.substringBeforeLast(logFilePath, StringPool.SLASH); + String targetName = StringUtils.substringAfterLast(logFilePath, StringPool.SLASH); + try { + ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } finally { + // 删除临时文件 + if(null != file) file.delete(); + } } public void saveAnalysis(GStoreMiddleProcessData middleData,Integer sampleId){ @@ -589,8 +607,7 @@ public class Sample_G_Analysis { calibration.setFunctionDef(efFunctionDef); calibration.setStartOfRange((int)efStartOfRange); calibration.setEndOfRange((int)efEndOfRange); - // todo 暂时固定 - calibration.setCoeffString("1,2,3"); + calibration.setCoeffString(efCoeffString); calibration.setModdate(new Date()); calibrations.add(calibration); } 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++){ diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java index 9c38dc05..4f477f36 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java @@ -60,11 +60,8 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im public void run(String... args) throws Exception { //调用dll System.loadLibrary("ReadPHDFile"); - //根据配置文件配置邮件获取策略定义时间条件 - Date systemStartupTime = null; - if(EmailReceivePolicy.HISTORY_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){ - systemStartupTime = DateUtils.parseDate("1970-01-01 00:00:00","yyyy-MM-dd HH:mm:ss"); - } + //根据配置文件配置邮件获取策略定义时间条件,默认EmailReceivePolicy.HISTORY_ORDER_RECEIVE.getPolicy() + Date systemStartupTime = DateUtils.parseDate("1970-01-01 00:00:00","yyyy-MM-dd HH:mm:ss"); if(EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){ systemStartupTime = new Date(); }