From 48a03b6d6f800cd3b606602f147a52233d23569e Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 24 Jul 2024 16:46:30 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9updateROI?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0;2=20=E5=A2=9E=E5=8A=A0/sel?= =?UTF-8?q?fStation/getGammaGated=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/controller/SelfStationController.java | 14 ++++++++++++-- .../jeecg/modules/service/ISelfStationService.java | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java index f34fffec..e072f946 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java @@ -1,5 +1,7 @@ package org.jeecg.modules.controller; +import com.google.gson.Gson; +import com.google.gson.JsonObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; @@ -15,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.List; @RestController @@ -51,8 +54,9 @@ public class SelfStationController { @PutMapping("updateROI") @ApiOperation(value = "更新ROI范围", notes = "更新ROI范围") - public Result updateROI(@RequestBody List roiParams, @RequestParam String sampleFileName, HttpServletRequest request) { - return selfStationService.updateROI(roiParams, sampleFileName, request); + public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName, HttpServletRequest request) { + ArrayList roiParamList = (ArrayList) new Gson().fromJson(roiParams, List.class); + return selfStationService.updateROI(roiParamList, sampleFileName, request); } @GetMapping("energyCalibration") @@ -281,6 +285,12 @@ public class SelfStationController { return selfStationService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount(), fittingBody.getSampleFileName(), fittingBody.getTabName(), fittingBody.isFittingBtn(), request); } + @GetMapping("getGammaGated") + @ApiOperation(value = "获取gamma对应count数据", notes = "获取gamma对应count数据") + public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, String sampleFileName, HttpServletRequest request) { + return selfStationService.getGammaGated(chartHeight, channelWidth, gammaChannel, sampleId, qcFileName, sampleFileName, request); + } + @GetMapping("NuclideLibrary") @ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据") public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java index dbecb3b0..39b0d5d9 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISelfStationService.java @@ -95,6 +95,8 @@ public interface ISelfStationService { Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count, String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request); + Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, String sampleFileName, HttpServletRequest request); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); From 1f94e14a704322645e7aa9c6cc14fe6ba296426d Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 24 Jul 2024 16:46:44 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9updateROI?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0;2=20=E5=A2=9E=E5=8A=A0/sel?= =?UTF-8?q?fStation/getGammaGated=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SelfStationServiceImpl.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) 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 6cd40c25..2c817d55 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 @@ -2944,6 +2944,56 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + @Override + public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, String sampleFileName, HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + //获取用户名称 + String userName = JwtUtil.getUserNameByToken(request); + //获取自建台站缓存信息 + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData betaDataFile = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); +// Cache cache = betaCache.getBetaCache(); +// BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName); + if (Objects.isNull(betaDataFile)) { + result.error500("Load basic file information first!"); + return result; + } + //选择矩形框高度 + Integer flagHeight = channelWidth * (chartHeight/256); + int value = Double.valueOf(flagHeight / 2).intValue(); + //计算得到最高值 + int up = gammaChannel - value; + if (up<0){ + up = 0; + } + //计算得到最低值 + int down = up + value; + EnergySpectrumStruct struct = betaDataFile.getQcStruct(); + if (Objects.nonNull(struct)) { + //Beta-Gamma Spectrum: QC + long bChannels = struct.b_channels; + List hCounts = struct.h_counts; + List serise_data = new LinkedList<>(); + for ( int i=0; i Date: Wed, 24 Jul 2024 17:12:44 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9updateROI?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/controller/SelfStationController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java index e072f946..c0d7d799 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java @@ -1,6 +1,8 @@ package org.jeecg.modules.controller; +import com.alibaba.fastjson.JSONArray; import com.google.gson.Gson; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -17,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; @@ -55,7 +58,7 @@ public class SelfStationController { @PutMapping("updateROI") @ApiOperation(value = "更新ROI范围", notes = "更新ROI范围") public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName, HttpServletRequest request) { - ArrayList roiParamList = (ArrayList) new Gson().fromJson(roiParams, List.class); + List roiParamList = JSONArray.parseArray(roiParams, ROIParam.class); return selfStationService.updateROI(roiParamList, sampleFileName, request); } From 9f7295673d22b5bc0a2083efa5452e29e238330d Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 24 Jul 2024 17:13:16 +0800 Subject: [PATCH 4/7] =?UTF-8?q?Revert=20"fix=EF=BC=9A=E4=BF=AE=E6=94=B9upd?= =?UTF-8?q?ateROI=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit aa99d7214b758f166c6460d976ec0f1cb652777c. --- .../org/jeecg/modules/controller/SelfStationController.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java index c0d7d799..e072f946 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java @@ -1,8 +1,6 @@ package org.jeecg.modules.controller; -import com.alibaba.fastjson.JSONArray; import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -19,7 +17,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; @@ -58,7 +55,7 @@ public class SelfStationController { @PutMapping("updateROI") @ApiOperation(value = "更新ROI范围", notes = "更新ROI范围") public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName, HttpServletRequest request) { - List roiParamList = JSONArray.parseArray(roiParams, ROIParam.class); + ArrayList roiParamList = (ArrayList) new Gson().fromJson(roiParams, List.class); return selfStationService.updateROI(roiParamList, sampleFileName, request); } From d64a0be200f3444c281a5a49108aa8e4f73ded1b Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 24 Jul 2024 17:15:56 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9updateROI?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/controller/SelfStationController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java index e072f946..08d144b6 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SelfStationController.java @@ -1,6 +1,9 @@ package org.jeecg.modules.controller; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; import com.google.gson.Gson; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -17,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; @@ -55,7 +59,10 @@ public class SelfStationController { @PutMapping("updateROI") @ApiOperation(value = "更新ROI范围", notes = "更新ROI范围") public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName, HttpServletRequest request) { - ArrayList roiParamList = (ArrayList) new Gson().fromJson(roiParams, List.class); + if (StrUtil.isBlank(roiParams)) { + return Result.error("roiParams cannot be empty!"); + } + List roiParamList = JSONArray.parseArray(roiParams, ROIParam.class); return selfStationService.updateROI(roiParamList, sampleFileName, request); } From 2e0894830204c61057077ae4033b4f3e6bc04826 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 25 Jul 2024 11:13:29 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix=EF=BC=9A=E5=A6=82=E4=BD=95=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E6=97=B6=E8=8E=B7=E5=8F=96beta=20calibration=20table?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/service/impl/SelfStationServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) 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 2c817d55..5d3d35a3 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 @@ -1794,6 +1794,11 @@ public class SelfStationServiceImpl implements ISelfStationService { } map.put("EToC", fittingParaToUiStr); + // todo 按照默认点选择刻度点 + // E_β=661.6-E_γ,E_γ=F(C) + //中心:C_β=F(E_β),范围:左[C_β-3√(C_β ), C_β+3√(C_β )]右 + // 高斯函数拟合得到拟合的中心道址,显示Energy vs. Channel + //判断人工交互的道值与能量对应参数数组是否为空 if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) { //存储计算参数道值 From 566657c339d0d1b5b609bdb1571d1faf698fc51d Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 25 Jul 2024 14:24:51 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix=EF=BC=9Abeta=20calibration=20table?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SelfStationServiceImpl.java | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) 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 5d3d35a3..f8d110b5 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 @@ -13,12 +13,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.cache.Cache; -import com.google.common.collect.Maps; import org.apache.commons.io.FileUtils; +import org.apache.commons.math3.fitting.GaussianCurveFitter; +import org.apache.commons.math3.fitting.WeightedObservedPoints; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.cache.SelfCache; -import org.jeecg.common.constant.DateConstant; import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; @@ -1742,6 +1742,9 @@ public class SelfStationServiceImpl implements ISelfStationService { } //Beta-Gamma Spectrum: QC 散点图相关数据 List histogramDataList = new LinkedList<>(); + // todo 减少数量 暂时写512 + gChannels = 512; + bChannels = 512; for (int column=0; column table = new LinkedList<>(); + for (int i = 0; i < oldScatterSeries.size(); i++) { + SeriseData data = oldScatterSeries.get(i); + WeightedObservedPoints points = new WeightedObservedPoints(); + // 通过散点图gamma的channel拿到当前beta横向数据 + List seriseDatas = this.getGateGamma(5, 256, (int) data.getX(), betaDataFile); + seriseDatas.forEach(f->{ + // x = beta channel, y = beta energy + double x = f.getX(); + double left = x - Math.cbrt(x); + double right = x + Math.cbrt(x); + points.add(x, left, right); + }); + // 使用高斯曲线拟合观测点 + GaussianCurveFitter fitter = GaussianCurveFitter.create(); + + double[] parameters = fitter.fit(points.toList()); + //表单数据信息 + TableWidget tableWidget = new TableWidget(); + tableWidget.setRowCount(i+1); + tableWidget.setChannel(parameters[0]); + tableWidget.setEnergy(parameters[0]); + System.out.println("table:" + parameters[0]); + table.add(tableWidget); + } + map.put("tableWidgets", table); + //判断人工交互的道值与能量对应参数数组是否为空 if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) { @@ -2998,6 +3029,39 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + private List getGateGamma(int channelWidth, int chartHeight, int gammaChannel, SelfStationData betaDataFile){ + List serise_data = new LinkedList<>(); + //选择矩形框高度 + Integer flagHeight = channelWidth * (chartHeight/256); + int value = Double.valueOf(flagHeight / 2).intValue(); + //计算得到最高值 + int up = gammaChannel - value; + if (up<0){ + up = 0; + } + //计算得到最低值 + int down = up + value; + EnergySpectrumStruct struct = betaDataFile.getQcStruct(); + if (Objects.nonNull(struct)) { + //Beta-Gamma Spectrum: QC + long bChannels = struct.b_channels; + List hCounts = struct.h_counts; + + for ( int i=0; i