From 16a1407216f7d6e77cd0532367fb609fc7e960d2 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Wed, 17 Jul 2024 14:33:04 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix=EF=BC=9A=E6=96=B0beta=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0fitting=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{ From 3c02c89ae5dc3d3fb267c256e405bc2768ebdce4 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Thu, 18 Jul 2024 09:06:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=BB=BA=E5=8F=B0?= =?UTF-8?q?=E7=AB=99=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E6=A0=B8=E7=B4=A0?= =?UTF-8?q?=E5=BA=93=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../struct/EnergySpectrumStruct.java | 4 +- .../controller/SelfStationController.java | 17 + .../SysDefaultNuclideSpectrumMapper.java | 8 +- .../xml/SysDefaultNuclideSpectrumMapper.xml | 4 +- .../modules/service/ISelfStationService.java | 5 + .../ISysDefaultNuclideSpectrumService.java | 4 +- .../service/impl/GammaServiceImpl.java | 14 +- .../service/impl/SelfStationServiceImpl.java | 304 +++++++++++++++++- .../SysDefaultNuclideSpectrumServiceImpl.java | 12 +- 9 files changed, 349 insertions(+), 23 deletions(-) diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java index ec50dd3c..0c3661d4 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java @@ -102,12 +102,12 @@ public class EnergySpectrumStruct { /* * 坐标: 经度值 * */ - public double longitude; + public double lon; /* * 坐标: 纬度值 * */ - public double latitude; + public double lat; /************************* Collection Block ******************/ 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 88591869..19e1e0c1 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 @@ -5,6 +5,7 @@ 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.entity.vo.UserLibraryInfo; import org.jeecg.modules.service.ISelfStationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -184,5 +185,21 @@ public class SelfStationController { return selfStationService.fitting(fittingBody.getParamA(), fittingBody.getParamB(), fittingBody.getParamC(), fittingBody.getTempPoints(), fittingBody.getCount(), fittingBody.getSampleFileName(), fittingBody.getTabName(), fittingBody.isFittingBtn(), 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) { + return selfStationService.NuclideLibrary(sampleId, fileName, editEnergy, err, libraryName, nuclideName, request); + } + @GetMapping("configUserLibrary") + @ApiOperation(value = "查看Config Nuclide Library页面数据", notes = "查看Config Nuclide Library页面数据") + public Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request) { + return selfStationService.configUserLibrary(sampleId, fileName, request); + } + + @PostMapping("saveUserLibrary") + @ApiOperation(value = "Config User Library页面save按钮", notes = "Config User Library页面save按钮") + public Result saveUserLibrary(@RequestBody UserLibraryInfo userLibraryInfo, HttpServletRequest request) { + return selfStationService.saveUserLibrary(userLibraryInfo.getUserLibraryName(), userLibraryInfo.getFileName(), request); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java index 783aec41..199f3e5c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java @@ -8,8 +8,12 @@ import java.util.List; public interface SysDefaultNuclideSpectrumMapper extends BaseMapper { - List findNuclidesByUserName(@Param(value = "userName") String userName, @Param(value = "systemType") String systemType); + List findNuclidesByUserName(@Param(value = "userName") String userName, + @Param(value = "systemType") String systemType, + @Param("useType") Integer useType); - void deleteNuclidesByUserName(@Param(value = "userName") String userName, @Param(value = "systemType") String systemType); + void deleteNuclidesByUserName(@Param(value = "userName") String userName, + @Param(value = "systemType") String systemType, + @Param("useType") Integer useType); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml index 766d47b0..69f838b5 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml @@ -7,7 +7,7 @@ nuclide_name from sys_default_nuclide - where use_type = 3 + where use_type = #{useType} and nuclide_type = #{systemType} and create_by = #{userName} @@ -15,7 +15,7 @@ delete from sys_default_nuclide - where use_type = 3 + where use_type = #{useType} and nuclide_type = #{systemType} and create_by = #{userName} 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 9f28d12a..911e91de 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 @@ -67,4 +67,9 @@ public interface ISelfStationService { Result fitting(Double paramA, Double paramB, Double paramC, List tempPointsArray, Integer count, String sampleFileName, String tabName, boolean fittingBtn, 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); + + Result saveUserLibrary(List userLibraryName, String fileName, HttpServletRequest request); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java index 481138e9..146a9537 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java @@ -7,8 +7,8 @@ import java.util.List; public interface ISysDefaultNuclideSpectrumService extends IService { - List findNuclidesByUserName(String userName, String systemType); + List findNuclidesByUserName(String userName, String systemType, Integer useType); - boolean saveNuclidesByUserName(List userLibraryName, String userName, String systemType); + boolean saveNuclidesByUserName(List userLibraryName, String userName, String systemType, Integer useType); } 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 42f90b0b..55761b08 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 @@ -212,9 +212,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi // 查询当前用户关联的核素信息 List userLib = new LinkedList<>(); // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 - userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase(), 3); if (CollectionUtils.isEmpty(userLib)) { - userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase(), 3); } userLib = userLib.stream().sorted().collect(Collectors.toList()); Map nuclideMap = new HashMap<>(); @@ -623,9 +623,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi // 查询当前用户关联的核素信息 List userLib = new LinkedList<>(); // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 - userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase(), 3); if (CollectionUtils.isEmpty(userLib)) { - userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase(), 3); } userLib = userLib.stream().sorted().collect(Collectors.toList()); Map nuclideMap = new HashMap<>(); @@ -3825,7 +3825,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return result; } userLibraryName = userLibraryName.stream().distinct().collect(Collectors.toList()); - boolean save = defaultNuclideSpectrumService.saveNuclidesByUserName(userLibraryName, userName, phd.getHeader().getSystem_type().toUpperCase()); + boolean save = defaultNuclideSpectrumService.saveNuclidesByUserName(userLibraryName, userName, phd.getHeader().getSystem_type().toUpperCase(), 3); if (save) { result.success("Modified successfully!"); // 重新计算峰值 @@ -3833,9 +3833,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi // 查询当前用户关联的核素信息 List userLib = new LinkedList<>(); // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 - userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase(), 3); if (CollectionUtils.isEmpty(userLib)) { - userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase(), 3); } Map nuclideMap = new HashMap<>(); for (Map.Entry entry:allNuclideMap.entrySet()) { 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 b57101ae..fb3158af 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 @@ -1,6 +1,8 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -8,11 +10,14 @@ import com.google.common.cache.Cache; import com.google.common.collect.Maps; import org.apache.commons.io.FileUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.cache.LocalCache; import org.jeecg.common.cache.SelfCache; import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.util.*; +import org.jeecg.modules.base.entity.configuration.GardsNuclLib; +import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; @@ -20,6 +25,7 @@ import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.ISelfStationService; +import org.jeecg.modules.service.ISysDefaultNuclideSpectrumService; import org.jeecg.modules.service.ISysUserColorService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,6 +35,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.*; import java.util.stream.Collectors; @@ -53,6 +61,10 @@ public class SelfStationServiceImpl implements ISelfStationService { private SelfCache selfStationCache; @Autowired private SpectrumAnalysisMapper spectrumAnalysisMapper; + @Autowired + private LocalCache localCache; + @Autowired + private ISysDefaultNuclideSpectrumService defaultNuclideSpectrumService; @Override public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, @@ -141,6 +153,30 @@ public class SelfStationServiceImpl implements ISelfStationService { resultMap.put("det", map); } } + if (ObjectUtil.isNotNull(selfStationData.getSampleStruct())){ + String systemType = selfStationData.getSampleStruct().getSystem_type(); + if (!redisUtil.hasKey(userName+StringPool.DASH+systemType + "-self") + || !redisUtil.hasKey(userName+StringPool.DASH+systemType+"-list-self")) { + //读取缓存的全部核素信息 + Map allNuclideMap = (Map) redisUtil.get("AllNuclideMap"); + // 查询当前用户关联的核素信息 + List userLib = new LinkedList<>(); + // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, systemType, 5); + if (CollectionUtils.isEmpty(userLib)) { + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", systemType, 5); + } + userLib = userLib.stream().sorted().collect(Collectors.toList()); + Map nuclideMap = new HashMap<>(); + for (Map.Entry entry:allNuclideMap.entrySet()) { + if (userLib.contains(entry.getKey())) { + nuclideMap.put(entry.getKey(), entry.getValue()); + } + } + redisUtil.set(userName+StringPool.DASH+systemType+"-list-self", userLib); + redisUtil.set(userName+StringPool.DASH+systemType+"-self", nuclideMap); + } + } } else { if (Objects.nonNull(sample)) { //返回结果map @@ -226,6 +262,30 @@ public class SelfStationServiceImpl implements ISelfStationService { resultMap.put("qc", map); } } + if (ObjectUtil.isNotNull(selfStationData.getSampleStruct())){ + String systemType = selfStationData.getSampleStruct().getSystem_type(); + if (!redisUtil.hasKey(userName+StringPool.DASH+systemType + "-self") + || !redisUtil.hasKey(userName+StringPool.DASH+systemType+"-list-self")) { + //读取缓存的全部核素信息 + Map allNuclideMap = (Map) redisUtil.get("AllNuclideMap"); + // 查询当前用户关联的核素信息 + List userLib = new LinkedList<>(); + // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, systemType, 5); + if (CollectionUtils.isEmpty(userLib)) { + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", systemType, 5); + } + userLib = userLib.stream().sorted().collect(Collectors.toList()); + Map nuclideMap = new HashMap<>(); + for (Map.Entry entry:allNuclideMap.entrySet()) { + if (userLib.contains(entry.getKey())) { + nuclideMap.put(entry.getKey(), entry.getValue()); + } + } + redisUtil.set(userName+StringPool.DASH+systemType+"-list-self", userLib); + redisUtil.set(userName+StringPool.DASH+systemType+"-self", nuclideMap); + } + } } else { if (StringUtils.isNotBlank(sampleFileName)) { //返回结果map @@ -1682,7 +1742,7 @@ public class SelfStationServiceImpl implements ISelfStationService { "2. You didn't change any setting or calibration."; result.error500(warning); } else if (flag == -1) { - Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()); + Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self"); //分析时将phd的核素map重置 phdOne.setPhdNuclideMap(nuclideLinesMap); //重新计算核素的活度浓度 @@ -1699,7 +1759,7 @@ public class SelfStationServiceImpl implements ISelfStationService { "\t3.Test QC again."; result.error500(warning); } else { - Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()); + Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self"); try { Map gammaResult = Maps.newHashMap(); @@ -1925,6 +1985,246 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + @Override + @DS("ora") + public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + String systemType = selfStationData.getSampleStruct().getSystem_type(); + List nuclides = new LinkedList<>(); + // 判断传入的数据是否都不为空 + if (org.apache.commons.lang3.StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)) { + double editEnergyDou = Double.valueOf(editEnergy); + double min = editEnergyDou - err; + double max = editEnergyDou + err; + if (libraryName.equals("UserLibrary")) { + //获取缓存的核素信息 + Map nuclideMap = (Map) redisUtil.get(userName+StringPool.DASH+systemType+"-self"); + //判断缓存的核素信息是否为空 + if (CollectionUtils.isNotEmpty(nuclideMap)) { + //遍历核素信息 + for (Map.Entry entry:nuclideMap.entrySet()) { + //获取核素的关联信息 + NuclideLines nuclideLines = entry.getValue(); + //获取核素关联的全部能量信息 + List venergy = nuclideLines.getVenergy(); + //遍历能量 + for (int i=0; i min && venergy.get(i) < max) { + nuclides.add(entry.getKey()); + break; + } + } + } + } + } else if (libraryName.equals("FULLLibrary")) { + nuclides = spectrumAnalysisMapper.getFULLNuclideNames(min, max); + } else if (libraryName.equals("RelevantLibrary")) { + nuclides = spectrumAnalysisMapper.getRelevantNuclideNames(min, max); + } + } else { + if (libraryName.equals("UserLibrary")) { + //redis中获取缓存的用户关注核素信息 + nuclides = (List)redisUtil.get(userName+StringPool.DASH+systemType+"-list-self"); + } else if (libraryName.equals("FULLLibrary")) { + nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_NUCL_LIB"); + } else if (libraryName.equals("RelevantLibrary")) { + nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_RELEVANT_NUCLIDE"); + } + } + map.put("nuclides", nuclides); + if (org.apache.commons.lang3.StringUtils.isBlank(nuclideName)) { + nuclideName = nuclides.get(0); + } + List nuclLinesLibs = InitNuclideLine(editEnergy, err, nuclideName); + map.put("nuclLinesLibs", nuclLinesLibs); + Map nuclideInfo = InitNuclideInfo(nuclideName); + map.put("nuclideInfo", nuclideInfo); + Map daughter = InitParentAndDaughter(nuclideName); + map.put("daughter", daughter); + result.setSuccess(true); + result.setResult(map); + return result; + } + + public List InitNuclideLine(String editEnergy, double err, String name) { + Double min = null; + Double max = null; + if (org.apache.commons.lang3.StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)) { + double editEnergyDou = Double.valueOf(editEnergy); + min = editEnergyDou - err; + max = editEnergyDou + err; + } + List nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name); + nuclideLines.stream().forEach(item -> { + if (Objects.nonNull(item.getYield())) { + item.setYield(Double.valueOf(String.format("%.3f", item.getYield()))); + } + if (Objects.nonNull(item.getYieldUncert())) { + item.setYieldUncert(Double.valueOf(String.format("%.3f", item.getYieldUncert()))); + } + }); + return nuclideLines; + } + + public Map InitNuclideInfo(String name) { + Map map = new HashMap<>(); + GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name); + if (Objects.nonNull(nuclideInfo)) { + Long numLines = nuclideInfo.getNumLines(); + map.put("lab_lines", numLines.toString()); + if (Objects.isNull(nuclideInfo.getHalflife())) { + map.put("lab_halfLife", ""); + } else { + String units = "D"; + double halflife = nuclideInfo.getHalflife().doubleValue(); + if (halflife >= 1000) { + halflife = halflife / 365.25; + units = "A"; + } else if (halflife < 0.1 && halflife >= 1.0 / 1440.0) { + halflife = halflife * 1440.0; + units = "M"; + } else if (halflife <= 1.0 / 1440.0 && halflife > 0.0) { + halflife = halflife * 86400.0; + units = "S"; + } + char flag = 'f'; + if (halflife >= 1000) { + flag = 'e'; + } + if (flag == 'f') { + map.put("lab_halfLife", String.format("%.3f", halflife) + units); + } else if (flag == 'e') { + NumberFormat numberFormat = new DecimalFormat("0.###E0"); + String formatNum = numberFormat.format(halflife); + map.put("lab_halfLife", formatNum + units); + } + } + if (Objects.isNull(nuclideInfo.getHalflifeErr())) { + map.put("lab_halfLifeErr", ""); + } else { + map.put("lab_halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue()) + "%"); + } + } + return map; + } + + public Map InitParentAndDaughter(String name) { + Map map = new HashMap<>(); + GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name); + List parentList = new LinkedList<>(); + if (Objects.nonNull(parentAndDaughter)) { + parentList.add(parentAndDaughter.getParents1()); + parentList.add(parentAndDaughter.getParents2()); + parentList.add(parentAndDaughter.getParents3()); + parentList.add(parentAndDaughter.getParents4()); + parentList.add(parentAndDaughter.getParents5()); + parentList.add(parentAndDaughter.getParents6()); + map.put("list_parent", parentList); + List daughterList = new LinkedList<>(); + TableDaughter tableDaughter1 = new TableDaughter(); + tableDaughter1.setDaughters(parentAndDaughter.getDaughters1()); + tableDaughter1.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios1().doubleValue()) + "%"); + tableDaughter1.setDaughtersstable(parentAndDaughter.getDaughtersstable1().intValue() == 1 ? "Stable" : "Unstable"); + daughterList.add(tableDaughter1); + TableDaughter tableDaughter2 = new TableDaughter(); + tableDaughter2.setDaughters(parentAndDaughter.getDaughters2()); + tableDaughter2.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios2().doubleValue()) + "%"); + tableDaughter2.setDaughtersstable(parentAndDaughter.getDaughtersstable2().intValue() == 1 ? "Stable" : "Unstable"); + daughterList.add(tableDaughter2); + TableDaughter tableDaughter3 = new TableDaughter(); + tableDaughter3.setDaughters(parentAndDaughter.getDaughters3()); + tableDaughter3.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios3().doubleValue()) + "%"); + tableDaughter3.setDaughtersstable(parentAndDaughter.getDaughtersstable3().intValue() == 1 ? "Stable" : "Unstable"); + daughterList.add(tableDaughter3); + TableDaughter tableDaughter4 = new TableDaughter(); + tableDaughter4.setDaughters(parentAndDaughter.getDaughters4()); + tableDaughter4.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios4().doubleValue()) + "%"); + tableDaughter4.setDaughtersstable(parentAndDaughter.getDaughtersstable4().intValue() == 1 ? "Stable" : "Unstable"); + daughterList.add(tableDaughter4); + TableDaughter tableDaughter5 = new TableDaughter(); + tableDaughter5.setDaughters(parentAndDaughter.getDaughters5()); + tableDaughter5.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios5().doubleValue()) + "%"); + tableDaughter5.setDaughtersstable(parentAndDaughter.getDaughtersstable5().intValue() == 1 ? "Stable" : "Unstable"); + daughterList.add(tableDaughter5); + map.put("table_daughter", daughterList); + } + return map; + } + + @Override + @DS("ora") + public Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request) { + Result result = new Result(); + Map> map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + String systemType = selfStationData.getSampleStruct().getSystem_type(); + List nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_NUCL_LIB"); + //redis中获取缓存的用户关注核素信息 + List userNuclides = (List)redisUtil.get(userName+StringPool.DASH+systemType+"-list-self"); + map.put("AllNuclides", nuclides); + map.put("UserNuclides", userNuclides); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result saveUserLibrary(List userLibraryName, String fileName, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + String systemType = selfStationData.getSampleStruct().getSystem_type(); + if (CollectionUtils.isEmpty(userLibraryName)) { + result.error500("The user custom nuclide library can't be null!"); + return result; + } + userLibraryName = userLibraryName.stream().distinct().collect(Collectors.toList()); + boolean save = defaultNuclideSpectrumService.saveNuclidesByUserName(userLibraryName, userName, systemType, 5); + if (save) { + result.success("Modified successfully!"); + // 重新计算峰值 + Map allNuclideMap = (Map) redisUtil.get("AllNuclideMap"); + // 查询当前用户关联的核素信息 + List userLib = new LinkedList<>(); + // 从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + userLib = defaultNuclideSpectrumService.findNuclidesByUserName(userName, systemType, 5); + if (CollectionUtils.isEmpty(userLib)) { + userLib = defaultNuclideSpectrumService.findNuclidesByUserName("admin", systemType, 5); + } + Map nuclideMap = new HashMap<>(); + for (Map.Entry entry:allNuclideMap.entrySet()) { + if (userLib.contains(entry.getKey())) { + nuclideMap.put(entry.getKey(), entry.getValue()); + } + } + redisUtil.set(userName+StringPool.DASH+systemType+"-list-self", userLib); + redisUtil.set(userName+StringPool.DASH+systemType+"-self", nuclideMap); + } else { + result.success("Modification failure!"); + } + return result; + } + private Map gammaAnalyse(PHDFile phd, Map nuclideLinesMap, Map colorMap) throws RuntimeException{ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java index 0a1dca78..7e550c8e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java @@ -20,20 +20,20 @@ public class SysDefaultNuclideSpectrumServiceImpl extends ServiceImpl findNuclidesByUserName(String userName, String systemType) { + public List findNuclidesByUserName(String userName, String systemType, Integer useType) { //查询当前用户的核素信息 - List nuclides = this.baseMapper.findNuclidesByUserName(userName, systemType); + List nuclides = this.baseMapper.findNuclidesByUserName(userName, systemType, useType); if (CollectionUtils.isEmpty(nuclides)){ - nuclides = this.baseMapper.findNuclidesByUserName("admin", systemType); + nuclides = this.baseMapper.findNuclidesByUserName("admin", systemType, useType); } return nuclides; } @Override @Transactional(propagation = Propagation.REQUIRES_NEW) - public boolean saveNuclidesByUserName(List userLibraryName, String userName, String systemType) { + public boolean saveNuclidesByUserName(List userLibraryName, String userName, String systemType, Integer useType) { //删除当前用户名,当前使用类型下所有的数据 - this.baseMapper.deleteNuclidesByUserName(userName, systemType); + this.baseMapper.deleteNuclidesByUserName(userName, systemType, useType); //删除后重新插入本次数据 List defaultNuclideList = new LinkedList<>(); for (String nuclideName: userLibraryName) { @@ -42,7 +42,7 @@ public class SysDefaultNuclideSpectrumServiceImpl extends ServiceImpl Date: Thu, 18 Jul 2024 18:16:59 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=BB=BA=E5=8F=B0?= =?UTF-8?q?=E7=AB=99=E5=A2=9E=E5=8A=A0Configure=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SelfStationController.java | 13 + .../modules/entity/vo/SelfStationVueData.java | 5 + .../modules/service/ISelfStationService.java | 5 + .../service/impl/SelfStationServiceImpl.java | 222 ++++++++++++++++++ 4 files changed, 245 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 19e1e0c1..aa1f852c 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.ConfigureData; import org.jeecg.modules.entity.vo.FittingBody; import org.jeecg.modules.entity.vo.UserLibraryInfo; import org.jeecg.modules.service.ISelfStationService; @@ -202,4 +203,16 @@ public class SelfStationController { public Result saveUserLibrary(@RequestBody UserLibraryInfo userLibraryInfo, HttpServletRequest request) { return selfStationService.saveUserLibrary(userLibraryInfo.getUserLibraryName(), userLibraryInfo.getFileName(), request); } + + @GetMapping("configure") + @ApiOperation(value = "analyze菜单下configure页面数据", notes = "analyze菜单下configure页面数据") + public Result configure(String fileName, HttpServletRequest request) { + return selfStationService.configure(fileName, request); + } + + @PostMapping("configureSave") + @ApiOperation(value = "analyze菜单下configure页面数据保存按钮", notes = "analyze菜单下configure页面数据保存按钮") + public Result configureSave(@RequestBody ConfigureData configureData, HttpServletRequest request) { + return selfStationService.configureSave(configureData, request); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java index 68c1185c..f71483e9 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java @@ -142,6 +142,11 @@ public class SelfStationVueData implements Serializable { mapEnerPara = new HashMap<>(); mapResoPara = new HashMap<>(); mapEffiPara = new HashMap<>(); + + ROIOnePHDFile = new PHDFile(); + ROITwoPHDFile = new PHDFile(); + ROIThreePHDFile = new PHDFile(); + ROIFourPHDFile = new PHDFile(); } } 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 911e91de..42108d86 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 @@ -1,6 +1,7 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.entity.vo.ConfigureData; import org.jeecg.modules.entity.vo.ParameterInfo; import org.jeecg.modules.entity.vo.SeriseData; import org.springframework.web.multipart.MultipartFile; @@ -72,4 +73,8 @@ public interface ISelfStationService { Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); Result saveUserLibrary(List userLibraryName, String fileName, HttpServletRequest request); + + Result configure(String fileName, HttpServletRequest request); + + Result configureSave(ConfigureData configureData, 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 fb3158af..d6956a00 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 @@ -1,5 +1,7 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; @@ -12,6 +14,7 @@ import org.apache.commons.io.FileUtils; 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; @@ -19,6 +22,7 @@ import org.jeecg.common.util.*; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.original.GardsSampleData; +import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.CalValuesHandler; @@ -27,6 +31,7 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.ISelfStationService; import org.jeecg.modules.service.ISysDefaultNuclideSpectrumService; import org.jeecg.modules.service.ISysUserColorService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -37,6 +42,9 @@ import java.io.*; import java.net.URLEncoder; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.text.ParseException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -153,6 +161,9 @@ public class SelfStationServiceImpl implements ISelfStationService { resultMap.put("det", map); } } + // 初始化自建台站Configure信息 + if (!StrUtil.equals(dbName, "RNAUTO")) initConfigure(analysisID, selfStationData); + // 初始化自建台站用户核素库信息 if (ObjectUtil.isNotNull(selfStationData.getSampleStruct())){ String systemType = selfStationData.getSampleStruct().getSystem_type(); if (!redisUtil.hasKey(userName+StringPool.DASH+systemType + "-self") @@ -230,6 +241,8 @@ public class SelfStationServiceImpl implements ISelfStationService { selfStationData.setSampleTmpPath(sampleFilePath); selfStationUtil.loadFile(selfStationData, null, null, "sample", map); resultMap.put("sample", map); + // 初始化Configure + initConfigure(struct, selfStationData); } } //判断det文件名是否为空 @@ -310,6 +323,100 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + public void initConfigure(EnergySpectrumStruct struct, SelfStationData selfStationData){ + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + PHDFile roiTwoPHDFile = selfStationData.getSampleVueData().getROITwoPHDFile(); + PHDFile roiThreePHDFile = selfStationData.getSampleVueData().getROIThreePHDFile(); + PHDFile roiFourPHDFile = selfStationData.getSampleVueData().getROIFourPHDFile(); + if(StrUtil.equalsIgnoreCase(struct.system_type, "P")) { + roiOnePHDFile.getSetting().setECutAnalysis_Low(35.0); + roiTwoPHDFile.getSetting().setECutAnalysis_Low(35.0); + roiThreePHDFile.getSetting().setECutAnalysis_Low(35.0); + roiFourPHDFile.getSetting().setECutAnalysis_Low(35.0); + roiOnePHDFile.getSetting().setBUpdateCal(true); + roiTwoPHDFile.getSetting().setBUpdateCal(true); + roiThreePHDFile.getSetting().setBUpdateCal(true); + roiFourPHDFile.getSetting().setBUpdateCal(true); + } + String collectionStartDate = struct.collection_start_date; + String collectionStartTime = struct.collection_start_time; + if (StrUtil.isNotBlank(collectionStartDate) && StrUtil.isNotBlank(collectionStartTime)) { + String str = collectionStartDate + StringPool.SPACE + collectionStartTime; + Date refTimeConc = null; + try { + refTimeConc = DateUtils.parseDate(str); + } catch (ParseException e) { + e.printStackTrace(); + } + roiOnePHDFile.getSetting().setRefTime_conc(refTimeConc); + roiTwoPHDFile.getSetting().setRefTime_conc(refTimeConc); + roiThreePHDFile.getSetting().setRefTime_conc(refTimeConc); + roiFourPHDFile.getSetting().setRefTime_conc(refTimeConc); + } + String acquisitionStartDate = struct.acquisition_start_date; + String acquisitionStartTime = struct.acquisition_start_time; + if (StrUtil.isNotBlank(acquisitionStartDate) && StrUtil.isNotBlank(acquisitionStartTime)) { + String str = acquisitionStartDate + StringPool.SPACE + acquisitionStartTime; + Date refTimeAct = null; + try { + refTimeAct = DateUtils.parseDate(str); + } catch (ParseException e) { + e.printStackTrace(); + } + roiOnePHDFile.getSetting().setRefTime_act(refTimeAct); + roiTwoPHDFile.getSetting().setRefTime_act(refTimeAct); + roiThreePHDFile.getSetting().setRefTime_act(refTimeAct); + roiFourPHDFile.getSetting().setRefTime_act(refTimeAct); + } + SpecSetup usedSetting = new SpecSetup(); + BeanUtils.copyProperties(roiOnePHDFile.getSetting(), usedSetting); + roiOnePHDFile.setUsedSetting(usedSetting); + roiTwoPHDFile.setUsedSetting(usedSetting); + roiThreePHDFile.setUsedSetting(usedSetting); + roiFourPHDFile.setUsedSetting(usedSetting); + } + + @DS("ora") + public void initConfigure(Integer idAnalysis, SelfStationData selfStationData){ + GardsAnalySetting analySetting = spectrumAnalysisMapper.getAnalySetting(idAnalysis); + if (Objects.nonNull(analySetting)) { + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + PHDFile roiTwoPHDFile = selfStationData.getSampleVueData().getROITwoPHDFile(); + PHDFile roiThreePHDFile = selfStationData.getSampleVueData().getROIThreePHDFile(); + PHDFile roiFourPHDFile = selfStationData.getSampleVueData().getROIFourPHDFile(); + List phdList = ListUtil.toList(roiOnePHDFile, roiTwoPHDFile, roiThreePHDFile, roiFourPHDFile); + for (PHDFile phd : phdList) { + phd.getUsedSetting().setECutAnalysis_Low(analySetting.getEcutanalysisLow()); + phd.getUsedSetting().setECutAnalysis_High((Objects.nonNull(analySetting.getEcutanalysisHigh())?(analySetting.getEcutanalysisHigh() <= phd.getUsedSetting().getECutAnalysis_Low()?-9999:analySetting.getEcutanalysisHigh()):-9999)); + phd.getUsedSetting().setEnergyTolerance(analySetting.getEnergytolerance()); + phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh()); + phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow()); + phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss()); + phd.getUsedSetting().setPss_low(analySetting.getPssLow()); + phd.getUsedSetting().setK_back(analySetting.getKBack()); + phd.getUsedSetting().setK_alpha(analySetting.getKAlpha()); + phd.getUsedSetting().setK_beta(analySetting.getKBeta()); + phd.getUsedSetting().setRiskLevelK(analySetting.getRisklevelk()); + phd.getUsedSetting().setBUpdateCal(analySetting.getBupdatecal() == 1); + phd.getUsedSetting().setKeepCalPeakSearchPeaks(analySetting.getKeepcalpeakserchpeaks() == 1); + } + Date reftimeAct = analySetting.getReftimeAct(); + if (Objects.nonNull(reftimeAct)) { + roiOnePHDFile.getUsedSetting().setRefTime_act(reftimeAct); + roiTwoPHDFile.getUsedSetting().setRefTime_act(reftimeAct); + roiThreePHDFile.getUsedSetting().setRefTime_act(reftimeAct); + roiFourPHDFile.getUsedSetting().setRefTime_act(reftimeAct); + } + Date reftimeConc = analySetting.getReftimeConc(); + if (Objects.nonNull(reftimeConc)) { + roiOnePHDFile.getUsedSetting().setRefTime_conc(reftimeConc); + roiTwoPHDFile.getUsedSetting().setRefTime_conc(reftimeConc); + roiThreePHDFile.getUsedSetting().setRefTime_conc(reftimeConc); + roiFourPHDFile.getUsedSetting().setRefTime_conc(reftimeConc); + } + } + } + @Override public void deleteSelfStationCache(String sampleFileName, HttpServletRequest request) { String userName = JwtUtil.getUserNameByToken(request); @@ -2225,6 +2332,121 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + @Override + public Result configure(String fileName, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + Map map = new HashMap<>(); + // 用当前谱使用的设置初始化界面控件 + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + SpecSetup setup = roiOnePHDFile.getUsedSetting(); + map.put("edit_ps_low", setup.getECutAnalysis_Low()); + map.put("edit_ps_high", setup.getECutAnalysis_High()); + map.put("edit_energy", setup.getEnergyTolerance()); + map.put("edit_pss_low", setup.getPss_low()); + map.put("edit_cal_low", setup.getCalibrationPSS_low()); + map.put("edit_cal_high", setup.getCalibrationPSS_high()); + map.put("checkBox_updateCal", setup.isBUpdateCal()); + map.put("checkBox_keepPeak", setup.isKeepCalPeakSearchPeaks()); + map.put("edit_bi_pss", setup.getBaseImprovePSS()); + map.put("edit_riskLevelK", setup.getRiskLevelK()); + map.put("edit_k_back", setup.getK_back()); + map.put("edit_k_alpha", setup.getK_alpha()); + map.put("edit_k_beta", setup.getK_beta()); + map.put("dateTime_Act", setup.getRefTime_act()); + map.put("dateTime_Conc", setup.getRefTime_conc()); + + // 当前谱文件为非 “P” 类型时禁用“刻度更新”模块 + String systemType = selfStationData.getSampleStruct().system_type; + if (!StrUtil.equalsIgnoreCase(systemType, "P")) + map.put("group_calPS", false); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result configureSave(ConfigureData configureData, HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + String fileName = configureData.getFileName(); + Cache selfCache = selfStationCache.getSelfCache(); + if (configureData.isApplyAll()) { + for (String key: selfCache.asMap().keySet()) { + SelfStationData selfStationData = selfCache.getIfPresent(key); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + PHDFile roiTwoPHDFile = selfStationData.getSampleVueData().getROITwoPHDFile(); + PHDFile roiThreePHDFile = selfStationData.getSampleVueData().getROIThreePHDFile(); + PHDFile roiFourPHDFile = selfStationData.getSampleVueData().getROIFourPHDFile(); + + List phdList = ListUtil.toList(roiOnePHDFile, roiTwoPHDFile, + roiThreePHDFile, roiFourPHDFile); + for (PHDFile phd : phdList) { + SpecSetup phdSetting = phd.getSetting(); + phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); + phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); + phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); + phdSetting.setPss_low(configureData.getPss_low()); + phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); + phdSetting.setK_back(configureData.getK_back()); + phdSetting.setK_alpha(configureData.getK_alpha()); + phdSetting.setK_beta(configureData.getK_beta()); + phdSetting.setRiskLevelK(configureData.getRiskLevelK()); + phdSetting.setBUpdateCal(configureData.isUpdateCalibration()); + phdSetting.setKeepCalPeakSearchPeaks(configureData.isKeepCalPeakSearchPeaks()); + phdSetting.setRefTime_act(configureData.getRefTime_act()); + phdSetting.setRefTime_conc(configureData.getRefTime_conc()); + } + } + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + map.put("checkBox_updateCal", roiOnePHDFile.getSetting().isBUpdateCal()); + } else { + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + result.error500("Please select the parse file first!"); + return result; + } + PHDFile roiOnePHDFile = selfStationData.getSampleVueData().getROIOnePHDFile(); + PHDFile roiTwoPHDFile = selfStationData.getSampleVueData().getROITwoPHDFile(); + PHDFile roiThreePHDFile = selfStationData.getSampleVueData().getROIThreePHDFile(); + PHDFile roiFourPHDFile = selfStationData.getSampleVueData().getROIFourPHDFile(); + + List phdList = ListUtil.toList(roiOnePHDFile, roiTwoPHDFile, + roiThreePHDFile, roiFourPHDFile); + for (PHDFile phd : phdList) { + SpecSetup phdSetting = phd.getSetting(); + phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low()); + phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High()); + phdSetting.setEnergyTolerance(configureData.getEnergyTolerance()); + phdSetting.setPss_low(configureData.getPss_low()); + phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS()); + phdSetting.setK_back(configureData.getK_back()); + phdSetting.setK_alpha(configureData.getK_alpha()); + phdSetting.setK_beta(configureData.getK_beta()); + phdSetting.setRiskLevelK(configureData.getRiskLevelK()); + phdSetting.setBUpdateCal(configureData.isUpdateCalibration()); + phdSetting.setKeepCalPeakSearchPeaks(configureData.isKeepCalPeakSearchPeaks()); + phdSetting.setRefTime_act(configureData.getRefTime_act()); + phdSetting.setRefTime_conc(configureData.getRefTime_conc()); + } + map.put("checkBox_updateCal", roiOnePHDFile.getSetting().isBUpdateCal()); + } + result.success("Save successfully"); + result.setResult(map); + return result; + } private Map gammaAnalyse(PHDFile phd, Map nuclideLinesMap, Map colorMap) throws RuntimeException{ From 3d97ffb5394d029241fa5e967a63f53736bfcd88 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 18 Jul 2024 18:45:05 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix=EF=BC=9A=E5=A2=9E=E5=8A=A0interactive?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=86=85=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/entity/vo/SeriseData.java | 2 + .../jeecg/common/util/SelfStationUtil.java | 35 + .../controller/SelfStationController.java | 94 ++ .../jeecg/modules/entity/vo/AcceptInfo.java | 2 + .../jeecg/modules/entity/vo/CommentsInfo.java | 2 + .../jeecg/modules/entity/vo/NuclideInfo.java | 2 + .../modules/entity/vo/SelfStationVueData.java | 16 + .../modules/service/ISelfStationService.java | 29 + .../service/impl/SelfStationServiceImpl.java | 987 ++++++++++++++++-- 9 files changed, 1091 insertions(+), 78 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java index 33919c5b..52486cc1 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java @@ -11,4 +11,6 @@ public class SeriseData implements Serializable { private double y; + private double e; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java index ee73686a..e1dc6c1f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java @@ -5,7 +5,9 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.google.common.cache.Cache; import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.cache.SelfCache; import org.jeecg.modules.base.abstracts.AbstractLogOrReport; import org.jeecg.modules.base.enums.CalName; import org.jeecg.modules.entity.vo.*; @@ -970,4 +972,37 @@ public class SelfStationUtil extends AbstractLogOrReport { out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n"); } } + + /** + * 根据ROI从selfStationData 获取对应的gamma数据 + * @param gammaROINum + * @param selfStationCache + * @return + */ + public PHDFile getGammaPHD(String fileName, String userName, int gammaROINum, SelfCache selfStationCache) { + PHDFile phd = null; + //获取自建台站缓存信息 + Cache selfCache = selfStationCache.getSelfCache(); + SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); + if (Objects.isNull(selfStationData)) { + return phd; + } + switch (gammaROINum) { + case 1: + phd = selfStationData.getSampleVueData().getROIOnePHDFile(); + break; + case 2: + phd = selfStationData.getSampleVueData().getROITwoPHDFile(); + break; + case 3: + phd = selfStationData.getSampleVueData().getROIThreePHDFile(); + break; + case 4: + phd = selfStationData.getSampleVueData().getROIFourPHDFile(); + break; + default: + break; + } + return phd; + } } 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 aa1f852c..3c341819 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 @@ -3,6 +3,7 @@ package org.jeecg.modules.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.entity.vo.ChangeData; import org.jeecg.modules.entity.vo.ConfigureData; import org.jeecg.modules.entity.vo.FittingBody; @@ -179,6 +180,99 @@ public class SelfStationController { return selfStationService.Reprocessing(fileName, processKey, request); } + @GetMapping("InteractiveTool") + @ApiOperation(value = "analyze菜单下InteractiveTool页面数据", notes = "analyze菜单下InteractiveTool页面数据") + public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) { + return selfStationService.InteractiveTool(sampleId, fileName, gammaROINum, request); + } + + @GetMapping("insertPeak") + @ApiOperation(value = "InteractiveTool页面Insert按钮页面", notes = "InteractiveTool页面Insert按钮页面") + public Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request) { + return selfStationService.insertPeak(sampleId, fileName, gammaROINum, curChan, request); + } + + @PostMapping("acceptResults") + @ApiOperation(value = "InteractiveTool页面Insert页面save", notes = "InteractiveTool页面Insert页面save") + public Result acceptResults(@RequestBody AcceptInfo acceptInfo, HttpServletRequest request) { + return selfStationService.acceptResults(acceptInfo.getFileName(), acceptInfo.getGammaROINum(), + acceptInfo.isAccept(), acceptInfo.getOldPeak(), acceptInfo.getTablePeaksList(), acceptInfo.getNewPeak(), + acceptInfo.getFlag(), request); + } + + @GetMapping("deletePeak") + @ApiOperation(value = "InteractiveTool页面delete按钮", notes = "InteractiveTool页面delete按钮") + public Result deletePeak(String fileName, int gammaROINum, int curRow, HttpServletRequest request) { + return selfStationService.deletePeak(fileName, curRow, gammaROINum, request); + } + + @GetMapping("fitPeak") + public Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request) { + return selfStationService.fitPeak(left, right, fileName, gammaROINum, request); + } + + @GetMapping("getGammaSelPosNuclide") + @ApiOperation(value = "gamma主页面选择channel加载对应核素信息接口", notes = "gamma主页面选择channel加载对应核素信息接口") + public Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy, HttpServletRequest request) { + return selfStationService.getGammaSelPosNuclide(sampleId, fileName, gammaROINum, channel, energy, request); + } + + @GetMapping("getGammaSelPosNuclideApp") + @ApiOperation(value = "gamma主页面选择channel加载对应核素信息接口", notes = "gamma主页面选择channel加载对应核素信息接口") + public Result getGammaSelPosNuclideApp(@RequestParam("sampleId") Integer sampleId,@RequestParam("fileName") String fileName, + int gammaROINum, + @RequestParam("channel") int channel,@RequestParam("energy") double energy, + HttpServletRequest request) { + return selfStationService.getGammaSelPosNuclide(sampleId, fileName, gammaROINum, channel, energy, request); + } + + @GetMapping("getSelPosNuclide") + @ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口") + public Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request) { + return selfStationService.getSelPosNuclide(sampleId, fileName, gammaROINum, channel, request); + } + + @PostMapping("addNuclide") + @ApiOperation(value = "InteractiveTool页面增加核素信息接口", notes = "InteractiveTool页面增加核素信息接口") + public Result addNuclide(@RequestBody NuclideInfo nuclideInfo, HttpServletRequest request) { + return selfStationService.addNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(), + nuclideInfo.getFileName(), nuclideInfo.getGammaRoiNum(), nuclideInfo.getList_identify(), request); + } + + @PostMapping("deleteNuclide") + @ApiOperation(value = "InteractiveTool页面删除核素信息接口", notes = "InteractiveTool页面删除核素信息接口") + public Result deleteNuclide(@RequestBody NuclideInfo nuclideInfo, HttpServletRequest request) { + return selfStationService.deleteNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(), + nuclideInfo.getFileName(), nuclideInfo.getGammaRoiNum(), nuclideInfo.getList_identify(), request); + } + + @GetMapping("viewPeakComment") + @ApiOperation(value = "InteractiveTool页面查看峰对应备注信息接口", notes = "InteractiveTool页面查看峰对应备注信息接口") + public Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request) { + return selfStationService.viewPeakComment(fileName, gammaROINum, curRow, request); + } + + @PostMapping("addPeakComment") + @ApiOperation(value = "InteractiveTool页面add峰对应备注信息接口", notes = "InteractiveTool页面add峰对应备注信息接口") + public Result addPeakComment(@RequestBody CommentsInfo commentsInfo, HttpServletRequest request) { + return selfStationService.addPeakComment(commentsInfo.getFileName(), commentsInfo.getCurRow(), + commentsInfo.getGammaROINum(),commentsInfo.getComments(), request); + } + + @GetMapping("viewGeneralComment") + @ApiOperation(value = "InteractiveTool页面查看备注信息接口", notes = "InteractiveTool页面查看备注信息接口") + public Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request) { + return selfStationService.viewGeneralComment(fileName, gammaROINum, request); + } + + @PostMapping("addGeneralComment") + @ApiOperation(value = "InteractiveTool页面add备注信息接口", notes = "InteractiveTool页面add备注信息接口") + public Result addGeneralComment(@RequestBody CommentsInfo commentsInfo, HttpServletRequest request) { + return selfStationService.addGeneralComment(commentsInfo.getFileName(), commentsInfo.getGammaROINum(), + commentsInfo.getComments(), request); + } + + /***************************************** beta ******************************************/ @PostMapping("fitting") @ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java index 686fafd2..1442df2a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/AcceptInfo.java @@ -20,4 +20,6 @@ public class AcceptInfo implements Serializable { private String flag; + private Integer gammaROINum; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CommentsInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CommentsInfo.java index dc8fa326..33bc8724 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CommentsInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CommentsInfo.java @@ -13,4 +13,6 @@ public class CommentsInfo implements Serializable { private String comments; + private int gammaROINum; + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfo.java index c47801c8..e114c762 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfo.java @@ -10,6 +10,8 @@ public class NuclideInfo implements Serializable { private Integer curRow; + private Integer gammaRoiNum; + private String nuclideName; private String fileName; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java index f71483e9..17db4439 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SelfStationVueData.java @@ -13,6 +13,10 @@ public class SelfStationVueData implements Serializable { /** * ROI-1结果数据 */ + /** + * ROI-1 Gamma文件名称 + */ + private String ROIOneFileName; /** * 折线图横纵坐标数组 */ @@ -34,6 +38,10 @@ public class SelfStationVueData implements Serializable { /** * ROI-2结果数据 */ + /** + * ROI-2 Gamma文件名称 + */ + private String ROITwoFileName; /** * 折线图横纵坐标数组 */ @@ -55,6 +63,10 @@ public class SelfStationVueData implements Serializable { /** * ROI-3结果数据 */ + /** + * ROI-3 Gamma文件名称 + */ + private String ROIThreeFileName; //折线图横纵坐标数组 private List ROIThreeList; private List ROIThreeCounts; @@ -70,6 +82,10 @@ public class SelfStationVueData implements Serializable { /** * ROI-4结果数据 */ + /** + * ROI-4 Gamma文件名称 + */ + private String ROIFourFileName; //折线图横纵坐标数组 private List ROIFourList; private List ROIFourCounts; 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 42108d86..b4bafa82 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 @@ -3,7 +3,9 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.entity.vo.ConfigureData; import org.jeecg.modules.entity.vo.ParameterInfo; +import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.entity.vo.SeriseData; +import org.jeecg.modules.entity.vo.TablePeaks; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -65,6 +67,33 @@ public interface ISelfStationService { Result Reprocessing(String fileName, String processKey, HttpServletRequest request); + Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request); + + Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request); + + Result acceptResults(String fileName, int gammaROINum, boolean accept, List oldPeak, List tablePeaksList, + List newPeak, String flag, HttpServletRequest request); + + Result deletePeak(String fileName, int curRow, int gammaROINum, HttpServletRequest request); + + Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request); + + Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy, HttpServletRequest request); + + Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request); + + Result addNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, List list_identify, HttpServletRequest request); + + Result deleteNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, List list_identify, HttpServletRequest request); + + Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request); + + Result addPeakComment(String fileName, int gammaROINum, int curRow, String comments, HttpServletRequest request); + + Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request); + + Result addGeneralComment(String fileName, int gammaROINum, String comments, 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 d6956a00..765dc047 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 @@ -4,10 +4,13 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; 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; @@ -240,6 +243,33 @@ public class SelfStationServiceImpl implements ISelfStationService { selfStationData.setSampleStruct(struct); selfStationData.setSampleTmpPath(sampleFilePath); selfStationUtil.loadFile(selfStationData, null, null, "sample", map); + + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + + // 根据ROI生成四个Gamma谱文件, 文件命名为Beta名称后面_ROI_x.PHD + String gammaOneName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_1.PHD"; + // 创建Gamma文件 + selfStationUtil.createGammaFile(path, gammaOneName, selfStationData.getSampleStruct(), sampleVueData.getROIOneCounts()); + + String gammaTwoName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_2.PHD"; + selfStationUtil.createGammaFile(path, gammaTwoName, selfStationData.getSampleStruct(), sampleVueData.getROITwoCounts()); + + String gammaThreeName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_3.PHD"; + selfStationUtil.createGammaFile(path, gammaThreeName, selfStationData.getSampleStruct(), sampleVueData.getROIThreeCounts()); + + String gammaFourName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_4.PHD"; + selfStationUtil.createGammaFile(path, gammaFourName, selfStationData.getSampleStruct(), sampleVueData.getROIFourCounts()); + + // Gamma文件内容转换为PHD实体 + sampleVueData.setROIOneFileName(gammaOneName); + sampleVueData.setROIOnePHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path)); + sampleVueData.setROITwoFileName(gammaTwoName); + sampleVueData.setROITwoPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path)); + sampleVueData.setROIThreeFileName(gammaThreeName); + sampleVueData.setROIThreePHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path)); + sampleVueData.setROIFourFileName(gammaFourName); + sampleVueData.setROIFourPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path)); + resultMap.put("sample", map); // 初始化Configure initConfigure(struct, selfStationData); @@ -1799,43 +1829,19 @@ public class SelfStationServiceImpl implements ISelfStationService { //获取自建台站缓存信息 Cache selfCache = selfStationCache.getSelfCache(); SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName); - - String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; - // 根据ROI生成四个Gamma谱文件 - // 文件命名为Beta名称后面_ROI_x.PHD - - // 生成Gamma文件名 - String gammaOneName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_1.PHD"; - // 创建Gamma文件 - selfStationUtil.createGammaFile(pathName, gammaOneName, selfStationData.getSampleStruct(), - selfStationData.getSampleVueData().getROIOneCounts()); - - String gammaTwoName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_2.PHD"; - selfStationUtil.createGammaFile(pathName, gammaTwoName, selfStationData.getSampleStruct(), - selfStationData.getSampleVueData().getROITwoCounts()); - - String gammaThreeName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_3.PHD"; - selfStationUtil.createGammaFile(pathName, gammaThreeName, selfStationData.getSampleStruct(), - selfStationData.getSampleVueData().getROIThreeCounts()); - - String gammaFourName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_4.PHD"; - selfStationUtil.createGammaFile(pathName, gammaFourName, selfStationData.getSampleStruct(), - selfStationData.getSampleVueData().getROIFourCounts()); - - - - // Gamma文件内容转换为PHD实体 - PHDFile phdOne = selfStationUtil.getGammaPHD(gammaTwoName, pathName); - PHDFile phdTwo = selfStationUtil.getGammaPHD(gammaTwoName, pathName); - PHDFile phdThree = selfStationUtil.getGammaPHD(gammaTwoName, pathName); - PHDFile phdFour = selfStationUtil.getGammaPHD(gammaTwoName, pathName); - -// Cache phdCache = localCache.getPHDCache(); -// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName); - if (Objects.isNull(phdOne)) { + if (Objects.isNull(selfStationData)) { result.error500("Please select the parse file first!"); return result; } + + SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); + + // Gamma文件内容转换为PHD实体 + PHDFile phdOne = sampleVueData.getROIOnePHDFile(); + PHDFile phdTwo = sampleVueData.getROITwoPHDFile(); + PHDFile phdThree = sampleVueData.getROIThreePHDFile(); + PHDFile phdFour = sampleVueData.getROIFourPHDFile(); + phdOne.setUserId(processKey); // 赋值xml文件存放路径 phdOne.setXmlFilePath(parameterProperties.getFilePath()); @@ -1848,59 +1854,876 @@ public class SelfStationServiceImpl implements ISelfStationService { "1. It has already Analyed.\n" + "2. You didn't change any setting or calibration."; result.error500(warning); - } else if (flag == -1) { - Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self"); - //分析时将phd的核素map重置 - phdOne.setPhdNuclideMap(nuclideLinesMap); - //重新计算核素的活度浓度 - gammaFileUtil.NuclidesIdent(phdOne, nuclideLinesMap); - phdOne.setEfficiencyParam(phdOne.getUsedEffiPara().getP()); - phdOne.setEfficiencyEnergy(phdOne.getUsedEffiKD().getG_energy()); - phdOne.setEfficiencyCurRow(0); - // 重新计算峰值 - Map nuclideLinesMDCMap = (Map) redisUtil.get("AllNuclideMap"); - gammaFileUtil.getNuclideMDCValue(phdOne, phdOne.getMdcInfoMap(), nuclideLinesMDCMap); - String warning = "Finish three tasks:\n" + - "\t1.Update efficiencies of all peaks;\n" + - "\t2.Identify nuclides again;\n" + - "\t3.Test QC again."; - result.error500(warning); } else { Map nuclideLinesMap = (Map) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self"); + if (flag == -1) { + //分析时将phd的核素map重置 + phdOne.setPhdNuclideMap(nuclideLinesMap); + //重新计算核素的活度浓度 + gammaFileUtil.NuclidesIdent(phdOne, nuclideLinesMap); + phdOne.setEfficiencyParam(phdOne.getUsedEffiPara().getP()); + phdOne.setEfficiencyEnergy(phdOne.getUsedEffiKD().getG_energy()); + phdOne.setEfficiencyCurRow(0); + // 重新计算峰值 + Map nuclideLinesMDCMap = (Map) redisUtil.get("AllNuclideMap"); + gammaFileUtil.getNuclideMDCValue(phdOne, phdOne.getMdcInfoMap(), nuclideLinesMDCMap); + String warning = "Finish three tasks:\n" + + "\t1.Update efficiencies of all peaks;\n" + + "\t2.Identify nuclides again;\n" + + "\t3.Test QC again."; + result.error500(warning); + } else { - try { - Map gammaResult = Maps.newHashMap(); - Map map1 = this.gammaAnalyse(phdOne, nuclideLinesMap, colorMap); - Map map2 = this.gammaAnalyse(phdTwo, nuclideLinesMap, colorMap); - Map map3 = this.gammaAnalyse(phdThree, nuclideLinesMap, colorMap); - Map map4 = this.gammaAnalyse(phdFour, nuclideLinesMap, colorMap); - gammaResult.put("ROI1", map1); - gammaResult.put("ROI2", map2); - gammaResult.put("ROI3", map3); - gammaResult.put("ROI4", map4); - SelfStationVueData sampleVueData = selfStationData.getSampleVueData(); - sampleVueData.setUsedEnerKD(phdOne.getUsedEnerKD()); - sampleVueData.setUsedEffiKD(phdOne.getUsedEffiKD()); - sampleVueData.setUsedResoKD(phdOne.getUsedResoKD()); - sampleVueData.setMapEnerKD(phdOne.getMapEnerKD()); - sampleVueData.setMapResoKD(phdOne.getMapResoKD()); - sampleVueData.setMapEffiKD(phdOne.getMapEffiKD()); - sampleVueData.setUsedEnerPara(phdOne.getUsedEnerPara()); - sampleVueData.setUsedEffiPara(phdOne.getUsedEffiPara()); - sampleVueData.setUsedResoPara(phdOne.getUsedResoPara()); - sampleVueData.setMapEnerPara(phdOne.getMapEnerPara()); - sampleVueData.setMapResoPara(phdOne.getMapResoPara()); - sampleVueData.setMapEffiPara(phdOne.getMapEffiPara()); + try { + Map gammaResult = Maps.newHashMap(); + Map map1 = this.gammaAnalyse(phdOne, nuclideLinesMap, colorMap); + Map map2 = this.gammaAnalyse(phdTwo, nuclideLinesMap, colorMap); + Map map3 = this.gammaAnalyse(phdThree, nuclideLinesMap, colorMap); + Map map4 = this.gammaAnalyse(phdFour, nuclideLinesMap, colorMap); + gammaResult.put("ROI1", map1); + gammaResult.put("ROI2", map2); + gammaResult.put("ROI3", map3); + gammaResult.put("ROI4", map4); - result.setSuccess(true); - result.setResult(gammaResult); - } catch (RuntimeException e) { - result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI")); + sampleVueData.setUsedEnerKD(phdOne.getUsedEnerKD()); + sampleVueData.setUsedEffiKD(phdOne.getUsedEffiKD()); + sampleVueData.setUsedResoKD(phdOne.getUsedResoKD()); + sampleVueData.setMapEnerKD(phdOne.getMapEnerKD()); + sampleVueData.setMapResoKD(phdOne.getMapResoKD()); + sampleVueData.setMapEffiKD(phdOne.getMapEffiKD()); + sampleVueData.setUsedEnerPara(phdOne.getUsedEnerPara()); + sampleVueData.setUsedEffiPara(phdOne.getUsedEffiPara()); + sampleVueData.setUsedResoPara(phdOne.getUsedResoPara()); + sampleVueData.setMapEnerPara(phdOne.getMapEnerPara()); + sampleVueData.setMapResoPara(phdOne.getMapResoPara()); + sampleVueData.setMapEffiPara(phdOne.getMapEffiPara()); + + result.setSuccess(true); + result.setResult(gammaResult); + } catch (RuntimeException e) { + result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI")); + } } } return result; } + @Override + public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map map = new HashMap<>(); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + Map colorMap = sysUserColorService.initColor(userName); + // 表单 + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); + // Chart 折线图 + List m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if (m_nSChan == 0) { + i = 1; + } + for (; i < m_nCount; ++i) { + m_vCount.add(phd.getSpec().getCounts().get(i)); + } + if (m_nSChan == 0) { + m_vCount.add(0L); + } + ChartData channelCountChart = gammaFileUtil.Channel_Count(phd, colorMap.get("Color_Spec")); + ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, colorMap.get("Color_Base")); + List channelPeakChart = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak")); + List channelBaseCPChart = gammaFileUtil.Channel_BaseCP(phd); + map.put("channelCountChart", channelCountChart); + map.put("channelBaseLineChart", channelBaseLineChart); + map.put("channelPeakChart", channelPeakChart); + map.put("channelBaseCPChart", channelBaseCPChart); + // Bar Chart 柱状图 + List differance = gammaFileUtil.Differance(phd, phd.getVPeak()); + map.put("barChart", differance); + // 赋值energy + map.put("energy", phd.getVEnergy()); + // 赋值BaseCtrls + map.put("BaseCtrls", phd.getBaseCtrls()); + // FitBaseLine颜色 + map.put("FitBaseLine", colorMap.get("Color_Fitbase")); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map map = new HashMap<>(); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + // 判断当前选中的channel是否在正常允许范围内 + if (curChan <= phd.getBaseCtrls().getRg_low() + 1 || curChan >= phd.getBaseCtrls().getRg_high() - 1) { + result.error500("Couldn't insert peak, maybe out of range"); + return result; + } + // 备份原来的峰列表 + List vOriPeaks = new LinkedList<>(); + vOriPeaks.addAll(phd.getVPeak()); + List peakCentroid = new LinkedList<>(); + List fwhmc = new LinkedList<>(); + List tail = new LinkedList<>(); + List tailAlpha = new LinkedList<>(); + List upperTail = new LinkedList<>(); + List upperTailAlpha = new LinkedList<>(); + List area = new LinkedList<>(); + List stepRatio = new LinkedList<>(); + for (PeakInfo peakInfo : vOriPeaks) { + peakCentroid.add(peakInfo.peakCentroid); + fwhmc.add(peakInfo.fwhmc); + tail.add(peakInfo.tail); + tailAlpha.add(peakInfo.tailAlpha); + upperTail.add(peakInfo.upperTail); + upperTailAlpha.add(peakInfo.upperTailAlpha); + area.add(peakInfo.area); + stepRatio.add(peakInfo.area * peakInfo.stepRatio); + } + // 声明基础数据 + List m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if (m_nSChan == 0) i = 1; + for (; i < m_nCount; ++i) { + m_vCount.add(phd.getSpec().getCounts().get(i).doubleValue()); + } + if (m_nSChan == 0) { + m_vCount.add(0.0); + } + // 添加到vPeak中 + gammaFileUtil.InitPara(phd); + // 插入峰 + StructInsertInput insertInput = new StructInsertInput(); + insertInput.peakCentroid = peakCentroid; + insertInput.fwhmc = fwhmc; + insertInput.tail = tail; + insertInput.tailAlpha = tailAlpha; + insertInput.upperTail = upperTail; + insertInput.upperTailAlpha = upperTailAlpha; + insertInput.area = area; + insertInput.stepRatio = stepRatio; + insertInput.usedEnerPara = phd.getUsedEnerPara().getP(); + insertInput.usedResoPara = phd.getUsedResoPara().getP(); + insertInput.usedEffiPara = phd.getUsedEffiPara().getP(); + insertInput.num_g_channel = phd.getSpec().getNum_g_channel(); + insertInput.begin_channel = phd.getSpec().getBegin_channel(); + insertInput.XCtrl = phd.getBaseCtrls().getXCtrl(); + insertInput.YCtrl = phd.getBaseCtrls().getYCtrl(); + insertInput.YSlope = phd.getBaseCtrls().getYSlope(); + insertInput.para_tail = phd.getPara_tail().getP(); + insertInput.para_tailAlpha = phd.getPara_tailAlpha().getP(); + insertInput.para_tailRight = phd.getPara_tailRight().getP(); + insertInput.para_tailRightAlpha = phd.getPara_tailRightAlpha().getP(); + insertInput.para_stepRatio = phd.getPara_stepRatio().getP(); + insertInput.rg_low = phd.getBaseCtrls().getRg_low(); + insertInput.rg_high = phd.getBaseCtrls().getRg_high(); + insertInput.curChan = curChan; + insertInput.vCount = m_vCount; + StructInsertOutput structInsertOutput = CalValuesHandler.insertPeaks(insertInput); + List newPeaks = new LinkedList<>(); + newPeaks.addAll(phd.getVPeak()); + if (structInsertOutput.vIdx.size() > 0) { + for (int j = 0; j < structInsertOutput.vIdx.size(); j++) { + int a = 0; + while (a < phd.getVPeak().size() && structInsertOutput.peakCentroid.get(j) > phd.getVPeak().get(a).peakCentroid) { + ++a; + } + PeakInfo peak = new PeakInfo(); + peak.index = a + 1; + peak.left = structInsertOutput.vLeft.get(j).intValue(); + peak.right = structInsertOutput.vRight.get(j).intValue(); + peak.peakCentroid = structInsertOutput.peakCentroid.get(j); + peak.energy = structInsertOutput.energy.get(j); + peak.area = structInsertOutput.area.get(j); + Double sensitivity = String.valueOf(structInsertOutput.sensitivity.get(j)).equalsIgnoreCase("nan") ? Double.NaN : structInsertOutput.sensitivity.get(j); + peak.sensitivity = sensitivity; + peak.fwhm = structInsertOutput.fwhm.get(j); + peak.fwhmc = structInsertOutput.fwhmc.get(j); + peak.stepRatio = structInsertOutput.stepRatio.get(j); + peak.tail = structInsertOutput.tail.get(j); + peak.tailAlpha = structInsertOutput.tailAlpha.get(j); + peak.upperTail = structInsertOutput.upperTail.get(j); + peak.upperTailAlpha = structInsertOutput.upperTailAlpha.get(j); + peak.efficiency = structInsertOutput.efficiency.get(j); + peak.BWWidthChan = 0; + peak.recoilBetaChan = Objects.isNull(structInsertOutput.recoilBetaChan.get(j))?"nan":String.valueOf(structInsertOutput.recoilBetaChan.get(j)); + peak.recoilDeltaChan = Objects.isNull(structInsertOutput.recoilDeltaChan.get(j))?"nan":String.valueOf(structInsertOutput.recoilDeltaChan.get(j)); + newPeaks.add(a, peak); + } + } + int left = structInsertOutput.vLeft.get(0).intValue(); + int right = structInsertOutput.vRight.get(0).intValue(); + + List vIdx = new LinkedList<>(); + int ii = 0; + for (PeakInfo peak : newPeaks) { + if (peak.peakCentroid >= right) { + break; + } else if (peak.peakCentroid > left) { + vIdx.add(ii); + } + ii++; + } + + FitPeakBaseLine(newPeaks, phd.getUsedEnerPara().getP(), vIdx, map); + map.put("oldPeaks", vOriPeaks); + map.put("newPeaks", newPeaks); + result.setSuccess(true); + result.setResult(map); + return result; + } + + public void FitPeakBaseLine(List vPeaks, List p, List vIdx, Map map) { + List tablePeaksList = new LinkedList<>(); + int peakNum = vIdx.size(); + for (int i = 0; i < peakNum; i++) { + int peakIdx = vIdx.get(i); + PeakInfo peak = vPeaks.get(peakIdx); + TablePeaks tablePeaks = new TablePeaks(); + tablePeaks.setLab(String.valueOf(peakIdx + 1)); + String nuclide = ""; + for (String peakNuclide : peak.nuclides) { + nuclide += peakNuclide + ";"; + } + tablePeaks.setNuclide(org.apache.commons.lang3.StringUtils.isBlank(nuclide) ? nuclide : nuclide.substring(0, nuclide.length() - 1)); + + tablePeaks.setEnergy(NumberFormatUtil.numberFormat(String.valueOf(peak.energy))); + tablePeaks.setNetArea(NumberFormatUtil.numberFormat(String.valueOf(peak.area))); + tablePeaks.setFwhm(NumberFormatUtil.numberFormat(String.valueOf(peak.fwhm))); + tablePeaks.setStep(NumberFormatUtil.numberFormat(String.valueOf(peak.area * peak.stepRatio))); + double deriva = CalValuesHandler.calDerivaOut(peak.peakCentroid, p); + tablePeaks.setBwGamma(NumberFormatUtil.numberFormat(String.valueOf(peak.BWWidthChan * deriva))); + tablePeaks.setNetAreaB(false); + tablePeaks.setCentroid(true); + tablePeaks.setFwhmB(true); + tablePeaksList.add(tablePeaks); + } + map.put("tablePeaksList", tablePeaksList); + } + + @Override + public Result acceptResults(String fileName, int gammaROINum, boolean accept, List oldPeak, + List tablePeaksList, List newPeak, String flag, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + try { + List m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + // 获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if (m_nSChan == 0) { + i = 1; + } + for (; i < m_nCount; ++i) { + m_vCount.add(phd.getSpec().getCounts().get(i)); + } + if (m_nSChan == 0) { + m_vCount.add(0L); + } + HashMap map = new HashMap<>(); + // 根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线 + if (accept) { + Map nuclideLinesMap = phd.getPhdNuclideMap();//(Map) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type()); + if (flag.equalsIgnoreCase("insert")) {// 如果传递的flag标识 是 Insert则进行峰值的插入 + //重新赋值index + for (int k=0; k vC_Rg = new LinkedList<>(); + vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_low())); + vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_high())); + + List vE_Rg = CalValuesHandler.calFcnEval(vC_Rg, phd.getUsedEnerPara().getP()).counts; + if (vE_Rg.size() != 2 || vE_Rg.get(0).isNaN() || vE_Rg.get(1).isNaN()) { + return result; + } + + List Af = new LinkedList<>(); + List Cf = new LinkedList<>(); + List Ff = new LinkedList<>(); + // 遍历列表中的数据 + for (int j = 0; j < tablePeaksList.size(); j++) { + TablePeaks nPeak = tablePeaksList.get(j); + PeakInfo peak = phd.getVPeak().get(Integer.valueOf(nPeak.getLab()) - 1); + double dE = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP()); + peak.energy = Double.parseDouble(nPeak.getEnergy()); + + if (peak.energy < vE_Rg.get(0) || peak.energy > vE_Rg.get(1)) { + result.error500("The energy isn't in the analysis range."); + return result; + } + List energys = new LinkedList<>(); + energys.add(peak.energy); + peak.peakCentroid = CalValuesHandler.energyToChannel(energys, phd.getUsedEnerPara().getP()).counts.get(0); + peak.area = Double.parseDouble(nPeak.getNetArea()); + peak.fwhm = Double.parseDouble(nPeak.getFwhm()); + peak.stepRatio = Double.valueOf(nPeak.getStep()) / peak.area; + peak.BWWidthChan = Double.valueOf(nPeak.getBwGamma()) / dE; + if (dE > 0) { + peak.fwhmc = peak.fwhm / dE; + } + + if (!tablePeaksList.get(j).isNetAreaB()) { + Af.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1); + } + if (!tablePeaksList.get(j).isCentroid()) { + Cf.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1); + } + if (!tablePeaksList.get(j).isFwhmB()) { + Ff.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1); + } + } + ObjectMapper mapper = new ObjectMapper(); + String phdStr = mapper.writeValueAsString(phd); + String strValue = CalValuesHandler.fitPeakFull(phdStr, Af, Cf, Ff); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry : parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class); + for (PeakInfo info:value) { + if (info.significance == -9999) { + info.significance = Double.POSITIVE_INFINITY; + } + } + phd.setVPeak(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List vBase = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); + phd.setVBase(vBase); + phd.getBaseCtrls().setBaseline(vBase); + } + } + // 重新计算peak的改变 + gammaFileUtil.PeaksChanged(phd); + //重新计算核素活度浓度 + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); + + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); + List channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak")); + map.put("channelPeakChart", channelPeak); + ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, colorMap.get("Color_Base")); + map.put("channelBaseLineChart", channelBaseLine); + List differance = gammaFileUtil.Differance(phd, phd.getVPeak()); + map.put("barChart", differance); + gammaFileUtil.UpdateChart(phd, map, colorMap); + } else {// 如果不保留 根据下标移除对应的vPeak数据 + if (CollectionUtils.isNotEmpty(oldPeak)) { + phd.getVPeak().clear(); + phd.setVPeak(oldPeak); + map.put("table", phd.getVPeak()); + List channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak")); + map.put("channelPeakChart", channelPeak); + } + } + result.setSuccess(true); + result.setResult(map); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return result; + } + + @Override + public Result deletePeak(String fileName, int gammaROINum, int curRow, HttpServletRequest request) { + Result result = new Result(); + //获取用户名称 + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + //获取缓存的核素信息 + Map nuclideMap = phd.getPhdNuclideMap(); + //获取颜色信息 + Map colorMap = sysUserColorService.initColor(userName); + //声明一个结果的map + HashMap map = new HashMap<>(); + //获取峰的大小 + int peakNum = phd.getVPeak().size(); + if (peakNum < 1) { + result.error500("No peak to delete."); + return result; + } + //判断当前要操作的下标是否在范围内 + if (curRow >= 0 && curRow < peakNum) { + //获取当前下标位置的峰值信息 + PeakInfo info = phd.getVPeak().get(curRow); + //获取当前选中的峰值信息的能量值 + double energy = info.energy; + if (CollectionUtils.isNotEmpty(info.nuclides)) { + //遍历核素信息 + for (int i=0; i= maxEnergy-0.5 && energy <= maxEnergy+0.5) { + //则需要删除所有关联的核素信息并 从MapNucAct中移除相关核素内容 + for (PeakInfo peakInfo: phd.getVPeak()) { + //如果峰的核素名称中包含当前删除的核素 + if (peakInfo.nuclides.contains(nuclideName)) { + peakInfo.nuclides.remove(nuclideName); + } + } + //从核素相关map中移除核素信息 + phd.getMapNucActMda().remove(nuclideName); + //移除核素信息 + nuclideMap.remove(nuclideName); + } + } + } + //将当前行从峰数组中移除 + phd.getVPeak().remove(curRow); + //重新计算核素活度浓度 + gammaFileUtil.NuclidesIdent(phd, nuclideMap); + //重新分析数据 + gammaFileUtil.PeaksChanged(phd); + for (int i = 0; i < phd.getVPeak().size(); i++) { + PeakInfo peakInfo = phd.getVPeak().get(i); + peakInfo.index = i; + } + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); + List channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak")); + map.put("channelPeakChart", channelPeak); + gammaFileUtil.UpdateChart(phd, map, colorMap); + } + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request) { + Result result = new Result(); + HashMap map = new HashMap<>(); + // 获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + // 判断当前phd文件对应的peak的数据是否小于1 + if (phd.getVPeak().size() < 1) { + result.error500("No peak to fit."); + return result; + } + // 判断当前选择的左侧道值是否大于右侧道值 + if (left > right) { + int temp = left; + left = right; + right = temp; + } + + // 找出与插入峰相关联的峰的索引 + List vIdx = new LinkedList<>(); + int ii = 0; + for (PeakInfo peak : phd.getVPeak()) { + if (peak.peakCentroid >= right) { + break; + } else if (peak.peakCentroid > left) { + vIdx.add(ii); + } + ii++; + } + if (CollectionUtils.isEmpty(vIdx)) { + result.error500("There are 0 peak between channel " + left + " and " + right); + return result; + } + // 备份原来的峰列表 + List vOriPeaks = phd.getVPeak(); + + FitPeakBaseLine(phd.getVPeak(), phd.getUsedEnerPara().getP(), vIdx, map); + map.put("oldPeaks", vOriPeaks); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy, + HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + if (phd.getVPeak().size() < 1) { + return result; + } +// if (energy > 0) { +// channel = (int) gammaFileUtil.GetEnergyByFloatChan(phd, (int) energy); +// } else if (channel > 0){ +// energy = gammaFileUtil.GetEnergyByFloatChan(phd, channel); +// } + int index = gammaFileUtil.FindNearPeak(phd.getVPeak(), channel, false); + + //获取缓存的核素信息 + Map nuclideMap = (Map) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type()); + Map nuclCoincidenceSumMap = (Map) redisUtil.get("nuclCoincidenceSumMap"); + //计算核素范围的最小能量值 + double min = energy - phd.getSetting().getEnergyTolerance(); + //计算核素范围的最大能量值 + double max = energy + phd.getSetting().getEnergyTolerance(); + //声明返回的数组内容 + List list_possible = new LinkedList<>(); + //判断缓存的核素信息是否为空 + if (CollectionUtils.isNotEmpty(nuclideMap)) { + //遍历核素信息 + for (Map.Entry entry:nuclideMap.entrySet()) { + //获取核素的关联信息 + NuclideLines nuclideLines = entry.getValue(); + //获取核素关联的全部能量信息 + List venergy = nuclideLines.getVenergy(); + List fullNames = nuclideLines.getFullNames(); + //遍历能量 + for (int i=0; i min && venergy.get(i) < max) { + list_possible.add(fullNames.get(i)); + } + } + } + } + if (phd.getHeader().getSystem_type().equals("P")) { + if (CollectionUtils.isNotEmpty(nuclCoincidenceSumMap)) { + for (Map.Entry entry:nuclCoincidenceSumMap.entrySet()) { + //获取核素的关联信息 + NuclideLines nuclideLines = entry.getValue(); + //获取核素关联的全部能量信息 + List venergy = nuclideLines.getVenergy(); + List fullNames = nuclideLines.getFullNames(); + //遍历能量 + for (int i=0; i min && venergy.get(i) < max) { + list_possible.add(fullNames.get(i)); + } + } + } + } + } + // 用户当前已选中的核素名称 + List list_identify = phd.getVPeak().get(index).nuclides; + + map.put("index", index); + map.put("possible", list_possible); + map.put("identify", list_identify); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + if (phd.getVPeak().size() < 1) { + return result; + } + int index = gammaFileUtil.FindNearPeak(phd.getVPeak(), channel, false); + + //获取缓存的核素信息 + Map nuclideMap = (Map) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type()); + //计算核素范围的最小能量值 + double min = phd.getVPeak().get(index).energy - phd.getSetting().getEnergyTolerance(); + //计算核素范围的最大能量值 + double max = phd.getVPeak().get(index).energy + phd.getSetting().getEnergyTolerance(); + //声明返回的数组内容 + List list_possible = new LinkedList<>(); + //判断缓存的核素信息是否为空 + if (CollectionUtils.isNotEmpty(nuclideMap)) { + //遍历核素信息 + for (Map.Entry entry:nuclideMap.entrySet()) { + //获取核素的关联信息 + NuclideLines nuclideLines = entry.getValue(); + //获取核素关联的全部能量信息 + List venergy = nuclideLines.getVenergy(); + //遍历能量 + for (int i=0; i min && venergy.get(i) < max) { + list_possible.add(entry.getKey()); + break; + } + } + } + } + // 用户当前已选中的核素名称 + List list_identify = phd.getVPeak().get(index).nuclides; + + map.put("index", index); + map.put("possible", list_possible); + map.put("identify", list_identify); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result addNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, + List list_identify, HttpServletRequest request) { + Result result = new Result(); + Map map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + // 获取需要新增的核素名称 + if (org.apache.commons.lang3.StringUtils.isBlank(nuclideName)) { + result.error500("The nuclide name cannot be empty!"); + return result; + } + // 判断当前用户的核素列表是否有核素信息 如果不为空就返回 不进行改变 + if (list_identify.indexOf(nuclideName) > 0) { + return result; + } + // 用户当前的核素信息新增核素名称 + list_identify.add(nuclideName); + // 根据要进行修改的列的数据下标 操作Vpeak数据 + List peakNuclides = phd.getVPeak().get(curRow).nuclides; + if (peakNuclides.indexOf(nuclideName) < 0 ) { + peakNuclides.add(nuclideName); + } + // 查询当前用户所关心的核素名称 + Map mapNucLines = (Map) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type()); + //用户当前缓存的核素信息 + Map phdNuclideMap = phd.getPhdNuclideMap(); + // 查询出核素信息 + NuclideLines it_line = mapNucLines.get(nuclideName); + // 如果核素信息不存在返回 + if (Objects.isNull(it_line)) { + return result; + } + List vPeakIdx = new LinkedList<>(); // 从 0 开始 + int t_idx = 0; + for (PeakInfo peak : phd.getVPeak()) { + if (peak.nuclides.contains(nuclideName)) { + vPeakIdx.add(t_idx); + } + t_idx++; + } + //重新计算核素的MDA值 + gammaFileUtil.CalcNuclideMDA(phd, it_line, nuclideName, vPeakIdx); + map.put("identify", list_identify); + //格式化核素表单内容 + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); + //如果当前缓存的谱核素信息不包含当前核素 + if (Objects.isNull(phdNuclideMap.get(nuclideName))) { + //将redis缓存的谱核素信息 存入到缓存map中 + phdNuclideMap.put(nuclideName, it_line); + phd.setPhdNuclideMap(phdNuclideMap); + } + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result deleteNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, + List list_identify, HttpServletRequest request) { + Result result = new Result(); + //获取用户名 + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + Map map = new HashMap<>(); + Map nuclideMap = phd.getPhdNuclideMap(); + //判断当前选择的核素名称是否包含在当前Peak的核素列表中 + int index = list_identify.indexOf(nuclideName); + if (index >= 0) { + // 如果所选的行下标小于0 或者 超出界限 则不进行处理 + if (curRow < 0 || curRow >= phd.getVPeak().size()) { + return result; + } + //从缓存信息中获取核素名称 + NuclideLines nuclideLines = nuclideMap.get(nuclideName); + //获取最大活度的核素位置 + int maxYeildIdx = nuclideLines.maxYeildIdx; + //获取最大活度对应的核素能量值 + Double maxEnergy = nuclideLines.getVenergy().get(maxYeildIdx); + //获取当前选中的峰值信息的能量值 + double energy = phd.getVPeak().get(curRow).energy; + //判断当前选中的峰值信息的能量值 是否在 最大活度对应的核素能量值公差范围内 + if (energy >= maxEnergy-0.5 && energy <= maxEnergy+0.5) { + //则需要删除所有关联的核素信息并 从MapNucAct中移除相关核素内容 + for (PeakInfo peakInfo: phd.getVPeak()) { + //如果峰的核素名称中包含当前删除的核素 + if (peakInfo.nuclides.contains(nuclideName)) { + peakInfo.nuclides.remove(nuclideName); + } + } + //从核素相关map中移除核素信息 + phd.getMapNucActMda().remove(nuclideName); + //移除核素信息 + nuclideMap.remove(nuclideName); + //重新计算核素活度浓度 + gammaFileUtil.NuclidesIdent(phd, nuclideMap); + //从核素的选中列表中移除对应下标的核素信息 + list_identify.remove(index); + //重新初始化峰列表信息 + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("identify", list_identify); + map.put("table", vPeak); + } else { + // 更新峰信息列表和表格 + // 根据核素名称获取对应的下标并从list_identify,phd.getVPeak()移除 + list_identify.remove(index); + int peakNuclIndex = phd.getVPeak().get(curRow).nuclides.indexOf(nuclideName); + phd.getVPeak().get(curRow).nuclides.remove(peakNuclIndex); + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + // 处理核素MDA、MDC + gammaFileUtil.ReCalcMdaMdc(phd, nuclideName, curRow + 1); + // 谱的峰信息通过stream流过滤出包含当前核素名称的峰信息 + List peakInfoList = phd.getVPeak().stream().filter(item -> item.nuclides.indexOf(nuclideName) >= 0).collect(Collectors.toList()); + //过滤结果小于等于0 则说明当前核素在峰值中不存在了 需要从缓存的核素信息map中移除核素 + if (peakInfoList.size() <= 0) { + //移除核素信息 + nuclideMap.remove(nuclideName); + } + map.put("identify", list_identify); + map.put("table", vPeak); + } + result.setSuccess(true); + result.setResult(map); + } + return result; + } + + @Override + public Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + if (curRow >= 0 && curRow < phd.getVPeak().size()) { + result.setSuccess(true); + result.setResult(phd.getVPeak().get(curRow).comments); + } else { + result.error500("Please first select the peak to which you want to add comments!"); + } + return result; + } + + @Override + public Result addPeakComment(String fileName, int gammaROINum, int curRow, String comments, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map map = new HashMap<>(); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + if (curRow >= 0 && curRow < phd.getVPeak().size()) { + phd.getVPeak().get(curRow).comments = comments; + List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); + map.put("table", vPeak); + result.setSuccess(true); + result.setResult(map); + } else { + result.error500("Please first select the peak to which you want to add comments!"); + } + return result; + } + + @Override + public Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + result.setSuccess(true); + result.setResult(phd.getTotalCmt()); + return result; + } + + @Override + public Result addGeneralComment(String fileName, int gammaROINum, String comments, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + // 从缓存中获取Gamma数据 + PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache); + if (Objects.isNull(phd)) { + result.error500("Please select the parse file first!"); + return result; + } + if (org.apache.commons.lang3.StringUtils.isNotBlank(comments)) { + phd.setTotalCmt(comments); + } + return Result.ok(); + } + @Override public Result fitting(Double paramA, Double paramB, Double paramC, List tempPoints, Integer count, String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request) { @@ -2448,6 +3271,14 @@ public class SelfStationServiceImpl implements ISelfStationService { return result; } + /** + * 执行gamma分析 + * @param phd gamma 数据 + * @param nuclideLinesMap 核素 + * @param colorMap 拟合数据的颜色 + * @return + * @throws RuntimeException + */ private Map gammaAnalyse(PHDFile phd, Map nuclideLinesMap, Map colorMap) throws RuntimeException{ From 5849612a3bb95f550c0be8f79e3960c8344f130f Mon Sep 17 00:00:00 2001 From: nieziyan Date: Thu, 18 Jul 2024 19:43:26 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat=EF=BC=9AbgSpectrum=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/entity/vo/SeriseData.java | 3 -- .../service/impl/SelfStationServiceImpl.java | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java index 52486cc1..8a520cdb 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SeriseData.java @@ -10,7 +10,4 @@ public class SeriseData implements Serializable { private double x; private double y; - - private double e; - } 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 765dc047..b2cd4644 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 @@ -273,6 +273,8 @@ public class SelfStationServiceImpl implements ISelfStationService { resultMap.put("sample", map); // 初始化Configure initConfigure(struct, selfStationData); + // 返回Beta和Gamma的数据 + bGSpectrum(struct, map); } } //判断det文件名是否为空 @@ -335,6 +337,8 @@ public class SelfStationServiceImpl implements ISelfStationService { Map map = new HashMap<>(); selfStationUtil.loadFile(selfStationData, null, null, "sample", map); resultMap.put("sample", map); + // 返回Beta和Gamma的数据 + bGSpectrum(selfStationData.getSampleStruct(), map); } if (StringUtils.isNotBlank(detFileName)) { //返回结果map @@ -447,6 +451,32 @@ public class SelfStationServiceImpl implements ISelfStationService { } } + public void bGSpectrum(EnergySpectrumStruct struct, Map map){ + List seriseDataB = new LinkedList<>(); + List seriseDataG = new LinkedList<>(); + + long numBChannel = struct.num_b_channel; + long numGChannel = struct.num_g_channel; + List bCounts = struct.b_counts; + List gCounts = struct.g_counts; + + for (int i = 0; i < numBChannel; i++) { + SeriseData seriseData = new SeriseData(); + seriseData.setX(i); + seriseData.setY(bCounts.get(i)); + seriseDataB.add(seriseData); + } + for (int i = 0; i < numGChannel; i++) { + SeriseData seriseData = new SeriseData(); + seriseData.setX(i); + seriseData.setY(gCounts.get(i)); + seriseDataG.add(seriseData); + } + Map result = new HashMap<>(); + map.put("bSpectrum", seriseDataB); + map.put("gSpectrum", seriseDataG); + } + @Override public void deleteSelfStationCache(String sampleFileName, HttpServletRequest request) { String userName = JwtUtil.getUserNameByToken(request); From f2d211b2b298e5c0f255c7077b41c45fa5a02d87 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Fri, 19 Jul 2024 09:20:32 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix=EF=BC=9Abeta=20energy=20calibration=20?= =?UTF-8?q?=E4=B8=ADqc=E8=B0=B1=E6=95=A3=E7=82=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/modules/service/impl/SelfStationServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 b2cd4644..5053419b 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 @@ -1694,9 +1694,9 @@ public class SelfStationServiceImpl implements ISelfStationService { } //Beta-Gamma Spectrum: QC 散点图相关数据 List histogramDataList = new LinkedList<>(); - for (int column=0; column0) { HistogramData histogramData = new HistogramData();