diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java index 03906ee2..f8ad0fca 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java @@ -34,6 +34,8 @@ public class SpectrumPathProperties implements Serializable { */ private String emlPath; + private String saveFilePath; + /** * 日志文件存储路径 */ diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 1e47e221..fd6ee86f 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -3105,9 +3105,9 @@ public class GammaFileUtil extends AbstractLogOrReport { - String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath; - String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath; - String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath; + String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsBaseLinePath; + String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsLcPath; + String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsScacPath; GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), qsSaveBaseLine); GammaReportUtil.writeFile(fileAnlyse.getVLc(), "LC", qsSaveLc); GammaReportUtil.writeFile(fileAnlyse.getVScac(), "SCSC", qsSaveScac); @@ -3136,9 +3136,9 @@ public class GammaFileUtil extends AbstractLogOrReport { middleData.analyses_baseline_absolute_filePath =qsSaveLc; middleData.analyses_lc_absolute_filePath=qsSaveLc; middleData.analyses_scac_absolute_filePath=qsSaveScac; - middleData.analyses_save_absolute_filePath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsSaveFile; + middleData.analyses_save_absolute_filePath=spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsSaveFile; middleData.analyses_absolute_LogPath=spectrumPathProperties.getLogPath()+StringPool.SLASH+qsLogPath; - middleData.analyses_absolute_ReportPath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsReportPath; + middleData.analyses_absolute_ReportPath=spectrumPathProperties.getSaveFilePath()+StringPool.SLASH+qsReportPath; if(fileAnlyse.getUsedEnerKD() != null && fileAnlyse.getUsedEnerKD().getG_energy().size() != 0) { middleData.calibration_pairs_E_Caltype = CalType.ENERGY_CAL.getType(); diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java index 7340fd47..25e0147c 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java @@ -27,4 +27,6 @@ public class CalValuesHandler { public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath, AnalysisProcess process); + public static native String fitPeakFull(String phd, List Af, List Cf, List Ff); + } 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 0cf63996..85bc7ffb 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 @@ -779,36 +779,8 @@ public class PHDFileUtil { } } -// public void CalQCBoundary() { -// //QC需要独立计算 -// //从本地缓存获取beta gamma的数组 -// Cache> cache = betaCache.getBetaCache(); -// //根据qc文件名称-用户名-beta的方式获取beta的内容 -// Map betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta"); -// List betaList = new LinkedList<>(); -// List betaFittingPara = new LinkedList<>(); -// List betaFittingParaToUi = new LinkedList<>(); -// if (CollectionUtils.isNotEmpty(betaMap)) { -// betaList = (List)betaMap.get("Series"); -// betaFittingPara = (List) betaMap.get("fittingPara"); -// betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); -// } -// //根据qc文件名称-用户名-gamma的方式获取gamma的内容 -// Map gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma"); -// List gammaList = new LinkedList<>(); -// List gammaFittingPara = new LinkedList<>(); -// List gammaFittingParaToUi = new LinkedList<>(); -// if (CollectionUtils.isNotEmpty(gammaMap)) { -// gammaList = (List)gammaMap.get("Series"); -// gammaFittingPara = (List) gammaMap.get("fittingPara"); -// gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); -// } -// } - public EnergySpectrumStruct analyzeFileSourceData(String filePath, String fileName) { - //加载dll工具库 - //System.loadLibrary("ReadPHDFile"); - EnergySpectrumStruct struct = new EnergySpectrumStruct(); + EnergySpectrumStruct struct = null; FTPClient ftpClient = ftpUtil.LoginFTP(); InputStream inputStream = null; File file = null; @@ -981,4 +953,59 @@ public class PHDFileUtil { return result; } + public List StringToDouble(List datas) { + List result = new LinkedList<>(); + for (String data: datas) { + result.add(Double.valueOf(data)); + } + return result; + } + + public void CalQCBoundary(List betaList, List gammaList, List betaFittingParaToUi, List gammaFittingParaToUi, EnergySpectrumStruct struct, Map map) { + //计算边界值 + CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam(); + if (CollectionUtils.isNotEmpty(betaList) && CollectionUtils.isNotEmpty(gammaList) && CollectionUtils.isNotEmpty(betaFittingParaToUi) && CollectionUtils.isNotEmpty(gammaFittingParaToUi)) { + calcBgBoundaryParam.g_e_cal = StringToDouble(gammaFittingParaToUi); + calcBgBoundaryParam.b_e_cal = StringToDouble(betaFittingParaToUi); + List bChannels = betaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + List bEnergys = betaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + List gChannels = gammaList.stream().map(SeriseData::getX).collect(Collectors.toList()); + List gEnergys = gammaList.stream().map(SeriseData::getY).collect(Collectors.toList()); + calcBgBoundaryParam.b_energy = bEnergys; + calcBgBoundaryParam.b_channel = bChannels; + calcBgBoundaryParam.g_channel = gChannels; + calcBgBoundaryParam.g_energy = gEnergys; + } else { + List gCentroidChannel = struct.g_centroid_channel; + List gEnergy = struct.g_energy; + calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel); + List bChannel = struct.b_channel; + List bElectronEnergy = struct.b_electron_energy; + calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel); + calcBgBoundaryParam.b_energy = struct.b_electron_energy; + calcBgBoundaryParam.b_channel = struct.b_channel; + calcBgBoundaryParam.g_channel = struct.g_centroid_channel; + calcBgBoundaryParam.g_energy = struct.g_energy; + } + calcBgBoundaryParam.ROI_B_start_x1 = struct.POI_B_x1; + calcBgBoundaryParam.ROI_B_stop_x2 = struct.POI_B_x2; + calcBgBoundaryParam.ROI_G_start_y1 = struct.POI_G_y1; + calcBgBoundaryParam.ROI_G_stop_y2 = struct.POI_G_y2; + BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam); + List boundaryList = new LinkedList<>(); + List roiBBoundaryStart = bgBoundary.ROI_B_Boundary_start; + List roiBBoundaryStop = bgBoundary.ROI_B_Boundary_stop; + List roiGBoundaryStart = bgBoundary.ROI_G_Boundary_start; + List roiGBoundaryStop = bgBoundary.ROI_G_Boundary_stop; + for (int i=0; i oldPeak; + private List tablePeaksList; + private List newPeak; private String flag; 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 658ebc27..a12aa94e 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 @@ -34,7 +34,7 @@ public interface IGammaService{ Result insertPeak(Integer sampleId, String fileName, Integer curChan, HttpServletRequest request); - Result acceptResults(String fileName, boolean accept, List oldPeak, List newPeak, String flag, HttpServletRequest request); + Result acceptResults(String fileName, boolean accept, List oldPeak, List tablePeaksList, List newPeak, String flag, HttpServletRequest request); Result deletePeak(String fileName, int curRow, 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 19e076bf..25fd377b 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 @@ -147,7 +147,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("样品文件不存在!"); return result; } - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); if (!flag){ @@ -424,7 +424,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return result; } //切割数据库存储的文件路径获取路径信息 - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); //切割数据库存储的文件路径获取文件名称 String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); //调用加载文件的方法 传入文件路径,文件名称,全局变量phd,响应结果result @@ -505,9 +505,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi int peakNum = 0; if (Objects.nonNull(analysis)){ phd.setId_analysis(analysis.getIdAnalysis().toString()); - phd.setBaseline_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getBaselinePath()); - phd.setLc_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getLcPath()); - phd.setScac_path(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + analysis.getScacPath()); + phd.setBaseline_path(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + analysis.getBaselinePath()); + phd.setLc_path(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + analysis.getLcPath()); + phd.setScac_path(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + analysis.getScacPath()); peakNum = analysis.getNumberOfPeaks(); phd.setTotalCmt(analysis.getComments()); phd.getBaseCtrls().setRg_low(analysis.getSearchStartChannel()); @@ -1157,7 +1157,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi a++; } PeakInfo peak = new PeakInfo(); - peak.index = a; + peak.index = a+1; peak.left = structInsertOutput.vLeft.get(j).intValue();; peak.right = structInsertOutput.vRight.get(j).intValue();; peak.peakCentroid = structInsertOutput.peakCentroid.get(j); @@ -1177,7 +1177,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi peak.recoilBetaChan = String.valueOf(structInsertOutput.recoilBetaChan.get(j)); peak.recoilDeltaChan = String.valueOf(structInsertOutput.recoilDeltaChan.get(j)); newPeaks.add(a, peak); - newPeak.add(peak); } } int left = structInsertOutput.vLeft.get(0).intValue(); @@ -1194,21 +1193,21 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi ii++; } - List tablePeaksList = FitPeakBaseLine(newPeaks, phd.getUsedEnerPara().getP(), vIdx); - map.put("tablePeaksList", tablePeaksList); + FitPeakBaseLine(newPeaks, phd.getUsedEnerPara().getP(), vIdx, map); map.put("oldPeaks", vOriPeaks); - map.put("newPeaks", newPeak); result.setSuccess(true); result.setResult(map); return result; } - public List FitPeakBaseLine(List vPeaks, List p, List vIdx) { + public void FitPeakBaseLine(List vPeaks, List p, List vIdx, Map map) { List tablePeaksList = new LinkedList<>(); + List newPeaks = new LinkedList<>(); int peakNum = vIdx.size(); for (int i=0; i oldPeak, List newPeak, String flag, HttpServletRequest request) { + public Result acceptResults(String fileName, boolean accept, List oldPeak, List tablePeaksList, List newPeak, String flag, HttpServletRequest request) { Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); @@ -1241,69 +1241,120 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("请先选择解析文件!"); return result; } - List m_vCount = new LinkedList<>(); - long m_nCount = phd.getSpec().getNum_g_channel(); - long m_nSChan = phd.getSpec().getBegin_channel(); - //获取当前角色的颜色配置 - Map colorMap = sysUserColorService.initColor(userName); - // 确保绘制曲线时所有谱都是从1道开始 - int i = 0; - if(m_nSChan == 0){ - i = 1; - } - for(; i map = new HashMap<>(); - //根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线 - if (accept){ - if (flag.equalsIgnoreCase("fit")) {//如果传递的flag标识 是 fit则进行修改峰值等数据 - for (int j=0; j m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if(m_nSChan == 0){ + i = 1; + } + for(; i map = new HashMap<>(); + //根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线 + if (accept){ + if (flag.equalsIgnoreCase("fit")) {//如果传递的flag标识 是 fit则进行修改峰值等数据 + for (int j=0; j vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); - map.put("table", vPeak); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); - map.put("channelPeakChart", channelPeak); - ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); - map.put("channelBaseLineChart", channelBaseLine); - List differance = gammaFileUtil.Differance(phd, phd.getVPeak(), m_vCount, m_nCount); - map.put("barChart", differance); - gammaFileUtil.UpdateChart(phd, map, colorMap); - } else {//如果不保留 根据下标移除对应的vPeak数据 - if (CollectionUtils.isNotEmpty(oldPeak)) { - phd.getVPeak().clear(); - phd.setVPeak(oldPeak); - map.put("table", phd.getVPeak()); + List vC_Rg = new LinkedList<>(); + vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_low())); + vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_high())); + + List vE_Rg = CalValuesHandler.calFcnEval(vC_Rg, phd.getUsedEnerPara().getP()).counts; + if(vE_Rg.size() != 2 || vE_Rg.get(0).isNaN() || vE_Rg.get(1).isNaN()) { + return result; + } + + List Af = new LinkedList<>(); + List Cf = new LinkedList<>(); + List Ff = new LinkedList<>(); + //遍历列表中的数据 + for(int j=0; j< tablePeaksList.size(); j++){ + TablePeaks nPeak = tablePeaksList.get(j); + PeakInfo peak = phd.getVPeak().get(Integer.valueOf(nPeak.getLab())-1); + double dE = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP()); + + if(peak.energy < vE_Rg.get(0) || peak.energy > vE_Rg.get(1)) { + result.error500("The energy isn't in the analysis range."); + return result; + } + List energys = new LinkedList<>(); + energys.add(peak.energy); + peak.peakCentroid = CalValuesHandler.energyToChannel(energys, phd.getUsedEnerPara().getP()).counts.get(0); + peak.stepRatio = Double.valueOf(nPeak.getStep()) / peak.area; + peak.BWWidthChan = Double.valueOf(nPeak.getBwGamma()) / dE; + if(dE > 0) { + peak.fwhmc = peak.fwhm / dE; + } + + if(!tablePeaksList.get(j).isNetAreaB()) { + Af.add(Integer.valueOf(tablePeaksList.get(j).getLab())); + } + if(!tablePeaksList.get(j).isCentroid()) { + Cf.add(Integer.valueOf(tablePeaksList.get(j).getLab())); + } + if(!tablePeaksList.get(j).isFwhmB()) { + Ff.add(Integer.valueOf(tablePeaksList.get(j).getLab())); + } + } + ObjectMapper mapper = new ObjectMapper(); + String phdStr = mapper.writeValueAsString(phd); + String str = CalValuesHandler.fitPeakFull(phdStr, Af, Cf, Ff); + + + //重新计算peak的改变 + gammaFileUtil.PeaksChanged(phd); + + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); + ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); + map.put("channelBaseLineChart", channelBaseLine); + List differance = gammaFileUtil.Differance(phd, phd.getVPeak(), m_vCount, m_nCount); + map.put("barChart", differance); + gammaFileUtil.UpdateChart(phd, map, colorMap); + } else {//如果不保留 根据下标移除对应的vPeak数据 + if (CollectionUtils.isNotEmpty(oldPeak)) { + phd.getVPeak().clear(); + phd.setVPeak(oldPeak); + map.put("table", phd.getVPeak()); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); + map.put("channelPeakChart", channelPeak); + } } + result.setSuccess(true); + result.setResult(map); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); } - result.setSuccess(true); - result.setResult(map); return result; } @@ -1385,16 +1436,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi } // 备份原来的峰列表 List vOriPeaks = phd.getVPeak(); - List newPeak = new LinkedList<>(); - for (int i=0; i tablePeaksList = FitPeakBaseLine(phd.getVPeak(), phd.getUsedEnerPara().getP(), vIdx); - map.put("tablePeaksList", tablePeaksList); + + FitPeakBaseLine(phd.getVPeak(), phd.getUsedEnerPara().getP(), vIdx, map); map.put("oldPeaks", vOriPeaks); - map.put("newPeaks", newPeak); result.setSuccess(true); result.setResult(map); return result; @@ -1757,44 +1801,55 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi @Override public Result replotBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request) { -// Result result = new Result(); -// HashMap map = new HashMap<>(); -// //获取用户名 -// String userName = JwtUtil.getUserNameByToken(request); -// //获取文件名称 -// String fileName = baseLineCtrls.getFileName(); -// Cache phdCache = localCache.getPHDCache(); -// PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); -// if (Objects.isNull(phd)){ -// result.error500("请先选择解析文件!"); -// return result; -// } -// List m_vCount = new LinkedList<>(); -// long m_nCount = phd.getSpec().getNum_g_channel(); -// long m_nSChan = phd.getSpec().getBegin_channel(); -// //获取当前角色的颜色配置 -// Map colorMap = sysUserColorService.initColor(userName); -// // 确保绘制曲线时所有谱都是从1道开始 -// int i = 0; -// if(m_nSChan == 0){ -// i = 1; -// } -// for(; i peakSet = gammaFileUtil.PeakSet(phd.getVPeak(), baseLineCtrls.getBaseline(), colorMap.get("Color_peak"), m_nCount, null, false); -// m_chart->AddData(CreateTempBaseLine(m_data->m_Color[Color_base], "BaseLine")); -// CreateShapeCP(MyChartSpace::Shape_Round); -// -// if(m_baseCtrl.BaseStack.size() > 2) m_baseCtrl.BaseStack.remove(1, m_baseCtrl.BaseStack.size()-2); -// } - - return null; + Result result = new Result(); + HashMap map = new HashMap<>(); + //获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + //获取文件名称 + String fileName = baseLineCtrls.getFileName(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + List m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if(m_nSChan == 0){ + i = 1; + } + for(; i peakSet = gammaFileUtil.PeakSet(phd.getVPeak(), baseLineCtrls.getBaseline(), colorMap.get("Color_peak"), m_nCount, null, false); + map.put("peakSet", peakSet); + ChartData chartData = gammaFileUtil.CreateTempBaseLine(colorMap.get("Color_base"), "BaseLine", m_baseCtrl); + map.put("chartData", chartData); + List shapeData = gammaFileUtil.CreateShapeCP(phd.getBaseCtrls()); + map.put("shapeData", shapeData); + if(m_baseCtrl.getBaseStack().size() > 2) { + for (int j =1; j 1) { - for (int i=0; i 1) { +// for (int i=0; i m_vCount = new LinkedList<>(); long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); @@ -3240,15 +3295,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi @Override public void viewARR(Integer sampleId, HttpServletResponse response) { - if(Objects.isNull(sampleId)) { - String waring = "The file isn't existed."; - } //获取自动处理生成的报告地址 String reportPath = spectrumAnalysisMapper.viewARR(sampleId); - if(StringUtils.isBlank(reportPath.trim())) { - String waring = "The file isn't existed."; - } - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt"; //连接ftp FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -3304,7 +3353,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if(StringUtils.isBlank(reportPath.trim())) { String waring = "The file isn't existed."; } - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt"; //连接ftp FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -3841,13 +3890,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi @Override public void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) { - if (Objects.isNull(sampleId)){ - String waring = "The file isn't existed."; - } String logPath = spectrumAnalysisMapper.findAutomaticLogPath(sampleId); - if (StringUtils.isBlank(logPath)){ - String waring = "The file isn't existed."; - } String pathName = StringPool.SLASH + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath.substring(0, logPath.lastIndexOf(StringPool.SLASH)); String fileName = logPath.substring(logPath.lastIndexOf(StringPool.SLASH) + 1); //连接ftp 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 98d20232..a530ccf7 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 @@ -41,6 +41,8 @@ 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.CalcBgBoundaryParam; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; @@ -309,6 +311,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { List sampleBoundary = new LinkedList<>(); List gasBoundary = new LinkedList<>(); List detBoundary = new LinkedList<>(); + List qcBoundary = new LinkedList<>(); if (Objects.isNull(sampleId)){ result.error500("请选择一条数据"); return result; @@ -338,7 +341,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = dbSpectrumFilePath.getSampleFilePath(); filePath.add(sampleFilePath); GardsSampleData sample = spectrumAnalysisMapper.findSampleByFilePath(sampleFilePath); - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); sampleMap = this.fenxi(pathName, fileName, sample.getSampleId(), sample.getStatus()); resultMap.put("sample",sampleMap); @@ -347,7 +350,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String gasBgFilePath = dbSpectrumFilePath.getGasBgFilePath(); filePath.add(gasBgFilePath); GardsSampleData gasBg = spectrumAnalysisMapper.findSampleByFilePath(gasBgFilePath); - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasBgFilePath.substring(0, gasBgFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasBgFilePath.substring(0, gasBgFilePath.lastIndexOf(StringPool.SLASH)); String fileName = gasBgFilePath.substring(gasBgFilePath.lastIndexOf(StringPool.SLASH)+1); if (Objects.nonNull(gasBg)) { gasBgMap = this.fenxi(pathName, fileName, gasBg.getSampleId(), gasBg.getStatus()); @@ -358,7 +361,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String detBgFilePath = dbSpectrumFilePath.getDetBgFilePath(); filePath.add(detBgFilePath); GardsSampleData detBg = spectrumAnalysisMapper.findSampleByFilePath(detBgFilePath); - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detBgFilePath.substring(0, detBgFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detBgFilePath.substring(0, detBgFilePath.lastIndexOf(StringPool.SLASH)); String fileName = detBgFilePath.substring(detBgFilePath.lastIndexOf(StringPool.SLASH)+1); if (Objects.nonNull(detBg)) { detBgMap = this.fenxi(pathName, fileName, detBg.getSampleId(), detBg.getStatus()); @@ -371,7 +374,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { dbSpectrumFilePath.setQcFilePath(dbQcFilePath); filePath.add(dbQcFilePath); GardsSampleData qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); String fileName = dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH)+1); if (Objects.nonNull(qc)) { qcMap = this.fenxi(pathName, fileName, qc.getSampleId(), qc.getStatus()); @@ -387,6 +390,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { sampleBoundary = (List) xeDataMap.get("SampleBoundary"); gasBoundary = (List) xeDataMap.get("GasBoundary"); detBoundary = (List) xeDataMap.get("DetBoundary"); + qcBoundary = (List) xeDataMap.get("QCBoundary"); bProcessed = true; if (CollectionUtils.isNotEmpty(sampleBoundary)) { sampleMap.put("Boundary", sampleBoundary); @@ -397,6 +401,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (CollectionUtils.isNotEmpty(detBoundary)) { detBgMap.put("Boundary", detBoundary); } + if (CollectionUtils.isNotEmpty(qcBoundary)) { + qcMap.put("Boundary", qcBoundary); + } } //Xe if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){ @@ -436,6 +443,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { List sampleBoundary = new LinkedList<>(); List gasBoundary = new LinkedList<>(); List detBoundary = new LinkedList<>(); + List qcBoundary = new LinkedList<>(); List filePath = new LinkedList<>(); Map sampleMap = new HashMap<>(); Map gasBgMap = new HashMap<>(); @@ -478,6 +486,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { sampleBoundary = (List) xeDataMap.get("SampleBoundary"); gasBoundary = (List) xeDataMap.get("GasBoundary"); detBoundary = (List) xeDataMap.get("DetBoundary"); + qcBoundary = (List) xeDataMap.get("QCBoundary"); bProcessed = true; savedAnalysisResult = true; //Xe @@ -506,6 +515,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (CollectionUtils.isNotEmpty(detBoundary)) { detBgMap.put("Boundary", detBoundary); } + if (CollectionUtils.isNotEmpty(qcBoundary)) { + qcMap.put("Boundary", qcBoundary); + } } resultMap.put("XeData", xeResultsSpectrumList); resultMap.put("bProcessed", bProcessed); @@ -583,7 +595,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //判断sampleId是否为空 如果不为空 则当前操作数据来源是数据库 文件路径从数据库中查询 if (Objects.nonNull(sampleId)) { String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); CommentData commentData = spectrumAnalysisMapper.viewComment(sampleId); if (Objects.nonNull(commentData)){ if (!commentData.getAnalyst().equals(userName)){ @@ -653,7 +665,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (StringUtils.isBlank(reportPath)){ throw new RuntimeException("自动处理程序生成报告不存在!"); } - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); + String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt"; //连接ftp FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -727,9 +739,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); 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)); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); } } else { sampleFilePath = path; @@ -766,49 +778,55 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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); + if (Objects.nonNull(sampleSourceData)) { + 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); } } if (StringUtils.isNotBlank(gasFilePath)){ EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, rrrLogInfo.getGasFileName()); - information.setGas_measid_name(gasSourceData.measurement_id); + if (Objects.nonNull(gasSourceData)) { + 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); + if (Objects.nonNull(detSourceData)) { + information.setDet_measid_name(detSourceData.measurement_id); + } } StringBuffer strBuffer = new StringBuffer(); strBuffer.append("CNL06 GENERATED REPORT").append("\n"); @@ -952,7 +970,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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(); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath(); } List lines = phdFileUtil.readLine(sampleFilePath); map.put("sample", lines); @@ -960,7 +978,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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(); + gasBgFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath(); } List lines = phdFileUtil.readLine(gasBgFilePath); map.put("gasBg", lines); @@ -968,7 +986,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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(); + detBgFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath(); } List lines = phdFileUtil.readLine(detBgFilePath); map.put("detBg", lines); @@ -977,7 +995,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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); + dbQcFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); } List lines = phdFileUtil.readLine(dbQcFilePath); map.put("qc", lines); @@ -994,7 +1012,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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)); + pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); } if (StringUtils.isNotBlank(sampleFileName)){ FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -1153,9 +1171,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); } dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - gasFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - detFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + 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()); @@ -1182,43 +1200,45 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { EnergySpectrumStruct gasSourceData = phdFileUtil.analyzeFileSourceData(gasFilePath, gasFileName); EnergySpectrumStruct detSourceData = phdFileUtil.analyzeFileSourceData(detFilePath, detFileName); try { - Date collectStartDate = DateUtils.parseDate(sampleSourceData.collection_start_date + StringPool.SPACE + sampleSourceData.collection_start_time); - Date collectStopDate = DateUtils.parseDate(sampleSourceData.collection_stop_date + StringPool.SPACE + sampleSourceData.collection_stop_time); - Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); - String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); - qcResult.setCollectTimeValue(collection_time_value); - if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ - qcResult.setCollectTimeStatus("Pass"); - }else { - qcResult.setCollectTimeStatus("Failed"); - } - String acquisition_live_sec = String.format("%.2f",sampleSourceData.acquisition_live_time/3600.0); - qcResult.setAcquisitionTimeValue(acquisition_live_sec); - if (acquisitionTimeSections.get(1) < sampleSourceData.acquisition_live_time/3600.0 && sampleSourceData.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ - qcResult.setAcquisitionTimeStatus("Pass"); - }else { - qcResult.setAcquisitionTimeStatus("Failed"); - } - String s_xe_stable_volume = String.valueOf(sampleSourceData.sample_volume_of_Xe); - qcResult.setXenonVolumeValue(s_xe_stable_volume); - if (xeVolumeSections.get(1) < sampleSourceData.sample_volume_of_Xe){ - qcResult.setXenonVolumeStatus("Pass"); - }else { - qcResult.setXenonVolumeStatus("Failed"); - } - // - String gasMeasurementID = gasSourceData.measurement_id; - if (gasMeasurementID.equals(sampleSourceData.gas_bk_measurement_id)){ - qcResult.setGasBgValueAndStatus(true); - }else { - qcResult.setGasBgValueAndStatus(false); - } - // - String detMeasurementID = detSourceData.measurement_id; - if (detMeasurementID.equals(sampleSourceData.detector_bk_measurement_id)){ - qcResult.setDetBgValueAndStatus(true); - }else { - qcResult.setDetBgValueAndStatus(false); + if (Objects.nonNull(sampleSourceData) && Objects.nonNull(gasSourceData) && Objects.nonNull(detSourceData)) { + Date collectStartDate = DateUtils.parseDate(sampleSourceData.collection_start_date + StringPool.SPACE + sampleSourceData.collection_start_time); + Date collectStopDate = DateUtils.parseDate(sampleSourceData.collection_stop_date + StringPool.SPACE + sampleSourceData.collection_stop_time); + Double collection_time = Double.valueOf(collectStopDate.getTime() / 1000 - collectStartDate.getTime() / 1000); + String collection_time_value = String.format("%.2f",Double.valueOf(collectStopDate.getTime()/1000 - collectStartDate.getTime()/ 1000)/3600.0); + qcResult.setCollectTimeValue(collection_time_value); + if (collectionTimeSections.get(1) < collection_time/3600 && collection_time/3600 < collectionTimeSections.get(4)){ + qcResult.setCollectTimeStatus("Pass"); + }else { + qcResult.setCollectTimeStatus("Failed"); + } + String acquisition_live_sec = String.format("%.2f",sampleSourceData.acquisition_live_time/3600.0); + qcResult.setAcquisitionTimeValue(acquisition_live_sec); + if (acquisitionTimeSections.get(1) < sampleSourceData.acquisition_live_time/3600.0 && sampleSourceData.acquisition_live_time/3600.0 < acquisitionTimeSections.get(4)){ + qcResult.setAcquisitionTimeStatus("Pass"); + }else { + qcResult.setAcquisitionTimeStatus("Failed"); + } + String s_xe_stable_volume = String.valueOf(sampleSourceData.sample_volume_of_Xe); + qcResult.setXenonVolumeValue(s_xe_stable_volume); + if (xeVolumeSections.get(1) < sampleSourceData.sample_volume_of_Xe){ + qcResult.setXenonVolumeStatus("Pass"); + }else { + qcResult.setXenonVolumeStatus("Failed"); + } + // + String gasMeasurementID = gasSourceData.measurement_id; + if (gasMeasurementID.equals(sampleSourceData.gas_bk_measurement_id)){ + qcResult.setGasBgValueAndStatus(true); + }else { + qcResult.setGasBgValueAndStatus(false); + } + // + String detMeasurementID = detSourceData.measurement_id; + if (detMeasurementID.equals(sampleSourceData.detector_bk_measurement_id)){ + qcResult.setDetBgValueAndStatus(true); + }else { + qcResult.setDetBgValueAndStatus(false); + } } } catch (ParseException e) { throw new RuntimeException(e); @@ -1297,7 +1317,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); if (Objects.nonNull(sampleId)) { sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + sampleFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); //查询数据库中结果的Xe数据 xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId); } else { @@ -1415,7 +1435,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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)); + qcPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); } } FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -1563,7 +1583,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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)); + qcPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); } } FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -1709,7 +1729,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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)); + samplePathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); } //加载dll工具库 //System.loadLibrary("ReadPHDFile"); @@ -1860,7 +1880,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { //判断sampleId是否存在 if (Objects.nonNull(sampleId)) { String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - filePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + filePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); } //加载dll工具库 //System.loadLibrary("ReadPHDFile"); @@ -2381,7 +2401,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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)); + qcPathName=StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); } } FTPClient ftpClient = ftpUtil.LoginFTP(); @@ -2473,7 +2493,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); String gasFilePath = dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); String detFilePath = dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); - List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, sampleFilePath, gasFilePath, detFilePath, userName); + String qcFilePath = ""; + 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)) { + qcFilePath=StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + } + List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, sampleFilePath, gasFilePath, detFilePath, qcFilePath, userName); map.put("xeData", analyseResult); map.put("bProcessed", true); map.put("savedAnalysisResult", true); @@ -2482,7 +2509,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } } else { String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, path, path, path, userName); + List analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, path, path, path, path, userName); map.put("XeData", analyseResult); map.put("bProcessed", true); map.put("savedAnalysisResult", true); @@ -2515,17 +2542,27 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); String gasFilePath = dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); String detFilePath = dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + String qcFilePath = ""; + 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)) { + qcFilePath=StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH)); + } m_loadData.put("sampleFilePath", sampleFilePath); m_loadData.put("gasFilePath", gasFilePath); m_loadData.put("detFilePath", detFilePath); + m_loadData.put("qcFilePath", qcFilePath); } } else { String sampleFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; String gasFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; String detFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + String qcFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; m_loadData.put("sampleFilePath", sampleFilePath); m_loadData.put("gasFilePath", gasFilePath); m_loadData.put("detFilePath", detFilePath); + m_loadData.put("qcFilePath", qcFilePath); } m_loadData.put("sampleFileName", sampleFileName); m_loadData.put("gasFileName", gasFileName); @@ -2543,7 +2580,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return result; } - private List BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, String sampleFilePath, String gasFilePath, String detFilePath, String userName) { + private List BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, String sampleFilePath, String gasFilePath, String detFilePath, String qcFilePath, String userName) { //根据文件路径 文件名称获取对应的临时文件 File sampleTmp = null; File gasTmp = null; @@ -2573,17 +2610,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Cache> cache = betaCache.getBetaCache(); //根据qc文件名称-用户名-beta的方式获取beta的内容 Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); List betaFittingPara = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); betaFittingPara = (List) betaMap.get("fittingPara"); betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); } //根据qc文件名称-用户名-gamma的方式获取gamma的内容 Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); List gammaFittingPara = new LinkedList<>(); List gammaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } @@ -2732,6 +2773,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } xeMap.put("DetBoundary", boundaryList); } + if (analyseData.isQcData()) { + if (StringUtils.isNotBlank(qcFilePath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap); + } + } + } //将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中 cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map); cache.put(sampleFileName + "-" + userName + "-xeData", xeMap); @@ -2766,6 +2815,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String sampleFilePath = m_loadData.get("sampleFilePath"); String gasFilePath = m_loadData.get("gasFilePath"); String detFilePath = m_loadData.get("detFilePath"); + String qcFilePath = m_loadData.get("qcFilePath"); //存储重新分析字段的实体类 SpectrumGroup spectrum_group = new SpectrumGroup(); //声明一个map 缓存重新分析用到的数据 @@ -2776,17 +2826,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Cache> cache = betaCache.getBetaCache(); //根据qc文件名称-用户名-beta的方式获取beta的内容 Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); List betaFittingPara = new LinkedList<>(); List betaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); betaFittingPara = (List) betaMap.get("fittingPara"); betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); } //根据qc文件名称-用户名-gamma的方式获取gamma的内容 Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); List gammaFittingPara = new LinkedList<>(); List gammaFittingParaToUi = new LinkedList<>(); if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); gammaFittingPara = (List) gammaMap.get("fittingPara"); gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); } @@ -2927,6 +2981,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } xeMap.put("DetBoundary", boundaryList); } + if (analyseData.isQcData()) { + if (StringUtils.isNotBlank(qcFilePath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcFilePath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap); + } + } + } //将重新计算的参数以及重新计算后的xeData的数据缓存到本地缓存中 cache.put(sampleFileName + "-" + userName + "-reAnalyseParam", map); cache.put(sampleFileName + "-" + userName + "-xeData", xeMap); @@ -2963,6 +3025,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { String samplePath = ""; String gasPath = ""; String detPath = ""; + String qcPath = ""; File sampleTmp = null; File gasTmp = null; File detTmp = null; @@ -2978,9 +3041,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); } dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID); - samplePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); - gasPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); - detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + samplePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + gasPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + detPath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + 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.getSaveFilePath() + StringPool.SLASH + dbQcFilePath.substring(0, dbQcFilePath.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; @@ -2988,6 +3057,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { samplePath = path; gasPath = path; detPath = path; + qcPath = path; } //根据文件路径 文件名称获取对应的临时文件 sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName); @@ -3000,6 +3070,22 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { map.put("sampleFileName", sampleFileName); //获取本地缓存的数据信息 Cache> cache = betaCache.getBetaCache(); + //根据qc文件名称-用户名-beta的方式获取beta的内容 + Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); + List betaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); + betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); + } + //根据qc文件名称-用户名-gamma的方式获取gamma的内容 + Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); + List gammaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); + gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); + } //根据key获取重新分析的参数 Map reAnalyseParam = cache.getIfPresent(sampleFileName + "-" + userName + "-reAnalyseParam"); //判断重新分析的参数信息是否为空 @@ -3008,6 +3094,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } //调用分析方法 phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + //分析qc文件信息并重新计算qc边界值 + if (StringUtils.isNotBlank(qcPath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); + } + } if (CollectionUtils.isNotEmpty(map)) { List xeDataList = (List) map.get("XeData"); if (CollectionUtils.isNotEmpty(xeDataList)){ @@ -3061,6 +3154,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { try { if (CollectionUtils.isNotEmpty(sampleFileNames)) { for (int i=0; i> cache = betaCache.getBetaCache(); + //根据qc文件名称-用户名-beta的方式获取beta的内容 + Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); + List betaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); + betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); + } + //根据qc文件名称-用户名-gamma的方式获取gamma的内容 + Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); + List gammaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); + gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); + } //根据key获取重新分析的参数 Map reAnalyseParam = cache.getIfPresent(sampleFileName + "-" + userName + "-reAnalyseParam"); //判断重新分析的参数信息是否为空 @@ -3116,6 +3236,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } //调用分析方法 phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + //分析qc文件信息并重新计算qc边界值 + if (StringUtils.isNotBlank(qcPath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); + } + } List xeDataList = (List) map.get("XeData"); if (CollectionUtils.isNotEmpty(xeDataList)){ for (GardsXeResultsSpectrum xeData:xeDataList) { @@ -3243,19 +3370,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(sampleId)) { SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(anlyseResultIn.getDbName(), sampleId, analysisID); if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ - anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH))); } if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { - anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH))); } if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { - anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH))); } if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) { String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); String qcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); if (StringUtils.isNotBlank(qcFilePath)) { - anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); } } } @@ -3412,9 +3539,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); - ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); + ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } finally { @@ -3500,18 +3627,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(sampleId)) { SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(anlyseResultIn.getDbName(), sampleId, analysisID); if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){ - anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH))); } if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) { - anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH))); } if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) { - anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH))); } if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) { String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss"); String qcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr); - anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); + anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH))); } } } else { diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java index 419fdebd..6b39656f 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java @@ -47,7 +47,7 @@ public class ReadLineUtil { try { ftpClient.enterLocalPassiveMode(); String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1); - String parameterFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH)); + String parameterFilePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH)); //判断文件路径是否为空 if (StringUtils.isNotBlank(parameterFilePath)){ //在当前工作路径下读取文件 @@ -187,7 +187,7 @@ public class ReadLineUtil { OutputStream outputStream = null; InputStream inputStream = null; try { - filePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + filePath; + filePath = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath; // 切换工作目录为 / ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);