From a06fbed52add64a82fc02d1fc7c538b895bb9e8b Mon Sep 17 00:00:00 2001 From: orgin Date: Wed, 13 Sep 2023 16:34:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20redis=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96GardsNuclLinesLib=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IGardsNuclLinesLibService.java | 3 ++ .../impl/GardsNuclLinesLibServiceImpl.java | 44 ++++++++++++++++--- .../impl/SysDefaultNuclideServiceImpl.java | 14 +++--- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java index b9e50971..61f51df1 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java @@ -3,6 +3,7 @@ package org.jeecg.modules.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.google.common.collect.Multimap; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.entity.vo.NuclideLines; import java.util.List; import java.util.Map; @@ -10,4 +11,6 @@ import java.util.Map; public interface IGardsNuclLinesLibService extends IService { Map> mapLines(List nuclideNames); + + Map defaultLines(List nuclideNames); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java index 20df66c1..45c3e3eb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java @@ -2,17 +2,12 @@ package org.jeecg.modules.system.service.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import org.apache.commons.collections.MultiHashMap; -import org.jeecg.common.util.ListUtils; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.entity.vo.NuclideLines; import org.jeecg.modules.system.mapper.GardsNuclLinesLibMapper; import org.jeecg.modules.system.service.IGardsNuclLibService; import org.jeecg.modules.system.service.IGardsNuclLinesLibService; @@ -21,6 +16,7 @@ import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -64,4 +60,40 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl defaultLines(List nuclideNames) { + Map result = new HashMap<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(GardsNuclLinesLib::getName, nuclideNames); + // 获取GardsNuclLinesLib核素数据 + List allNuclide = list(wrapper); + Map halfLife = nuclLibService.halfLife(nuclideNames); + + // 按照 QT源代码 处理数据 + for (int i = 0; i < allNuclide.size(); i++) { + NuclideLines nuclideLines; + GardsNuclLinesLib lib = allNuclide.get(i); + nuclideLines = result.containsKey(lib.getName()) ? result.get(lib.getName()) : new NuclideLines(); + + nuclideLines.getFullNames().add(lib.getFullName()); + nuclideLines.getVEnergy().add(lib.getEnergy()); + nuclideLines.getVUncertE().add(lib.getEnergyUncert()); + nuclideLines.getVYield().add(lib.getYield() / 100); + nuclideLines.getVUncertY().add(lib.getYieldUncert()); + + int keyFlag = lib.getKeyFlag(); + if (keyFlag > 0){ + nuclideLines.setKey_flag(i); + nuclideLines.setMaxYeildIdx(i); + } + + String name = lib.getName(); + Double day = halfLife.get(name); + if (ObjectUtil.isNotNull(day)) + lib.setHalflife(day * 86400); + + result.put(lib.getName(), nuclideLines); + } + return result; + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java index d90f723f..cabc5c91 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java @@ -16,6 +16,7 @@ import org.jeecg.common.constant.RedisConstant; import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide; +import org.jeecg.modules.entity.vo.NuclideLines; import org.jeecg.modules.monitor.domain.RedisInfo; import org.jeecg.modules.system.mapper.SysDefaultNuclideMapper; import org.jeecg.modules.system.service.IGardsNuclLinesLibService; @@ -24,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @@ -108,21 +106,27 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl linesHashMap = new HashMap<>(); + List nuclideTypes = ListUtil.toList("G","P"); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysDefaultNuclide::getUseType,1); wrapper.in(SysDefaultNuclide::getNuclideType,nuclideTypes); + // 获取自动处理需要的默认核素参数 List nuclides = list(wrapper); + // 根据核素类型分组 Map> nuclideMap = nuclides.stream() .filter(nuclide -> StrUtil.isNotBlank(nuclide.getNuclideName())) .collect(Collectors.groupingBy(SysDefaultNuclide::getNuclideType)); + // 获取GardsNuclLinesLib核素数据 for (Map.Entry> entry : nuclideMap.entrySet()) { List nuclideNames = entry.getValue().stream() .map(SysDefaultNuclide::getNuclideName) .collect(Collectors.toList()); + String nuclideType = entry.getKey(); String key = RedisConstant.NUCLIDE_LINES_LIB + nuclideType; - Map> mapLines = nuclLinesLibService.mapLines(nuclideNames); + Map mapLines = nuclLinesLibService.defaultLines(nuclideNames); redisUtil.set(key,mapLines); } }