diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java index ce82e75e..09e203b7 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java @@ -32,10 +32,16 @@ public class AnalyseData implements Serializable { private CalibrationParam b_calibration_param; - private String dbName; + private List dbNames; private List sampleIds; + private List sampleFileNames; + + private List gasFileNames; + + private List detFileNames; + public AnalyseData(){ sampleData = false; GasBgData = false; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/StatisticsQueryData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/StatisticsQueryData.java index 46f287f7..23e59bcf 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/StatisticsQueryData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/StatisticsQueryData.java @@ -13,6 +13,8 @@ public class StatisticsQueryData implements Serializable { private String dbName; + private Integer detectorId; + private String detectorName; private Integer stationId; @@ -57,6 +59,6 @@ public class StatisticsQueryData implements Serializable { private String endDate; - private List detectorList; + private List detectorList; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 6d761f33..da536368 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -65,6 +65,7 @@ public class GammaFileUtil { result.error500("ftp连接失败"); return false; } + InputStream inputStream = null; //加载dll工具库 System.loadLibrary("ReadPHDFile"); try { @@ -83,7 +84,7 @@ public class GammaFileUtil { } FTPFile ftpFile = ftpFiles.get(0); if (Objects.nonNull(ftpFile)) { - InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); //声明一个临时文件 File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 @@ -242,8 +243,8 @@ public class GammaFileUtil { phd.getSetting().setECutAnalysis_Low(35.0); phd.getSetting().setBUpdateCal(true); } - phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); + phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); + phd.getSetting().setRefTime_act(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")); phd.setUsedSetting(phd.getSetting()); phd.setBAnalyed(false); @@ -259,6 +260,9 @@ public class GammaFileUtil { if (Objects.nonNull(ftpClient)){ ftpClient.disconnect(); } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -271,7 +275,6 @@ public class GammaFileUtil { String fileName = phd.getFilename(); //文件名称需要加上自动处理的前缀以及修改不同的文件后缀名 String subFileName = fileName.substring(0, fileName.lastIndexOf(StringPool.DOT)); - pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; if(StringUtils.isNotBlank(subFileName)){ //连接ftp FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -406,7 +409,7 @@ public class GammaFileUtil { j++; line = readLines.get(j); if (!line.contains("#")){ - line1 += " " + line; + line1 += StringPool.SPACE + line; }else { break; } @@ -441,7 +444,7 @@ public class GammaFileUtil { j++; line = readLines.get(j); if (!line.contains("#")){ - block_data += " " + line; + block_data += StringPool.SPACE + line; }else { break; } @@ -792,12 +795,14 @@ public class GammaFileUtil { qcState.set(3, phd.getQcItems().get("samp_vol").isBPass()?"BLUE":"RED"); if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - if(Objects.isNull(phd.getQcItems().get("Be7-FWHM"))) { + if(Objects.nonNull(phd.getQcItems().get("Be7-FWHM"))) { qcState.set(4, phd.getQcItems().get("Be7-FWHM").isBPass()?"BLUE":"RED"); + } + if(Objects.nonNull(phd.getQcItems().get("Ba140-MDC"))) { qcState.set(5, phd.getQcItems().get("Ba140-MDC").isBPass()?"BLUE":"RED"); } } else if(phd.getHeader().getSystem_type().equalsIgnoreCase("G")) { - if(Objects.isNull(phd.getQcItems().get("Xe133-MDC"))) { + if(Objects.nonNull(phd.getQcItems().get("Xe133-MDC"))) { qcState.set(6, phd.getQcItems().get("Xe133-MDC").isBPass()?"BLUE":"RED"); } } @@ -807,13 +812,13 @@ public class GammaFileUtil { public void RunQC(PHDFile phd){ System.loadLibrary("GammaAnaly"); try { - Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); - Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); + Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()); + Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time()); + Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()); - double collect_hour = (start.getTime()/1000 - end.getTime()/1000) / 3600.0; + double collect_hour = (end.getTime()/1000 - start.getTime()/1000) / 3600.0; double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0; - double Decay_hour = (end.getTime()/1000 - acq.getTime()/1000) / 3600.0; + double Decay_hour = (acq.getTime()/1000 - end.getTime()/1000) / 3600.0; Double ener_Be7 = 0.0; Map vMdcInfoMap = new HashMap<>(); @@ -912,9 +917,9 @@ public class GammaFileUtil { if(vMdcInfo.size() < 3 || vMdcInfo.get(2) == 0) { return 0.0; } - Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + 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 Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); // 衰变时间 double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间 @@ -1146,18 +1151,18 @@ public class GammaFileUtil { detailInfo.set(5, phd.getHeader().getSpectrum_quantity()); // Spectral_Qualifier detailInfo.set(6, phd.getHeader().getSample_ref_id()); // SRID detailInfo.set(7, phd.getStatus()); // Sample_Status - String collect_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)); + String collect_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)); Date collect_stop_dt = DateUtils.parseDate(collect_stop,"yyyy/MM/dd HH:mm:ss"); - detailInfo.set(8, phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time()); - Date date = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); + detailInfo.set(8, phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()); + Date date = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)),"yyyy/MM/dd HH:mm:ss"); double timeSpan = (collect_stop_dt.getTime()/1000 - date.getTime()/1000) / 3600.0; detailInfo.set(9, String.format("%.2f", timeSpan));// Sampling_Time detailInfo.set(10, String.format("%.2f", phd.getCollect().getAir_volume())); if(timeSpan != 0){ detailInfo.set(11, String.format("%.2f", phd.getCollect().getAir_volume()/timeSpan)); } - detailInfo.set(12, phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); - String start_time = phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)); + detailInfo.set(12, phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()); + String start_time = phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)); Date start_date = DateUtils.parseDate(start_time, "yyyy/MM/dd HH:mm:ss"); detailInfo.set(13, String.format("%.2f", phd.getAcq().getAcquisition_real_time())); detailInfo.set(14, String.format("%.2f", phd.getAcq().getAcquisition_live_time())); @@ -1771,9 +1776,9 @@ public class GammaFileUtil { private boolean CalculateMDCs(PHDFile phd, NuclideActMda nucActMda, int mainPeakIdx, double lambda, double keyLineYield, double CCF){ // 计算衰变校正因子——DCF try { - Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0, phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + 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 Td = collectStop.getTime()/1000 - acqStart.getTime()/1000; // 衰变时间 double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间 @@ -2015,7 +2020,7 @@ public class GammaFileUtil { // Polynomial: y=a0+a1*x+a2*x^2+a3*x^3 equation +="Energy = "+m_curParam.getP().get(1)+" + C * "+m_curParam.getP().get(2); for(int i=3; i<=p_size; ++i) { - equation += " + C" + (i-1) +" * "+m_curParam.getP().get(i)+""; + equation += " + C" + (i-1) +" * "+m_curParam.getP().get(i)+""; } } else if(p_size == 1) { equation = "Energy = "+m_curParam.getP().get(1)+" * C"; @@ -2081,9 +2086,9 @@ public class GammaFileUtil { // Square root of polynomial: y = sqrt(a0+a1*x+a2*x^2+a3*x^3 ) equation += "FWHM = ("+m_curParam.getP().get(1)+" + E * "+m_curParam.getP().get(2); for(int i=3; i<=p_size; ++i) { - equation += " + E"+(i-1)+" * "+m_curParam.getP().get(i); + equation += " + E"+(i-1)+" * "+m_curParam.getP().get(i); } - equation += ")"+1+"/"+2+""; + equation += ")"+1+"/"+2+""; } return equation; } @@ -2177,15 +2182,15 @@ public class GammaFileUtil { for(int i=1; i<=p_size; ++i) { if(m_curParam.getP().get(i) <= 0) break; } - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1-exp(-("+m_curParam.getP().get(4)+" / E)"+m_curParam.getP().get(5)+"))"; + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1-exp(-("+m_curParam.getP().get(4)+" / E)"+m_curParam.getP().get(5)+"))"; } break; case 6: // Polynomial in log(y) against log(x): log(y) = a0 + a1*log(x) +a2*log(x)^2+ a3*log(x)^3 if(p_size >= 2) { equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(E)"; for(int i=3; i<=p_size; ++i) { - equation += " + "+m_curParam.getP().get(i)+" * log(E)"+(i-1)+""; + equation += " + "+m_curParam.getP().get(i)+" * log(E)"+(i-1)+""; } } break; @@ -2193,27 +2198,27 @@ public class GammaFileUtil { if(p_size >= 3) { equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(C/E)"; for(int i=3; i<=p_size; ++i) { - equation += " + "+m_curParam.getP().get(i)+" * log(C/E)"+(i-1)+""; + equation += " + "+m_curParam.getP().get(i)+" * log(C/E)"+(i-1)+""; } } break; case 93: // HAE Efficiency (1-3): y=S*exp(-(E1/x)^k)*(1- exp(-(2*E3/(x-E3))^n)) if(p_size == 5) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-(2 * "+m_curParam.getP().get(4)+" / (E - "+m_curParam.getP().get(4)+"))"+m_curParam.getP().get(5)+"))"; + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-(2 * "+m_curParam.getP().get(4)+" / (E - "+m_curParam.getP().get(4)+"))"+m_curParam.getP().get(5)+"))"; } break; case 94: // HAE Efficiency (1-2): y=S*exp(-(E1/x)^k)*(1- exp(-b*(1/(x-E2))^m)) if(p_size == 6) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+"))"; + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+"))"; } break; case 95: // HAE Efficiency (1-2-3): y = S * exp(-(E1/x)^k) * (1- exp(-b*(1/(x-E2))^m)) *(1 - exp(-(2*E3/(E-E3))^n)) if(p_size == 8) { - equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ - "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+")) * "+ - "(1 - exp(-(2 * "+m_curParam.getP().get(7)+" / (E - "+m_curParam.getP().get(7)+"))"+m_curParam.getP().get(8)+"))"; + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+")) * "+ + "(1 - exp(-(2 * "+m_curParam.getP().get(7)+" / (E - "+m_curParam.getP().get(7)+"))"+m_curParam.getP().get(8)+"))"; } break; } @@ -2606,27 +2611,27 @@ public class GammaFileUtil { strBuffer.append(" \n"); strBuffer.append(" Nuclide Halflife(s) Activity(Bq) RelErr% MDA(Bq) Conc(uBq/m^3) MDC\n"); for (int i=0; i nucline,GStoreMiddleProcessData middleData, String type) throws ParseException { boolean bRet=true; - //标准名称规范化 String dataType = fileAnlyse.getMsgInfo().getData_type(); String subDirSavePath = ""; @@ -3343,8 +3347,8 @@ public class GammaFileUtil { } //sample info - middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+" "+fileAnlyse.getCollect().getCollection_start_time(); - middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+" "+fileAnlyse.getCollect().getCollection_stop_time(); + middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time(); + middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time(); if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) { middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); @@ -3359,7 +3363,7 @@ public class GammaFileUtil { middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue()); } middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume()); - middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+" "+fileAnlyse.getAcq().getAcquisition_start_time(); + middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time(); String acquisition_start = middleData.sample_acquisiton_start; Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss"); @@ -3408,7 +3412,7 @@ public class GammaFileUtil { halflife /= 3600; units = 'H'; } - tableNuclideActivity.setHalfLife(halflife+" "+units); + tableNuclideActivity.setHalfLife(halflife+StringPool.SPACE+units); tableNuclideActivity.setEnergy(nuc.getVEnergy().get(nuc.getCalculateIdx()).toString()); tableNuclideActivity.setYield(String.valueOf(nuc.getVYield().get(nuc.getCalculateIdx())*100)); @@ -3436,7 +3440,7 @@ public class GammaFileUtil { } public String RightFill(String str, int fieldWidth) { - String fillChar = " "; + String fillChar = StringPool.SPACE; int fillNum = fieldWidth - str.length(); while(fillNum > 0) { str+=fillChar; @@ -3450,11 +3454,11 @@ public class GammaFileUtil { spectrum.append("BEGIN IMS2.0\r\n"); spectrum.append("MSG_TYPE "+phd.getMsgInfo().getMsg_type()+"\r\n"); - spectrum.append("MSG_ID "+phd.getMsgInfo().getMsg_id()+" "+phd.getMsgInfo().getMsg_src_code()+"\r\n"); + spectrum.append("MSG_ID "+phd.getMsgInfo().getMsg_id()+StringPool.SPACE+phd.getMsgInfo().getMsg_src_code()+"\r\n"); if(phd.getMsgInfo().isVerify_srid()) { spectrum.append("REF_ID\r\n"); - spectrum.append(phd.getMsgInfo().getRef_id_str()+" "+phd.getMsgInfo().getRef_src_code()+" "+phd.getMsgInfo().getSeq_num()+" "+phd.getMsgInfo().getTot_num()+"\r\n"); - spectrum.append("PROD_ID "+phd.getMsgInfo().getProduct_id()+" "+phd.getMsgInfo().getDelivery_id()+"\r\n"); + spectrum.append(phd.getMsgInfo().getRef_id_str()+StringPool.SPACE+phd.getMsgInfo().getRef_src_code()+StringPool.SPACE+phd.getMsgInfo().getSeq_num()+StringPool.SPACE+phd.getMsgInfo().getTot_num()+"\r\n"); + spectrum.append("PROD_ID "+phd.getMsgInfo().getProduct_id()+StringPool.SPACE+phd.getMsgInfo().getDelivery_id()+"\r\n"); } spectrum.append("DATA_TYPE "+phd.getMsgInfo().getData_type()+"\r\n"); @@ -3475,13 +3479,13 @@ public class GammaFileUtil { // #Header spectrum.append("#Header "+phd.getHeader().getDesignator()+"\r\n"); spectrum.append(RightFill(phd.getHeader().getSite_code(), 5)+ - " "+RightFill(phd.getHeader().getDetector_code(), 9)+ - " "+RightFill(phd.getHeader().getSystem_type().toUpperCase(), 1)+ - " "+RightFill(phd.getHeader().getSample_geometry(), 17)+ - " "+RightFill(phd.getHeader().getSpectrum_quantity(), 4)+"\r\n"); + StringPool.SPACE+RightFill(phd.getHeader().getDetector_code(), 9)+ + StringPool.SPACE+RightFill(phd.getHeader().getSystem_type().toUpperCase(), 1)+ + StringPool.SPACE+RightFill(phd.getHeader().getSample_geometry(), 17)+ + StringPool.SPACE+RightFill(phd.getHeader().getSpectrum_quantity(), 4)+"\r\n"); spectrum.append(phd.getHeader().getSample_ref_id() + "\r\n"); - spectrum.append(RightFill(phd.getHeader().getMeasurement_id(), 31)+" "+RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31)+" "+phd.getHeader().getGas_bk_measurement_id()+"\r\n"); - spectrum.append(phd.getHeader().getTransmit_date()+" "+phd.getHeader().getTransmit_time()+"\r\n"); + spectrum.append(RightFill(phd.getHeader().getMeasurement_id(), 31)+StringPool.SPACE+RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31)+StringPool.SPACE+phd.getHeader().getGas_bk_measurement_id()+"\r\n"); + spectrum.append(phd.getHeader().getTransmit_date()+StringPool.SPACE+phd.getHeader().getTransmit_time()+"\r\n"); // #Comment if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { @@ -3493,21 +3497,21 @@ public class GammaFileUtil { // #Collection spectrum.append("#Collection\r\n"); - spectrum.append(phd.getCollect().getCollection_start_date()+" "+phd.getCollect().getCollection_start_time()+ - " "+phd.getCollect().getCollection_stop_date()+" "+phd.getCollect().getCollection_stop_time()+" "+phd.getCollect().getAir_volume()+"\r\n"); + spectrum.append(phd.getCollect().getCollection_start_date()+StringPool.SPACE+phd.getCollect().getCollection_start_time()+ + StringPool.SPACE+phd.getCollect().getCollection_stop_date()+StringPool.SPACE+phd.getCollect().getCollection_stop_time()+StringPool.SPACE+phd.getCollect().getAir_volume()+"\r\n"); // #Acquisition spectrum.append("#Acquisition\r\n"); - spectrum.append(phd.getAcq().getAcquisition_start_date()+" "+phd.getAcq().getAcquisition_start_time()+ - " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ - " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); + spectrum.append(phd.getAcq().getAcquisition_start_date()+StringPool.SPACE+phd.getAcq().getAcquisition_start_time()+ + StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ + StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); // #Processing if(phd.getProcess().getSample_volume_of_Xe() > 0) { spectrum.append("#Processing\r\n"); - spectrum.append(RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8)+"\r\n"+ - " "+RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8)+"\r\n"+ - " "+phd.getProcess().getArchive_bottle_id()+"\r\n"); + spectrum.append(RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8)+StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8)+"\r\n"+ + StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8)+StringPool.SPACE+RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8)+"\r\n"+ + StringPool.SPACE+phd.getProcess().getArchive_bottle_id()+"\r\n"); } // #Sample @@ -3525,22 +3529,22 @@ public class GammaFileUtil { int fieldWidth = 12; for(int i=0; i 0) { + bd = bd.setScale(0, RoundingMode.HALF_UP); + } else { + bd = bd.setScale(1, RoundingMode.HALF_UP); + } rData = "_S_"+Fulltype+"_"+bd+".PHD"; } else if(dataType.contains(DataType.GASBKPHD.getType())){ bd = bd.setScale(1, RoundingMode.HALF_UP); 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 5b98b13e..267c3eac 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 @@ -8,10 +8,16 @@ import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.jeecg.common.properties.SpectrumPathProperties; +import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataTypeAbbr; +import org.jeecg.modules.base.enums.XeNuclideName; +import org.jeecg.modules.entity.GardsCalibrationSpectrum; +import org.jeecg.modules.entity.GardsROIChannelsSpectrum; +import org.jeecg.modules.entity.GardsROIResultsSpectrum; import org.jeecg.modules.entity.GardsXeResultsSpectrum; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.native_jni.EnergySpectrumHandler; +import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.BgBoundary; import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; @@ -507,7 +513,6 @@ public class PHDFileUtil { String measurementName = nameStandUtil.GetFileNameFromDateTime(measurementId, fileSuffix); String gasFileName = nameStandUtil.GetFileNameFromDateTime(gasBkMeasurementId, "_G.PHD"); String detaFileName = nameStandUtil.GetFileNameFromDateTime(detectorBkMeasurementId, "_D.PHD"); - map.put("measurementName", measurementName); map.put("gasFileName", gasFileName); map.put("detaFileName", detaFileName); map.put("sampleSystemType", systemType); @@ -740,5 +745,239 @@ public class PHDFileUtil { 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); + //获取路径下所有文件信息 + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + if (CollectionUtils.isNotEmpty(ftpFiles)){ + //根据文件名称 分别获取 sample gas det文件 + List files = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(files)){ + FTPFile ftpFile = files.get(0); + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + file = File.createTempFile("tmp", 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 BgDataAnlyseResultIn analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, Map map) { + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + //调用动态库解析文件 + BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + BgDataAnlyseResultIn resultIn = new BgDataAnlyseResultIn(); + resultIn.setXe131m_con(bgAnalyseResult.Xe131m_con); + resultIn.setXe131m_uncer(bgAnalyseResult.Xe131m_uncer); + resultIn.setMDC_Xe131m(bgAnalyseResult.MDC_Xe131m); + resultIn.setLC_Xe131m(bgAnalyseResult.LC_Xe131m); + resultIn.setXe131mFlag(bgAnalyseResult.XE_131m_NID_FLAG); + resultIn.setXe133_con(bgAnalyseResult.Xe133_con); + resultIn.setXe133_uncer(bgAnalyseResult.Xe133_uncer); + resultIn.setMDC_Xe133(bgAnalyseResult.MDC_Xe133); + resultIn.setLC_Xe133(bgAnalyseResult.LC_Xe133); + resultIn.setXe133Flag(bgAnalyseResult.XE_133_NID_FLAG); + resultIn.setXe133m_con(bgAnalyseResult.Xe133m_con); + resultIn.setXe133m_uncer(bgAnalyseResult.Xe133m_uncer); + resultIn.setMDC_Xe133m(bgAnalyseResult.MDC_Xe133m); + resultIn.setLC_Xe133m(bgAnalyseResult.LC_Xe133m); + resultIn.setXe133mFlag(bgAnalyseResult.XE_133m_NID_FLAG); + resultIn.setXe135_con(bgAnalyseResult.Xe135_con); + resultIn.setXe135_uncer(bgAnalyseResult.Xe135_uncer); + resultIn.setMDC_Xe135(bgAnalyseResult.MDC_Xe135); + resultIn.setLC_Xe135(bgAnalyseResult.LC_Xe135); + resultIn.setXe135Flag(bgAnalyseResult.XE_135_NID_FLAG); + + List gammaCalibrationSpectrumList = new LinkedList<>(); + GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); + gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_e_c.get(0)); + gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_e_c.get(1)); + gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_e_c.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationS); + GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); + gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_e_c.get(0)); + gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_e_c.get(1)); + gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_e_c.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationG); + GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); + gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_e_c.get(0)); + gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_e_c.get(1)); + gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_e_c.get(2)); + gammaCalibrationSpectrumList.add(gammaCalibrationD); + List betaCalibrationSpectrumList = new LinkedList<>(); +// GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); +// betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); +// betaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); +// betaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); +// betaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); +// betaCalibrationSpectrumList.add(betaCalibrationS); +// GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); +// betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); +// betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); +// betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); +// betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); +// betaCalibrationSpectrumList.add(betaCalibrationG); +// GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); +// betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); +// betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); +// betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); +// betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); +// betaCalibrationSpectrumList.add(betaCalibrationD); + List roiChannelsSpectrumList = new LinkedList<>(); + for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); + for (int i=0; ibgAnalyseResult.MDC.get(i)) { +// roiResults.setNidFlag(1); +// } else { +// roiResults.setNidFlag(0); +// } + roiResultsSpectrumList.add(roiResults); + } + map.put("gammaCalibrationSpectrumList", gammaCalibrationSpectrumList); + map.put("betaCalibrationSpectrumList", betaCalibrationSpectrumList); + map.put("roiChannelsSpectrumList", roiChannelsSpectrumList); + map.put("roiResultsSpectrumList", roiResultsSpectrumList); + map.put("bProcessed", true); + return resultIn; + } + + public EnergySpectrumStruct analyzeFileSourceData(String filePath, String fileName) { + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + EnergySpectrumStruct struct = new EnergySpectrumStruct(); + FTPClient ftpClient = ftpUtil.LoginFTP(); + InputStream inputStream = null; + try { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(filePath); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(ftpFiles)){ + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)){ + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", 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(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return struct; + } + + public List analyzeQCResultXe(File sampleTmp, File gasTmp, File detTmp){ + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + //调用动态库解析文件 + BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + List xeResultsSpectrumList = new LinkedList<>(); + GardsXeResultsSpectrum Xe131m = new GardsXeResultsSpectrum(); + Xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + Xe131m.setMdc(bgAnalyseResult.MDC_Xe131m); + Xe131m.setConc(bgAnalyseResult.Xe131m_con); + Xe131m.setConcErr(bgAnalyseResult.Xe131m_uncer); + Xe131m.setLc(bgAnalyseResult.LC_Xe131m); + xeResultsSpectrumList.add(Xe131m); + GardsXeResultsSpectrum Xe133 = new GardsXeResultsSpectrum(); + Xe133.setNuclideName(XeNuclideName.XE_133.getType()); + Xe133.setMdc(bgAnalyseResult.MDC_Xe133); + Xe133.setConc(bgAnalyseResult.Xe133_con); + Xe133.setConcErr(bgAnalyseResult.Xe133_uncer); + Xe133.setLc(bgAnalyseResult.LC_Xe133); + xeResultsSpectrumList.add(Xe133); + GardsXeResultsSpectrum Xe133m = new GardsXeResultsSpectrum(); + Xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + Xe133m.setMdc(bgAnalyseResult.MDC_Xe133m); + Xe133m.setConc(bgAnalyseResult.Xe133m_con); + Xe133m.setConcErr(bgAnalyseResult.Xe133m_uncer); + Xe133m.setLc(bgAnalyseResult.LC_Xe133m); + xeResultsSpectrumList.add(Xe133m); + GardsXeResultsSpectrum Xe135 = new GardsXeResultsSpectrum(); + Xe135.setNuclideName(XeNuclideName.XE_135.getType()); + Xe135.setMdc(bgAnalyseResult.MDC_Xe135); + Xe135.setConc(bgAnalyseResult.Xe135_con); + Xe135.setConcErr(bgAnalyseResult.Xe135_uncer); + Xe135.setLc(bgAnalyseResult.LC_Xe135); + xeResultsSpectrumList.add(Xe135); + return xeResultsSpectrumList; + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java index bbee4e4a..eb6b0bde 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/UserTaskUtil.java @@ -21,7 +21,7 @@ public class UserTaskUtil { * 根据用户名称查询当前用户是否有权限操作当前台站的信息 * @return */ - public boolean checkUserStation(Integer stationId, String userName){ + public boolean checkUserStation(Integer stationId, String userName) { boolean flag = false; //根据用户名称查询用户id SysUser user = userTaskService.findUserByName(userName); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index d2ed282b..e2141efc 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -42,6 +42,12 @@ public class GammaController { @Autowired private IGammaService gammaService; + @GetMapping("initValue") + @ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据") + public Result initValue(Integer sampleId, String dbName) { + return gammaService.initValue(sampleId, dbName); + } + @GetMapping("gammaByDB") public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName){ return gammaService.gammaByDB(dbName, sampleId); @@ -119,10 +125,10 @@ public class GammaController { return gammaService.addPeakComment(commentsInfo.getFileName(), commentsInfo.getCurRow(), commentsInfo.getComments()); } - @GetMapping("viewGenralComment") + @GetMapping("viewGeneralComment") @ApiOperation(value = "InteractiveTool页面查看备注信息接口", notes = "InteractiveTool页面查看备注信息接口") - public Result viewGenralComment(String fileName) { - return gammaService.viewGenralComment(fileName); + public Result viewGeneralComment(String fileName) { + return gammaService.viewGeneralComment(fileName); } @PostMapping("addGeneralComment") @@ -179,8 +185,8 @@ public class GammaController { @GetMapping("energyCalibration") @ApiOperation(value = "查看Energy Calibration数据", notes = "查看Energy Calibration数据") - public Result energyCalibration(@RequestParam Integer sampleId, String fileName) { - return gammaService.energyCalibration(sampleId, fileName); + public Result energyCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { + return gammaService.energyCalibration(sampleId, fileName, currentText); } @PostMapping("changeDataEnergy") @@ -197,8 +203,8 @@ public class GammaController { @GetMapping("resolutionCalibration") @ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据") - public Result resolutionCalibration(@RequestParam Integer sampleId, String fileName) { - return gammaService.resolutionCalibration(sampleId, fileName); + public Result resolutionCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { + return gammaService.resolutionCalibration(sampleId, fileName, currentText); } @PostMapping("changeDataResolution") @@ -215,8 +221,8 @@ public class GammaController { @GetMapping("EfficiencyCalibration") @ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据") - public Result EfficiencyCalibration(@RequestParam Integer sampleId, String fileName) { - return gammaService.EfficiencyCalibration(sampleId, fileName); + public Result EfficiencyCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { + return gammaService.EfficiencyCalibration(sampleId, fileName, currentText); } @PostMapping("changeDataEfficiency") 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 dfe1e77d..78177f4a 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 @@ -76,8 +76,8 @@ public class SpectrumAnalysesController { @GetMapping("viewComment") @ApiOperation(value = "查看comment数据", notes = "查看comment数据") - public Result viewComment(Integer sampleId, HttpServletRequest request) { - return spectrumAnalysisService.viewComment(sampleId, request); + public Result viewComment(Integer sampleId, String sampleFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewComment(sampleId, sampleFileName, request); } @GetMapping("viewARR") @@ -86,46 +86,46 @@ public class SpectrumAnalysesController { spectrumAnalysisService.viewARR(sampleId, response); } - @GetMapping("viewRRR") + @PostMapping("viewRRR") @ApiOperation(value = "查看RRR报告", notes = "查看RRR报告") - public Result viewRRR(String dbName, Integer sampleId, boolean sampleData, boolean GasBgData, boolean DetBgData, boolean QCData, boolean bGammaEnergyValid, boolean bBetaEnergyValid) { - return spectrumAnalysisService.viewRRR(dbName, sampleId, sampleData, GasBgData, DetBgData, QCData, bGammaEnergyValid, bBetaEnergyValid); + public Result viewRRR(@RequestBody RRRLogInfo rrrLogInfo, HttpServletRequest request) { + return spectrumAnalysisService.viewRRR(rrrLogInfo, request); } @GetMapping("viewSpectrum") @ApiOperation(value = "查看Spectrum数据", notes = "查看Spectrum数据") - public Result viewSpectrum(Integer sampleId) { - return spectrumAnalysisService.viewSpectrum(sampleId); + public Result viewSpectrum(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewSpectrum(sampleId, dbName, sampleFileName, gasFileName, detFileName, qcFileName, request); } @GetMapping("viewSampleInformation") @ApiOperation(value = "查看SampleInformation数据", notes = "查看SampleInformation数据") - public Result viewSampleInformation(Integer sampleId){ - return spectrumAnalysisService.viewSampleInformation(sampleId); + public Result viewSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewSampleInformation(sampleId, sampleFileName, request); } @GetMapping("exportSampleInformation") @ApiOperation(value = "导出SampleInformation数据", notes = "导出SampleInformation数据") - public void exportSampleInformation(Integer sampleId, HttpServletResponse response){ - spectrumAnalysisService.exportSampleInformation(sampleId,response); + public void exportSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request, HttpServletResponse response){ + spectrumAnalysisService.exportSampleInformation(sampleId, sampleFileName, request,response); } @GetMapping("viewQCResult") @ApiOperation(value = "查看QC Result数据", notes = "查看QC Result数据") - public Result viewQCResult(Integer sampleId){ - return spectrumAnalysisService.viewQCResult(sampleId); + public Result viewQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewQCResult(sampleId, dbName, sampleFileName, gasFileName ,detFileName, request); } @GetMapping("exportQCResult") @ApiOperation(value = "导出QC Result数据", notes = "导出QC Result数据") - public void exportQCResult(Integer sampleId,HttpServletResponse response){ - spectrumAnalysisService.exportQCResult(sampleId,response); + public void exportQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response){ + spectrumAnalysisService.exportQCResult(sampleId, dbName, sampleFileName, gasFileName ,detFileName, request,response); } @GetMapping("viewRLR") @ApiOperation(value = "查看RLR数据", notes = "查看RLR数据") - public Result viewRLR(Integer sampleId) { - return spectrumAnalysisService.viewRLR(sampleId); + public Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewRLR(sampleId, sampleFileName, gasFileName, detFileName, request); } @GetMapping("exportRLR") @@ -136,26 +136,26 @@ public class SpectrumAnalysesController { @GetMapping("viewGammaDetectorCalibration") @ApiOperation(value = "查询GammaDetectorCalibration数据", notes = "查询GammaDetectorCalibration数据") - public Result viewGammaDetectorCalibration(Integer sampleId) { - return spectrumAnalysisService.viewGammaDetectorCalibration(sampleId); + public Result viewGammaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewGammaDetectorCalibration(sampleId, qcFileName, request); } @GetMapping("viewBetaDetectorCalibration") @ApiOperation(value = "查询BetaDetectorCalibration数据", notes = "查询BetaDetectorCalibration数据") - public Result viewBetaDetectorCalibration(Integer sampleId) { - return spectrumAnalysisService.viewBetaDetectorCalibration(sampleId); + public Result viewBetaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewBetaDetectorCalibration(sampleId, qcFileName, request); } @GetMapping("viewExtrapolation") @ApiOperation(value = "查询Extrapolation数据", notes = "查询Extrapolation数据") - public Result viewExtrapolation(Integer sampleId) { - return spectrumAnalysisService.viewExtrapolation(sampleId); + public Result viewExtrapolation(Integer sampleId, String sampleFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewExtrapolation(sampleId, sampleFileName, request); } @GetMapping("viewMDC") @ApiOperation(value = "查看MDC数据", notes = "查看MDC数据") - public Result viewMDC(Integer sampleId) { - return spectrumAnalysisService.viewMDC(sampleId); + public Result viewMDC(Integer sampleId, String sampleFileName, HttpServletRequest request) { + return spectrumAnalysisService.viewMDC(sampleId, sampleFileName, request); } @GetMapping("changeDetector") @@ -172,8 +172,8 @@ public class SpectrumAnalysesController { @GetMapping("statisticsQueryBtn") @ApiOperation(value = "报警按钮分析数据", notes = "报警按钮分析数据") - public Result statisticsQueryBtn(String detectorName, Integer stationId, String statisticsType, @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { - return spectrumAnalysisService.statisticsQueryBtn(detectorName, stationId, statisticsType, startTime, endTime); + public Result statisticsQueryBtn(Integer detectorId, String detectorName, Integer stationId, String statisticsType, @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + return spectrumAnalysisService.statisticsQueryBtn(detectorId, detectorName, stationId, statisticsType, startTime, endTime); } @PostMapping("fitting") @@ -184,8 +184,8 @@ public class SpectrumAnalysesController { @GetMapping("getGammaGated") @ApiOperation(value = "获取gamma对应count数据", notes = "获取gamma对应count数据") - public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId) { - return spectrumAnalysisService.getGammaGated(chartHeight, channelWidth, gammaChannel, sampleId); + public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, HttpServletRequest request) { + return spectrumAnalysisService.getGammaGated(chartHeight, channelWidth, gammaChannel, sampleId, qcFileName, request); } @PostMapping("ReAnalyse") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationPairsSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationPairsSpectrum.java index 7bf8041b..c2005096 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationPairsSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationPairsSpectrum.java @@ -58,4 +58,9 @@ public class GardsCalibrationPairsSpectrum implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date moddate; + /** + * 数据类型 + */ + private String dataType; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationSpectrum.java index b27866e6..4c5f4075 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsCalibrationSpectrum.java @@ -104,4 +104,9 @@ public class GardsCalibrationSpectrum implements Serializable { private String coeffString; + /** + * 数据类型 + */ + private String dataType; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsROIChannelsSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsROIChannelsSpectrum.java index c9e083de..c20aa34f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsROIChannelsSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsROIChannelsSpectrum.java @@ -50,4 +50,6 @@ public class GardsROIChannelsSpectrum implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date moddate; + private String dataType; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java index 608ee41a..c671c694 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgDataAnlyseResultIn.java @@ -13,6 +13,11 @@ public class BgDataAnlyseResultIn implements Serializable { */ private String comment; + /** + * 标识本次操作是否进行过解析 + */ + private boolean bProcessed; + /** * 分析员名称 */ @@ -200,5 +205,24 @@ public class BgDataAnlyseResultIn implements Serializable { private int Xe135Flag; + private List s_roi_cts; + + private List LC; + + private List g_roi_cts; + + private List d_roi_cts; + + private List s_deduct_d_cts; + + private List g_deduct_d_cts; + + private List ROI_net_coutns; + + private List ROI_net_err; + + private List ROI_con_uncer; + + private List MDC; } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/RRRLogInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/RRRLogInfo.java new file mode 100644 index 00000000..caaf08de --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/RRRLogInfo.java @@ -0,0 +1,47 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; +import org.jeecg.modules.entity.GardsCalibrationSpectrum; +import org.jeecg.modules.entity.GardsROIChannelsSpectrum; +import org.jeecg.modules.entity.GardsROIResultsSpectrum; +import org.jeecg.modules.entity.GardsXeResultsSpectrum; + +import java.io.Serializable; +import java.util.List; + +@Data +public class RRRLogInfo implements Serializable { + + private String dbName; + + private Integer sampleId; + + private boolean sampleData; + + private boolean gasBgData; + + private boolean detBgData; + + private boolean qcData; + + private boolean bGammaEnergyValid; + + private boolean bBetaEnergyValid; + + private String sampleFileName; + + private String gasFileName; + + private String detFileName; + + private List roiChannelsSpectrumList; + + private List roiResultsSpectrumList; + + private List xeResultsSpectrumList; + + private List gammaCalibrationParamList; + + private List betaCalibrationParamList; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index b2d27224..04819932 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.base.entity.configuration.GardsDetectors; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; @@ -39,17 +40,17 @@ public interface SpectrumAnalysisMapper { GardsSampleDataSpectrum findSampleByFilePath(@Param(value = "filePath") String filePath); - List getDetectorList(@Param(value = "stationId") Integer stationId); + List getDetectorList(@Param(value = "stationId") Integer stationId); List statisticsQueryNuclides(@Param(value = "statisticsQueryData") StatisticsQueryData statisticsQueryData); - List statisticsQueryCollection(String startDate, String endDate, List detectorList); + List statisticsQueryCollection(String startDate, String endDate, List detectorList); - List statisticsQueryAcquisition(String startDate, String endDate, List detectorList); + List statisticsQueryAcquisition(String startDate, String endDate, List detectorList); - List statisticsQueryXeVolumn(String startDate, String endDate, List detectorList); + List statisticsQueryXeVolumn(String startDate, String endDate, List detectorList); - List statisticsQuerySampleVolumn(String startDate, String endDate, List detectorList); + List statisticsQuerySampleVolumn(String startDate, String endDate, List detectorList); String getStatus(@Param(value = "sampleId") Integer sampleId); @@ -77,9 +78,13 @@ public interface SpectrumAnalysisMapper { Integer getAnalysisID(@Param(value = "dbName") String dbName, @Param(value = "sampleId") Integer sampleId); - GardsCalibrationSpectrum ReadGammaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); + List ReadGammaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); - GardsCalibrationSpectrum ReadBetaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); + List ReadGammaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); + + List ReadBetaFitChannelEnergy(@Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); + + List ReadBetaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); List ReadROIChannels(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); @@ -139,6 +144,8 @@ public interface SpectrumAnalysisMapper { void insertXeResult(List xeResults); + void deleteROIResults(Integer idAnalysis); + String getIdAnalysisByIdAnalyst(@Param(value = "sampleId") String sampleId, @Param(value = "userName") String userName); void deletePeaks(Integer idAnalysis); 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 9768fb49..8fc657af 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 @@ -120,7 +120,7 @@ TRIM(org_sample.SITE_DET_CODE) siteDetCode, org_sample.COLLECT_START collectStart FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample, - ${dbName} analyses + ${dbName}.GARDS_ANALYSES analyses analyses.SAMPLE_ID = #{sampleId} AND org_sample.SAMPLE_ID=analyses.SAMPLE_ID @@ -218,8 +218,8 @@ - + SELECT DETECTOR_ID,DETECTOR_CODE FROM CONFIGURATION.GARDS_DETECTORS WHERE STATION_ID = #{stationId} + + + + @@ -566,7 +596,6 @@ ${dbName}.GARDS_ROI_RESULTS ROI_RESULTS WHERE ROI_RESULTS.IDANALYSIS = #{idAnalysis} - AND ROI_RESULTS.SAMPLE_ID = #{sampleId} ORDER BY ROI_RESULTS.ROI ASC @@ -582,7 +611,6 @@ ${dbName}.GARDS_XE_RESULTS XE_RESULTS WHERE XE_RESULTS.IDANALYSIS = #{idAnalysis} - AND XE_RESULTS.SAMPLE_ID = #{sampleId} SELECT IDANALYSIS FROM RNMAN.GARDS_ANALYSES WHERE SAMPLE_ID = #{sampleId} AND ANALYST = #{userName} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java index 9e65494f..0cf767be 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java @@ -3,6 +3,7 @@ package org.jeecg.modules.native_jni.struct; import java.util.List; public class BgAnalyseResult { + /************************** GARDS_XE_RESULTS START**************************/ /************************** XE_131m **************************/ public double Xe131m_con; @@ -44,36 +45,39 @@ public class BgAnalyseResult { public List ROI_net_coutns_err; public List ROI_con_uncer; public List ROI_con_uncer_err; - - public List MDC; + public List MDC; public List dNidFlag; /************************** GARDS_ROI_RESULTS end **************************/ - /************************** GARDS_ROI_RESULTS START**************************/ + /************************** GARDS_CALIBRATION START**************************/ + public List s_b_fitting_c_e; public List s_b_fitting_e_c; public int s_b_fitting_type; public String s_b_fitting_type_def; + public List s_g_fitting_c_e; public List s_g_fitting_e_c; public int s_g_fitting_type; public String s_g_fitting_type_def; - + public List g_b_fitting_c_e; public List g_b_fitting_e_c; public int g_b_fitting_type; public String g_b_fitting_type_def; + public List g_g_fitting_c_e; public List g_g_fitting_e_c; public int g_g_fitting_type; public String g_g_fitting_type_def; - + public List d_b_fitting_c_e; public List d_b_fitting_e_c; public int d_b_fitting_type; public String d_b_fitting_type_def; + public List d_g_fitting_c_e; public List d_g_fitting_e_c; public int d_g_fitting_type; public String d_g_fitting_type_def; /************************** GARDS_CALIBRATION end **************************/ - /************************** GARDS_CALIBRATION START**************************/ + /************************** GARDS_ROI_CHANNELS START**************************/ public List S_ROI; public List S_ROI_B_Boundary_start; public List S_ROI_B_Boundary_stop; @@ -174,4 +178,5 @@ public class BgAnalyseResult { ", error_log='" + error_log + '\'' + '}'; } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 0dc4930e..2e9cf877 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -39,7 +39,7 @@ public interface IGammaService{ Result addPeakComment(String fileName, int curRow, String comments); - Result viewGenralComment(String fileName); + Result viewGeneralComment(String fileName); Result addGeneralComment(String fileName, String comments); @@ -57,19 +57,19 @@ public interface IGammaService{ List KorSumInput(CoeffData coeffData); - Result energyCalibration(Integer sampleId, String fileName); + Result energyCalibration(Integer sampleId, String fileName, String currentText); Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); Result applyDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); - Result resolutionCalibration(Integer sampleId, String fileName); + Result resolutionCalibration(Integer sampleId, String fileName, String currentText); Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); Result applyDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); - Result EfficiencyCalibration(Integer sampleId, String fileName); + Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText); Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName); 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 e2c56c37..c37156fd 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 @@ -27,43 +27,43 @@ public interface ISpectrumAnalysisService { Result deleteDBSpectrumChartData(Integer[] sampleIds); - Result viewComment(Integer sampleId, HttpServletRequest request); + Result viewComment(Integer sampleId, String sampleFileName, HttpServletRequest request); void viewARR(Integer sampleId, HttpServletResponse response); - Result viewRRR(String dbName, Integer sampleId, boolean sampleData, boolean GasBgData, boolean DetBgData, boolean QCData, boolean bGammaEnergyValid, boolean bBetaEnergyValid); + Result viewRRR(RRRLogInfo rrrLogInfo, HttpServletRequest request); - Result viewSpectrum(Integer sampleId); + Result viewSpectrum(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request); - Result viewSampleInformation(Integer sampleId); + Result viewSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request); - void exportSampleInformation(Integer sampleId, HttpServletResponse response); + void exportSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request, HttpServletResponse response); - Result viewQCResult(Integer sampleId); + Result viewQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request); - void exportQCResult(Integer sampleId, HttpServletResponse response); + void exportQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response); - Result viewRLR(Integer sampleId); + Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request); void exportRLR(Integer sampleId, HttpServletResponse response); - Result viewGammaDetectorCalibration(Integer sampleId); + Result viewGammaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request); - Result viewBetaDetectorCalibration(Integer sampleId); + Result viewBetaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request); - Result viewExtrapolation(Integer sampleId); + Result viewExtrapolation(Integer sampleId, String sampleFileName, HttpServletRequest request); - Result viewMDC(Integer sampleId); + Result viewMDC(Integer sampleId, String sampleFileName, HttpServletRequest request); Result changeDetector(String stationName); Result statisticsQuery(StatisticsQueryData statisticsQueryData); - Result statisticsQueryBtn(String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime); + Result statisticsQueryBtn(Integer detectorId, String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime); Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count); - Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId); + Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, HttpServletRequest request); Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index c751402c..d705a233 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 @@ -340,6 +340,8 @@ public class GammaServiceImpl implements IGammaService { map.put("barChart", differance); //赋值energy map.put("energy", phd.getVEnergy()); + //赋值BaseCtrls + map.put("BaseCtrls", phd.getBaseCtrls()); result.setSuccess(true); result.setResult(map); return result; @@ -672,7 +674,7 @@ public class GammaServiceImpl implements IGammaService { return result; } int index = list_identify.indexOf(nuclideName); - if(index>0) { + if(index>=0) { // 如果所选的行下标小于0 或者 超出界限 则不进行处理 if(curRow < 0 || curRow >= phd.getVPeak().size()) { return result; @@ -734,7 +736,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result viewGenralComment(String fileName) { + public Result viewGeneralComment(String fileName) { Result result = new Result(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -948,7 +950,7 @@ public class GammaServiceImpl implements IGammaService { } // date of Zero Time - Date datetime = DateUtils.parseDate(date + " " + time, "yyyy-MM-dd HH:mm:ss"); + Date datetime = DateUtils.parseDate(date + StringPool.SPACE + time); Date oriDate = DateUtils.parseDate("1970-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss"); double second = (datetime.getTime()/1000 - oriDate.getTime()/1000) - t - 8*60*60; @@ -1061,7 +1063,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result energyCalibration(Integer sampleId, String fileName) { + public Result energyCalibration(Integer sampleId, String fileName, String currentText) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1071,14 +1073,16 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - String usedEner = phd.getUsedEner(); + if (StringUtils.isBlank(currentText)) { + currentText = phd.getUsedEner(); + } List dataSourceList = phd.getMapEnerKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); - List m_vCurCentroid = phd.getMapEnerKD().get(usedEner).getCentroid_channel(); - List m_vCurEnergy = phd.getMapEnerKD().get(usedEner).getG_energy(); - List m_vCurUncert = phd.getMapEnerKD().get(usedEner).getUncertainty(); + List m_vCurCentroid = phd.getMapEnerKD().get(currentText).getCentroid_channel(); + List m_vCurEnergy = phd.getMapEnerKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapEnerKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = phd.getMapEnerPara().get(usedEner); + ParameterInfo m_curParam = phd.getMapEnerPara().get(currentText); map.put("param", m_curParam); int num = m_vCurEnergy.size(); if(num < 1){ @@ -1099,6 +1103,8 @@ public class GammaServiceImpl implements IGammaService { String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam); map.put("equation", equation); gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, map); + map.put("rg_low", phd.getBaseCtrls().getRg_low()); + map.put("rg_high", phd.getBaseCtrls().getRg_high()); result.setSuccess(true); result.setResult(map); return result; @@ -1193,7 +1199,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result resolutionCalibration(Integer sampleId, String fileName) { + public Result resolutionCalibration(Integer sampleId, String fileName, String currentText) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1203,20 +1209,21 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - String usedReso = phd.getUsedReso(); + if (StringUtils.isBlank(currentText)) { + currentText = phd.getUsedReso(); + } List dataSourceList = phd.getMapResoKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); - List m_vCurReso = phd.getMapResoKD().get(usedReso).getFWHM(); - List m_vCurEnergy = phd.getMapResoKD().get(usedReso).getG_energy(); - List m_vCurUncert = phd.getMapResoKD().get(usedReso).getUncertainty(); + List m_vCurReso = phd.getMapResoKD().get(currentText).getFWHM(); + List m_vCurEnergy = phd.getMapResoKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapResoKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = phd.getMapResoPara().get(usedReso); + ParameterInfo m_curParam = phd.getMapResoPara().get(currentText); map.put("param", m_curParam); int num = m_vCurEnergy.size(); if(num < 1){ return result; } - List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; List resolutionDataList = new LinkedList<>(); for(int i=0; i map = new HashMap<>(); List m_vFuncName = new LinkedList<>(); @@ -1335,20 +1344,21 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - String usedEffi = phd.getUsedEffi(); + if (StringUtils.isBlank(currentText)) { + currentText = phd.getUsedEffi(); + } List dataSourceList = phd.getMapEffiKD().keySet().stream().collect(Collectors.toList()); map.put("list_dataSource", dataSourceList); - List m_vCurEffi = phd.getMapEffiKD().get(usedEffi).getEfficiency(); - List m_vCurEnergy = phd.getMapEffiKD().get(usedEffi).getG_energy(); - List m_vCurUncert = phd.getMapEffiKD().get(usedEffi).getUncertainty(); + List m_vCurEffi = phd.getMapEffiKD().get(currentText).getEfficiency(); + List m_vCurEnergy = phd.getMapEffiKD().get(currentText).getG_energy(); + List m_vCurUncert = phd.getMapEffiKD().get(currentText).getUncertainty(); map.put("uncert", m_vCurUncert); - ParameterInfo m_curParam = phd.getMapEffiPara().get(usedEffi); + ParameterInfo m_curParam = phd.getMapEffiPara().get(currentText); map.put("param", m_curParam); int num = m_vCurEnergy.size(); if(num < 1){ return result; } - List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; List efficiencyDataList = new LinkedList<>(); for(int i=0; i map = new HashMap<>(); try { - String collect_start = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); - String collect_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time(); - String acq_start = phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time(); + String collect_start = phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time(); + String collect_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time(); + String acq_start = phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time(); Date collect_stop_dt = DateUtils.parseDate(collect_stop); Date collect_start_dt = DateUtils.parseDate(collect_start); double Sampling_Time = (collect_stop_dt.getTime()/1000 - collect_start_dt.getTime()/1000) / 3600.0; @@ -1935,8 +1947,8 @@ public class GammaServiceImpl implements IGammaService { map.put("Obj_authorized", "High-resolution non-destructive gamma spectroscopy."); map.put("Obj_instruction", "`0"); // Init #Collection - String col_start = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); - String col_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time(); + String col_start = phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time(); + String col_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time(); map.put("collect_start", col_start); map.put("collect_stop", col_stop); map.put("collect_airVolume", phd.getCollect().getAir_volume()); 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 d335357c..f7a39fb6 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 @@ -2,7 +2,6 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; @@ -14,25 +13,22 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; -import org.apache.poi.ss.usermodel.Workbook; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.util.*; +import org.jeecg.modules.base.entity.configuration.GardsDetectors; import org.jeecg.modules.base.entity.original.*; import org.jeecg.modules.base.enums.*; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.EnergySpectrumHandler; -import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.BgBoundary; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; -import org.jeecgframework.poi.excel.ExcelExportUtil; -import org.jeecgframework.poi.excel.entity.ExportParams; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -45,7 +41,8 @@ import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; -import static org.jeecg.modules.base.enums.ExportTemplate.*; +import static org.jeecg.modules.base.enums.ExportTemplate.QcResult_B; +import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_B; @Service("spectrumAnalysisService") @DS("ora") @@ -218,7 +215,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { throw new RuntimeException(e); } finally { try { - ftpClient.disconnect(); + if (Objects.nonNull(ftpClient)) { + ftpClient.disconnect(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -254,7 +253,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.error500("ftp文件查询失败"); return result; } - String sampleFileName = fileData.get("measurementName"); + String sampleFileName = fileName; String sampleSystemType = fileData.get("sampleSystemType"); if (sampleSystemType.equals(SystemType.BETA.getType())) { //加载并获取当前路径下所有的文件名称并进行名称格式化 仅需要格式化和sample文件同一个台站 名称格式化为最终名称 @@ -313,22 +312,47 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { public Result getDBSpectrumChart(String dbName, Integer sampleId) { Result result = new Result(); Map resultMap = new HashMap<>(); + List gammaCalibrationSpectrumList= new LinkedList<>(); + List betaCalibrationSpectrumList = new LinkedList<>(); + List roiChannelsSpectrumList = new LinkedList<>(); + List roiResultsSpectrumList = new LinkedList<>(); + List gammaCalibrationPairsList = new LinkedList<>(); + List betaCalibrationPairsList = new LinkedList<>(); + List xeResultsSpectrumList = new LinkedList<>(); if (Objects.isNull(sampleId)){ result.error500("请选择一条数据"); return result; } if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO.GARDS_ANALYSES"; + dbName = "RNAUTO"; + Integer idAnalysis = spectrumAnalysisMapper.getAnalysisID("RNAUTO", sampleId); + gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNAUTO", idAnalysis, sampleId); + betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNAUTO", idAnalysis, sampleId); + roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNAUTO", idAnalysis, sampleId); + roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNAUTO", idAnalysis, sampleId); + xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults("RNAUTO", idAnalysis, sampleId); }else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN.GARDS_ANALYSES"; + dbName = "RNMAN"; + Integer idAnalysis = spectrumAnalysisMapper.getAnalysisID("RNMAN", sampleId); + gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(idAnalysis, sampleId); + gammaCalibrationSpectrumList = spectrumAnalysisMapper.ReadGammaCalibrationParam("RNMAN", idAnalysis, sampleId); + betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(idAnalysis, sampleId); + betaCalibrationSpectrumList = spectrumAnalysisMapper.ReadBetaCalibrationParam("RNMAN", idAnalysis, sampleId); + roiChannelsSpectrumList = spectrumAnalysisMapper.ReadROIChannels("RNMAN", idAnalysis, sampleId); + roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNMAN", idAnalysis, sampleId); + xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults("RNMAN", idAnalysis, sampleId); + resultMap.put("gammaCalibrationPairsList", gammaCalibrationPairsList); + resultMap.put("betaCalibrationPairsList", betaCalibrationPairsList); }else { result.error500("数据库类型不存在"); return result; } + resultMap.put("gammaCalibrationSpectrumList", gammaCalibrationSpectrumList); + resultMap.put("betaCalibrationSpectrumList", betaCalibrationSpectrumList); + resultMap.put("roiChannelsSpectrumList", roiChannelsSpectrumList); + resultMap.put("roiResultsSpectrumList", roiResultsSpectrumList); //查询数据库文件信息 SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); - //查询数据库中结果的Xe数据 - List xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); List filePath = new LinkedList<>(); if (Objects.nonNull(dbSpectrumFilePath)) { Map sampleMap = new HashMap<>(); @@ -341,7 +365,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsSampleData sample = spectrumAnalysisMapper.findSampleByFilePath(sampleFilePath); String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - sampleMap = this.fenxi(pathName, fileName, xeDataList, sample.getSampleId(), sample.getStatus()); + sampleMap = this.fenxi(pathName, fileName, xeResultsSpectrumList, sample.getSampleId(), sample.getStatus()); resultMap.put("sample",sampleMap); } if(StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){ @@ -350,7 +374,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsSampleData gasBg = spectrumAnalysisMapper.findSampleByFilePath(gasBgFilePath); String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasBgFilePath.substring(0, gasBgFilePath.lastIndexOf(StringPool.SLASH)); String fileName = gasBgFilePath.substring(gasBgFilePath.lastIndexOf(StringPool.SLASH)+1); - gasBgMap = this.fenxi(pathName, fileName, xeDataList, gasBg.getSampleId(), gasBg.getStatus()); + gasBgMap = this.fenxi(pathName, fileName, xeResultsSpectrumList, gasBg.getSampleId(), gasBg.getStatus()); resultMap.put("gasBg",gasBgMap); } if(StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())){ @@ -359,7 +383,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsSampleData detBg = spectrumAnalysisMapper.findSampleByFilePath(detBgFilePath); String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detBgFilePath.substring(0, detBgFilePath.lastIndexOf(StringPool.SLASH)); String fileName = detBgFilePath.substring(detBgFilePath.lastIndexOf(StringPool.SLASH)+1); - detBgMap = this.fenxi(pathName, fileName, xeDataList, detBg.getSampleId(), detBg.getStatus()); + detBgMap = this.fenxi(pathName, fileName, xeResultsSpectrumList, detBg.getSampleId(), detBg.getStatus()); resultMap.put("detBg",detBgMap); } String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); @@ -370,11 +394,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { GardsSampleData qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); String fileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); - qcMap = this.fenxi(pathName, fileName, xeDataList, qc.getSampleId(), qc.getStatus()); + qcMap = this.fenxi(pathName, fileName, xeResultsSpectrumList, qc.getSampleId(), qc.getStatus()); resultMap.put("qc",qcMap); } phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); + resultMap.put("bProcessed", false); resultMap.put("savedAnalysisResult", true); + } else { + resultMap.clear(); } result.setSuccess(true); result.setResult(resultMap); @@ -416,6 +443,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { resultMap.put("qc",qcMap); } phdFileUtil.getLightColor(sampleMap,gasBgMap,detBgMap,qcMap); + resultMap.put("bProcessed", false); resultMap.put("savedAnalysisResult", false); result.setSuccess(true); result.setResult(resultMap); @@ -482,13 +510,31 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewComment(Integer sampleId, HttpServletRequest request) { + public Result viewComment(Integer sampleId, String sampleFileName, HttpServletRequest request) { Result result = new Result(); CommentInfo commentInfo = new CommentInfo(); + //根据请求体获取当前登录用户名 String userName = JwtUtil.getUserNameByToken(request); - String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - String pathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + //上传路径 + String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + //判断sampleId是否为空 如果不为空 则当前操作数据来源是数据库 文件路径从数据库中查询 + if (Objects.nonNull(sampleId)) { + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + CommentData commentData = spectrumAnalysisMapper.viewComment(sampleId); + if (Objects.nonNull(commentData)){ + if (!commentData.getAnalyst().equals(userName)){ + if (StringUtils.isNotBlank(commentData.getComment())){ + String line = "------------------------------------------------------------"; + String comment = line+"\n[ User "+commentData.getAnalyst()+" Comment ] : \n"+commentData.getComment()+"\n"+line+" \n"; + commentInfo.setSpectrumOtherCommentInfo(comment); + } + }else { + commentInfo.setSpectrumAnalysisCommentInfo(commentData.getComment()); + } + } + } + //连接ftp FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); @@ -502,10 +548,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 ftpClient.setControlEncoding("UTF-8"); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; ftpClient.changeWorkingDirectory(pathName); List ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(sampleFileName)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(ftpFiles)){ result.error500("ftp下对应文件不存在"); return result; @@ -536,18 +581,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { throw new RuntimeException(e); } } - CommentData commentData = spectrumAnalysisMapper.viewComment(sampleId); - if (Objects.nonNull(commentData)){ - if (!commentData.getAnalyst().equals(userName)){ - if (StringUtils.isNotBlank(commentData.getComment())){ - String line = "------------------------------------------------------------"; - String comment = line+"\n[ User "+commentData.getAnalyst()+" Comment ] : \n"+commentData.getComment()+"\n"+line+" \n"; - commentInfo.setSpectrumOtherCommentInfo(comment); - } - }else { - commentInfo.setSpectrumAnalysisCommentInfo(commentData.getComment()); - } - } result.setSuccess(true); result.setResult(commentInfo); return result; @@ -614,222 +647,114 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewRRR(String dbName, Integer sampleId, boolean sampleData, boolean GasBgData, boolean DetBgData, boolean QCData, boolean bGammaEnergyValid, boolean bBetaEnergyValid) { + public Result viewRRR(RRRLogInfo rrrLogInfo, HttpServletRequest request) { Result result = new Result(); - //GetAnalysisID sample_id - if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO"; - }else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN"; + String userName = JwtUtil.getUserNameByToken(request); + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + GardsCalibrationSpectrum gammaCalibrationParamS = new GardsCalibrationSpectrum(); + GardsCalibrationSpectrum gammaCalibrationParamG = new GardsCalibrationSpectrum(); + GardsCalibrationSpectrum gammaCalibrationParamD = new GardsCalibrationSpectrum(); + GardsCalibrationSpectrum betaCalibrationParamS = new GardsCalibrationSpectrum(); + GardsCalibrationSpectrum betaCalibrationParamG = new GardsCalibrationSpectrum(); + GardsCalibrationSpectrum betaCalibrationParamD = new GardsCalibrationSpectrum(); + String sampleFilePath = ""; + String gasFilePath = ""; + String detFilePath = ""; + if (StringUtils.isNotBlank(rrrLogInfo.getDbName()) && Objects.nonNull(rrrLogInfo.getSampleId())) { + String dbName = rrrLogInfo.getDbName(); + Integer sampleId = rrrLogInfo.getSampleId(); + //GetAnalysisID sample_id + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + }else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + } + Integer analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId); + SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); + if (Objects.nonNull(dbSpectrumFilePath)){ + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + } + } else { + sampleFilePath = path; + gasFilePath = path; + detFilePath = path; + } + List channelsSpectrums = rrrLogInfo.getRoiChannelsSpectrumList(); + List resultsSpectrums = rrrLogInfo.getRoiResultsSpectrumList(); + List xeResultsSpectrums = rrrLogInfo.getXeResultsSpectrumList(); + //#SAMPLE: LIMITS PER ROI GAMMA + List gammaCalibrationParamList = rrrLogInfo.getGammaCalibrationParamList(); + for (int i=0; i betaCalibrationParamList = rrrLogInfo.getBetaCalibrationParamList(); + for (int i=0; i ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(ftpFiles)){ - result.error500("ftp下对应文件不存在"); - return result; - } - FTPFile ftpFile = ftpFiles.get(0); - if (Objects.nonNull(ftpFile)){ - inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - - information.setSample_measid_name(struct.measurement_id); - information.setSample_det_measid_name(struct.detector_bk_measurement_id); - information.setSample_gas_measid_name(struct.gas_bk_measurement_id); - information.setSit_det_code(struct.site_code); - information.setSample_type(struct.system_type); - information.setGeometry(struct.sample_geometry); - information.setSpectral_qualifie(struct.spectrum_quantity); - String transmit_dtg_str=struct.transmit_date+" "+struct.transmit_time; - Date transmit_dtg = DateUtils.parseDate(transmit_dtg_str); - information.setTransmit_dtg(transmit_dtg); - information.setDetect_code(struct.detector_code); - information.setMeasurementID(struct.measurement_id.replace("\\","/")); - information.setBkgdMeasurementID(struct.detector_bk_measurement_id.replace("\\","/")); - information.setGasBkgdMeasurementID(struct.gas_bk_measurement_id.replace("\\","/")); - information.setSampleRefId(struct.sample_ref_id); - String collect_start_str = struct.collection_start_date+" "+struct.collection_start_time; - Date collect_start = DateUtils.parseDate(collect_start_str); - information.setCollect_start(collect_start); - String collect_stop_str = struct.collection_stop_date+" "+struct.collection_stop_time; - Date collect_stop = DateUtils.parseDate(collect_stop_str); - information.setCollect_stop(collect_stop); - information.setS_xe_stable_volume(struct.air_volume); - String acquisition_start_str = struct.acquisition_start_date+" "+struct.acquisition_start_time; - Date acquisition_start = DateUtils.parseDate(acquisition_start_str); - information.setAcquisition_start(acquisition_start); - long dataTime = (long) (acquisition_start.getTime() + struct.acquisition_live_time * 1000); - String acquisition_stop_str = DateUtils.formatDate(new Date(dataTime), "yyyy-MM-dd HH:mm:ss"); - Date acquisition_stop = DateUtils.parseDate(acquisition_stop_str); - information.setAcquisition_stop(acquisition_stop); - information.setAcquisition_real_sec(struct.acquisition_real_time); - information.setAcquisition_live_sec(struct.acquisition_live_time); - information.setS_volume_of_Xe(struct.sample_volume_of_Xe); - } - } catch (IOException e) { - throw new RuntimeException(e); - } catch (ParseException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (ObjectUtil.isNotNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){ - String filePath = dbSpectrumFilePath.getGasBgFilePath(); - String pathName = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH)); - String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH)+1); - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return result; - } - InputStream inputStream = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; - ftpClient.changeWorkingDirectory(pathName); - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(ftpFiles)){ - result.error500("ftp下对应文件不存在"); - return result; - } - FTPFile ftpFile = ftpFiles.get(0); - if (Objects.nonNull(ftpFile)){ - inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - - information.setGas_measid_name(struct.measurement_id); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (ObjectUtil.isNotNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())){ - String filePath = dbSpectrumFilePath.getDetBgFilePath(); - String pathName = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH)); - String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH)+1); - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return result; - } - InputStream inputStream = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; - ftpClient.changeWorkingDirectory(pathName); - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(ftpFiles)){ - result.error500("ftp下对应文件不存在"); - return result; - } - FTPFile ftpFile = ftpFiles.get(0); - if (Objects.nonNull(ftpFile)){ - inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - - information.setDet_measid_name(struct.measurement_id); - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (ObjectUtil.isNotNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } + if (StringUtils.isNotBlank(sampleFilePath)){ + try { + EnergySpectrumStruct sampleSourceData = phdFileUtil.analyzeFileSourceData(sampleFilePath, rrrLogInfo.getSampleFileName()); + information.setSample_measid_name(sampleSourceData.measurement_id); + information.setSample_det_measid_name(sampleSourceData.detector_bk_measurement_id); + information.setSample_gas_measid_name(sampleSourceData.gas_bk_measurement_id); + information.setSit_det_code(sampleSourceData.site_code); + information.setSample_type(sampleSourceData.system_type); + information.setGeometry(sampleSourceData.sample_geometry); + information.setSpectral_qualifie(sampleSourceData.spectrum_quantity); + String transmit_dtg_str=sampleSourceData.transmit_date+StringPool.SPACE+sampleSourceData.transmit_time; + Date transmit_dtg = DateUtils.parseDate(transmit_dtg_str); + information.setTransmit_dtg(transmit_dtg); + information.setDetect_code(sampleSourceData.detector_code); + information.setMeasurementID(sampleSourceData.measurement_id.replace("\\","/")); + information.setBkgdMeasurementID(sampleSourceData.detector_bk_measurement_id.replace("\\","/")); + information.setGasBkgdMeasurementID(sampleSourceData.gas_bk_measurement_id.replace("\\","/")); + information.setSampleRefId(sampleSourceData.sample_ref_id); + String collect_start_str = sampleSourceData.collection_start_date+StringPool.SPACE+sampleSourceData.collection_start_time; + Date collect_start = DateUtils.parseDate(collect_start_str); + information.setCollect_start(collect_start); + String collect_stop_str = sampleSourceData.collection_stop_date+StringPool.SPACE+sampleSourceData.collection_stop_time; + Date collect_stop = DateUtils.parseDate(collect_stop_str); + information.setCollect_stop(collect_stop); + information.setS_xe_stable_volume(sampleSourceData.air_volume); + String acquisition_start_str = sampleSourceData.acquisition_start_date+StringPool.SPACE+sampleSourceData.acquisition_start_time; + Date acquisition_start = DateUtils.parseDate(acquisition_start_str); + information.setAcquisition_start(acquisition_start); + long dataTime = (long) (acquisition_start.getTime() + sampleSourceData.acquisition_live_time * 1000); + String acquisition_stop_str = DateUtils.formatDate(new Date(dataTime), "yyyy/MM/dd HH:mm:ss"); + Date acquisition_stop = DateUtils.parseDate(acquisition_stop_str); + information.setAcquisition_stop(acquisition_stop); + information.setAcquisition_real_sec(sampleSourceData.acquisition_real_time); + information.setAcquisition_live_sec(sampleSourceData.acquisition_live_time); + information.setS_volume_of_Xe(sampleSourceData.sample_volume_of_Xe); + } catch (ParseException e) { + throw new RuntimeException(e); } } - //#SAMPLE: LIMITS PER ROI GAMMA - GardsCalibrationSpectrum gammaCalibrationParam = spectrumAnalysisMapper.ReadGammaCalibrationParam(dbName, analysisID, sampleId); - //#SAMPLE: LIMITS PER ROI BETA - GardsCalibrationSpectrum betaCalibrationParam = spectrumAnalysisMapper.ReadBetaCalibrationParam(dbName, analysisID, sampleId); - //#SAMPLE: LIMITS PER ROI - List channelsSpectrums = spectrumAnalysisMapper.ReadROIChannels(dbName, analysisID, sampleId); - //#GROSS COUNTS PER ROI - List resultsSpectrums = spectrumAnalysisMapper.ReadROIResults(dbName, analysisID, sampleId); - //#RESULT SUMMARY - List xeResultsSpectrums = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId); + if (StringUtils.isNotBlank(gasFilePath)){ + EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, rrrLogInfo.getGasFileName()); + information.setGas_measid_name(gasSourceData.measurement_id); + } + if (StringUtils.isNotBlank(detFilePath)){ + EnergySpectrumStruct detSourceData = phdFileUtil.analyzeFileSourceData(detFilePath, rrrLogInfo.getDetFileName()); + information.setDet_measid_name(detSourceData.measurement_id); + } StringBuffer strBuffer = new StringBuffer(); strBuffer.append("CNL06 GENERATED REPORT").append("\n"); strBuffer.append("REVIEWED RADIONUCLIDE REPORT").append("\n"); @@ -861,7 +786,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { strBuffer.append("\n"); strBuffer.append("#SAMPLE Old CALIBRATION").append("\n"); strBuffer.append(" Old Beta Old Gamma ").append("\n"); - if (sampleData){ + if (rrrLogInfo.isSampleData()){ strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); }else { @@ -872,17 +797,17 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { strBuffer.append("#SAMPLE New CALIBRATION").append("\n"); strBuffer.append(" New Beta New Gamma ").append("\n"); strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); - strBuffer.append(" E(x) = ("+betaCalibrationParam.getCoeff1()+")+("+betaCalibrationParam.getCoeff2()+")*x+("+betaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n"); + strBuffer.append(" E(x) = ("+betaCalibrationParamS.getCoeff1()+")+("+betaCalibrationParamS.getCoeff2()+")*x+("+betaCalibrationParamS.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParamS.getCoeff1()+")+("+gammaCalibrationParamS.getCoeff2()+")*x+("+gammaCalibrationParamS.getCoeff3()+")x*x").append("\n"); strBuffer.append("\n"); strBuffer.append("#SAMPLE: LIMITS PER ROI").append("\n"); strBuffer.append(" Roi Beta Gamma ").append("\n"); for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) { - strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); + strBuffer.append(StringPool.SPACE+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); } strBuffer.append("\n"); strBuffer.append("#DET Old CALIBRATION").append("\n"); strBuffer.append(" Old Beta Old Gamma ").append("\n"); - if (DetBgData){ + if (rrrLogInfo.isDetBgData()){ strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); }else { @@ -893,17 +818,17 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { strBuffer.append("#DET New CALIBRATION").append("\n"); strBuffer.append(" New Beta New Gamma ").append("\n"); strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); - strBuffer.append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n"); + strBuffer.append(" E(x) = ("+gammaCalibrationParamD.getCoeff1()+")+("+gammaCalibrationParamD.getCoeff2()+")*x+("+gammaCalibrationParamD.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParamD.getCoeff1()+")+("+gammaCalibrationParamD.getCoeff2()+")*x+("+gammaCalibrationParamD.getCoeff3()+")x*x").append("\n"); strBuffer.append("\n"); strBuffer.append("#DET: LIMITS PER ROI").append("\n"); strBuffer.append(" Roi Beta Gamma ").append("\n"); for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) { - strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); + strBuffer.append(StringPool.SPACE+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); } strBuffer.append("\n"); strBuffer.append("#GAS Old CALIBRATION").append("\n"); strBuffer.append(" Old Beta Old Gamma ").append("\n"); - if (GasBgData){ + if (rrrLogInfo.isGasBgData()){ strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); }else { @@ -914,36 +839,36 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { strBuffer.append("#GAS New CALIBRATION").append("\n"); strBuffer.append(" New Beta New Gamma ").append("\n"); strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n"); - strBuffer.append(" E(x) = ("+betaCalibrationParam.getCoeff1()+")+("+betaCalibrationParam.getCoeff2()+")*x+("+betaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n"); + strBuffer.append(" E(x) = ("+betaCalibrationParamG.getCoeff1()+")+("+betaCalibrationParamG.getCoeff2()+")*x+("+betaCalibrationParamG.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParamG.getCoeff1()+")+("+gammaCalibrationParamG.getCoeff2()+")*x+("+gammaCalibrationParamG.getCoeff3()+")x*x").append("\n"); strBuffer.append("\n"); strBuffer.append("#GAS: LIMITS PER ROI").append("\n"); strBuffer.append(" Roi Beta Gamma ").append("\n"); for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) { - strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); + strBuffer.append(StringPool.SPACE+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n"); } strBuffer.append("\n"); strBuffer.append("#GROSS COUNTS PER ROI").append("\n"); strBuffer.append(" Roi Sample GasBkgnd DetBkgnd ").append("\n"); for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums) { - strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getSGross()+" "+resultsSpectrum.getGGross()+" "+resultsSpectrum.getBGross()+"").append("\n"); + strBuffer.append(StringPool.SPACE+resultsSpectrum.getRoi()+" "+resultsSpectrum.getSGross()+" "+resultsSpectrum.getGGross()+" "+resultsSpectrum.getBGross()+"").append("\n"); } strBuffer.append("\n"); strBuffer.append("#NET COUNTS AND LC PER ROI").append("\n"); strBuffer.append(" Roi Net count ").append("\n"); for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){ - strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getNet()+" +/- "+Math.sqrt(resultsSpectrum.getNetErr())).append("\n"); + strBuffer.append(StringPool.SPACE+resultsSpectrum.getRoi()+" "+resultsSpectrum.getNet()+" +/- "+Math.sqrt(resultsSpectrum.getNetErr())).append("\n"); } strBuffer.append("\n"); strBuffer.append("#CONCENTRATION AND LC PER ROI").append("\n"); strBuffer.append(" Roi Conc(mBq/m3) LC(mBq/m3) MDC(mBq/m3): "); for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){ - strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getConcErr()+" +/- "+resultsSpectrum.getConcErr()+" "+resultsSpectrum.getLc()+" "+resultsSpectrum.getMdc()).append("\n"); + strBuffer.append(StringPool.SPACE+resultsSpectrum.getRoi()+" "+resultsSpectrum.getConcErr()+" +/- "+resultsSpectrum.getConcErr()+" "+resultsSpectrum.getLc()+" "+resultsSpectrum.getMdc()).append("\n"); } strBuffer.append("\n"); strBuffer.append("#RESULT SUMMARY").append("\n"); strBuffer.append(" Nuclide Name Conc LC MDC NID Flag ").append("\n"); for (GardsXeResultsSpectrum xeResultsSpectrum:xeResultsSpectrums) { - strBuffer.append(" "+xeResultsSpectrum.getNuclideName()+" "+xeResultsSpectrum.getConc()+" +/- "+xeResultsSpectrum.getConcErr()+" "+xeResultsSpectrum.getLc()+" "+xeResultsSpectrum.getMdc()+" "+xeResultsSpectrum.getNidFlag()).append("\n"); + strBuffer.append(StringPool.SPACE+xeResultsSpectrum.getNuclideName()+" "+xeResultsSpectrum.getConc()+" +/- "+xeResultsSpectrum.getConcErr()+" "+xeResultsSpectrum.getLc()+" "+xeResultsSpectrum.getMdc()+" "+xeResultsSpectrum.getNidFlag()).append("\n"); } strBuffer.append("\n"); @@ -953,33 +878,51 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewSpectrum(Integer sampleId) { + public Result viewSpectrum(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map> map = new HashMap<>(); - String dbName = "RNAUTO.GARDS_ANALYSES"; - SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); - if (Objects.nonNull(dbSpectrumFilePath)) { - if(StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ - String sampleFilePath = StringPool.SLASH+ spectrumPathProperties.getRootPath() +StringPool.SLASH+dbSpectrumFilePath.getSampleFilePath(); - List lines = phdFileUtil.readLine(sampleFilePath); - map.put("sample", lines); + SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) { + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + }else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; } - if(StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){ - String gasBgFilePath = StringPool.SLASH+ spectrumPathProperties.getRootPath() +StringPool.SLASH+dbSpectrumFilePath.getGasBgFilePath(); - List lines = phdFileUtil.readLine(gasBgFilePath); - map.put("gasBg", lines); + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); + } + if(StringUtils.isNotBlank(sampleFileName)) { + String sampleFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName + StringPool.SLASH + sampleFileName; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())) { + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath(); } - if(StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())){ - String detBgFilePath = StringPool.SLASH+ spectrumPathProperties.getRootPath() +StringPool.SLASH+dbSpectrumFilePath.getDetBgFilePath(); - List lines = phdFileUtil.readLine(detBgFilePath); - map.put("detBg", lines); + List lines = phdFileUtil.readLine(sampleFilePath); + map.put("sample", lines); + } + if(StringUtils.isNotBlank(gasFileName)) { + String gasBgFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName + StringPool.SLASH + gasFileName; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { + gasBgFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath(); } - String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - String dbQcFilePath = StringPool.SLASH+ spectrumPathProperties.getRootPath() +StringPool.SLASH+spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); - if(StringUtils.isNotBlank(dbQcFilePath)){ - List lines = phdFileUtil.readLine(dbQcFilePath); - map.put("qc", lines); + List lines = phdFileUtil.readLine(gasBgFilePath); + map.put("gasBg", lines); + } + if(StringUtils.isNotBlank(detFileName)) { + String detBgFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName + StringPool.SLASH + detFileName; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { + detBgFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath(); } + List lines = phdFileUtil.readLine(detBgFilePath); + map.put("detBg", lines); + } + if (StringUtils.isNotBlank(qcFileName)) { + String dbQcFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName + StringPool.SLASH + qcFileName; + if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) { + String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + dbQcFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); + } + List lines = phdFileUtil.readLine(dbQcFilePath); + map.put("qc", lines); } result.setSuccess(true); result.setResult(map); @@ -987,12 +930,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewSampleInformation(Integer sampleId) { - Result result = new Result(); - String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - if (StringUtils.isNotBlank(sampleFilePath)){ - String pathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + public Result viewSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + if (Objects.nonNull(sampleId)) { + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + } + if (StringUtils.isNotBlank(sampleFileName)){ FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); @@ -1006,10 +952,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 ftpClient.setControlEncoding("UTF-8"); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; ftpClient.changeWorkingDirectory(pathName); List ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(sampleFileName)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(ftpFiles)){ result.error500("ftp下对应的文件不存在"); return result; @@ -1030,7 +975,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleRefId = struct.sample_ref_id; String sit_det_code = struct.site_code; String detect_code = struct.detector_code; - String sample_id = sampleId.toString(); + String sample_id = Objects.nonNull(sampleId)?sampleId.toString():""; Date collectStartDate = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time.substring(0, struct.collection_start_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); Date collectStopDate = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time.substring(0, struct.collection_stop_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); String collect_start = DateUtils.formatDate(collectStartDate, "yyyy/MM/dd HH:mm:ss"); @@ -1069,7 +1014,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { inputStream.close(); } result.setSuccess(true); - result.setResult(strBuffer); + result.setResult(strBuffer.toString()); } } catch (IOException e) { throw new RuntimeException(e); @@ -1092,8 +1037,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public void exportSampleInformation(Integer sampleId, HttpServletResponse response) { - Result result = viewSampleInformation(sampleId); + public void exportSampleInformation(Integer sampleId, String sampleFileName, HttpServletRequest request, HttpServletResponse response) { + Result result = viewSampleInformation(sampleId, sampleFileName, request); StringBuffer buffer = result.getResult(); if (ObjectUtil.isNull(buffer)) return; String sampleInfo = buffer.toString(); @@ -1117,9 +1062,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewQCResult(Integer sampleId) { + public Result viewQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); QCResult qcResult = new QCResult(); + //获取各数据的范围信息 Sections sections = new Sections(); List collectionTimeSections = sections.getCollectionTimeSections(); String collectionMerits = collectionTimeSections.get(1) + "~" + collectionTimeSections.get(4); @@ -1132,211 +1079,98 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { qcResult.setXenonVolumeEvaluationMetrics(xeMerits); String xe133MDCEvaluationMetrics = "0.001 ~ 5"; qcResult.setXe133MDCEvaluationMetrics(xe133MDCEvaluationMetrics); - String dbName = "RNAUTO.GARDS_ANALYSES"; - SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); - //查询数据库中结果的Xe数据 - List xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); - if (Objects.nonNull(dbSpectrumFilePath)){ - String bkgdMeasurementID = ""; - String gasBkgdMeasurementID = ""; - if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return result; - } - InputStream inputStream = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - String sampleFilePath = dbSpectrumFilePath.getSampleFilePath(); - String samplePathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String sampleFileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - samplePathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + samplePathName; - ftpClient.changeWorkingDirectory(samplePathName); - List sampleFtpFiles = Arrays.asList(ftpClient.listFiles()); - sampleFtpFiles=sampleFtpFiles.stream().filter(item -> item.getName().equals(sampleFileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(sampleFtpFiles)){ - result.error500("ftp下对应的SAMPLE文件不存在"); - return result; - } - FTPFile sampleFtpFile = sampleFtpFiles.get(0); - if (Objects.nonNull(sampleFtpFile)){ - inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - bkgdMeasurementID = struct.detector_bk_measurement_id; - gasBkgdMeasurementID = struct.gas_bk_measurement_id; - Date collectStartDate = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time.substring(0, struct.collection_start_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Date collectStopDate = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time.substring(0, struct.collection_stop_time.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); - String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); - qcResult.setCollectTimeValue(collection_time_value); - if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ - qcResult.setCollectTimeStatus("Pass"); - }else { - qcResult.setCollectTimeStatus("Failed"); - } - String acquisition_live_sec = String.format("%.2f",struct.acquisition_live_time/3600.0); - qcResult.setAcquisitionTimeValue(acquisition_live_sec); - if (acquisitionTimeSections.get(1) < struct.acquisition_live_time/3600.0 && struct.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ - qcResult.setAcquisitionTimeStatus("Pass"); - }else { - qcResult.setAcquisitionTimeStatus("Failed"); - } - String s_xe_stable_volume = String.valueOf(struct.sample_volume_of_Xe); - qcResult.setXenonVolumeValue(s_xe_stable_volume); - if (xeVolumeSections.get(1) < struct.sample_volume_of_Xe){ - qcResult.setXenonVolumeStatus("Pass"); - }else { - qcResult.setXenonVolumeStatus("Failed"); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } catch (ParseException 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); - } - } + //获取数据信息 + SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + GardsXeResultsSpectrum gardsXeResults = new GardsXeResultsSpectrum(); + String sampleFilePath = ""; + String gasFilePath = ""; + String detFilePath = ""; + List xeDataList = new LinkedList<>(); + //判断是否有sampleId和dbName 如果有则说明数据来源DB + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) { + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + }else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; } - if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){ - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return result; - } - InputStream inputStream = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - String gasBgFilePath = dbSpectrumFilePath.getGasBgFilePath(); - String gasBgPathName = gasBgFilePath.substring(0, gasBgFilePath.lastIndexOf(StringPool.SLASH)); - String gasBgFileName = gasBgFilePath.substring(gasBgFilePath.lastIndexOf(StringPool.SLASH)+1); - gasBgPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasBgPathName; - ftpClient.changeWorkingDirectory(gasBgPathName); - List gasBgFtpFiles = Arrays.asList(ftpClient.listFiles()); - gasBgFtpFiles=gasBgFtpFiles.stream().filter(item -> item.getName().equals(gasBgFileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(gasBgFtpFiles)){ - result.error500("ftp下对应的GasBg文件不存在"); - return result; - } - FTPFile gasBgFtpFile = gasBgFtpFiles.get(0); - if (Objects.nonNull(gasBgFtpFile)){ - inputStream = ftpClient.retrieveFileStream(gasBgFtpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - String measurementID = struct.measurement_id; - if (measurementID.equals(gasBkgdMeasurementID)){ - qcResult.setGasBgValueAndStatus(true); - }else { - qcResult.setGasBgValueAndStatus(false); - } - } - } 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); - } - } + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + //查询数据库中结果的Xe数据 + xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); + xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); + gardsXeResults = xeDataList.get(0); + } else {//如果没有数据来源就是File + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + sampleFilePath = path; + gasFilePath = path; + detFilePath = path; + File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); + File gasTmp = phdFileUtil.analyzeFile(path, gasFileName); + File detTmp = phdFileUtil.analyzeFile(path, detFileName); + if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { + result.error500("ftp下文件不存在"); + return result; } - if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())){ - FTPClient ftpClient = ftpUtil.LoginFTP(); - if (Objects.isNull(ftpClient)){ - result.error500("ftp连接失败"); - return result; - } - InputStream inputStream = null; - try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - String detBgFilePath = dbSpectrumFilePath.getDetBgFilePath(); - String detBgPathName = detBgFilePath.substring(0, detBgFilePath.lastIndexOf(StringPool.SLASH)); - String detBgFileName = detBgFilePath.substring(detBgFilePath.lastIndexOf(StringPool.SLASH)+1); - detBgPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detBgPathName; - ftpClient.changeWorkingDirectory(detBgPathName); - List detBgFtpFiles = Arrays.asList(ftpClient.listFiles()); - detBgFtpFiles=detBgFtpFiles.stream().filter(item -> item.getName().equals(detBgFileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(detBgFtpFiles)){ - result.error500("ftp下对应的DetBg文件不存在"); - return result; - } - FTPFile detBgFtpFile = detBgFtpFiles.get(0); - if (Objects.nonNull(detBgFtpFile)){ - inputStream = ftpClient.retrieveFileStream(detBgFtpFile.getName()); - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - String measurementID = struct.measurement_id; - if (measurementID.equals(bkgdMeasurementID)){ - qcResult.setDetBgValueAndStatus(true); - }else { - qcResult.setDetBgValueAndStatus(false); - } - } - } 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); - } - } - } - if (CollectionUtils.isNotEmpty(xeDataList)){ - List xeData = xeDataList.stream().filter(item -> item.getNuclideName().equals("Xe133")).collect(Collectors.toList()); - GardsXeResultsSpectrum gardsXeResults = xeData.get(0); - qcResult.setXe133MDCValue(String.valueOf(gardsXeResults.getMdc())); - if ( 0.001 < gardsXeResults.getMdc() && gardsXeResults.getMdc() < 5.0 ){ - qcResult.setXe133MDCStatus("Pass"); + xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); + xeDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); + gardsXeResults = xeDataList.get(0); + } + //解析sample,gas,det文件并判断数据状态 + if (StringUtils.isNotBlank(sampleFileName) && StringUtils.isNotBlank(gasFileName) && StringUtils.isNotBlank(detFileName)) { + EnergySpectrumStruct sampleSourceData = phdFileUtil.analyzeFileSourceData(sampleFilePath, sampleFileName); + EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, gasFileName); + EnergySpectrumStruct detSourceData = phdFileUtil.analyzeFileSourceData(detFilePath, detFileName); + try { + Date collectStartDate = DateUtils.parseDate(sampleSourceData.collection_start_date + StringPool.SPACE + sampleSourceData.collection_start_time); + Date collectStopDate = DateUtils.parseDate(sampleSourceData.collection_stop_date + StringPool.SPACE + sampleSourceData.collection_stop_time); + Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); + String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); + qcResult.setCollectTimeValue(collection_time_value); + if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ + qcResult.setCollectTimeStatus("Pass"); }else { - qcResult.setXe133MDCStatus("Failed"); + qcResult.setCollectTimeStatus("Failed"); } + String acquisition_live_sec = String.format("%.2f",sampleSourceData.acquisition_live_time/3600.0); + qcResult.setAcquisitionTimeValue(acquisition_live_sec); + if (acquisitionTimeSections.get(1) < sampleSourceData.acquisition_live_time/3600.0 && sampleSourceData.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ + qcResult.setAcquisitionTimeStatus("Pass"); + }else { + qcResult.setAcquisitionTimeStatus("Failed"); + } + String s_xe_stable_volume = String.valueOf(sampleSourceData.sample_volume_of_Xe); + qcResult.setXenonVolumeValue(s_xe_stable_volume); + if (xeVolumeSections.get(1) < sampleSourceData.sample_volume_of_Xe){ + qcResult.setXenonVolumeStatus("Pass"); + }else { + qcResult.setXenonVolumeStatus("Failed"); + } + // + String gasMeasurementID = gasSourceData.measurement_id; + if (gasMeasurementID.equals(sampleSourceData.gas_bk_measurement_id)){ + qcResult.setGasBgValueAndStatus(true); + }else { + qcResult.setGasBgValueAndStatus(false); + } + // + String detMeasurementID = detSourceData.measurement_id; + if (detMeasurementID.equals(sampleSourceData.detector_bk_measurement_id)){ + qcResult.setDetBgValueAndStatus(true); + }else { + qcResult.setDetBgValueAndStatus(false); + } + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + if (Objects.nonNull(gardsXeResults)){ + qcResult.setXe133MDCValue(String.valueOf(gardsXeResults.getMdc())); + if ( 0.001 < gardsXeResults.getMdc() && gardsXeResults.getMdc() < 5.0 ){ + qcResult.setXe133MDCStatus("Pass"); + }else { + qcResult.setXe133MDCStatus("Failed"); } } result.setSuccess(true); @@ -1345,8 +1179,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public void exportQCResult(Integer sampleId, HttpServletResponse response) { - Result result = viewQCResult(sampleId); + public void exportQCResult(Integer sampleId, String dbName, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request, HttpServletResponse response) { + Result result = viewQCResult(sampleId, dbName, sampleFileName, gasFileName, detFileName, request); QCResult qcResult = result.getResult(); if (ObjectUtil.isNull(qcResult)) return; Map dataMap = BeanUtil.beanToMap(qcResult); @@ -1356,18 +1190,34 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewRLR(Integer sampleId) { + public Result viewRLR(Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) { Result result = new Result(); RlrDataValues rlrDataValues = new RlrDataValues(); - String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + String userName = JwtUtil.getUserNameByToken(request); + String sampleFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + List xeDataList = new LinkedList<>(); + if (Objects.nonNull(sampleId)) { + sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + //查询数据库中结果的Xe数据 + xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); + } else { + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName); + File gasTmp = phdFileUtil.analyzeFile(path, gasFileName); + File detTmp = phdFileUtil.analyzeFile(path, detFileName); + if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) { + result.error500("ftp下文件不存在"); + return result; + } + xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp); + } FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); return result; } InputStream inputStream = null; - //查询数据库中结果的Xe数据 - List xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); try { //切换被动模式 ftpClient.enterLocalPassiveMode(); @@ -1376,10 +1226,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { ftpClient.setControlEncoding("UTF-8"); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); if (StringUtils.isNotBlank(sampleFilePath)){ - String samplePathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String sampleFileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - samplePathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + samplePathName; - ftpClient.changeWorkingDirectory(samplePathName); + ftpClient.changeWorkingDirectory(sampleFilePath); List sampleFtpFiles = Arrays.asList(ftpClient.listFiles()); sampleFtpFiles=sampleFtpFiles.stream().filter(item -> item.getName().equals(sampleFileName)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(sampleFtpFiles)){ @@ -1405,28 +1252,28 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { rlrDataValues.setAcq_start_time(struct.acquisition_start_time); rlrDataValues.setAcq_live_time(String.valueOf(struct.acquisition_live_time)); if (CollectionUtils.isNotEmpty(xeDataList)){ - List xe131mDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals("Xe131m")).collect(Collectors.toList()); + List xe131mDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_131m.getType())).collect(Collectors.toList()); GardsXeResultsSpectrum xe131m = xe131mDataList.get(0); rlrDataValues.setXe131m_conc(String.valueOf(xe131m.getConc())); rlrDataValues.setXe131m_uncert_conc(String.valueOf(xe131m.getConcErr())); rlrDataValues.setXe131m_MDC(String.valueOf(xe131m.getMdc())); rlrDataValues.setXe131m_LC(String.valueOf(xe131m.getLc())); - List xe133DataList = xeDataList.stream().filter(item -> item.getNuclideName().equals("Xe133")).collect(Collectors.toList()); + List xe133DataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); GardsXeResultsSpectrum xe133 = xe133DataList.get(0); rlrDataValues.setXe133_conc(String.valueOf(xe133.getConc())); rlrDataValues.setXe133_uncert_conc(String.valueOf(xe133.getConcErr())); rlrDataValues.setXe133_MDC(String.valueOf(xe133.getMdc())); rlrDataValues.setXe133_LC(String.valueOf(xe133.getLc())); - List xe133mDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals("Xe133m")).collect(Collectors.toList()); + List xe133mDataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133m.getType())).collect(Collectors.toList()); GardsXeResultsSpectrum xe133m = xe133mDataList.get(0); rlrDataValues.setXe133m_conc(String.valueOf(xe133m.getConc())); rlrDataValues.setXe133m_uncert_conc(String.valueOf(xe133m.getConcErr())); rlrDataValues.setXe133m_MDC(String.valueOf(xe133m.getMdc())); rlrDataValues.setXe133m_LC(String.valueOf(xe133m.getLc())); - List xe135DataList = xeDataList.stream().filter(item -> item.getNuclideName().equals("Xe135")).collect(Collectors.toList()); + List xe135DataList = xeDataList.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_135.getType())).collect(Collectors.toList()); GardsXeResultsSpectrum xe135 = xe135DataList.get(0); rlrDataValues.setXe135_conc(String.valueOf(xe135.getConc())); rlrDataValues.setXe135_uncert_conc(String.valueOf(xe135.getConcErr())); @@ -1455,24 +1302,20 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public void exportRLR(Integer sampleId, HttpServletResponse response) { - Result result = viewRLR(sampleId); - RlrDataValues rlrDataValues = (RlrDataValues)result.getResult(); - Map dataMap = BeanUtil.beanToMap(rlrDataValues); - // 将Null值替换为"",避免空指针异常(或者在模板中进行判断) - dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); - String export = "RLR-Beta.xls"; - String template = RLR_B.getName(); - ExportUtil.exportXls(response, template, dataMap,export); - } - - @Override - public Result viewGammaDetectorCalibration(Integer sampleId) { + public Result viewGammaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request) { Result result = new Result(); Map map = new HashMap<>(); - GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + String userName = JwtUtil.getUserNameByToken(request); + String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + //如果sampleId不为空 + if (Objects.nonNull(sampleId)) { + GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); + String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + if (StringUtils.isNotBlank(dbQcFilePath)) { + qcPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + } + } FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); @@ -1480,11 +1323,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } InputStream inputStream = null; try { - if (StringUtils.isNotBlank(dbQcFilePath)){ - String qcPathName = dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); - String qcFileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); - qcPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcPathName; - ftpClient.changeWorkingDirectory(qcPathName); + if (StringUtils.isNotBlank(qcPath)){ + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(qcPath); List qcFtpFiles = Arrays.asList(ftpClient.listFiles()); qcFtpFiles=qcFtpFiles.stream().filter(item -> item.getName().equals(qcFileName)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(qcFtpFiles)){ @@ -1600,12 +1446,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewBetaDetectorCalibration(Integer sampleId) { + public Result viewBetaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request) { Result result = new Result(); Map map = new HashMap<>(); - GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + String userName = JwtUtil.getUserNameByToken(request); + String qcPath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + if (Objects.nonNull(sampleId)) { + GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); + String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + if (StringUtils.isNotBlank(dbQcFilePath)) { + qcPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + } + } FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); @@ -1613,17 +1466,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } InputStream inputStream = null; try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - if (StringUtils.isNotBlank(dbQcFilePath)){ - String qcPathName = dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); - String qcFileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); - qcPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcPathName; - ftpClient.changeWorkingDirectory(qcPathName); + if (StringUtils.isNotBlank(qcPath)){ + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(qcPath); List qcFtpFiles = Arrays.asList(ftpClient.listFiles()); qcFtpFiles=qcFtpFiles.stream().filter(item -> item.getName().equals(qcFileName)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(qcFtpFiles)){ @@ -1742,10 +1592,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewExtrapolation(Integer sampleId) { + public Result viewExtrapolation(Integer sampleId, String sampleFileName, HttpServletRequest request) { Result result = new Result(); Map map = new HashMap<>(); - String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + String userName = JwtUtil.getUserNameByToken(request); + String samplePathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + if (Objects.nonNull(sampleId)){ + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + samplePathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + } //加载dll工具库 System.loadLibrary("ReadPHDFile"); FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -1754,17 +1609,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return result; } InputStream inputStream = null; - if (StringUtils.isNotBlank(sampleFilePath)){ - String samplePathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String sampleFileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - try { + try { + if (StringUtils.isNotBlank(samplePathName)) { //切换被动模式 ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 ftpClient.setControlEncoding("UTF-8"); ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - samplePathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + samplePathName; ftpClient.changeWorkingDirectory(samplePathName); List sampleFtpFiles = Arrays.asList(ftpClient.listFiles()); sampleFtpFiles = sampleFtpFiles.stream().filter(item-> item.getName().equals(sampleFileName)).collect(Collectors.toList()); @@ -1783,7 +1635,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //读取文件信息 EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); //Acquisition - String acquisitionStart = struct.acquisition_start_date + " " + struct.acquisition_start_time; + String acquisitionStart = struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time; String acquisitionRealTime = String.valueOf(struct.acquisition_real_time); String acquisitionLiveTime = String.valueOf(struct.acquisition_live_time); map.put("acquisitionStart", acquisitionStart); @@ -1848,19 +1700,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } map.put("betaProjectedSeriseData", betaProjectedSeriseData); } + } + } 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); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (Objects.nonNull(inputStream)){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } } } result.setSuccess(true); @@ -1893,33 +1745,90 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result viewMDC(Integer sampleId) { + public Result viewMDC(Integer sampleId, String sampleFileName, HttpServletRequest request) { Result result = new Result(); Map map = new HashMap<>(); - GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - if (Objects.isNull(sampleData)){ - result.error500("样品数据信息不存在!"); + String userName = JwtUtil.getUserNameByToken(request); + String filePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + //判断sampleId是否存在 + if (Objects.nonNull(sampleId)) { + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + filePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + } + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + result.error500("ftp连接失败"); return result; } - Integer stationId = sampleData.getStationId(); - //根据台站id查询台站名称 - Map stationMap = (Map)redisUtil.get("stationMap"); - if (CollectionUtils.isEmpty(stationMap)){ - result.error500("台站缓存信息为空!"); - return result; + InputStream inputStream = null; + try { + if (StringUtils.isNotBlank(filePath)) { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(filePath); + List sampleFtpFiles = Arrays.asList(ftpClient.listFiles()); + sampleFtpFiles = sampleFtpFiles.stream().filter(item-> item.getName().equals(sampleFileName)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(sampleFtpFiles)){ + result.error500("ftp下对应的SAMPLE文件不存在"); + return result; + } + FTPFile sampleFtpFile = sampleFtpFiles.get(0); + if (Objects.nonNull(sampleFtpFile)){ + //获取ftp文件的输入流 + inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //ftp文件输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + //读取文件信息 + EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + String stationName = struct.site_code; + //根据台站id查询台站名称 + Map stationMap = (Map)redisUtil.get("stationMap"); + if (CollectionUtils.isEmpty(stationMap)){ + result.error500("台站缓存信息为空!"); + return result; + } + List stationNames = stationMap.values().stream().collect(Collectors.toList()); + int index = stationNames.indexOf(stationName); + if (index<0){ + result.error500("台站信息不存在!"); + return result; + } + List stationIds = stationMap.keySet().stream().collect(Collectors.toList()); + String stationId = String.valueOf(stationIds.get(index)); + map.put("stationId", stationId); + map.put("stationName", stationName); + //根据台站id查询探测器集合 + List detectorList = new LinkedList<>(); + GardsDetectors detectors = new GardsDetectors(); + detectors.setDetectorCode("All"); + detectorList.add(detectors); + List stationDetectorList = spectrumAnalysisMapper.getDetectorList(Integer.valueOf(stationId)); + detectorList.addAll(stationDetectorList); + map.put("detectorList", detectorList); + } + } + } 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); + } } - String stationName = ""; - if (Objects.nonNull(stationMap.get(String.valueOf(stationId)))){ - stationName = stationMap.get(String.valueOf(stationId)); - } - map.put("stationId", stationId); - map.put("stationName", stationName); - //根据台站id查询探测器集合 - List detectorList = new LinkedList<>(); - detectorList.add("All"); - List stationDetectorList = spectrumAnalysisMapper.getDetectorList(stationId); - detectorList.addAll(stationDetectorList); - map.put("detectorList", detectorList); result.setSuccess(true); result.setResult(map); return result; @@ -1946,9 +1855,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { map.put("stationId", stationId); map.put("stationName", stationName); //根据台站id查询探测器集合 - List detectorList = new LinkedList<>(); - detectorList.add("All"); - List stationDetectorList = spectrumAnalysisMapper.getDetectorList(Integer.valueOf(stationId)); + List detectorList = new LinkedList<>(); + GardsDetectors detectors = new GardsDetectors(); + detectors.setDetectorCode("All"); + detectorList.add(detectors); + List stationDetectorList = spectrumAnalysisMapper.getDetectorList(Integer.valueOf(stationId)); detectorList.addAll(stationDetectorList); map.put("detectorList", detectorList); result.setSuccess(true); @@ -1963,23 +1874,24 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.error500("开始时间不能为空"); return result; } - String startDate = DateUtils.formatDate(statisticsQueryData.getStartTime(), "yyyy/MM/dd"); + String startDate = DateUtils.formatDate(statisticsQueryData.getStartTime(), "yyyy-MM-dd"); statisticsQueryData.setStartDate(startDate); if (Objects.isNull(statisticsQueryData.getEndTime())){ result.error500("结束时间不能为空"); return result; } - String endDate = DateUtils.formatDate(statisticsQueryData.getEndTime(), "yyyy/MM/dd"); + String endDate = DateUtils.formatDate(statisticsQueryData.getEndTime(), "yyyy-MM-dd"); statisticsQueryData.setEndDate(endDate); - List detectorList = new LinkedList<>(); + List detectorIdList = new LinkedList<>(); if (StringUtils.isNotBlank(statisticsQueryData.getDetectorName())){ if (statisticsQueryData.getDetectorName().equals("All")){ - detectorList = spectrumAnalysisMapper.getDetectorList(statisticsQueryData.getStationId()); + List detectorList = spectrumAnalysisMapper.getDetectorList(statisticsQueryData.getStationId()); + detectorIdList = detectorList.stream().map(GardsDetectors::getDetectorId).collect(Collectors.toList()); }else { - detectorList.add(statisticsQueryData.getDetectorName()); + detectorIdList.add(statisticsQueryData.getDetectorId()); } } - statisticsQueryData.setDetectorList(detectorList); + statisticsQueryData.setDetectorList(detectorIdList); List items = new LinkedList<>(); if (statisticsQueryData.isMDC()){ items.add("GXR.MDC"); @@ -1993,185 +1905,180 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } //根据类型判断查询对应数据 List statisticsData = spectrumAnalysisMapper.statisticsQueryNuclides(statisticsQueryData); - if(CollectionUtils.isNotEmpty(statisticsData)){ - List stcGraphList = new LinkedList<>(); - if (statisticsQueryData.getNuclidesList().contains("Xe131m")){ - List xe131m = statisticsData.stream().filter(item -> item.getNuclideName().equals("Xe131m")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(xe131m)){ - if (statisticsQueryData.isMDC()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe131m MDC"); - stcGraph.setM_GraphPen("#00cafd"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe131m) { - keys.add(data.getCollectStart()); - values.add(data.getMdc()); - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); + List stcGraphList = new LinkedList<>(); + if (statisticsQueryData.getNuclidesList().contains(XeNuclideName.XE_131m.getType())){ + StcGraph stcGraphMDC = new StcGraph(); + stcGraphMDC.setM_strGraphName("Xe131m MDC"); + stcGraphMDC.setM_GraphPen("#00cafd"); + StcGraph stcGraphAct = new StcGraph(); + stcGraphAct.setM_strGraphName("Xe131m Activity Concentration"); + stcGraphAct.setM_GraphPen("#f89c1f"); + List xe131m = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(statisticsData)) { + xe131m = statisticsData.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_131m.getType())).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(xe131m)){ + if (statisticsQueryData.isMDC()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe131m) { + keys.add(data.getCollectStart()); + values.add(data.getMdc()); } - if (statisticsQueryData.isActivity()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe131m Activity Concentration"); - stcGraph.setM_GraphPen("#f89c1f"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe131m) { - keys.add(data.getCollectStart()); - if (statisticsQueryData.isMDC()){ - values.add(data.getMdc()); - }else { - values.add(data.getConc()); - } - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); + stcGraphMDC.setM_Keys(keys); + stcGraphMDC.setM_Values(values); + } + if (statisticsQueryData.isActivity()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe131m) { + keys.add(data.getCollectStart()); + values.add(data.getConc()); } + stcGraphAct.setM_Keys(keys); + stcGraphAct.setM_Values(values); } } - if (statisticsQueryData.getNuclidesList().contains("Xe133m")){ - List xe133m = statisticsData.stream().filter(item -> item.getNuclideName().equals("Xe133m")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(xe133m)){ - if (statisticsQueryData.isMDC()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe133m MDC"); - stcGraph.setM_GraphPen("#119e4f"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe133m) { - keys.add(data.getCollectStart()); - values.add(data.getMdc()); - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - if (statisticsQueryData.isActivity()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe133m Activity Concentration"); - stcGraph.setM_GraphPen("#fff64f"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe133m) { - keys.add(data.getCollectStart()); - if (statisticsQueryData.isMDC()){ - values.add(data.getMdc()); - }else { - values.add(data.getConc()); - } - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - } - } - if (statisticsQueryData.getNuclidesList().contains("Xe133")){ - List xe133 = statisticsData.stream().filter(item -> item.getNuclideName().equals("Xe133")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(xe133)){ - if (statisticsQueryData.isMDC()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe133 MDC"); - stcGraph.setM_GraphPen("#00cafd"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe133) { - keys.add(data.getCollectStart()); - values.add(data.getMdc()); - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - if (statisticsQueryData.isActivity()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe133 Activity Concentration"); - stcGraph.setM_GraphPen("#01a99a"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe133) { - keys.add(data.getCollectStart()); - if (statisticsQueryData.isMDC()){ - values.add(data.getMdc()); - }else { - values.add(data.getConc()); - } - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - } - } - if (statisticsQueryData.getNuclidesList().contains("Xe135")){ - List xe135 = statisticsData.stream().filter(item -> item.getNuclideName().equals("Xe135")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(xe135)){ - if (statisticsQueryData.isMDC()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe135 MDC"); - stcGraph.setM_GraphPen("#1775e7"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe135) { - keys.add(data.getCollectStart()); - values.add(data.getMdc()); - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - if (statisticsQueryData.isActivity()){ - StcGraph stcGraph = new StcGraph(); - stcGraph.setM_strGraphName("Xe135 Activity Concentration"); - stcGraph.setM_GraphPen("#ff32ab"); - List keys = new LinkedList<>(); - List values = new LinkedList<>(); - for (StatisticsData data:xe135) { - keys.add(data.getCollectStart()); - if (statisticsQueryData.isMDC()){ - values.add(data.getMdc()); - }else { - values.add(data.getConc()); - } - } - stcGraph.setM_Keys(keys); - stcGraph.setM_Values(values); - stcGraphList.add(stcGraph); - } - } - } - result.setSuccess(true); - result.setResult(stcGraphList); + stcGraphList.add(stcGraphMDC); + stcGraphList.add(stcGraphAct); } + if (statisticsQueryData.getNuclidesList().contains(XeNuclideName.XE_133m.getType())){ + StcGraph stcGraphMDC = new StcGraph(); + stcGraphMDC.setM_strGraphName("Xe133m MDC"); + stcGraphMDC.setM_GraphPen("#119e4f"); + StcGraph stcGraphAct = new StcGraph(); + stcGraphAct.setM_strGraphName("Xe133m Activity Concentration"); + stcGraphAct.setM_GraphPen("#fff64f"); + List xe133m = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(statisticsData)) { + xe133m = statisticsData.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133m.getType())).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(xe133m)){ + if (statisticsQueryData.isMDC()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe133m) { + keys.add(data.getCollectStart()); + values.add(data.getMdc()); + } + stcGraphMDC.setM_Keys(keys); + stcGraphMDC.setM_Values(values); + } + if (statisticsQueryData.isActivity()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe133m) { + keys.add(data.getCollectStart()); + values.add(data.getConc()); + } + stcGraphAct.setM_Keys(keys); + stcGraphAct.setM_Values(values); + } + } + stcGraphList.add(stcGraphMDC); + stcGraphList.add(stcGraphAct); + } + if (statisticsQueryData.getNuclidesList().contains(XeNuclideName.XE_133.getType())){ + StcGraph stcGraphMDC = new StcGraph(); + stcGraphMDC.setM_strGraphName("Xe133 MDC"); + stcGraphMDC.setM_GraphPen("#00cafd"); + StcGraph stcGraphAct = new StcGraph(); + stcGraphAct.setM_strGraphName("Xe133 Activity Concentration"); + stcGraphAct.setM_GraphPen("#01a99a"); + List xe133 = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(statisticsData)) { + xe133 = statisticsData.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_133.getType())).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(xe133)){ + if (statisticsQueryData.isMDC()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe133) { + keys.add(data.getCollectStart()); + values.add(data.getMdc()); + } + stcGraphMDC.setM_Keys(keys); + stcGraphMDC.setM_Values(values); + } + if (statisticsQueryData.isActivity()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe133) { + keys.add(data.getCollectStart()); + values.add(data.getConc()); + } + stcGraphAct.setM_Keys(keys); + stcGraphAct.setM_Values(values); + } + } + stcGraphList.add(stcGraphMDC); + stcGraphList.add(stcGraphAct); + } + if (statisticsQueryData.getNuclidesList().contains(XeNuclideName.XE_135.getType())){ + StcGraph stcGraphMDC = new StcGraph(); + stcGraphMDC.setM_strGraphName("Xe135 MDC"); + stcGraphMDC.setM_GraphPen("#1775e7"); + StcGraph stcGraphAct = new StcGraph(); + stcGraphAct.setM_strGraphName("Xe135 Activity Concentration"); + stcGraphAct.setM_GraphPen("#ff32ab"); + List xe135 = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(statisticsData)) { + xe135 = statisticsData.stream().filter(item -> item.getNuclideName().equals(XeNuclideName.XE_135.getType())).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(xe135)){ + if (statisticsQueryData.isMDC()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe135) { + keys.add(data.getCollectStart()); + values.add(data.getMdc()); + } + stcGraphMDC.setM_Keys(keys); + stcGraphMDC.setM_Values(values); + } + if (statisticsQueryData.isActivity()){ + List keys = new LinkedList<>(); + List values = new LinkedList<>(); + for (StatisticsData data:xe135) { + keys.add(data.getCollectStart()); + values.add(data.getConc()); + } + stcGraphAct.setM_Keys(keys); + stcGraphAct.setM_Values(values); + } + } + stcGraphList.add(stcGraphMDC); + stcGraphList.add(stcGraphAct); + } + result.setSuccess(true); + result.setResult(stcGraphList); return result; } @Override - public Result statisticsQueryBtn(String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime) { + public Result statisticsQueryBtn(Integer detectorId, String detectorName, Integer stationId, String statisticsType, Date startTime, Date endTime) { Result result = new Result(); if (Objects.isNull(startTime)){ result.error500("开始时间不能为空"); return result; } - String startDate = DateUtils.formatDate(startTime, "yyyy/MM/dd"); + String startDate = DateUtils.formatDate(startTime, "yyyy-MM-dd"); if (Objects.isNull(endTime)){ result.error500("结束时间不能为空"); return result; } - String endDate = DateUtils.formatDate(endTime, "yyyy/MM/dd"); - List detectorList = new LinkedList<>(); + String endDate = DateUtils.formatDate(endTime, "yyyy-MM-dd"); + List detectorIdList = new LinkedList<>(); if (StringUtils.isNotBlank(detectorName)){ if (detectorName.equals("All")){ - detectorList = spectrumAnalysisMapper.getDetectorList(stationId); + List detectorList = spectrumAnalysisMapper.getDetectorList(stationId); + detectorIdList = detectorList.stream().map(GardsDetectors::getDetectorId).collect(Collectors.toList()); }else { - detectorList.add(detectorName); + detectorIdList.add(detectorId); } } if (statisticsType.equals("Colloc_Time")) { - List statisticsData = spectrumAnalysisMapper.statisticsQueryCollection(startDate, endDate, detectorList); + List statisticsData = spectrumAnalysisMapper.statisticsQueryCollection(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Colloction Time"); stcGraph.setM_GraphPen("green"); @@ -2186,7 +2093,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.setSuccess(true); result.setResult(stcGraph); } else if (statisticsType.equals("Acq_Time")) { - List statisticsData = spectrumAnalysisMapper.statisticsQueryAcquisition(startDate, endDate, detectorList); + List statisticsData = spectrumAnalysisMapper.statisticsQueryAcquisition(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Acquisition Time"); stcGraph.setM_GraphPen("green"); @@ -2201,7 +2108,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.setSuccess(true); result.setResult(stcGraph); } else if (statisticsType.equals("Xe_volumn")) { - List statisticsData = spectrumAnalysisMapper.statisticsQueryXeVolumn(startDate, endDate, detectorList); + List statisticsData = spectrumAnalysisMapper.statisticsQueryXeVolumn(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Xe Volumn"); stcGraph.setM_GraphPen("green"); @@ -2216,7 +2123,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.setSuccess(true); result.setResult(stcGraph); } else if (statisticsType.equals("Sample_Volumn")) { - List statisticsData = spectrumAnalysisMapper.statisticsQuerySampleVolumn(startDate, endDate, detectorList); + List statisticsData = spectrumAnalysisMapper.statisticsQuerySampleVolumn(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Sample Volumn"); stcGraph.setM_GraphPen("green"); @@ -2331,7 +2238,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId) { + public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, HttpServletRequest request) { //选择矩形框高度 Integer flagHeight = channelWidth * (chartHeight/256); int value = Double.valueOf(flagHeight / 2).intValue(); @@ -2344,9 +2251,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { int down = up + value; Result result = new Result(); Map map = new HashMap<>(); - GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); - String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); - String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + String userName = JwtUtil.getUserNameByToken(request); + String qcPathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + if (Objects.nonNull(sampleId)) { + GardsSampleData sampleData = spectrumAnalysisMapper.getSampleData(sampleId); + String collectStartStr = DateUtils.formatDate(sampleData.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); + String dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), collectStartStr); + if (StringUtils.isNotBlank(dbQcFilePath)) { + qcPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + } + } FTPClient ftpClient = ftpUtil.LoginFTP(); if (Objects.isNull(ftpClient)){ result.error500("ftp连接失败"); @@ -2354,16 +2268,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } InputStream inputStream = null; try { - //切换被动模式 - ftpClient.enterLocalPassiveMode(); - ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); - // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 - ftpClient.setControlEncoding("UTF-8"); - ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); - if (StringUtils.isNotBlank(dbQcFilePath)){ - String qcPathName = dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); - String qcFileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); - qcPathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcPathName; + if (StringUtils.isNotBlank(qcPathName)){ + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); ftpClient.changeWorkingDirectory(qcPathName); List qcFtpFiles = Arrays.asList(ftpClient.listFiles()); qcFtpFiles=qcFtpFiles.stream().filter(item -> item.getName().equals(qcFileName)).collect(Collectors.toList()); @@ -2420,16 +2331,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request) { - String dbName = ""; - if (analyseData.getDbName().equalsIgnoreCase("auto")){ - dbName = "RNAUTO.GARDS_ANALYSES"; - }else if (analyseData.getDbName().equalsIgnoreCase("man")){ - dbName = "RNMAN.GARDS_ANALYSES"; - } String userName = JwtUtil.getUserNameByToken(request); if ("CurrentSpectrum".equals(analyseData.getApplyType())) { List sampleIds = analyseData.getSampleIds(); if (CollectionUtils.isNotEmpty(sampleIds)){ + String dbName = analyseData.getDbNames().get(0); Integer sampleId = sampleIds.get(0); SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); if (Objects.nonNull(dbSpectrumFilePath)) { @@ -2441,6 +2347,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Map m_loadData = new HashMap<>(); for (int i=0; i map = new HashMap<>(); + //拼接ftp上传临时文件路径 + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + JwtUtil.getUserNameByToken(request); //声明一个实体类获取数据库中文件路径 SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + Integer analysisID = null; + String samplePath = ""; + String gasPath = ""; + String detPath = ""; //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ if (dbName.equalsIgnoreCase("auto")){ - dbName = "RNAUTO.GARDS_ANALYSES"; + dbName = "RNAUTO"; } else if (dbName.equalsIgnoreCase("man")){ - dbName = "RNMAN.GARDS_ANALYSES"; + dbName = "RNMAN"; } + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId); dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); - } else { + samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ result.error500("Data load From DB need to pass in sampleId and dbName"); return result; + } else {//如果sampleId,dbNamed都为空 就指向ftp上传文件临时路径 + samplePath = path; + gasPath = path; + detPath = path; } - //拼接ftp上传临时文件路径 - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +JwtUtil.getUserNameByToken(request); - //判断数据库文件路径是否为空 如果为空 就指向ftp上传文件临时路径 - String samplePath = StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())?dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)):path; - String gasPath = StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())?dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)):path; - String detPath = StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())?dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)):path; - //加载dll工具库 - System.loadLibrary("ReadPHDFile"); //根据文件路径 文件名称获取对应的临时文件 - File sampleTmp = this.analyze(samplePath, sampleFileName); - File gasTmp = this.analyze(gasPath, gasFileName); - File detTmp = this.analyze(detPath, detFileName); - //调用动态库解析文件 - BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); - BgDataAnlyseResultIn resultIn = new BgDataAnlyseResultIn(); - resultIn.setXe131m_con(bgAnalyseResult.Xe131m_con); - resultIn.setXe131m_uncer(bgAnalyseResult.Xe131m_uncer); - resultIn.setMDC_Xe131m(bgAnalyseResult.MDC_Xe131m); - resultIn.setLC_Xe131m(bgAnalyseResult.LC_Xe131m); - resultIn.setXe131mFlag(bgAnalyseResult.XE_131m_NID_FLAG); - resultIn.setXe133_con(bgAnalyseResult.Xe133_con); - resultIn.setXe133_uncer(bgAnalyseResult.Xe133_uncer); - resultIn.setMDC_Xe133(bgAnalyseResult.MDC_Xe133); - resultIn.setLC_Xe133(bgAnalyseResult.LC_Xe133); - resultIn.setXe133Flag(bgAnalyseResult.XE_133_NID_FLAG); - resultIn.setXe133m_con(bgAnalyseResult.Xe133m_con); - resultIn.setXe133m_uncer(bgAnalyseResult.Xe133m_uncer); - resultIn.setMDC_Xe133m(bgAnalyseResult.MDC_Xe133m); - resultIn.setLC_Xe133m(bgAnalyseResult.LC_Xe133m); - resultIn.setXe133mFlag(bgAnalyseResult.XE_133m_NID_FLAG); - resultIn.setXe135_con(bgAnalyseResult.Xe135_con); - resultIn.setXe135_uncer(bgAnalyseResult.Xe135_uncer); - resultIn.setMDC_Xe135(bgAnalyseResult.MDC_Xe135); - resultIn.setLC_Xe135(bgAnalyseResult.LC_Xe135); - resultIn.setXe135Flag(bgAnalyseResult.XE_135_NID_FLAG); - List xeDataList = getXeResults(resultIn, null, null); - if (CollectionUtils.isNotEmpty(xeDataList)){ - for (GardsXeResultsSpectrum xeData:xeDataList) { - Double conc = xeData.getConc(); - Double mdc = xeData.getMdc(); - if (conc < 0){ - xeData.setColor("red"); - } else if (0 mdc) { - xeData.setColor("green"); - } - } - map.put("XeData", xeDataList); + File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); + File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); + File detTmp = phdFileUtil.analyzeFile(detPath, detFileName); + if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { + result.error500("ftp文件获取失败!"); + return result; + } + map.put("sampleFileName", sampleFileName); + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); + if (Objects.nonNull(resultIn)) { + List xeDataList = getXeResults(resultIn, sampleId, analysisID); + if (CollectionUtils.isNotEmpty(xeDataList)){ + for (GardsXeResultsSpectrum xeData:xeDataList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + } else if (0 mdc) { + xeData.setColor("green"); + } + } + map.put("XeData", xeDataList); + } + map.put("savedAnalysisResult", true); } - map.put("savedAnalysisResult", true); result.setSuccess(true); result.setResult(map); return result; } - private File analyze(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); - //获取路径下所有文件信息 - List ftpFiles = Arrays.asList(ftpClient.listFiles()); - if (CollectionUtils.isNotEmpty(ftpFiles)){ - //根据文件名称 分别获取 sample gas det文件 - List files = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(files)){ - FTPFile ftpFile = files.get(0); - inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); - file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(ftpClient)){ - ftpClient.disconnect(); - } - if (inputStream != null){ - inputStream.close(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return file; - } - @Override public Result analyseAllSpectrum(List dbNames, List sampleIds, List sampleFileNames, List gasFileNames, List detFileNames, HttpServletRequest request) { - for (int i=0; i> mapList = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(sampleFileNames)) { + for (int i=0; i map = new HashMap<>(); + //声明一个实体类获取数据库中文件路径 + SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + Integer analysisID = null; + //如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径 + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){ + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + } else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + } + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId); + dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId); + } else if ( (Objects.isNull(sampleId) && StringUtils.isNotBlank(dbName)) || (Objects.nonNull(sampleId) && StringUtils.isBlank(dbName)) ){ + result.error500("Data load From DB need to pass in sampleId and dbName"); + return result; + } + //拼接ftp上传临时文件路径 + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +JwtUtil.getUserNameByToken(request); + //判断数据库文件路径是否为空 如果为空 就指向ftp上传文件临时路径 + String samplePath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ + samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + } + String gasPath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { + gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + } + String detPath = path; + if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { + detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + } + //根据文件路径 文件名称获取对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); + File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName); + File detTmp = phdFileUtil.analyzeFile(detPath, detFileName); + map.put("sampleFileName", sampleFileName); + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); + List xeDataList = getXeResults(resultIn, sampleId, analysisID); + if (CollectionUtils.isNotEmpty(xeDataList)){ + for (GardsXeResultsSpectrum xeData:xeDataList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + } else if (0 mdc) { + xeData.setColor("green"); + } + } + map.put("XeData", xeDataList); + } + map.put("savedAnalysisResult", true); + mapList.add(map); + } } - - return null; + result.setSuccess(true); + result.setResult(mapList); + return result; } @Override @@ -2763,7 +2680,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //gards_calibration 数据表 List calibrationList = getCalibration(anlyseResultIn, sampleId, gasId, detId, idAnalysis); //判断是否分析过 - if (Objects.nonNull(isExist)) { + if (Objects.nonNull(isExist)) { //删除Gards_Calibration表数据 spectrumAnalysisMapper.deleteCalibration(idAnalysis); //新增数据 @@ -2799,14 +2716,24 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { spectrumAnalysisMapper.insertXeResult(xeResults); } //gards_roi_results数据表 + List roiResultsSpectrumList = getROIResult(anlyseResultIn, sampleId, idAnalysis, isExist); + if(Objects.nonNull(isExist)) { + //删除gards_roi_results数据表数据 + spectrumAnalysisMapper.deleteROIResults(idAnalysis); + //新增gards_roi_results数据表数据 + + } else { + //新增gards_roi_results数据表数据 + + } return result; } public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn){ //获取ftp文件路径下临时文件 - File sampleTmp = this.analyze(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - File gasTmp = this.analyze(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); - File detTmp = this.analyze(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); System.loadLibrary("ReadPHDFile"); //如果勾选了Energy Calibration页面下sample Data if (Objects.nonNull(sampleTmp)){ @@ -2953,7 +2880,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { public void getROILimit(BgDataAnlyseResultIn anlyseResultIn) { //获取ftp文件路径下临时文件 - File sampleTmp = this.analyze(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); System.loadLibrary("ReadPHDFile"); if (Objects.nonNull(sampleTmp)){ EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath()); @@ -3287,4 +3214,39 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return readLines; } + public List getROIResult(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer idAnalysis, Integer isExist) { + List roiResultsSpectrumList = new LinkedList<>(); + //第一种 直接从数据库获取的 并没有进行过改变 + if (Objects.nonNull(isExist) && !anlyseResultIn.isBProcessed()) { + for (int i=0; ianlyseResultIn.getMDC().get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); + } + roiResultsSpectrumList.add(roiResults); + } + } else if (Objects.nonNull(isExist) && anlyseResultIn.isBProcessed()) {//第二种 从数据库获取的但是进行过改变 + + } else if (Objects.isNull(isExist) && anlyseResultIn.isBProcessed()) {//第三种 文件加载的数据 + + } + return roiResultsSpectrumList; + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java index d2f52d97..af99c9a5 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumFileServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; @@ -177,6 +178,6 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService { fileSize /= 1024; index++; } - return String.format("%.2f", fileSize) + " " + units[index]; + return String.format("%.2f", fileSize) + StringPool.SPACE + units[index]; } }