diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java index f1aebd6e..0343ce2c 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java @@ -50,34 +50,39 @@ public class NumberFormatUtil { //总数字个数是6位的数 public static String numberSixLen(String number) { - Double preNum = null; - String suffixNum = ""; - //判断传进来的数据是否是科学计数法的数据 - if (number.indexOf("e") > 0) { - String calNumber = number.substring(0, number.indexOf("e")); - if (calNumber.length() < 6) { + String value = ""; + if (number.equalsIgnoreCase("nan")) { + value = number; + } else { + Double preNum = null; + String suffixNum = ""; + //判断传进来的数据是否是科学计数法的数据 + if (number.indexOf("e") > 0) { + String calNumber = number.substring(0, number.indexOf("e")); + if (calNumber.length() < 6) { + preNum = Double.valueOf(number); + } else { + preNum = Double.valueOf(calNumber); + suffixNum = number.substring(number.indexOf("e")); + } + } else if (number.indexOf("E") > 0) { + String calNumber = number.substring(0, number.indexOf("E")); + if (calNumber.length() < 6) { + preNum = Double.valueOf(number); + } else { + preNum = Double.valueOf(calNumber); + suffixNum = number.substring(number.indexOf("E")); + } + } else { preNum = Double.valueOf(number); - } else { - preNum = Double.valueOf(calNumber); - suffixNum = number.substring(number.indexOf("e")); } - } else if (number.indexOf("E") > 0) { - String calNumber = number.substring(0, number.indexOf("E")); - if (calNumber.length() < 6) { - preNum = Double.valueOf(number); - } else { - preNum = Double.valueOf(calNumber); - suffixNum = number.substring(number.indexOf("E")); + double absNum = Math.abs(preNum); + //获取长度 + int length = String.valueOf(absNum).substring(0, String.valueOf(absNum).indexOf(StringPool.DOT)).length(); + value = String.format("%." + (6 - length) + "f", preNum); + if (StringUtils.isNotBlank(suffixNum)) { + value = value + suffixNum; } - } else { - preNum = Double.valueOf(number); - } - double absNum = Math.abs(preNum); - //获取长度 - int length = String.valueOf(absNum).substring(0, String.valueOf(absNum).indexOf(StringPool.DOT)).length(); - String value = String.format("%." + (6 - length) + "f", preNum); - if (StringUtils.isNotBlank(suffixNum)) { - value = value + suffixNum; } return value; } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java index 0739895b..33d25597 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java @@ -4,10 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; import java.io.Serializable; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; @Data @JsonIgnoreProperties(ignoreUnknown = true) @@ -17,6 +14,8 @@ public class PHDFile implements Serializable { private String xmlFilePath; + private String tmpFilePath; + private boolean isValid; // 是否有效谱 private boolean bAnalyed; // 记录是否被分析 @@ -215,8 +214,8 @@ public class PHDFile implements Serializable { calibration = new CalibrationBlock(); sampleBlock = new SampleBlock(); certificate = new CertificateBlock(); - QcItems = new HashMap<>(); - mapNucActMda = new HashMap<>(); + QcItems = new TreeMap<>(); + mapNucActMda = new TreeMap<>(); } } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index bdad11e2..2371dc12 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -65,6 +65,7 @@ public class GammaFileUtil extends AbstractLogOrReport { phd.setFilename(fileName); String fromPath = pathName + StringPool.SLASH + fileName; File file = ftpUtil.downloadFile(fromPath, "betaGamma"); + phd.setTmpFilePath(file.getAbsolutePath()); if (Objects.isNull(file)) { result.error500("ftp file can't find"); return false; @@ -235,9 +236,6 @@ public class GammaFileUtil extends AbstractLogOrReport { }catch (ParseException e) { throw new RuntimeException(e); - } finally { - if (Objects.nonNull(file)) - file.delete(); } return true; } @@ -274,9 +272,7 @@ public class GammaFileUtil extends AbstractLogOrReport { String baselineFileName = prefixName+"_"+subFileName + ".baseline"; String fromPathBase = pathName + StringPool.SLASH + baselineFileName; - File file = ftpUtil.downloadFile(fromPathBase, "betaGamma"); - inputStreamBase = new FileInputStream(file); -// inputStreamBase = ftpUtil.downloadFileStream(fromPathBase); + inputStreamBase = ftpUtil.downloadFileStream(fromPathBase); // 调用处理BaseCtrl的方法 ReadBaseCtrlInfo(phd, inputStreamBase); // 将phdFile的BaseCtrls的BaseLine部分数据 赋值给 phdFile的vBase @@ -504,15 +500,15 @@ public class GammaFileUtil extends AbstractLogOrReport { //计算得到衰减耗时 double Decay_hour = (acq.getTime()/1000 - end.getTime()/1000) / 3600.0; //声明一个double数据 - Double ener_Be7 = 0.0; + List Be7Value = new LinkedList<>(); //声明一个map用于存储计算数据 Map vMdcInfoMap = new HashMap<>(); //声明一个数组存储计算数据 List vMdcInfo = new LinkedList<>(); //声明一个数组存储QcItems数据 - Map qcItems = new LinkedHashMap<>(); + Map qcItems = new TreeMap<>(); //调用方法 读取文件信息 判断QC数据 - if(!ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { + if(!ReadQCLimit(qcItems, vMdcInfoMap, Be7Value, phd.getHeader().getSystem_type().toUpperCase())) { String WARNING = "Read QC Flags from SystemManager.xml Failed!"; } //判断map是否为空 @@ -555,12 +551,8 @@ public class GammaFileUtil extends AbstractLogOrReport { if(phd.isValid() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { //判断system_type是否匹配P if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - //声明一个energy集合 - List energy = new LinkedList<>(); - //集合增加数据 - energy.add(ener_Be7); //调用算法计算 - CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); + CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(Be7Value, phd.getUsedResoPara().getP()); //获取计算结果的counts赋值给 fwhm集合 List fwhm = calValuesOut.counts; //获取QcItems中Be7-FWHM数据 @@ -646,22 +638,24 @@ public class GammaFileUtil extends AbstractLogOrReport { //获取能谱获取时间 Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); //计算采样时间 - double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000); + double Ts = (collectStop.getTime()/1000 - collectStart.getTime()/1000); //计算衰变时间 - double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); + double Td = (acqStart.getTime()/1000 - collectStop.getTime()/1000); //获取能谱获取实时间 double Ta = phd.getAcq().getAcquisition_real_time(); //获取能谱获取活时间 double Tl = phd.getAcq().getAcquisition_live_time(); //获取样品采样体积 double Svol = phd.getCollect().getAir_volume(); - double DCF1, DCF2, DCF3; + double DCF1 = 0; + double DCF2 = 0; + double DCF3 = 0; //计算得到lamda计算值 double lambda = Math.log(2.0) / (vMdcInfo.get(2) * 86400); if ( Ts == 0 ) { DCF1 = 1; } else { - DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts)); + DCF1 = lambda * Ts / (1-Math.exp(-lambda * Ts)); } if ( Td == 0 ) { DCF2 = 1; @@ -674,7 +668,7 @@ public class GammaFileUtil extends AbstractLogOrReport { DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta)); } //计算得到DCF_conc - double DCF_conc = Math.exp(lambda * (phd.getUsedSetting().getRefTime_conc().getTime()/1000 - collectStart.getTime()/1000)); + double DCF_conc = Math.exp(lambda * (collectStart.getTime()/1000 - phd.getUsedSetting().getRefTime_conc().getTime()/1000)); //声明一个集合 List energy = new LinkedList<>(); energy.add(vMdcInfo.get(0)); @@ -705,7 +699,7 @@ public class GammaFileUtil extends AbstractLogOrReport { for(int i=1; i= vMdcInfo.get(0)) { index = i; - if(phd.getVEnergy().get(i) - vMdcInfo.get(0) > vMdcInfo.get(0) - phd.getVEnergy().get(i-1)){ + if( (phd.getVEnergy().get(i) - vMdcInfo.get(0)) > (vMdcInfo.get(0) - phd.getVEnergy().get(i-1)) ){ index = i-1; } break; @@ -720,7 +714,7 @@ public class GammaFileUtil extends AbstractLogOrReport { } } - public boolean ReadQCLimit(Map qcItems, Map vMdcInfoMap, Double ener_Be7, String systemType) { + public boolean ReadQCLimit(Map qcItems, Map vMdcInfoMap, List Be7Value, String systemType) { try { String filePath = parameterProperties.getFilePath()+ File.separator +"SystemManager.xml"; //创建一个文档解析器工厂 @@ -778,7 +772,7 @@ public class GammaFileUtil extends AbstractLogOrReport { Node item = attributes.item(j); //判断属性名称是否是 number if(item.getNodeName().equals(CalType.ENERGY_CAL.getType())) { - ener_Be7 = Double.valueOf(item.getNodeValue()); + Be7Value.add(Double.valueOf(item.getNodeValue())); } } } @@ -1264,8 +1258,6 @@ public class GammaFileUtil extends AbstractLogOrReport { } public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ - //解析获取临时文件信息 - File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename()); ObjectMapper mapper = new ObjectMapper(); try { String phdStr = mapper.writeValueAsString(phd); @@ -1273,7 +1265,7 @@ public class GammaFileUtil extends AbstractLogOrReport { if (ObjectUtil.isNull(analysisProcess)){ analysisProcess = ApplicationContextUtil.getContext().getBean(AnalysisProcess.class); } - String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath(), analysisProcess); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, phd.getTmpFilePath(), analysisProcess); Map parseMap = JSON.parseObject(strValue, Map.class); for (Map.Entry entry:parseMap.entrySet()) { if (entry.getKey().equalsIgnoreCase("bAnalyed")) { @@ -1441,8 +1433,8 @@ public class GammaFileUtil extends AbstractLogOrReport { phd.setUsedTotEPara(value); } if (entry.getKey().equalsIgnoreCase("mapNucActMda")) { - HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); - Map value = new HashMap<>(); + TreeMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), TreeMap.class); + Map value = new TreeMap<>(); for (Map.Entry objectEntry:jsonMap.entrySet()) { String key = objectEntry.getKey(); NuclideActMda entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), NuclideActMda.class); @@ -1467,10 +1459,6 @@ public class GammaFileUtil extends AbstractLogOrReport { } catch (RuntimeException e) { e.printStackTrace(); log.error("AnalyseSpectrum(): {}", e.getMessage()); - } finally { - if (Objects.nonNull(tmpFile)) { - tmpFile.delete(); - } } return true; } @@ -1618,8 +1606,8 @@ public class GammaFileUtil extends AbstractLogOrReport { if(rate > 0.8 || bActBigger) { ActMda.setHalflife(halflife); ActMda.setKey_flag(-1); - if(!vNuclides.contains(iter.getKey())) // 需要计算活度浓度的核素 - { + // 需要计算活度浓度的核素 + if(!vNuclides.contains(iter.getKey())) { ActMda.setBCalculateMDA(true); } else { ActMda.setActivity(0); @@ -1677,12 +1665,11 @@ public class GammaFileUtil extends AbstractLogOrReport { if(strList.size() == 3) { mapHalflife.put(strList.get(0), Double.valueOf(strList.get(2)) * 86400); } - }else { + } else { i=j; break; } } - break; } if(line.contains("#Identify")) { for (int j=i+1; j0?StringUtils.join(middleData.peaks_Nuclide_name.get(i), StringPool.SEMICOLON):""; strBuffer.append(rowFormat(data14, idPeak, energy, peakCentroid, fwhm, area, areaErr, signif, sensit, nuclide)); //换行 strBuffer.append(System.lineSeparator()); @@ -2499,7 +2479,7 @@ public class GammaFileUtil extends AbstractLogOrReport { String activity = String.format("%.3f", Double.valueOf(middleData.nucl_ided_activ_key.get(i))) + " bq"; String relErr = String.format("%.3f", (Double.valueOf(middleData.nucl_ided_activ_key_err.get(i)) / Double.valueOf(middleData.nucl_ided_activ_key.get(i)) * 100)) + " %"; String conc = middleData.nucl_ided_Concentration.get(i) + " uBq/m^3"; - String mdc = StringUtils.join(middleData.nucl_ided_MDC, " "); + String mdc = StringUtils.join(middleData.nucl_ided_MDC.get(i), " "); strBuffer.append(rowFormat(data15, nuclideName, halflife, activity, relErr, conc, mdc)); //换行 strBuffer.append(System.lineSeparator()); @@ -2689,10 +2669,10 @@ public class GammaFileUtil extends AbstractLogOrReport { peaksUsed++; } } - strBuffer.append(StringPool.SPACE+peaksUsed+" peaks with ID ("+(peaksUsed/middleData.peaks_idPeak.size()*100)+"%):"); + strBuffer.append(StringPool.SPACE+peaksUsed+" peaks with ID ("+NumberFormatUtil.numberSixLen(String.valueOf(peaksUsed/middleData.peaks_idPeak.size()*100))+"%):"); //换行 strBuffer.append(System.lineSeparator()); - strBuffer.append(StringPool.SPACE+(middleData.peaks_idPeak.size()-peaksUsed)+" peaks without ID("+Double.valueOf(middleData.peaks_idPeak.size()-peaksUsed)/middleData.peaks_idPeak.size()*100+"%):"); + strBuffer.append(StringPool.SPACE+(middleData.peaks_idPeak.size()-peaksUsed)+" peaks without ID("+NumberFormatUtil.numberSixLen(String.valueOf(Double.valueOf(middleData.peaks_idPeak.size()-peaksUsed)/middleData.peaks_idPeak.size()*100))+"%):"); //换行 strBuffer.append(System.lineSeparator()); //换行 @@ -2916,7 +2896,7 @@ public class GammaFileUtil extends AbstractLogOrReport { //换行 strBuffer.append(System.lineSeparator()); for (int i=0;i 1000000) { + if (Double.isFinite(nuc.getConcentration())) { DecimalFormat decimalFormat = new DecimalFormat("0.###E0"); nuc.setConcentration(Double.valueOf(decimalFormat.format(nuc.getConcentration()))); } - String str_con = (nuc.getConcentration() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration()))); + String str_con = (Double.isFinite(nuc.getConcentration())? nuc.getConcentration() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration())) : "inf"); tableNuclideActivity.setConc(str_con); - if (nuc.getMdc() > 1000000) { + if (Double.isFinite(nuc.getMdc())) { DecimalFormat decimalFormat = new DecimalFormat("0.###E0"); - nuc.setConcentration(Double.valueOf(decimalFormat.format(nuc.getMdc()))); + nuc.setMdc(Double.valueOf(decimalFormat.format(nuc.getMdc()))); } - String str_mdc = (nuc.getMdc() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc()))); + String str_mdc = (Double.isFinite(nuc.getMdc())? nuc.getMdc() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc())) : "inf"); tableNuclideActivity.setMdc(str_mdc); nuclideActivityList.add(tableNuclideActivity); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/db/GammaDatabase.db b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/db/GammaDatabase.db deleted file mode 100644 index 1a94d792..00000000 Binary files a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/db/GammaDatabase.db and /dev/null differ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index 5285b5fe..502415e0 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -281,17 +281,13 @@ public class PHDFileUtil extends AbstractLogOrReport { } public List readLine(String filePath) { - File file = null; List allLines = new ArrayList<>(); try { - file = ftpUtil.downloadFile(filePath, "betaGamma"); - return FileUtils.readLines(file, ftpUtil.getEncoding()); + File file = new File(filePath); + return FileUtils.readLines(file, "UTF-8"); }catch (IOException e){ e.printStackTrace(); return allLines; - } finally { - if (ObjectUtil.isNotNull(file)) - file.delete(); } } @@ -431,7 +427,6 @@ public class PHDFileUtil extends AbstractLogOrReport { detBgMap.put("DetBgBtn", "RedLight"); qcMap.put("DetBgBtn", "RedLight"); } - } public Map getFileData(String filePath, String sampleFileName) { @@ -583,47 +578,46 @@ public class PHDFileUtil extends AbstractLogOrReport { return rData; } - public File analyzeFile(String path, String fileName) { - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; - File file = null; - try { - //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - //切换文件路径 - ftpClient.changeWorkingDirectory(path); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)){ - file = File.createTempFile("betaGamma", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return file; - } +// public File analyzeFile(String path, String fileName) { +// //连接ftp +// FTPClient ftpClient = ftpUtil.LoginFTP(); +// InputStream inputStream = null; +// File file = null; +// try { +// //被动模式 +// ftpClient.enterLocalPassiveMode(); +// //设置文件类型--二进制文件 +// ftpClient.setFileType(FTP.BINARY_FILE_TYPE); +// // +// ftpClient.setControlEncoding("UTF-8"); +// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); +// //切换文件路径 +// ftpClient.changeWorkingDirectory(path); +// inputStream = ftpClient.retrieveFileStream(fileName); +// if (Objects.nonNull(inputStream)){ +// file = File.createTempFile("betaGamma", null); +// //将ftp文件的输入流复制给临时文件 +// FileUtils.copyInputStreamToFile(inputStream, file); +// } +// } catch (IOException e) { +// throw new RuntimeException(e); +// } finally { +// try { +// if (Objects.nonNull(ftpClient)){ +// ftpClient.disconnect(); +// } +// if (Objects.nonNull(inputStream)){ +// inputStream.close(); +// } +// } catch (IOException e) { +// throw new RuntimeException(e); +// } +// } +// return file; +// } public boolean analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map map, BetaDataFile betaDataFile) { boolean bRet = true; - long start = System.currentTimeMillis(); //调用动态库解析文件 BgAnalyseResult analyseResult = null; if (Objects.isNull(BgCalPara)) { @@ -631,8 +625,8 @@ public class PHDFileUtil extends AbstractLogOrReport { } else { analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); } - System.out.println("beta分析总耗时:"+ (System.currentTimeMillis() - start)); if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) { + System.out.println(analyseResult.error_log); bRet = false; return bRet; } else { @@ -723,47 +717,6 @@ public class PHDFileUtil extends AbstractLogOrReport { } } - public EnergySpectrumStruct analyzeFileSourceData(String filePath, String fileName) { - EnergySpectrumStruct struct = null; - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; - File file = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(filePath); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)){ - //声明一个临时文件 - file = File.createTempFile("betaGamma", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - if (Objects.nonNull(file)) { - file.delete(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return struct; - } - public EnergySpectrumStruct analyzeFileSourceData(File uploadFile) { EnergySpectrumStruct struct = null; InputStream inputStream = null; @@ -1378,39 +1331,39 @@ public class PHDFileUtil extends AbstractLogOrReport { out.append(System.lineSeparator()); //第十五行数据 String dataFormat2 = "%-45s%-11s"; - out.append(rowFormat(dataFormat2, "Acquisition_live_sec[s] :", String.valueOf(sample.acquisition_live_time))); + out.append(rowFormat(dataFormat2, "Acquisition_live_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(sample.acquisition_live_time)))); //换行 out.append(System.lineSeparator()); //第十六行数据 - out.append(rowFormat(dataFormat2, "Acquisition_real_sec[s] :", String.valueOf(sample.acquisition_real_time))); + out.append(rowFormat(dataFormat2, "Acquisition_real_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(sample.acquisition_real_time)))); //换行 out.append(System.lineSeparator()); //第十七行数据 - long secs = 0; + double secs = 0.0; try { Date stop = DateUtils.parseDate(sample.collection_stop_date + StringPool.SPACE + sample.collection_stop_time); Date start = DateUtils.parseDate(sample.collection_start_date + StringPool.SPACE + sample.collection_start_time); - secs = (stop.getTime() - start.getTime()) / 1000; + secs = (Double.valueOf(stop.getTime()) - Double.valueOf(start.getTime()))/1000; } catch (ParseException e) { throw new RuntimeException(e); } - out.append(rowFormat(dataFormat2, "Collection time[s] :", String.valueOf(secs))); + out.append(rowFormat(dataFormat2, "Collection time[s] :", String.valueOf(Math.round(secs)))); //换行 out.append(System.lineSeparator()); //第十八行数据 - out.append(rowFormat(dataFormat2, "GASBK Spectrum acquisition_live_sec[s] :", String.valueOf(gas.acquisition_live_time))); + out.append(rowFormat(dataFormat2, "GASBK Spectrum acquisition_live_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(gas.acquisition_live_time)))); //换行 out.append(System.lineSeparator()); //第十九行数据 - out.append(rowFormat(dataFormat2, "GASBK Spectrum acquisition_real_sec[s] :", String.valueOf(gas.acquisition_real_time))); + out.append(rowFormat(dataFormat2, "GASBK Spectrum acquisition_real_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(gas.acquisition_real_time)))); //换行 out.append(System.lineSeparator()); //第二十行数据 - out.append(rowFormat(dataFormat2, "DETBK Spectrum acquisition_live_sec[s] :", String.valueOf(det.acquisition_live_time))); + out.append(rowFormat(dataFormat2, "DETBK Spectrum acquisition_live_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(det.acquisition_live_time)))); //换行 out.append(System.lineSeparator()); //第二十一行数据 - out.append(rowFormat(dataFormat2, "DETBK Spectrum acquisition_real_sec[s] :", String.valueOf(det.acquisition_real_time))); + out.append(rowFormat(dataFormat2, "DETBK Spectrum acquisition_real_sec[s] :", NumberFormatUtil.numberSixLen(String.valueOf(det.acquisition_real_time)))); //换行 out.append(System.lineSeparator()); //换行 @@ -1421,11 +1374,11 @@ public class PHDFileUtil extends AbstractLogOrReport { out.append(System.lineSeparator()); //第二十三行数据 String dataFormat3 = "%-21s%-11s"; - out.append(rowFormat(dataFormat3, "XE volume[ml] :", String.valueOf(sample.sample_volume_of_Xe))); + out.append(rowFormat(dataFormat3, "XE volume[ml] :", NumberFormatUtil.numberSixLen(String.valueOf(sample.air_volume)))); //换行 out.append(System.lineSeparator()); //第二十四行数据 - out.append(rowFormat(dataFormat3, "Air volume[m3] :", String.valueOf(sample.air_volume))); + out.append(rowFormat(dataFormat3, "Air volume[m3] :", NumberFormatUtil.numberSixLen(String.valueOf(sample.sample_volume_of_Xe)))); //换行 out.append(System.lineSeparator()); //换行 @@ -1469,9 +1422,9 @@ public class PHDFileUtil extends AbstractLogOrReport { for (int i = 0; i < sample.ratio_id.size(); i++) { String low = String.valueOf(sample.ROI_num_lower_G_energy_ROI.get(i)); String high = String.valueOf(sample.ROI_num_highter_G_energy_ROI.get(i)); - String ratio = String.valueOf(sample.count_ratio.get(i)); - String uncert = String.valueOf(sample.count_ratio_uncertainty.get(i)); - out.append(rowFormat(dataFormat5, low, high, ratio, uncert)); + String ratio = String.format("%.6f", sample.count_ratio.get(i)); + String uncert = String.format("%.6f", sample.count_ratio_uncertainty.get(i)); + out.append(rowFormat(dataFormat5, high, low, ratio, uncert)); //换行 out.append(System.lineSeparator()); //换行 @@ -1524,9 +1477,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第三十六行数据 - if (bgAnalyseResult.s_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_c_e)) { - if (bgAnalyseResult.s_b_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(2))))); + if (bgAnalyseResult.s_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_e_c)) { + if (bgAnalyseResult.s_b_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1536,9 +1489,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第三十七行数据 - if (bgAnalyseResult.s_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_e_c)) { - if (bgAnalyseResult.s_b_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_e_c.get(2))))); + if (bgAnalyseResult.s_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_b_fitting_c_e)) { + if (bgAnalyseResult.s_b_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_b_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1554,9 +1507,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第三十六行数据 - if (bgAnalyseResult.s_g_fitting_c_e !=null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_c_e)) { - if (bgAnalyseResult.s_g_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(2))))); + if (bgAnalyseResult.s_g_fitting_e_c !=null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_e_c)) { + if (bgAnalyseResult.s_g_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1566,9 +1519,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第三十七行数据 - if (bgAnalyseResult.s_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_e_c)) { - if (bgAnalyseResult.s_g_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_e_c.get(2))))); + if (bgAnalyseResult.s_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.s_g_fitting_c_e)) { + if (bgAnalyseResult.s_g_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.s_g_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1598,7 +1551,7 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十一行数据 - String dataFormat7 = "ROI : %-7sBeta : %-2sto %-4schannels Gamma : %-4sto %-8s"; + String dataFormat7 = "ROI : %-7sBeta : %-2s to %-4s channels Gamma : %-4s to %-8s"; for (int i = 0; i < bgAnalyseResult.S_ROI.size(); i++) { String roi = String.valueOf(bgAnalyseResult.S_ROI.get(i)); String bStart = String.valueOf(bgAnalyseResult.S_ROI_B_Boundary_start.get(i)); @@ -1624,9 +1577,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十四行数据 - if (bgAnalyseResult.d_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_c_e)) { - if (bgAnalyseResult.d_b_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(2))))); + if (bgAnalyseResult.d_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_e_c)) { + if (bgAnalyseResult.d_b_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1637,9 +1590,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十五行数据 - if (bgAnalyseResult.d_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_e_c)) { - if (bgAnalyseResult.d_b_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_e_c.get(2))))); + if (bgAnalyseResult.d_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_b_fitting_c_e)) { + if (bgAnalyseResult.d_b_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_b_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1655,9 +1608,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十四行数据 - if (bgAnalyseResult.d_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_c_e)) { - if (bgAnalyseResult.d_g_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(2))))); + if (bgAnalyseResult.d_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_e_c)) { + if (bgAnalyseResult.d_g_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1667,9 +1620,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十五行数据 - if (bgAnalyseResult.d_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_e_c)) { - if (bgAnalyseResult.d_g_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_e_c.get(2))))); + if (bgAnalyseResult.d_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.d_g_fitting_c_e)) { + if (bgAnalyseResult.d_g_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.d_g_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1693,12 +1646,12 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第四十八行数据 - for (int i = 0; i < bgAnalyseResult.S_ROI.size(); i++) { - String roi = String.valueOf(bgAnalyseResult.S_ROI.get(i)); - String bStart = String.valueOf(bgAnalyseResult.S_ROI_B_Boundary_start.get(i)); - String bStop = String.valueOf(bgAnalyseResult.S_ROI_B_Boundary_stop.get(i)); - String gStart = String.valueOf(bgAnalyseResult.S_ROI_G_Boundary_start.get(i)); - String gStop = String.valueOf(bgAnalyseResult.S_ROI_G_Boundary_stop.get(i)); + for (int i = 0; i < bgAnalyseResult.D_ROI.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.D_ROI.get(i)); + String bStart = String.valueOf(bgAnalyseResult.D_ROI_B_Boundary_start.get(i)); + String bStop = String.valueOf(bgAnalyseResult.D_ROI_B_Boundary_stop.get(i)); + String gStart = String.valueOf(bgAnalyseResult.D_ROI_G_Boundary_start.get(i)); + String gStop = String.valueOf(bgAnalyseResult.D_ROI_G_Boundary_stop.get(i)); out.append(rowFormat(dataFormat7, roi, bStart, bStop, gStart, gStop)); //换行 out.append(System.lineSeparator()); @@ -1720,9 +1673,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第五十一行数据 - if (bgAnalyseResult.g_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_c_e)) { - if (bgAnalyseResult.g_b_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(2))))); + if (bgAnalyseResult.g_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_e_c)) { + if (bgAnalyseResult.g_b_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1732,9 +1685,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第五十二行数据 - if (bgAnalyseResult.g_b_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_e_c)) { - if (bgAnalyseResult.g_b_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_e_c.get(2))))); + if (bgAnalyseResult.g_b_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_b_fitting_c_e)) { + if (bgAnalyseResult.g_b_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_b_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1750,9 +1703,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第五十四行数据 - if (bgAnalyseResult.g_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_c_e)) { - if (bgAnalyseResult.g_g_fitting_c_e.size() > 0) { - out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(2))))); + if (bgAnalyseResult.g_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_e_c)) { + if (bgAnalyseResult.g_g_fitting_e_c.size() > 0) { + out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(2))))); } else { out.append(rowFormat("energy to channel equation: CH(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1762,9 +1715,9 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第五十五行数据 - if (bgAnalyseResult.g_g_fitting_e_c != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_e_c)) { - if (bgAnalyseResult.g_g_fitting_e_c.size() > 0) { - out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_e_c.get(2))))); + if (bgAnalyseResult.g_g_fitting_c_e != null && CollectionUtils.isNotEmpty(bgAnalyseResult.g_g_fitting_c_e)) { + if (bgAnalyseResult.g_g_fitting_c_e.size() > 0) { + out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(0))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(1))), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.g_g_fitting_c_e.get(2))))); } else { out.append(rowFormat("channel to energy equation: E(x) = (%s)+(%s)*x+(%s)x*x", "?1", "?2", "?3")); } @@ -1788,12 +1741,12 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第五十八行数据 - for (int i = 0; i < bgAnalyseResult.S_ROI.size(); i++) { - String roi = String.valueOf(bgAnalyseResult.S_ROI.get(i)); - String bStart = String.valueOf(bgAnalyseResult.S_ROI_B_Boundary_start.get(i)); - String bStop = String.valueOf(bgAnalyseResult.S_ROI_B_Boundary_stop.get(i)); - String gStart = String.valueOf(bgAnalyseResult.S_ROI_G_Boundary_start.get(i)); - String gStop = String.valueOf(bgAnalyseResult.S_ROI_G_Boundary_stop.get(i)); + for (int i = 0; i < bgAnalyseResult.G_ROI.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.G_ROI.get(i)); + String bStart = String.valueOf(bgAnalyseResult.G_ROI_B_Boundary_start.get(i)); + String bStop = String.valueOf(bgAnalyseResult.G_ROI_B_Boundary_stop.get(i)); + String gStart = String.valueOf(bgAnalyseResult.G_ROI_G_Boundary_start.get(i)); + String gStop = String.valueOf(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i)); out.append(rowFormat(dataFormat7, roi, bStart, bStop, gStart, gStop)); //换行 out.append(System.lineSeparator()); @@ -1812,8 +1765,8 @@ public class PHDFileUtil extends AbstractLogOrReport { out.append(System.lineSeparator()); //第六十行数据 String dataFormat8 = "ROI : %-8sSample : %-8sGasBkgnd : %-7sDetBkgnd : %-8s"; - for (int i = 0; i < bgAnalyseResult.ROI.size(); i++) { - String roi = String.valueOf(bgAnalyseResult.ROI.get(i)); + for (int i = 0; i < bgAnalyseResult.G_ROI_G_Boundary_stop.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i)); String sCts = String.valueOf(bgAnalyseResult.s_roi_cts.get(i)); String gCts = String.valueOf(bgAnalyseResult.g_roi_cts.get(i)); String dCts = String.valueOf(bgAnalyseResult.d_roi_cts.get(i)); @@ -1833,22 +1786,19 @@ public class PHDFileUtil extends AbstractLogOrReport { out.append(System.lineSeparator()); //换行 out.append(System.lineSeparator()); - //第六十二行信息 - out.append(titleFormat("Net counts and Lc per ROI%s", 5, StringPool.DOT)); - //换行 - out.append(System.lineSeparator()); - //换行 - out.append(System.lineSeparator()); +// //第六十二行信息 +// out.append(titleFormat("Net counts and Lc per ROI%s", 5, StringPool.DOT)); +// //换行 +// out.append(System.lineSeparator()); +// //换行 +// out.append(System.lineSeparator()); //第六十三行数据 String dataFormat9 = "ROI : %-8sNet count : %-2s+/- %-20sLC : %-12s"; - for (int i = 0; i < bgAnalyseResult.ROI.size(); i++) { - String roi = String.valueOf(bgAnalyseResult.ROI.get(i)); - String net = String.valueOf(bgAnalyseResult.ROI_net_coutns.get(i)); - String netErr = String.valueOf(bgAnalyseResult.ROI_net_coutns_err.get(i)); - String lcCts = "0"; - if (i > 0) { - lcCts = String.valueOf(bgAnalyseResult.LC_CTS.get(i-1)); - } + for (int i = 0; i < bgAnalyseResult.G_ROI_G_Boundary_stop.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i)); + String net = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.ROI_net_coutns.get(i))); + String netErr = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.ROI_net_coutns_err.get(i))); + String lcCts = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_CTS.get(i))); out.append(rowFormat(dataFormat9, roi, net, netErr, lcCts)); //换行 out.append(System.lineSeparator()); @@ -1867,18 +1817,12 @@ public class PHDFileUtil extends AbstractLogOrReport { out.append(System.lineSeparator()); //第六十五行数据 String dataFormat10 = "ROI : %-8sConc : %-2s+/- %-2smBq/m3 LC : %-2smBq/m3 MDC : %-2smBq/m3 "; - for (int i = 0; i < bgAnalyseResult.ROI.size(); i++) { - String roi = String.valueOf(bgAnalyseResult.ROI.get(i)); - String conc = String.valueOf(bgAnalyseResult.ROI_con_uncer.get(i)); - String concErr = String.valueOf(bgAnalyseResult.ROI_con_uncer_err.get(i)); - String lc = "0"; - if (i > 0) { - lc = String.valueOf(bgAnalyseResult.LC.get(i-1)); - } - String mdc = "0"; - if (i > 0) { - mdc = String.valueOf(bgAnalyseResult.MDC.get(i-1)); - } + for (int i = 0; i < bgAnalyseResult.G_ROI_G_Boundary_stop.size(); i++) { + String roi = String.valueOf(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i)); + String conc = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.ROI_con_uncer.get(i))); + String concErr = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.ROI_con_uncer_err.get(i))); + String lc = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC.get(i))); + String mdc = NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC.get(i))); out.append(rowFormat(dataFormat10, roi, conc, concErr, lc, mdc)); //换行 out.append(System.lineSeparator()); @@ -1896,7 +1840,7 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第六十七行数据 - out.append(rowFormat("XE-135 Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe135_con)), + out.append(rowFormat("XE-135 Conc : %-9s +/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9s mBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe135_con)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe135_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe135)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe135)), String.valueOf(bgAnalyseResult.XE_135_NID_FLAG))); //换行 @@ -1904,29 +1848,29 @@ public class PHDFileUtil extends AbstractLogOrReport { //换行 out.append(System.lineSeparator()); //第六十八行数据 - out.append(rowFormat("XE-131M Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe131m_con)), + out.append(rowFormat("XE-131M Conc : %-9s +/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9s mBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe131m_con)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe131m_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe131m)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe131m)), String.valueOf(bgAnalyseResult.XE_131m_NID_FLAG))); //换行 out.append(System.lineSeparator()); //换行 out.append(System.lineSeparator()); - //第六十九行数据 - out.append(rowFormat("XE-133 Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_con)), - NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe133)), - NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe133)), String.valueOf(bgAnalyseResult.XE_133_NID_FLAG))); - //换行 - out.append(System.lineSeparator()); - //换行 - out.append(System.lineSeparator()); //第七十行数据 - out.append(rowFormat("XE-133M Conc : %-9s+/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9smBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133m_con)), + out.append(rowFormat("XE-133M Conc : %-9s +/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9s mBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133m_con)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133m_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe133m)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe133m)), String.valueOf(bgAnalyseResult.XE_133m_NID_FLAG))); //换行 out.append(System.lineSeparator()); //换行 out.append(System.lineSeparator()); + //第六十九行数据 + out.append(rowFormat("XE-133 Conc : %-9s +/- %-8smBq/m3 LC : %-9smBq/m3 MDC : %-9s mBq/m3 Nid flag : %-6s", NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_con)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.Xe133_uncer)), NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.LC_Xe133)), + NumberFormatUtil.numberFormat(String.valueOf(bgAnalyseResult.MDC_Xe133)), String.valueOf(bgAnalyseResult.XE_133_NID_FLAG))); + //换行 + out.append(System.lineSeparator()); + //换行 + out.append(System.lineSeparator()); //第七十一行信息 out.append(titleFormat("%s NCC analysis finished %s", 40, StringPool.DOT, StringPool.DOT)); //换行 diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index 5004e51d..8f58b8b4 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -226,21 +226,21 @@ public class SpectrumAnalysesController { } @PostMapping("saveToHTML") - public void saveToHTML(HttpServletResponse response, + public void saveToHTML(HttpServletRequest request, HttpServletResponse response, @RequestBody BgDataAnlyseResultIn anlyseResultIn){ - spectrumAnalysisService.saveToHTML(anlyseResultIn, response); + spectrumAnalysisService.saveToHTML(anlyseResultIn, request, response); } @PostMapping("saveToExcel") - public void saveToExcel(HttpServletResponse response, + public void saveToExcel(HttpServletRequest request, HttpServletResponse response, @RequestBody BgDataAnlyseResultIn anlyseResultIn){ - spectrumAnalysisService.saveToExcel(anlyseResultIn, response); + spectrumAnalysisService.saveToExcel(anlyseResultIn, request, response); } @PostMapping("saveToTxt") - public void saveToTxt(HttpServletResponse response, + public void saveToTxt(HttpServletRequest request, HttpServletResponse response, @RequestBody BgDataAnlyseResultIn anlyseResultIn){ - spectrumAnalysisService.saveToTxt(anlyseResultIn, response); + spectrumAnalysisService.saveToTxt(anlyseResultIn, request, response); } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java index f29ce0f9..402a9942 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BetaDataFile.java @@ -13,6 +13,14 @@ import java.util.List; public class BetaDataFile implements Serializable { //基本数据信息 + private String sampleTmpPath; + + private String detTmpPath; + + private String gasTmpPath; + + private String qcTmpPath; + private String sampleFilePathName; private String sampleFileName; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml index cf2afd89..ee38731f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml @@ -580,7 +580,6 @@ WHERE ROI_CHANNELS.SAMPLE_ID = SAMPLE_DATA.SAMPLE_ID AND ROI_CHANNELS.IDANALYSIS = #{idAnalysis} - AND ROI_CHANNELS.SAMPLE_ID = #{sampleId} ORDER BY ROI_CHANNELS.ROI ASC diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index f88bfdd8..e73caecd 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -80,9 +80,9 @@ public interface ISpectrumAnalysisService { Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request); - void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response); + void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response); - void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response); + void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response); - void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response); + void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index cd670af6..ed2e39ee 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -157,17 +157,20 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi } String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH) + 1); + // 读取文件内容 + // 调用加载文件的方法 传入文件路径,文件名称,全局变量phd,响应结果result boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + // 如果文件加载失败 返回失败原因 if (!flag) { return result; } - // 声明基础数组信息 + // 加载phd数据所需的lc,scac,baseline数据 if (dbName.equals("auto")) { gammaFileUtil.SetBaseInfo(phd, "RNAUTO"); } else if (dbName.equals("man")) { gammaFileUtil.SetBaseInfo(phd, userName); } - // 从数据库中读取相关信息 + // 从数据库中读取phd其他相关信息 boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result); if (!redisUtil.hasKey(userName+"-"+phd.getHeader().getSystem_type())) { // 查询当前用户关联的核素信息 @@ -177,17 +180,24 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isEmpty(userLib)) { userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } + userLib = userLib.stream().sorted().collect(Collectors.toList()); Map nuclideMap = GetNuclideLines(userLib); redisUtil.set(userName+"-"+phd.getHeader().getSystem_type(), nuclideMap); } + // 判断数据库信息是否读取正常 if (!bRet) { return result; } + gammaFileUtil.Qcstate(phd); key = fileName + "-" + userName; } else { String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; String fileName = samfileName; - boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + // 加载文件内容 + boolean bRet = gammaFileUtil.loadFile(pathName, fileName, phd, result); + if (!bRet) { + return result; + } if (!redisUtil.hasKey(userName+"-"+phd.getHeader().getSystem_type())) { // 查询当前用户关联的核素信息 List userLib = new LinkedList<>(); @@ -196,12 +206,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isEmpty(userLib)) { userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } - Map nuclideMap = GetNuclideLines(userLib); + userLib = userLib.stream().sorted().collect(Collectors.toList()); + Map nuclideMap = GetNuclideLinesLocal(userLib); redisUtil.set(userName+"-"+phd.getHeader().getSystem_type(), nuclideMap); } - if (!flag) { - return result; - } key = fileName + "-" + userName; } phdCache.put(key, phd); @@ -480,6 +488,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isEmpty(userLib)) { userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } + userLib = userLib.stream().sorted().collect(Collectors.toList()); Map nuclideMap = GetNuclideLines(userLib); redisUtil.set(userName+"-"+phd.getHeader().getSystem_type(), nuclideMap); } @@ -845,7 +854,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isEmpty(userLib)) { userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } - Map nuclideMap = GetNuclideLines(userLib); + userLib = userLib.stream().sorted().collect(Collectors.toList()); + Map nuclideMap = GetNuclideLinesLocal(userLib);//GetNuclideLinesLocal(userLib); redisUtil.set(userName+"-"+phd.getHeader().getSystem_type(), nuclideMap); } } @@ -880,6 +890,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String username = loginUser.getUsername(); String key = fileName + StrUtil.DASHED + username; + Cache phdCache = localCache.getPHDCache(); + PHDFile phdFile = phdCache.getIfPresent(key); + if (StringUtils.isNotBlank(phdFile.getTmpFilePath())) { + File file = new File(phdFile.getTmpFilePath()); + file.delete(); + } // 删除指定key的Cache localCache.deletePHDCache(key); } @@ -1036,13 +1052,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi phd.setXmlFilePath(parameterProperties.getFilePath()); // 获取当前角色的颜色配置 Map colorMap = sysUserColorService.initColor(userName); -// // 查询当前用户关联的核素信息 -// List nuclides = new LinkedList<>(); -// // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 -// nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); -// if (CollectionUtils.isEmpty(nuclides)) { -// nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); -// } // 分析文件数据 int flag = gammaFileUtil.AnalyseData(phd); if (flag == 0) { @@ -1063,10 +1072,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi Map nuclideLinesMap = (Map) redisUtil.get(userName+"-"+phd.getHeader().getSystem_type());//GetNuclideLines(nuclides); gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap); // 重新分析各峰值对应的核素信息 -// gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); Map map = new HashMap<>(); gammaFileUtil.UpdateChart(phd, map, colorMap); // 更新 ‘QC Flags’ 状态 + phd.getQcItems().clear(); List qcstate = gammaFileUtil.Qcstate(phd); map.put("QCFlag", qcstate); map.put("bAnalyed", phd.isBAnalyed()); @@ -1111,6 +1121,55 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return mapLines; } + public Map GetNuclideLinesLocal(List nuclideList) { + Map mapLines = new HashMap<>(); + if (nuclideList.size() < 1) { + return mapLines; + } + //需要查询的两个表的名称 + String table_lines = "lines"; + String table_lib = "libdata"; + // 建立数据库连接 + Connection conn = dbUtil.openDB(); + Statement statement = null; + try { + statement = conn.createStatement(); + for (String name : nuclideList) { + NuclideLines nlines = new NuclideLines(); + //根据核素名称查询相关核素信息 + String sql1 = "select fullname, energy, energy_uncert, yield, yield_uncert, key_flag from "+table_lines+" where name = '"+name+"' Order by energy"; + ResultSet resultSet = statement.executeQuery(sql1); + int j=0; + while (resultSet.next()) { + nlines.getFullNames().add(resultSet.getString("fullname")); + nlines.getVenergy().add(resultSet.getDouble("energy")); + nlines.getVuncertE().add(resultSet.getDouble("energy_uncert")); + nlines.getVyield().add(resultSet.getDouble("yield") / 100); + nlines.getVuncertY().add(resultSet.getDouble("yield_uncert")); + if (Objects.nonNull(resultSet.getInt("key_flag")) && resultSet.getInt("key_flag") > 0) { + nlines.key_flag = j; + nlines.maxYeildIdx = j; + } + ++j; + } + mapLines.put(name, nlines); + } + String names = "'" + String.join("','", nuclideList) + "'"; + String sql2 = "select name, halflife from "+table_lib+" where name in ("+names+")"; + ResultSet executeQuery = statement.executeQuery(sql2); + while (executeQuery.next()) { + NuclideLines nuclideLines = mapLines.get(executeQuery.getString("name")); + nuclideLines.setHalflife(Double.valueOf(executeQuery.getDouble("halflife")) == null ? 0 : executeQuery.getDouble("halflife") * 86400);// 将天转换成秒 + mapLines.put(executeQuery.getString("name"), nuclideLines); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + dbUtil.close(statement, conn); + } + return mapLines; + } + @Override public Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request) { Result result = new Result(); @@ -3677,24 +3736,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (StringUtils.isBlank(reportPath)) { throw new RuntimeException("The automatic handler generated report does not exist!"); } - String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); - String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH) + 1) + ".txt"; - // 连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)) { - throw new RuntimeException("ftp connection failed"); - } + String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"; InputStream inputStream = null; ServletOutputStream outputStream = null; try { - // 切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - inputStream = ftpClient.retrieveFileStream(fileName); + inputStream = ftpUtil.downloadFileStream(pathFileName); if (Objects.nonNull(inputStream)) { outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -3708,9 +3754,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi throw new RuntimeException(e); } finally { try { - if (Objects.nonNull(ftpClient)) { - ftpClient.disconnect(); - } if (ObjectUtil.isNotNull(inputStream)) { inputStream.close(); } @@ -3727,24 +3770,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi public void exportARR(Integer sampleId, HttpServletResponse response) { // 获取自动处理生成的报告地址 String reportPath = spectrumAnalysisMapper.viewARR(sampleId); - String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); - String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH) + 1) + ".txt"; - // 连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)) { - throw new RuntimeException("ftp connection failed"); - } + String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"; InputStream inputStream = null; ServletOutputStream outputStream = null; try { - // 切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - inputStream = ftpClient.retrieveFileStream(fileName); + inputStream = ftpUtil.downloadFileStream(pathFileName); if (Objects.nonNull(inputStream)) { // 设置响应类型 response.setContentType("application/octet-stream"); @@ -3762,9 +3792,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi throw new RuntimeException(e); } finally { try { - if (Objects.nonNull(ftpClient)) { - ftpClient.disconnect(); - } if (ObjectUtil.isNotNull(inputStream)) { inputStream.close(); } @@ -4266,24 +4293,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (StringUtils.isBlank(logPath)) { throw new RuntimeException("The log generated by the automatic processor does not exist!"); } - String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath.substring(0, logPath.lastIndexOf(StringPool.SLASH)); - String fileName = logPath.substring(logPath.lastIndexOf(StringPool.SLASH) + 1); - // 连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)) { - throw new RuntimeException("ftp connection failed"); - } + String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath; InputStream inputStream = null; ServletOutputStream outputStream = null; try { - // 切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - ftpClient.changeWorkingDirectory(pathName); - inputStream = ftpClient.retrieveFileStream(fileName); + inputStream = ftpUtil.downloadFileStream(pathFileName); if (Objects.nonNull(inputStream)) { outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -4297,9 +4311,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi throw new RuntimeException(e); } finally { try { - if (Objects.nonNull(ftpClient)) { - ftpClient.disconnect(); - } if (ObjectUtil.isNotNull(inputStream)) { inputStream.close(); } 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 0f87d7b6..64b41d6d 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 @@ -412,6 +412,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements betaDataFile.setSampleFileName(sampleFileName); sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); if (Objects.nonNull(sampleTmp)) { + betaDataFile.setSampleTmpPath(sampleTmp.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); betaDataFile.setSampleStruct(struct); sampleMap = phdFileUtil.getSourceData(struct, sample.getSampleId(), sample.getStatus(), "sample", betaDataFile); @@ -425,6 +426,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements betaDataFile.setGasFileName(gasFileName); gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); if (Objects.nonNull(gasTmp)) { + betaDataFile.setGasTmpPath(gasTmp.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath()); betaDataFile.setGasStruct(struct); gasBgMap = phdFileUtil.getSourceData(struct, gasBg.getSampleId(), gasBg.getStatus(), "gas", betaDataFile); @@ -438,6 +440,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements betaDataFile.setDetFileName(detFileName); detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); if (Objects.nonNull(detTmp)) { + betaDataFile.setDetTmpPath(detTmp.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath()); betaDataFile.setDetStruct(struct); detBgMap = phdFileUtil.getSourceData(struct, detBg.getSampleId(), detBg.getStatus(), "det", betaDataFile); @@ -451,6 +454,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements betaDataFile.setQcFileName(qcFileName); qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma"); if (Objects.nonNull(qcTmp)) { + betaDataFile.setQcTmpPath(qcTmp.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(qcTmp.getAbsolutePath()); betaDataFile.setQcStruct(struct); qcMap = phdFileUtil.getSourceData(struct, qc.getSampleId(), qc.getStatus(), "qc", betaDataFile); @@ -509,19 +513,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } catch (Exception e) { e.printStackTrace(); - } finally { - if (Objects.nonNull(sampleTmp)) { - sampleTmp.delete(); - } - if (Objects.nonNull(gasTmp)) { - gasTmp.delete(); - } - if (Objects.nonNull(detTmp)) { - detTmp.delete(); - } - if (Objects.nonNull(qcTmp)) { - qcTmp.delete(); - } } result.setSuccess(true); result.setResult(resultMap); @@ -554,7 +545,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements String detBgFilePath = path + StringPool.SLASH + detFileName; String dbQcFilePath = path + StringPool.SLASH + qcFileName; if(StringUtils.isNotBlank(sampleFileName)){ - EnergySpectrumStruct struct = getSourceData(sampleFilePath); + EnergySpectrumStruct struct = getSourceData(sampleFilePath, "sample", betaDataFile); if (Objects.nonNull(struct)) { betaDataFile.setSampleStruct(struct); betaDataFile.setSampleFilePathName(sampleFilePath); @@ -565,7 +556,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } if(StringUtils.isNotBlank(gasFileName)){ - EnergySpectrumStruct struct = getSourceData(gasBgFilePath); + EnergySpectrumStruct struct = getSourceData(gasBgFilePath, "gas", betaDataFile); if (Objects.nonNull(struct)) { betaDataFile.setGasStruct(struct); betaDataFile.setGasFilePathName(gasBgFilePath); @@ -576,7 +567,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } if(StringUtils.isNotBlank(detFileName)){ - EnergySpectrumStruct struct = getSourceData(detBgFilePath); + EnergySpectrumStruct struct = getSourceData(detBgFilePath, "det", betaDataFile); if (Objects.nonNull(struct)) { betaDataFile.setDetStruct(struct); betaDataFile.setDetFilePathName(detBgFilePath); @@ -587,7 +578,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } if(StringUtils.isNotBlank(qcFileName)){ - EnergySpectrumStruct struct = getSourceData(dbQcFilePath); + EnergySpectrumStruct struct = getSourceData(dbQcFilePath, "qc", betaDataFile); if (Objects.nonNull(struct)) { betaDataFile.setQcStruct(struct); betaDataFile.setQcFilePathName(dbQcFilePath); @@ -640,20 +631,27 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //获取文件解析结果 - public EnergySpectrumStruct getSourceData(String filePathName) { + public EnergySpectrumStruct getSourceData(String filePathName, String type, BetaDataFile betaDataFile) { EnergySpectrumStruct struct = null; File file = null; try { //根据完整的文件路径 获取临时文件 file = ftpUtil.downloadFile(filePathName, "betaGamma"); - //解析文件内容 - struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + if (Objects.nonNull(file)) { + if (type.equalsIgnoreCase("sample")) { + betaDataFile.setSampleTmpPath(file.getAbsolutePath()); + } else if (type.equalsIgnoreCase("gas")) { + betaDataFile.setGasTmpPath(file.getAbsolutePath()); + } else if (type.equalsIgnoreCase("det")) { + betaDataFile.setDetTmpPath(file.getAbsolutePath()); + } else if (type.equalsIgnoreCase("qc")) { + betaDataFile.setQcTmpPath(file.getAbsolutePath()); + } + //解析文件内容 + struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + } } catch (Exception e) { e.printStackTrace(); - } finally { - if (Objects.nonNull(file)) { - file.delete(); - } } return struct; } @@ -697,6 +695,28 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements public void deleteSpectrumCacheData(String sampleFileName, HttpServletRequest request) { String userName = JwtUtil.getUserNameByToken(request); String betaKey = sampleFileName + "-" + userName; + Cache cache = betaCache.getBetaCache(); + BetaDataFile betaDataFile = cache.getIfPresent(betaKey); + String sampleTmpPath = betaDataFile.getSampleTmpPath(); + if (StringUtils.isNotBlank(sampleTmpPath)) { + File file = new File(sampleTmpPath); + file.delete(); + } + String gasTmpPath = betaDataFile.getGasTmpPath(); + if (StringUtils.isNotBlank(gasTmpPath)) { + File file = new File(gasTmpPath); + file.delete(); + } + String detTmpPath = betaDataFile.getDetTmpPath(); + if (StringUtils.isNotBlank(detTmpPath)) { + File file = new File(detTmpPath); + file.delete(); + } + String qcTmpPath = betaDataFile.getQcTmpPath(); + if (StringUtils.isNotBlank(qcTmpPath)) { + File file = new File(qcTmpPath); + file.delete(); + } betaCache.deleteBetaCache(betaKey); } @@ -803,6 +823,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements if (betaDataFile.isSaveAnalysisResult()) { //对分析后的内容进行数据获取 List channelsSpectrums = betaDataFile.getRoiChannelsSpectrumList(); + List roiChannelsSpectrumsSample = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("S")).collect(Collectors.toList()); + List roiChannelsSpectrumsGas = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("G")).collect(Collectors.toList()); + List roiChannelsSpectrumsDet = channelsSpectrums.stream().filter(item -> item.getDataType().equalsIgnoreCase("D")).collect(Collectors.toList()); List resultsSpectrums = betaDataFile.getRoiResultsSpectrumList(); List xeResultsSpectrums = betaDataFile.getXeResultsSpectrumList(); for (int i=0; i> map = new HashMap<>(); - if(StringUtils.isNotBlank(betaDataFile.getSampleFilePathName())) { - List lines = phdFileUtil.readLine(betaDataFile.getSampleFilePathName()); + if(StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { + List lines = phdFileUtil.readLine(betaDataFile.getSampleTmpPath()); map.put("sample", lines); } - if(StringUtils.isNotBlank(betaDataFile.getGasFilePathName())) { - List lines = phdFileUtil.readLine(betaDataFile.getGasFilePathName()); + if(StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { + List lines = phdFileUtil.readLine(betaDataFile.getGasTmpPath()); map.put("gasBg", lines); } - if(StringUtils.isNotBlank(betaDataFile.getDetFilePathName())) { - List lines = phdFileUtil.readLine(betaDataFile.getDetFilePathName()); + if(StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { + List lines = phdFileUtil.readLine(betaDataFile.getDetTmpPath()); map.put("detBg", lines); } - if (StringUtils.isNotBlank(betaDataFile.getQcFilePathName())) { - List lines = phdFileUtil.readLine(betaDataFile.getQcFilePathName()); + if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) { + List lines = phdFileUtil.readLine(betaDataFile.getQcTmpPath()); map.put("qc", lines); } result.setSuccess(true); @@ -1573,9 +1623,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements map.put("max", max); map.put("gammaSpectrum", seriseDataList); - betaDataFile.setGammaList(oldScatterSeries); - betaDataFile.setGammaFittingPara(fittingParaStr); - betaDataFile.setGammaFittingParaToUi(fittingParaToUiStr); + if (betaDataFile.getGammaList().size()<=0) { + betaDataFile.setGammaList(oldScatterSeries); + } + if (betaDataFile.getGammaFittingPara().size()<=0) { + betaDataFile.setGammaFittingPara(fittingParaStr); + } + if (betaDataFile.getGammaFittingParaToUi().size()<=0) { + betaDataFile.setGammaFittingParaToUi(fittingParaToUiStr); + } betaDataFile.setGammaFittingParaOld(fittingParaStr); betaDataFile.setGammaFittingParaToUiOld(fittingParaToUiStr); } @@ -1681,9 +1737,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } map.put("EToC", fittingParaToUiStr); - betaDataFile.setBetaList(oldScatterSeries); - betaDataFile.setBetaFittingPara(fittingParaStr); - betaDataFile.setBetaFittingParaToUi(fittingParaToUiStr); + if (betaDataFile.getBetaList().size()<=0) { + betaDataFile.setBetaList(oldScatterSeries); + } + if (betaDataFile.getBetaFittingPara().size()<=0) { + betaDataFile.setBetaFittingPara(fittingParaStr); + } + if (betaDataFile.getBetaFittingParaToUi().size()<=0) { + betaDataFile.setBetaFittingParaToUi(fittingParaToUiStr); + } betaDataFile.setBetaFittingParaOld(fittingParaStr); betaDataFile.setBetaFittingParaToUiOld(fittingParaToUiStr); } @@ -2632,10 +2694,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } private Map BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, BetaDataFile betaDataFile) { - //根据文件路径 文件名称获取对应的临时文件 - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; //声明一个map 缓存xeData计算后的结果 Map xeMap = new HashMap<>(); try { @@ -2709,13 +2767,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements //判断是否勾选了qc spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); betaDataFile.setBgPara(spectrum_group.BgCalPara); - //获取sample文件 - sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); - //获取gas文件 - gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); - //获取det文件 - detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); - + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { + sampleTmp = new File(betaDataFile.getSampleTmpPath()); + } + if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { + gasTmp = new File(betaDataFile.getGasTmpPath()); + } + if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { + detTmp = new File(betaDataFile.getDetTmpPath()); + } if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) { //调用分析方法进行分析操作 boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, betaDataFile); @@ -2770,111 +2833,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } else { xeMap.put("XeData", Collections.EMPTY_LIST); } -// if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) { -// return Collections.EMPTY_LIST; -// } else { -// //生成分析操作日志 -// EnergySpectrumStruct sample = betaDataFile.getSampleStruct(); -// EnergySpectrumStruct gas = betaDataFile.getGasStruct(); -// EnergySpectrumStruct det = betaDataFile.getDetStruct(); -// String logName = betaDataFile.getSampleFileName().replace("PHD", "log"); -// phdFileUtil.OutPutRnLog(analyseResult, sample, gas, det, logName); -// //存入计算后得到的xeData数据 -// GardsXeResultsSpectrum xe131m = new GardsXeResultsSpectrum(); -// xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); -// xe131m.setConc(analyseResult.Xe131m_con); -// xe131m.setConcErr(analyseResult.Xe131m_uncer); -// xe131m.setLc(analyseResult.LC_Xe131m); -// xe131m.setMdc(analyseResult.MDC_Xe131m); -// xe131m.setNidFlag(analyseResult.XE_131m_NID_FLAG); -// xeResultsSpectrumList.add(xe131m); -// GardsXeResultsSpectrum xe133 = new GardsXeResultsSpectrum(); -// xe133.setNuclideName(XeNuclideName.XE_133.getType()); -// xe133.setConc(analyseResult.Xe133_con); -// xe133.setConcErr(analyseResult.Xe133_uncer); -// xe133.setLc(analyseResult.LC_Xe133); -// xe133.setMdc(analyseResult.MDC_Xe133); -// xe133.setNidFlag(analyseResult.XE_133_NID_FLAG); -// xeResultsSpectrumList.add(xe133); -// GardsXeResultsSpectrum xe133m = new GardsXeResultsSpectrum(); -// xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); -// xe133m.setConc(analyseResult.Xe133m_con); -// xe133m.setConcErr(analyseResult.Xe133m_uncer); -// xe133m.setLc(analyseResult.LC_Xe133m); -// xe133m.setMdc(analyseResult.MDC_Xe133m); -// xe133m.setNidFlag(analyseResult.XE_133m_NID_FLAG); -// xeResultsSpectrumList.add(xe133m); -// GardsXeResultsSpectrum xe135 = new GardsXeResultsSpectrum(); -// xe135.setNuclideName(XeNuclideName.XE_135.getType()); -// xe135.setConc(analyseResult.Xe135_con); -// xe135.setConcErr(analyseResult.Xe135_uncer); -// xe135.setLc(analyseResult.LC_Xe135); -// xe135.setMdc(analyseResult.MDC_Xe135); -// xe135.setNidFlag(analyseResult.XE_135_NID_FLAG); -// xeResultsSpectrumList.add(xe135); -// xeMap.put("XeData", xeResultsSpectrumList); -// //新计算得到的边界值 -// if (CollectionUtils.isNotEmpty(analyseResult.S_ROI_B_Boundary_start)) { -// List boundaryList = new LinkedList<>(); -// for (int i=0; i boundaryList = new LinkedList<>(); -// for (int i=0; i boundaryList = new LinkedList<>(); -// for (int i=0; i cache = betaCache.getBetaCache(); //返回最终结果用的map Map> analyseResultMap = new HashMap<>(); - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; try { //需要操作的数据集合 for (String sampleFileName: analyseData.getSampleFileNames()){ @@ -2967,9 +2925,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); sampleBetaData.setBgPara(spectrum_group.BgCalPara); - sampleTmp = ftpUtil.downloadFile(sampleBetaData.getSampleFilePathName(), "betaGamma"); - gasTmp = ftpUtil.downloadFile(sampleBetaData.getGasFilePathName(), "betaGamma"); - detTmp = ftpUtil.downloadFile(sampleBetaData.getDetFilePathName(), "betaGamma"); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + if (StringUtils.isNotBlank(sampleBetaData.getSampleTmpPath())) { + sampleTmp = new File(sampleBetaData.getSampleTmpPath()); + } + if (StringUtils.isNotBlank(sampleBetaData.getGasTmpPath())) { + gasTmp = new File(sampleBetaData.getGasTmpPath()); + } + if (StringUtils.isNotBlank(sampleBetaData.getDetTmpPath())) { + detTmp = new File(sampleBetaData.getDetTmpPath()); + } if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) { //调用分析方法进行分析操作 boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, sampleBetaData); @@ -3031,16 +2998,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } catch (Exception e) { e.printStackTrace(); - } finally { - if (Objects.nonNull(sampleTmp)) { - sampleTmp.delete(); - } - if (Objects.nonNull(gasTmp)) { - gasTmp.delete(); - } - if (Objects.nonNull(detTmp)) { - detTmp.delete(); - } } return analyseResultMap.get(currentFileName); } @@ -3058,16 +3015,21 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements return result; } Map map = new HashMap<>(); - //生成临时文件 - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; BgCalibratePara BgCalPara = null; try { //根据文件路径 文件名称获取对应的临时文件 - sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); - gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); - detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); + File sampleTmp = null; + File gasTmp = null; + File detTmp = null; + if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { + sampleTmp = new File(betaDataFile.getSampleTmpPath()); + } + if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { + gasTmp = new File(betaDataFile.getGasTmpPath()); + } + if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { + detTmp = new File(betaDataFile.getDetTmpPath()); + } if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { result.error500("Failed to obtain the ftp file. Procedure!"); return result; @@ -3143,16 +3105,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } 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); @@ -3167,9 +3119,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements //获取本地缓存 Cache cache = betaCache.getBetaCache(); Map> mapList = new HashMap<>(); - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; try { if (CollectionUtils.isNotEmpty(sampleFileNames)) { for (int i=0; i betaList = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); @@ -3257,16 +3215,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } 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(mapList.get(currentFileName)); @@ -3413,26 +3361,26 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements return result; } //处理数据 获取对应的channel/energy值 - getChannelAndEnergy(anlyseResultIn, betaList, gammaList); + getChannelAndEnergy(anlyseResultIn, betaList, gammaList, betaDataFile); //分析文件内容 - analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara); + analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaDataFile); //判断文件是否存储过 如果没有则解析文件并进行存储 - if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){ + if ( !OriginalDataStore(betaDataFile, "gas", gasFilePathName) ){ result.error500("gasFile save failed"); return result; } - if ( !OriginalDataStore(anlyseResultIn.getDetFilePath(), anlyseResultIn.getGasFileName(), detFilePathName, anlyseResultIn.getUserName()) ){ + if ( !OriginalDataStore(betaDataFile, "det", detFilePathName) ){ result.error500("detFile save failed"); return result; } if (StringUtils.isNotBlank(anlyseResultIn.getQcFileName())) { - if ( !OriginalDataStore(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName(), qcFilePathName, anlyseResultIn.getUserName()) ){ + if ( !OriginalDataStore(betaDataFile, "qc", qcFilePathName) ){ result.error500("qcFile save failed"); return result; } qcId = spectrumAnalysisMapper.getSampleId(qcFilePathName); } - if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){ + if ( !OriginalDataStore(betaDataFile, "sample", sampleFilePathName) ){ result.error500("sampleFile save failed"); return result; } @@ -3545,44 +3493,43 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } //上传本次文件到ftp人工交互存储路径下 - File sampleTmp = null; - File gasTmp = null; - File detTmp = null; - File qcTmp = null; try { - sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); - gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); - detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); - qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma"); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); - ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp)); + if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { + File sampleTmp = new File(betaDataFile.getSampleTmpPath()); + ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); + } + if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { + File gasTmp = new File(betaDataFile.getGasTmpPath()); + ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); + } + if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { + File detTmp = new File(betaDataFile.getDetTmpPath()); + ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); + } + if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) { + File qcTmp = new File(betaDataFile.getQcTmpPath()); + ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp)); + } } catch (FileNotFoundException e) { throw new RuntimeException(e); - } finally { - sampleTmp.delete(); - gasTmp.delete(); - detTmp.delete(); - qcTmp.delete(); } if (Objects.nonNull(sampleId)) { - SpectrumData sampleData = getSpectrumData(sampleId); + SpectrumData sampleData = getSpectrumData(sampleId, betaDataFile, "sample"); betaDataFile.setSampleSpectrumData(sampleData); map.put("sample", sampleData); } if (Objects.nonNull(gasId)) { - SpectrumData gasData = getSpectrumData(gasId); + SpectrumData gasData = getSpectrumData(gasId, betaDataFile, "gas"); betaDataFile.setGasSpectrumData(gasData); map.put("gas", gasData); } if (Objects.nonNull(detId)) { - SpectrumData detData = getSpectrumData(detId); + SpectrumData detData = getSpectrumData(detId, betaDataFile, "det"); betaDataFile.setDetSpectrumData(detData); map.put("det", detData); } if (Objects.nonNull(qcId)) { - SpectrumData qcData = getSpectrumData(qcId); + SpectrumData qcData = getSpectrumData(qcId, betaDataFile, "qc"); betaDataFile.setQcSpectrumData(qcData); map.put("qc", qcData); } @@ -3631,9 +3578,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements anlyseResultIn.setDetFilePath(betaDataFile.getDetFilePathName().substring(0, betaDataFile.getDetFilePathName().lastIndexOf(StringPool.SLASH))); anlyseResultIn.setQcFilePath(betaDataFile.getQcFilePathName().substring(0, betaDataFile.getQcFilePathName().lastIndexOf(StringPool.SLASH))); //处理数据 获取对应的channel/energy值 - getChannelAndEnergy(anlyseResultIn, betaList, gammaList); + getChannelAndEnergy(anlyseResultIn, betaList, gammaList, betaDataFile); //分析文件内容 - analyzeSavePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi); + analyzeSavePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi, betaDataFile); // 返回需要Save的数据 return anlyseResultIn; } @@ -3726,11 +3673,13 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements /* * 提取(saveToHtml|saveToTxt|saveToExcel)公共部分 * */ - private Map exportData(BgDataAnlyseResultIn anlyseResultIn){ + private Map exportData(BgDataAnlyseResultIn anlyseResultIn, String userName){ // 解析文件,生成导出数据 Map analyze = shiftSaveData(getSaveData(anlyseResultIn)); + Cache cache = betaCache.getBetaCache(); + BetaDataFile betaDataFile = cache.getIfPresent(anlyseResultIn.getSampleFileName() + "-" + userName); // 转换能谱结构数据 - EnergySpectrumStruct energySpectrumStruct = phdFileUtil.analyzeFileSourceData(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + EnergySpectrumStruct energySpectrumStruct = betaDataFile.getSampleStruct(); ESStructDto esStructDto = new ESStructDto(); ClassUtil.copyProperties(energySpectrumStruct, esStructDto); analyze.putAll(BeanUtil.beanToMap(esStructDto)); @@ -3741,9 +3690,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } @Override - public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) { + public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) { + String userName = JwtUtil.getUserNameByToken(request); // 解析文件,生成导出数据 - Map analyze = exportData(anlyseResultIn); + Map analyze = exportData(anlyseResultIn, userName); // 解析生成Html字符串并导出为Html文件 String result = parseHtml(analyze); PrintWriter writer = null; @@ -3765,9 +3715,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } @Override - public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) { + public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) { + String userName = JwtUtil.getUserNameByToken(request); // 解析文件,生成导出数据 - Map analyze = exportData(anlyseResultIn); + Map analyze = exportData(anlyseResultIn, userName); // 将Null值替换为"",避免空指针异常(集合为空集合,不能为null) analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); String export = "SaveToExcel.xls"; @@ -3781,9 +3732,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } @Override - public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) { + public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) { + String userName = JwtUtil.getUserNameByToken(request); // 解析文件,生成导出数据 - Map analyze = exportData(anlyseResultIn); + Map analyze = exportData(anlyseResultIn, userName); // 生成指定格式的导出数据备用 List roiChannelsDtosS = (List) analyze.get("roiChannelsS"); @@ -3970,15 +3922,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements return xeResultStrs; } - public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List betaList, List gammaList) { + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List betaList, List gammaList, BetaDataFile betaDataFile) { 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()); + sampleTmp = new File(betaDataFile.getSampleTmpPath()); + gasTmp = new File(betaDataFile.getGasTmpPath()); + detTmp = new File(betaDataFile.getDetTmpPath()); //如果勾选了Energy Calibration页面下sample Data if (Objects.nonNull(sampleTmp)) { if(anlyseResultIn.isCheckSample()) { @@ -4071,28 +4023,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } 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, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara,List betaFittingParaToUi, List gammaFittingParaToUi) { + public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara,List betaFittingParaToUi, List gammaFittingParaToUi, BetaDataFile betaDataFile) { 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()); + sampleTmp = new File(betaDataFile.getSampleTmpPath()); + gasTmp = new File(betaDataFile.getGasTmpPath()); + detTmp = new File(betaDataFile.getDetTmpPath()); //调用动态库解析文件 //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 @@ -4335,28 +4277,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } 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 analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara) { + public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List betaFittingPara, List gammaFittingPara, BetaDataFile betaDataFile) { 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()); + sampleTmp = new File(betaDataFile.getSampleTmpPath()); + gasTmp = new File(betaDataFile.getGasTmpPath()); + detTmp = new File(betaDataFile.getDetTmpPath()); //调用动态库解析文件 //Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选 //如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容 @@ -4560,16 +4492,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } catch (Exception e) { e.printStackTrace(); - } finally { - if (Objects.nonNull(sampleTmp)) { - sampleTmp.delete(); - } - if (Objects.nonNull(gasTmp)) { - gasTmp.delete(); - } - if (Objects.nonNull(detTmp)) { - detTmp.delete(); - } } } @@ -4654,74 +4576,74 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements return calibrationPairsList; } - public void getROILimit(BgDataAnlyseResultIn anlyseResultIn) { - File sampleTmp = null; - try { - //获取ftp文件路径下临时文件 - sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - if (Objects.nonNull(sampleTmp)){ - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); - List poiBX1 = sourceData.POI_B_x1; - List poiBX2 = sourceData.POI_B_x2; - List poiGY1 = sourceData.POI_G_y1; - List poiGY2 = sourceData.POI_G_y2; - //ROI Limit - List report_limit_roi = new LinkedList<>(); - for(int pos=1;pos<=poiBX1.size();pos++) { - report_limit_roi.add(String.valueOf(pos)); - } - List beginB = new LinkedList<>(); - for(int pos=1;pos<=poiBX1.size();pos++) { - beginB.add(String.valueOf(poiBX1.get(pos))); - } - List endB = new LinkedList<>(); - for(int pos=0;pos beginG = new LinkedList<>(); - for(int pos=1;pos<=poiGY1.size();pos++) { - beginG.add(String.valueOf(poiGY1.get(pos))); - } - List endG = new LinkedList<>(); - for(int pos=0;pos ratio_id = sourceData.ratio_id; - List ROI_num_highter_G_energy_ROI = sourceData.ROI_num_highter_G_energy_ROI; - List ROI_num_lower_G_energy_ROI = sourceData.ROI_num_lower_G_energy_ROI; - List count_ratio = sourceData.count_ratio; - List count_ratio_uncertainty = sourceData.count_ratio_uncertainty; - List countRatioList = new LinkedList<>(); - for(int pos=0;pos countRatioUncertaintyList = new LinkedList<>(); - for(int pos=0;pos bg_efficiency = sourceData.bg_efficiency; - List nuclide_name = sourceData.nuclide_name; - List ROI_number = sourceData.ROI_number; - List uncertainty = sourceData.uncertainty; - List efficiencyList = new LinkedList<>(); - for(int pos=0;pos uncertaintyList = new LinkedList<>(); - for(int pos=0;pos poiBX1 = sourceData.POI_B_x1; +// List poiBX2 = sourceData.POI_B_x2; +// List poiGY1 = sourceData.POI_G_y1; +// List poiGY2 = sourceData.POI_G_y2; +// //ROI Limit +// List report_limit_roi = new LinkedList<>(); +// for(int pos=1;pos<=poiBX1.size();pos++) { +// report_limit_roi.add(String.valueOf(pos)); +// } +// List beginB = new LinkedList<>(); +// for(int pos=1;pos<=poiBX1.size();pos++) { +// beginB.add(String.valueOf(poiBX1.get(pos))); +// } +// List endB = new LinkedList<>(); +// for(int pos=0;pos beginG = new LinkedList<>(); +// for(int pos=1;pos<=poiGY1.size();pos++) { +// beginG.add(String.valueOf(poiGY1.get(pos))); +// } +// List endG = new LinkedList<>(); +// for(int pos=0;pos ratio_id = sourceData.ratio_id; +// List ROI_num_highter_G_energy_ROI = sourceData.ROI_num_highter_G_energy_ROI; +// List ROI_num_lower_G_energy_ROI = sourceData.ROI_num_lower_G_energy_ROI; +// List count_ratio = sourceData.count_ratio; +// List count_ratio_uncertainty = sourceData.count_ratio_uncertainty; +// List countRatioList = new LinkedList<>(); +// for(int pos=0;pos countRatioUncertaintyList = new LinkedList<>(); +// for(int pos=0;pos bg_efficiency = sourceData.bg_efficiency; +// List nuclide_name = sourceData.nuclide_name; +// List ROI_number = sourceData.ROI_number; +// List uncertainty = sourceData.uncertainty; +// List efficiencyList = new LinkedList<>(); +// for(int pos=0;pos uncertaintyList = new LinkedList<>(); +// for(int pos=0;pos getCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { List calibrationSpectrumList = new LinkedList<>(); @@ -4903,7 +4825,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } @Transactional - public boolean OriginalDataStore(String filePath, String fileName, String filePathName, String userName) { + public boolean OriginalDataStore(BetaDataFile betaDataFile, String type, String filePathName) { //根据新的文件路径名称查询数据是否存在 GardsSampleData isExist = spectrumAnalysisMapper.findSampleByFile(filePathName); //如果数据已经存入过数据库 则 修改状态后返回 @@ -4912,27 +4834,25 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements spectrumAnalysisMapper.updateAnalysesStatus(filePathName); return true; } - //连接ftp - FTPClient ftpClient = ftpUtil.LoginFTP(); - InputStream inputStream = null; + //读取文件内容 + EnergySpectrumStruct sourceData = null; File file = null; try { - //被动模式 - ftpClient.enterLocalPassiveMode(); - //设置文件类型--二进制文件 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - //切换文件路径 - ftpClient.changeWorkingDirectory(filePath); - inputStream = ftpClient.retrieveFileStream(fileName); - if (Objects.nonNull(inputStream)){ - file = File.createTempFile("betaGamma", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - //读取文件内容 - EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + if (Objects.nonNull(betaDataFile)){ + + if (type.equalsIgnoreCase("sample")) { + file = new File(betaDataFile.getSampleTmpPath()); + sourceData = betaDataFile.getSampleStruct(); + } else if (type.equalsIgnoreCase("gas")) { + file = new File(betaDataFile.getGasTmpPath()); + sourceData = betaDataFile.getGasStruct(); + } else if (type.equalsIgnoreCase("det")) { + file = new File(betaDataFile.getDetTmpPath()); + sourceData = betaDataFile.getDetStruct(); + } else if (type.equalsIgnoreCase("qc")) { + file = new File(betaDataFile.getQcTmpPath()); + sourceData = betaDataFile.getQcStruct(); + } //获取文件中块名信息 List readLines = getFileBlockList(file); //查询台站id @@ -4983,22 +4903,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } } return true; - } catch (IOException e) { + } catch (Exception e) { throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - if (Objects.nonNull(file)) { - file.delete(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } } } @@ -5041,15 +4947,24 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements return roiResultsList; } - public SpectrumData getSpectrumData(Integer sampleId) { + public SpectrumData getSpectrumData(Integer sampleId, BetaDataFile betaDataFile, String type) { //根据 sampleId获取sampleData的数据内容 GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - //获取文件存储路径 - String inputFileName = sampleData.getInputFileName(); - //拼接完整的ftp路径 - String filePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + inputFileName; - File file = ftpUtil.downloadFile(filePath, "betaGamma"); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + File file = null; + EnergySpectrumStruct struct = null; + if (type.equalsIgnoreCase("sample")) { + file = new File(betaDataFile.getSampleTmpPath()); + struct = betaDataFile.getSampleStruct(); + } else if (type.equalsIgnoreCase("gas")) { + file = new File(betaDataFile.getGasTmpPath()); + struct = betaDataFile.getGasStruct(); + } else if (type.equalsIgnoreCase("det")) { + file = new File(betaDataFile.getDetTmpPath()); + struct = betaDataFile.getDetStruct(); + } else if (type.equalsIgnoreCase("qc")) { + file = new File(betaDataFile.getQcTmpPath()); + struct = betaDataFile.getQcStruct(); + } SpectrumData spectrumData = new SpectrumData(); try { //封装散点图下的基础数据信息