From 16a1407216f7d6e77cd0532367fb609fc7e960d2 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 17 Jul 2024 14:33:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=96=B0beta=20=E5=A2=9E=E5=8A=A0f?= =?UTF-8?q?itting=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SelfStationController.java | 9 + .../modules/service/ISelfStationService.java | 5 + .../service/impl/SelfStationServiceImpl.java | 192 ++++++++++++++++++ 3 files changed, 206 insertions(+) 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 bece1cfc..88591869 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 @@ -4,6 +4,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.entity.vo.ChangeData; +import org.jeecg.modules.entity.vo.FittingBody; import org.jeecg.modules.service.ISelfStationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -176,4 +177,12 @@ public class SelfStationController { return selfStationService.Reprocessing(fileName, processKey, request); } + + @PostMapping("fitting") + @ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线") + public Result fitting(@RequestBody FittingBody fittingBody, HttpServletRequest request) { + return selfStationService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount(), fittingBody.getSampleFileName(), fittingBody.getTabName(), fittingBody.isFittingBtn(), 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 696fd9aa..9f28d12a 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 @@ -2,6 +2,7 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.entity.vo.ParameterInfo; +import org.jeecg.modules.entity.vo.SeriseData; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -62,4 +63,8 @@ public interface ISelfStationService { Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request); Result Reprocessing(String fileName, String processKey, HttpServletRequest request); + + Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count, + String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request); + } 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 1562e811..b57101ae 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 @@ -1734,6 +1734,198 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + @Override + public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count, + String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request) { + Result result = new Result(); + //获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + //获取自建台站缓存信息 + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName); +// Cache cache = betaCache.getBetaCache(); +// BetaDataFile selfStationData = cache.getIfPresent(sampleFileName + "-" + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Load basic file information first!"); + return result; + } + Map map = new HashMap<>(); + //记录点位的x轴数据 + List xs = new LinkedList<>(); + //记录点位的y轴数据 + List ys = new LinkedList<>(); + //接收算法计算得到的公式的数据 + List fittingPara = new LinkedList<>(); + //记录计算结果转换为字符串后数据的数组 第一组公式 + List fittingParaStr = new LinkedList<>(); + //记录点位道值的数组 + List channels = new LinkedList<>(); + //新计算的点位数组 + List seriseDataList = new LinkedList<>(); + //页面展示的表单数据数组 + List tableWidgets = new LinkedList<>(); + //新计算得到的线点位数组 + List newLineSeries = new LinkedList<>(); + //计算得到的新能量数组 + List> energyList = new LinkedList<>(); + //记录计算结果转换成字符串后数据的数组 第二组公式 + List fittingParaToUiStr = new LinkedList<>(); + //tempPoint数组大小需要大于2个值 + if ((CollectionUtils.isNotEmpty(tempPoints) && tempPoints.size() > 2 && Objects.nonNull(count) && tempPoints.size() != count) + || (Objects.isNull(paramA) || StringUtils.isBlank(String.valueOf(paramA))) + || (Objects.isNull(paramB) || StringUtils.isBlank(String.valueOf(paramB))) + || (Objects.isNull(paramC) || StringUtils.isBlank(String.valueOf(paramC))) ){ + //遍历临时点数组 将点位的横坐标以及纵坐标封装到对应的数组 + for (int i=0; i energys = EnergySpectrumHandler.GetFileFittingData(channels,fittingPara); + //如果当前fitting按钮没有进行过操作 并且 操作的是gamma探测器相关的 + if (tabName.equalsIgnoreCase("gamma") && !fittingBtn) { + //根据临时点的道值修改对应能量值 + //遍历所有道值 + for (int i=0; i< channels.size(); i++) { + //获取道值 + double channel = channels.get(i).doubleValue(); + //遍历临时点数据 + for (int j=0; j newEnergy = new LinkedList<>(); + newEnergy.add(calEnergy); + energyList.add(newEnergy); + } + //遍历道值添加各道值对应点数据到数组 + for (int i=0; i fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs); + for (Double para:fittingParaToUi) { + fittingParaToUiStr.add(String.valueOf(para)); + } + map.put("EToC", fittingParaToUiStr); + } else { + //添加公式的数据到公式一的数组 + fittingPara.add(paramA); + fittingPara.add(paramB); + fittingPara.add(paramC); + //将公式各数据转换成字符串存到数组中 + fittingParaStr.add(String.valueOf(paramA)); + fittingParaStr.add(String.valueOf(paramB)); + fittingParaStr.add(String.valueOf(paramC)); + map.put("CToE", fittingParaStr); + //遍历点位数组 将横坐标的数据加入到数组中 + for (int i=0; i energys = EnergySpectrumHandler.GetFileFittingData(channels,fittingPara); + for (Double calEnergy:energys) { + List newEnergy = new LinkedList<>(); + newEnergy.add(calEnergy); + energyList.add(newEnergy); + } + //遍历道值 将道值和新的能量封装到新的点位数组 + for (int i=0; i fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs); + for (Double para:fittingParaToUi) { + fittingParaToUiStr.add(String.valueOf(para)); + } + map.put("EToC", fittingParaToUiStr); + } + if (tabName.equalsIgnoreCase("beta")) { + selfStationData.setBetaListNow(tempPoints); + selfStationData.setBetaFittingParaNow(fittingParaStr); + selfStationData.setBetaFittingParaToUiNow(fittingParaToUiStr); + selfStationData.setBetaNewEnergyListNow(energyList); + } else if (tabName.equalsIgnoreCase("gamma")) { + selfStationData.setGammaListNow(tempPoints); + selfStationData.setGammaFittingParaNow(fittingParaStr); + selfStationData.setGammaFittingParaToUiNow(fittingParaToUiStr); + selfStationData.setGammaNewEnergyListNow(energyList); + //gamma的进行计算后将当前的beta缓存的数据进行重置 + selfStationData.setBetaListNow(Collections.EMPTY_LIST); + selfStationData.setBetaFittingParaNow(Collections.EMPTY_LIST); + selfStationData.setBetaFittingParaToUiNow(Collections.EMPTY_LIST); + selfStationData.setBetaNewEnergyListNow(Collections.EMPTY_LIST); + } + result.setSuccess(true); + result.setResult(map); + return result; + } + + private Map gammaAnalyse(PHDFile phd, Map nuclideLinesMap, Map colorMap) throws RuntimeException{