From 34ae27846314f5202b56aae76e808033a234d111 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 13 Sep 2023 15:27:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AEsampleFileName=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20XeData=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0flag=E5=AD=97=E6=AE=B5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SpectrumAnalysisServiceImpl.java | 158 ++++++++++-------- 1 file changed, 86 insertions(+), 72 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 957db613..4c92d6ab 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 @@ -253,7 +253,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { result.error500("ftp文件查询失败"); return result; } - String sampleFileName = fileName; + String sampleFileName = matchFileName; String sampleSystemType = fileData.get("sampleSystemType"); if (sampleSystemType.equals(SystemType.BETA.getType())) { //加载并获取当前路径下所有的文件名称并进行名称格式化 仅需要格式化和sample文件同一个台站 名称格式化为最终名称 @@ -2539,10 +2539,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Double mdc = xeData.getMdc(); if (conc < 0){ xeData.setColor("red"); + xeData.setNidFlag(0); } else if (0 mdc) { xeData.setColor("green"); + xeData.setNidFlag(1); } } map.put("XeData", xeDataList); @@ -2610,10 +2613,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Double mdc = xeData.getMdc(); if (conc < 0){ xeData.setColor("red"); + xeData.setNidFlag(0); } else if (0 mdc) { xeData.setColor("green"); + xeData.setNidFlag(1); } } map.put("XeData", xeDataList); @@ -2630,6 +2636,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result saveToDB(BgDataAnlyseResultIn anlyseResultIn) { Result result = new Result(); + Map map = new HashMap<>(); String beginDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); String endDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); //判断当前分析员是否有过排班任务 @@ -2643,29 +2650,35 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { getChannelAndEnergy(anlyseResultIn); //获取ROI Limit数据 // getROILimit(anlyseResultIn); - //计算得到各文件的边界值 - BgBoundary sampleBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); - BgBoundary gasBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); - BgBoundary detBoundary = phdFileUtil.CalBoundary(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); //处理文件名称 String sampleFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); String gasFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); String detFilePathName = phdFileUtil.NameStandardBy(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); //判断文件是否存储过 如果没有则解析文件并进行存储 if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("gasFile save failed"); return result; } if ( !OriginalDataStore(anlyseResultIn.getDetFilePath(), anlyseResultIn.getGasFileName(), detFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("detFile save failed"); return result; } if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){ - result.error500("file save failed"); + result.error500("sampleFile save failed"); return result; } //判断当前分析员是否有过历史分析当前文件 Integer isExist = spectrumAnalysisMapper.SampleIsExist(sampleFilePathName, anlyseResultIn.getUserName()); + //获取sample,gas,det对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); + File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); + File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName()); + if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) { + result.error500("ftp文件获取失败!"); + return result; + } + //解析文件内容获取对应数据 + BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map); //根据文件名称查询对应的sampleId--- sampleFile gasFile detFile Integer sampleId = spectrumAnalysisMapper.getSampleId(sampleFilePathName); Integer gasId = spectrumAnalysisMapper.getSampleId(gasFilePathName); @@ -2685,79 +2698,88 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { gardsAnalyses.setUsedgasphdId(gasId); gardsAnalyses.setUseddetphdId(detId); gardsAnalyses.setAnalyst(anlyseResultIn.getUserName()); + map.put("gardsAnalyses", gardsAnalyses); if (Objects.nonNull(isExist)){ - spectrumAnalysisMapper.updateGardsAnalyses(gardsAnalyses); + //spectrumAnalysisMapper.updateGardsAnalyses(gardsAnalyses); }else {//如果没有分析过就新增--GARDS_ANALYSES - spectrumAnalysisMapper.insertGardsAnalyses(gardsAnalyses); + //spectrumAnalysisMapper.insertGardsAnalyses(gardsAnalyses); } //查询analysisId根据sampleId 分析员名称--GARDS_ANALYSES GardsAnalysesSpectrum analysis = spectrumAnalysisMapper.getAnalysis("RNMAN.GARDS_ANALYSES", sampleId); Integer idAnalysis = analysis.getIdAnalysis(); //获取sample,gas,det三个文件分别对应的beta,gamma数据集合 List calibrationPairsList = getCalibrationPairs(anlyseResultIn, sampleId, gasId, detId, idAnalysis); + map.put("calibrationPairsList", calibrationPairsList); //如果分析过--删除GARDS_CALIBRATION_PAIRS表数据 新增GARDS_CALIBRATION_PAIRS表数据 if (Objects.nonNull(isExist)){ //根据idAnalysis删除GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.deleteCalibrationPairs(idAnalysis); + //spectrumAnalysisMapper.deleteCalibrationPairs(idAnalysis); //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); }else {//如果没有分析过--新增GARDS_CALIBRATION_PAIRS表数据 //新增GARDS_CALIBRATION_PAIRS表数据 - spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); + //spectrumAnalysisMapper.insertCalibrationPairs(calibrationPairsList); } //gards_calibration 数据表 List calibrationList = getCalibration(anlyseResultIn, sampleId, gasId, detId, idAnalysis); + map.put("calibrationList", calibrationList); //判断是否分析过 if (Objects.nonNull(isExist)) { //删除Gards_Calibration表数据 - spectrumAnalysisMapper.deleteCalibration(idAnalysis); + //spectrumAnalysisMapper.deleteCalibration(idAnalysis); //新增数据 - spectrumAnalysisMapper.insertCalibration(calibrationList); + //spectrumAnalysisMapper.insertCalibration(calibrationList); } else { //新增数据 - spectrumAnalysisMapper.insertCalibration(calibrationList); + //spectrumAnalysisMapper.insertCalibration(calibrationList); } //gards_roi_channels数据表 List roiChannelsList = new LinkedList<>(); - getROIChannel(sampleId, idAnalysis, sampleBoundary, roiChannelsList); - getROIChannel(gasId, idAnalysis, gasBoundary, roiChannelsList); - getROIChannel(detId, idAnalysis, detBoundary, roiChannelsList); + List roiChannelsSpectrumList = (List) map.get("roiChannelsSpectrumList"); + getROIChannel(sampleId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + getROIChannel(gasId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + getROIChannel(detId, idAnalysis, roiChannelsSpectrumList, roiChannelsList); + map.put("roiChannelsList", roiChannelsList); //如果分析过数据 if (Objects.nonNull(isExist)){ //删除gards_roi_channels数据表数据 - spectrumAnalysisMapper.deleteROIChannels(idAnalysis); + //spectrumAnalysisMapper.deleteROIChannels(idAnalysis); //新增gards_roi_channels数据表数据 - spectrumAnalysisMapper.insertROIChannels(roiChannelsList); + //spectrumAnalysisMapper.insertROIChannels(roiChannelsList); }else {//没有分析过 //新增gards_roi_channels数据表数据 - spectrumAnalysisMapper.insertROIChannels(roiChannelsList); + //spectrumAnalysisMapper.insertROIChannels(roiChannelsList); } //gards_Xe_results数据表 List xeResults = getXeResults(anlyseResultIn, sampleId, idAnalysis); + map.put("xeResults", xeResults); if(Objects.nonNull(isExist)) { //删除gards_Xe_results数据表数据 - spectrumAnalysisMapper.deleteXeResult(idAnalysis); + //spectrumAnalysisMapper.deleteXeResult(idAnalysis); //新增gards_Xe_results数据表数据 - spectrumAnalysisMapper.insertXeResult(xeResults); + //spectrumAnalysisMapper.insertXeResult(xeResults); } else { //新增gards_Xe_results数据表数据 - spectrumAnalysisMapper.insertXeResult(xeResults); + //spectrumAnalysisMapper.insertXeResult(xeResults); } //gards_roi_results数据表 List roiResultsSpectrumList = getROIResult(anlyseResultIn, sampleId, idAnalysis, isExist); + map.put("roiResultsSpectrumList", roiResultsSpectrumList); if(Objects.nonNull(isExist)) { //删除gards_roi_results数据表数据 - spectrumAnalysisMapper.deleteROIResults(idAnalysis); + //spectrumAnalysisMapper.deleteROIResults(idAnalysis); //新增gards_roi_results数据表数据 - + //spectrumAnalysisMapper.insertROIResults(roiResultsSpectrumList); } else { //新增gards_roi_results数据表数据 - + //spectrumAnalysisMapper.insertROIResults(roiResultsSpectrumList); } + result.setSuccess(true); + result.setResult(map); return result; } - public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn){ + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn) { //获取ftp文件路径下临时文件 File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName()); File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName()); @@ -2965,7 +2987,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { uncertaintyList.add(String.valueOf(uncertainty.get(pos))); } } - } public List getCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) { @@ -3059,16 +3080,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return calibrationSpectrumList; } - public void getROIChannel(Integer sampleId, Integer idAnalysis, BgBoundary bgBoundary, List roiChannelsList) { - for (int i=0; i roiChannelsSpectrumList, List roiChannelsList) { + for (int i=0; i readLines = getFileBlockList(file); - //根据新的文件路径名称查询数据是否存在 - Integer isExist = spectrumAnalysisMapper.SampleIsExist(filePathName, userName); - //如果数据已经存入过数据库 则 修改状态后返回 - if (Objects.nonNull(isExist)){ - //如果文件已经存入过数据库则修改状态 - spectrumAnalysisMapper.updateAnalysesStatus(filePathName); - return true; - } //查询台站id Integer stationId = spectrumAnalysisMapper.getStationId(sourceData.site_code); Integer detectorId = spectrumAnalysisMapper.getDetectorId(sourceData.detector_code); @@ -3244,35 +3265,28 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { 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); + for (int i=0; ianlyseResultIn.getMDC().get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); } - } else if (Objects.nonNull(isExist) && anlyseResultIn.isBProcessed()) {//第二种 从数据库获取的但是进行过改变 - - } else if (Objects.isNull(isExist) && anlyseResultIn.isBProcessed()) {//第三种 文件加载的数据 - + roiResultsSpectrumList.add(roiResults); } return roiResultsSpectrumList; }