From 5290d50b656b1ad9cbbe2068e4e02a896498da1c Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 12 Dec 2023 16:01:09 +0800 Subject: [PATCH] =?UTF-8?q?system=E5=90=AF=E5=8A=A8=E6=97=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=A0=B8=E7=B4=A0=E7=9B=B8=E5=85=B3=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20=E4=BA=BA=E5=B7=A5=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E5=88=86=E6=9E=90gamma=E9=83=A8=E5=88=86NuclLib=20Review?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=85=A2=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/mapper/GardsNuclLibMapper.java | 2 + .../modules/mapper/xml/GardsNuclLibMapper.xml | 6 + .../modules/service/IGardsNuclLibService.java | 2 + .../service/impl/GardsNuclLibServiceImpl.java | 14 +++ .../service/impl/GammaServiceImpl.java | 119 ++++++++++-------- .../jeecg/JeecgSystemCloudApplication.java | 5 + 6 files changed, 93 insertions(+), 55 deletions(-) diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/GardsNuclLibMapper.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/GardsNuclLibMapper.java index 7526eea1..e75ed8fd 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/GardsNuclLibMapper.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/GardsNuclLibMapper.java @@ -12,4 +12,6 @@ public interface GardsNuclLibMapper extends BaseMapper { List halfLife(List nuclideNames); List allName(); + + List getNucliLib(); } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclLibMapper.xml b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclLibMapper.xml index 3ea2789e..e59a0426 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclLibMapper.xml +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclLibMapper.xml @@ -17,7 +17,13 @@ + + + + \ No newline at end of file diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/IGardsNuclLibService.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/IGardsNuclLibService.java index 3393771e..4472e165 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/IGardsNuclLibService.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/IGardsNuclLibService.java @@ -11,4 +11,6 @@ public interface IGardsNuclLibService extends IService { Map halfLife(List nuclideNames); List allName(); + + void getNucliLib(); } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/GardsNuclLibServiceImpl.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/GardsNuclLibServiceImpl.java index eadd64bc..1881b7a1 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/GardsNuclLibServiceImpl.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/service/impl/GardsNuclLibServiceImpl.java @@ -5,22 +5,29 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.base.dto.GardsNuclLibDto; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.mapper.GardsNuclLibMapper; import org.jeecg.modules.service.IGardsNuclLibService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; @Service @DS("ora") public class GardsNuclLibServiceImpl extends ServiceImpl implements IGardsNuclLibService { + @Autowired + private RedisUtil redisUtil; + @Override public Map halfLife(List nuclideNames) { Map halfLife = MapUtil.newHashMap(); @@ -38,4 +45,11 @@ public class GardsNuclLibServiceImpl extends ServiceImpl gardsNuclLibs = this.baseMapper.getNucliLib(); + Map nuclLibMap = gardsNuclLibs.stream().collect(Collectors.toMap(GardsNuclLib::getName, Function.identity())); + redisUtil.set("nuclLibs", nuclLibMap); + } } 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 60c74eeb..0db36589 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 @@ -977,6 +977,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.setResult(chartDataList); } compareFile.delete(); + } else { + result.error500("比较文件不存在!"); + return result; } return result; } @@ -1062,6 +1065,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.setResult(stripMap); } stripFile.delete(); + } else { + result.error500("比较文件不存在!"); + return result; } return result; } @@ -2105,7 +2111,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - InitTable(name, map, phd, colorMap); + InitTable(name, map, phd, colorMap, nuclideMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); @@ -2130,67 +2136,68 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi // return nuclideList; // } - public void InitTable(String name, Map map, PHDFile phd, Map colorMap) { + public void InitTable(String name, Map map, PHDFile phd, Map colorMap, Map nuclideMap) { InitNuclideInfo(name, map); long span = phd.getSpec().getG_energy_span(); - List nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span); - if (CollectionUtils.isNotEmpty(nuclideTableList)) { - nuclideTableList.stream().forEach(item-> { - if (Objects.nonNull(item.getEnergy())) { - item.setEnergy(Double.valueOf(String.format("%.3f", item.getEnergy()))); - } else { - item.setEnergy(Double.valueOf(String.format("%.3f", 0.0))); + + //判断缓存的核素信息是否为空 + if (CollectionUtils.isNotEmpty(nuclideMap)) { + //获取当前核素名称的核素集合 + NuclideLines lines = nuclideMap.get(name); + List nuclideTableList = new LinkedList<>();//spectrumAnalysisMapper.getNuclideTable(name, span); + for (int i=0; i= 30 && lines.venergy.get(i) <= span) { + GardsNuclLinesLib nuclLinesLib = new GardsNuclLinesLib(); + nuclLinesLib.setFullName(lines.fullNames.get(i)); + nuclLinesLib.setEnergy(Double.valueOf(String.format("%.3f", lines.venergy.get(i)))); + nuclLinesLib.setEnergyUncert(Objects.nonNull(lines.vuncertE.get(i))?Double.valueOf(String.format("%.3f", lines.vuncertE.get(i))):0.0); + nuclLinesLib.setYield(Objects.nonNull(lines.vyield.get(i))?Double.valueOf(String.format("%.3f", lines.vyield.get(i)*100)):0.0); + nuclLinesLib.setYieldUncert(Objects.nonNull(lines.vuncertY.get(i))?Double.valueOf(String.format("%.3f", lines.vuncertY.get(i))):0.0); + nuclideTableList.add(nuclLinesLib); + } } - if (Objects.nonNull(item.getEnergyUncert())) { - item.setEnergyUncert(Double.valueOf(String.format("%.3f", item.getEnergyUncert()))); - } else { - item.setEnergyUncert(Double.valueOf(String.format("%.3f", 0.0))); - } - if (Objects.nonNull(item.getYield())) { - item.setYield(Double.valueOf(String.format("%.3f", item.getYield()))); - } else { - item.setYield(Double.valueOf(String.format("%.3f", 0.0))); - } - if (Objects.nonNull(item.getYieldUncert())) { - item.setYieldUncert(Double.valueOf(String.format("%.3f", item.getYieldUncert()))); - } else { - item.setYieldUncert(Double.valueOf(String.format("%.3f", 0.0))); - } - }); - nuclideTableList.stream().max(Comparator.comparing(GardsNuclLinesLib::getYield)).get().setKeyFlag(1); - map.put("table", nuclideTableList); - gammaFileUtil.InitChart(nuclideTableList, phd, map, colorMap); + } + if (CollectionUtils.isNotEmpty(nuclideTableList)) { + nuclideTableList = nuclideTableList.stream().sorted(Comparator.comparing(GardsNuclLinesLib::getYield)).collect(Collectors.toList()); + nuclideTableList.stream().max(Comparator.comparing(GardsNuclLinesLib::getYield)).get().setKeyFlag(1); + map.put("table", nuclideTableList); + gammaFileUtil.InitChart(nuclideTableList, phd, map, colorMap); + } } } public void InitNuclideInfo(String name, Map map) { map.put("name", name); - - GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name); - if (Objects.nonNull(nuclideInfo)) { - map.put("lines", nuclideInfo.getNumLines()); - if (Objects.isNull(nuclideInfo.getHalflife())) { - map.put("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) { - halflife = halflife * 1440; - units = "M"; - } else if (halflife <= 1.0 / 1440 && halflife > 0) { - halflife = halflife * 86400; - units = "S"; + Map nuclLibs = (Map) redisUtil.get("nuclLibs"); + if (CollectionUtils.isNotEmpty(nuclLibs)) { + GardsNuclLib nuclideInfo = nuclLibs.get(name); + if (Objects.nonNull(nuclideInfo)) { + map.put("lines", nuclideInfo.getNumLines()); + if (Objects.isNull(nuclideInfo.getHalflife())) { + map.put("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) { + halflife = halflife * 1440; + units = "M"; + } else if (halflife <= 1.0 / 1440 && halflife > 0) { + halflife = halflife * 86400; + units = "S"; + } + halflife = halflife + 0.0001; + map.put("halfLife", String.format("%.3f", halflife) + units); + } + if (Objects.isNull(nuclideInfo.getHalflifeErr())) { + map.put("halfLifeErr", ""); + } else { + map.put("halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue()) + "%"); } - halflife = halflife + 0.0001; - map.put("halfLife", String.format("%.3f", halflife) + units); - } - if (Objects.isNull(nuclideInfo.getHalflifeErr())) { - map.put("halfLifeErr", ""); - } else { - map.put("halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue()) + "%"); } } } @@ -2207,7 +2214,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi return result; } Map colorMap = sysUserColorService.initColor(userName); - InitTable(nuclideName, map, phd, colorMap); + //获取缓存的核素信息 + Map nuclideMap = (Map) redisUtil.get(userName+"-"+phd.getHeader().getSystem_type()); + InitTable(nuclideName, map, phd, colorMap, nuclideMap); result.setSuccess(true); result.setResult(map); return result; @@ -2255,7 +2264,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - InitTable(name, map, phd, colorMap); + InitTable(name, map, phd, colorMap, nuclideMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); diff --git a/jeecg-server-cloud/armd-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java b/jeecg-server-cloud/armd-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java index ae50f174..ea5070ee 100644 --- a/jeecg-server-cloud/armd-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java +++ b/jeecg-server-cloud/armd-system-cloud-start/src/main/java/org/jeecg/JeecgSystemCloudApplication.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.base.BaseMap; import org.jeecg.common.constant.GlobalConstants; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.service.IGardsNuclLibService; import org.jeecg.modules.system.service.IGardsDetectorsService; import org.jeecg.modules.system.service.IGardsNuclearfacilityService; import org.jeecg.modules.system.service.IGardsStationsService; @@ -42,6 +43,8 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im private IGardsDetectorsService gardsDetectorsService; @Autowired private IGardsNuclearfacilityService gardsNuclearfacilityService; + @Autowired + private IGardsNuclLibService gardsNuclLibService; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { @@ -81,5 +84,7 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer im gardsDetectorsService.findDetectors(); //触发缓存一下核设施信息 gardsNuclearfacilityService.findNuclearFacility(); + //触发缓存一下核素信息 + gardsNuclLibService.getNucliLib(); } } \ No newline at end of file