From 5719c210ca526df31cdb47a620ef402e40c7478e Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 22 Aug 2024 11:19:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=87=AA=E5=BB=BA=E5=8F=B0?= =?UTF-8?q?=E7=AB=99beta=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/native_jni/CalValuesHandler.java | 2 - .../native_jni/EnergySpectrumHandler.java | 1 + .../entity/GardsXeResultsSpectrum.java | 4 ++ .../service/impl/SelfStationServiceImpl.java | 71 ++++++++++++++----- 4 files changed, 57 insertions(+), 21 deletions(-) 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 91beeb3c..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,8 +27,6 @@ public class CalValuesHandler { public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath, AnalysisProcess process); - public static native String selfBgAnalyse(String PHDPath, String param); - public static native String fitPeakFull(String phd, List Af, List Cf, List Ff); } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java index e78f373d..009f8129 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java @@ -84,4 +84,5 @@ public class EnergySpectrumHandler { public static native List GetFittingData(List data, String fitType, List fittingPara); + public static native String selfBgAnalyse(String PHDPath, String param); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java index 86144cb9..ada56e86 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsXeResultsSpectrum.java @@ -38,6 +38,10 @@ public class GardsXeResultsSpectrum implements Serializable { * 感兴趣区MDC */ private Double mdc; + /** + * 感兴趣区MDC + */ + private Double mda; /** * 感兴趣区LC */ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index 6cc2e9e8..dfbae38e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -487,7 +487,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf String detFilePath = path + StringPool.SLASH + detFileName; //返回结果map Map map = new HashMap<>(); - //获取sample分析后的对象 + //获取det分析后的对象 EnergySpectrumStruct struct = selfStationUtil.getSourceData(detFilePath, "det", selfStationData); if (Objects.nonNull(struct)) { selfStationData.setDetStruct(struct); @@ -506,7 +506,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf String qcFilePath = path + StringPool.SLASH + qcFileName; //返回结果map Map map = new HashMap<>(); - //获取sample分析后的对象 + //获取QC分析后的对象 EnergySpectrumStruct struct = selfStationUtil.getSourceData(qcFilePath, "qc", selfStationData); if (Objects.nonNull(struct)) { selfStationData.setQcStruct(struct); @@ -2547,7 +2547,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf PHDFile phdFour = sampleVueData.getROIFourPHDFile(); Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self"); - Map roiMap = new HashMap<>(); + Map resultMap = new HashMap<>(); try { boolean bROI1 = selfStationUtil.checkROIRenew(sampleVueData, SelfStationConstant.ROI1); boolean bROI2 = selfStationUtil.checkROIRenew(sampleVueData, SelfStationConstant.ROI2); @@ -2564,20 +2564,17 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf } // 如果参数修改 或者 修改某个ROI 只重新分析某个gamma if (flag != 0 || bROI1) { - roiMap.put(SelfStationConstant.ROI1, this.gammaAnalyse(processKey, phdOne, nuclideLinesMap, colorMap, flag)); + resultMap.put(SelfStationConstant.ROI1, this.gammaAnalyse(processKey, phdOne, nuclideLinesMap, colorMap, flag)); } if (flag != 0 || bROI2) { - roiMap.put(SelfStationConstant.ROI2, this.gammaAnalyse(processKey, phdTwo, nuclideLinesMap, colorMap, flag)); + resultMap.put(SelfStationConstant.ROI2, this.gammaAnalyse(processKey, phdTwo, nuclideLinesMap, colorMap, flag)); } if (flag != 0 || bROI3) { - roiMap.put(SelfStationConstant.ROI3, this.gammaAnalyse(processKey, phdThree, nuclideLinesMap, colorMap, flag)); + resultMap.put(SelfStationConstant.ROI3, this.gammaAnalyse(processKey, phdThree, nuclideLinesMap, colorMap, flag)); } if (flag != 0 || bROI4) { - roiMap.put(SelfStationConstant.ROI4, this.gammaAnalyse(processKey, phdFour, nuclideLinesMap, colorMap, flag)); + resultMap.put(SelfStationConstant.ROI4, this.gammaAnalyse(processKey, phdFour, nuclideLinesMap, colorMap, flag)); } -// roiMap.put(SelfStationConstant.ROI2, this.gammaAnalyse(processKey, phdTwo, nuclideLinesMap, colorMap, bROI2)); -// roiMap.put(SelfStationConstant.ROI3, this.gammaAnalyse(processKey, phdThree, nuclideLinesMap, colorMap, bROI3)); -// roiMap.put(SelfStationConstant.ROI4, this.gammaAnalyse(processKey, phdFour, nuclideLinesMap, colorMap, bROI4)); // 用于下次分析判断是否更新 sampleVueData.setUsedROIOneBetaStart(sampleVueData.getROIOneBetaStart()); sampleVueData.setUsedROIOneBetaStop(sampleVueData.getROIOneBetaStop()); @@ -2602,11 +2599,12 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf sampleVueData.setMapResoPara(phdOne.getMapResoPara()); sampleVueData.setMapEffiPara(phdOne.getMapEffiPara()); - // todo 调用beta分析 - this.betaAnalyse(selfStationData.getSampleFilePathName(), selfStationData, nuclideLinesMap); + // 调用beta分析 + List betaResult = this.betaAnalyse(selfStationData, nuclideLinesMap); + resultMap.put("XeData", betaResult); result.setSuccess(true); - result.setResult(roiMap); + result.setResult(resultMap); selfStationData.setBAnalyed(true); } catch (RuntimeException e) { Log.error("analyse error:", e); @@ -2617,10 +2615,16 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf return result; } - private void betaAnalyse(String phdPath, SelfStationData selfStationData, Map nuclideLinesMap) throws JsonProcessingException { + /** + * beta分析 + * @param selfStationData 自建台站缓存数据 + * @param nuclideLinesMap 核素信息 + * @throws JsonProcessingException + */ + private List betaAnalyse(SelfStationData selfStationData, Map nuclideLinesMap) throws JsonProcessingException { SelfStationVueData sampleData = selfStationData.getSampleVueData(); EnergySpectrumStruct struct = selfStationData.getSampleStruct(); - + String phdPath = selfStationData.getSampleFilePathName(); // 获取自建台站参数 SelfParameter selfParameter = (SelfParameter) redisUtil.get(RedisConstant.SELF_PARAMETER); HashMap nuclideMap = selfParameter.getNuclideMap(); @@ -2629,9 +2633,32 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf HashMap nuclideParam = this.getBetaAnalyseNuclideParam(sampleData, nuclideMap, struct.POI_G_y1, struct.POI_G_y2, nuclideLinesMap); Console.log(JSON.toJSONString(nuclideParam)); // 调用beta分析算法 - ObjectMapper mapper = new ObjectMapper(); - String result = CalValuesHandler.selfBgAnalyse(phdPath, JSON.toJSONString(mapper.writeValueAsString(nuclideParam))); - Console.log(result); + String resultStr = EnergySpectrumHandler.selfBgAnalyse(phdPath, JSON.toJSONString(nuclideParam)); + List xeDataList = new ArrayList<>(); + if (StrUtil.isNotBlank(resultStr)) { + xeDataList = JSON.parseArray(resultStr,GardsXeResultsSpectrum.class); + xeDataList.forEach(GardsXeResultsSpectrum::getMdc); + 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(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc())))); + xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc())))); + } + } + } + Console.log(resultStr); + return xeDataList; } /** @@ -2701,8 +2728,14 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf return param; } + /** + * 得到 baseline计数 + * @param sampleData 谱数据 + * @param nuclideName 核素名称 + * @param energy 能量 + * @return + */ private double getBetaAnalyseBaseLineCount(SelfStationVueData sampleData,String nuclideName, Double energy) { - HashMap nuclideParam = Maps.newHashMap(); double baseLineCount = 0; String currentText = null; List vBase = null;