From 602345508ecdecab9dca2e7f04a98cf7a8e5e169 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 3 Nov 2023 10:33:00 +0800 Subject: [PATCH] =?UTF-8?q?beta,gamma=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E8=BF=94=E5=9B=9E=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD=E5=8F=A5=20beta=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BD=93=E5=88=86=E6=9E=90=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=9C=89=E9=94=99=E8=AF=AF=E6=97=B6=EF=BC=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 4 + .../org/jeecg/common/util/PHDFileUtil.java | 7 +- .../service/impl/GammaServiceImpl.java | 6 +- .../impl/SpectrumAnalysisServiceImpl.java | 158 +++++++++--------- 4 files changed, 95 insertions(+), 80 deletions(-) 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 cdb5cd8b..e8d6431d 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -65,6 +65,10 @@ public class GammaFileUtil extends AbstractLogOrReport { phd.setFilename(fileName); String fromPath = pathName + StringPool.SLASH + fileName; File file = ftpUtil.downloadFile(fromPath, "betaGamma"); + if (Objects.isNull(file)) { + result.error500("ftp file can't find"); + return false; + } try { //读取文件信息 EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); 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 01cbd7ff..fccf5a01 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 @@ -605,7 +605,8 @@ public class PHDFileUtil extends AbstractLogOrReport { return file; } - public void analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map map) { + public boolean analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map map) { + boolean bRet = true; //调用动态库解析文件 BgAnalyseResult analyseResult = null; if (Objects.isNull(BgCalPara)) { @@ -614,7 +615,8 @@ public class PHDFileUtil extends AbstractLogOrReport { analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), BgCalPara); } if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) { - return; + bRet = false; + return bRet; } else { EnergySpectrumStruct sample = analyzeFileSourceData(sampleTmp); EnergySpectrumStruct gas = analyzeFileSourceData(gasTmp); @@ -695,6 +697,7 @@ public class PHDFileUtil extends AbstractLogOrReport { } map.put("DetBoundary", boundaryList); } + return bRet; } } 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 762f7c5c..d43fece3 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 @@ -834,6 +834,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi phd = new PHDFile(); // 加载文件内容 boolean bRet = gammaFileUtil.loadFile(path, fileName, phd, result); + if (!bRet) { + return result; + } if (!redisUtil.hasKey(fileName+"-"+userName)) { // 查询当前用户关联的核素信息 List userLib = new LinkedList<>(); @@ -845,9 +848,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi Map nuclideMap = GetNuclideLines(userLib); redisUtil.set(fileName+"-"+userName, nuclideMap); } - if (!bRet) { - return result; - } } // 更新 ‘QC Flags’ 状态 List qcstate = gammaFileUtil.Qcstate(phd); 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 ef18a282..6fc3b545 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 @@ -3,7 +3,6 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; @@ -13,8 +12,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.cache.Cache; -import com.google.common.collect.Lists; -import kotlin.collections.EmptyList; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.net.ftp.FTP; @@ -36,7 +33,7 @@ import org.jeecg.modules.base.dto.ROIChannelsDto; import org.jeecg.modules.base.dto.ROIResultsDto; import org.jeecg.modules.base.dto.XeResultsDto; import org.jeecg.modules.base.entity.configuration.GardsDetectors; -import org.jeecg.modules.base.entity.original.*; +import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.rnman.*; import org.jeecg.modules.base.enums.*; import org.jeecg.modules.entity.*; @@ -59,13 +56,10 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; -import java.net.URLEncoder; -import java.sql.*; import java.text.ParseException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.Date; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -563,6 +557,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(inputStream)){ //声明一个临时文件 file = File.createTempFile("betaGamma", null); + if (Objects.isNull(file)) { + throw new RuntimeException("ftp file can't find!"); + } //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); map = phdFileUtil.getSourceData(file.getAbsolutePath(), sampleId, status); @@ -3115,10 +3112,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); } + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); } map.put("XeData", analyseResult); - map.put("bProcessed", true); - map.put("savedAnalysisResult", true); result.setSuccess(true); result.setResult(map); } @@ -3196,10 +3193,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); } + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); } map.put("XeData", analyseResultList); - map.put("bProcessed", true); - map.put("savedAnalysisResult", true); result.setSuccess(true); result.setResult(map); } @@ -3549,7 +3546,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) { BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); if (StringUtils.isNotBlank(analyseResult.error_log) && !analyseResult.error_log.equalsIgnoreCase("no error.")) { - continue; + analyseResultMap.put(sampleFileName, Collections.EMPTY_LIST); } else { //生成分析操作日志 EnergySpectrumStruct sample = phdFileUtil.analyzeFileSourceData(sampleTmp); @@ -3745,40 +3742,45 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { BgCalPara = (BgCalibratePara) reAnalyseParam.get("reAnalyseParam"); } //调用分析方法 - 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)){ - for (GardsXeResultsSpectrum xeData:xeDataList) { - Double conc = xeData.getConc(); - Double mdc = xeData.getMdc(); - if (conc < 0){ - xeData.setColor("red"); - xeData.setNidFlag(0); - } else if (0 mdc) { - xeData.setColor("green"); - xeData.setNidFlag(1); - } - xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); - xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); - xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); + boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + if (bRet) { + //分析qc文件信息并重新计算qc边界值 + if (StringUtils.isNotBlank(qcPath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); } } - //更新分析后的缓存信息 - cache.put(sampleFileName + "-" + userName + "-xeData", map); - betaCache.setBetaCache(cache); - map.put("bProcessed", true); - map.put("savedAnalysisResult", true); + if (CollectionUtils.isNotEmpty(map)) { + List xeDataList = (List) map.get("XeData"); + if (CollectionUtils.isNotEmpty(xeDataList)){ + for (GardsXeResultsSpectrum xeData:xeDataList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + xeData.setNidFlag(0); + } else if (0 mdc) { + xeData.setColor("green"); + xeData.setNidFlag(1); + } + xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); + xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); + xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); + } + } + //更新分析后的缓存信息 + cache.put(sampleFileName + "-" + userName + "-xeData", map); + betaCache.setBetaCache(cache); + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); + } + } else { + map.clear(); + map.put("XeData", Collections.EMPTY_LIST); } } catch (Exception e) { e.printStackTrace(); @@ -3891,40 +3893,46 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } if(Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) { //调用分析方法 - 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) { - Double conc = xeData.getConc(); - Double mdc = xeData.getMdc(); - if (conc < 0){ - xeData.setColor("red"); - xeData.setNidFlag(0); - } else if (0 mdc) { - xeData.setColor("green"); - xeData.setNidFlag(1); + boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map); + if (bRet) { + //分析qc文件信息并重新计算qc边界值 + if (StringUtils.isNotBlank(qcPath)) { + EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(qcPath, qcFileName); + if (Objects.nonNull(struct)) { + phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map); } - xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); - xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); - xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); } + List xeDataList = (List) map.get("XeData"); + if (CollectionUtils.isNotEmpty(xeDataList)){ + for (GardsXeResultsSpectrum xeData:xeDataList) { + Double conc = xeData.getConc(); + Double mdc = xeData.getMdc(); + if (conc < 0){ + xeData.setColor("red"); + xeData.setNidFlag(0); + } else if (0 mdc) { + xeData.setColor("green"); + xeData.setNidFlag(1); + } + xeData.setMdc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getMdc())).substring(0, String.valueOf(Math.abs(xeData.getMdc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getMdc()))); + xeData.setConc(Double.valueOf(String.format("%."+(6 - String.valueOf(Math.abs(xeData.getConc())).substring(0, String.valueOf(Math.abs(xeData.getConc())).lastIndexOf(StringPool.DOT)).length())+"f", xeData.getConc()))); + xeData.setConcErr(Double.valueOf(String.format("%."+((6 - String.valueOf(Math.abs(xeData.getConcErr())).substring(0, String.valueOf(Math.abs(xeData.getConcErr())).lastIndexOf(StringPool.DOT)).length()))+"f", xeData.getConcErr()))); + } + } + //更新分析后的缓存信息 + cache.put(sampleFileName + "-" + userName + "-xeData", map); + betaCache.setBetaCache(cache); + map.put("bProcessed", true); + map.put("savedAnalysisResult", true); + mapList.put(sampleFileName, map); + } else { + map.clear(); + map.put("XeData", Collections.EMPTY_LIST); + mapList.put(sampleFileName, map); } - //更新分析后的缓存信息 - cache.put(sampleFileName + "-" + userName + "-xeData", map); - betaCache.setBetaCache(cache); - map.put("bProcessed", true); - map.put("savedAnalysisResult", true); - mapList.put(sampleFileName, map); } } }