fix: 计算mdc

This commit is contained in:
xiaoguangbin 2024-01-10 14:30:44 +08:00
parent cf0325a63b
commit df5cfd5fd1
8 changed files with 79 additions and 120 deletions

View File

@ -1,18 +0,0 @@
package org.jeecg.modules.base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.entity.vo.HalfData;
import org.jeecg.modules.entity.vo.NuclideLine;
import java.util.List;
public interface GardsNuclLibMapper extends BaseMapper<GardsNuclLib> {
List<String> findNuclidesAnalysis();
List<NuclideLine> getNuclideLines(@Param("name") String name);
HalfData getOneHalf(@Param("name") String name);
}

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.base.mapper.BaseCommonMapper">
<select id="findNuclidesAnalysis" resultType="java.lang.String">
select NAME from CONFIGURATION.GARDS_NUCL_LIB
</select>
<select id="getNuclideLines" resultType="org.jeecg.modules.entity.vo.NuclideLine">
SELECT FULLNAME as fullName,
ENERGY as energy,
ENERGY_UNCERT as energyUncert,
YIELD as yield,
YIELD_UNCERT as yieldUncert,
KEY_FLAG as keyFlag
from CONFIGURATION.GARDS_NUCL_LINES_LIB WHERE NAME = #{name} ORDER BY ENERGY
</select>
<select id="getOneHalf" resultType="org.jeecg.modules.entity.vo.HalfData">
SELECT
NAME as name,
HALFLIFE as half
FROM
CONFIGURATION.GARDS_NUCL_LIB
WHERE NAME = #{name}
</select>
</mapper>

View File

@ -1,10 +0,0 @@
package org.jeecg.modules.base.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
public interface IGardsNuclLibService extends IService<GardsNuclLib> {
void getNuclideMap();
}

View File

@ -1,64 +0,0 @@
package org.jeecg.modules.base.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.mapper.GardsNuclLibMapper;
import org.jeecg.modules.base.service.IGardsNuclLibService;
import org.jeecg.modules.entity.vo.HalfData;
import org.jeecg.modules.entity.vo.NuclideLine;
import org.jeecg.modules.entity.vo.NuclideLines;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
@DS("ora")
public class GardsNuclLibServiceImpl extends ServiceImpl<GardsNuclLibMapper, GardsNuclLib> implements IGardsNuclLibService {
@Autowired
private RedisUtil redisUtil;
@Override
public void getNuclideMap() {
List<String> nuclideLibs = this.baseMapper.findNuclidesAnalysis();
Map<String, NuclideLines> nuclideMap = GetNuclideLines(nuclideLibs);
redisUtil.set("AllNuclideMap", nuclideMap);
}
public Map<String, NuclideLines> GetNuclideLines(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if (nuclideList.size() < 1) {
return mapLines;
}
for (String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
List<NuclideLine> nuclideLineList = this.baseMapper.getNuclideLines(name);
for (int j = 0; j < nuclideLineList.size(); j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergyUncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYieldUncert());
if (Objects.nonNull(nuclideLineList.get(j).getKeyFlag()) && nuclideLineList.get(j).getKeyFlag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
}
mapLines.put(name, nlines);
}
for (String name:nuclideList) {
HalfData half = this.baseMapper.getOneHalf(name);
NuclideLines nuclideLines = mapLines.get(half.getName());
nuclideLines.setHalflife(half.getHalf() == null ? 0 : half.getHalf() * 86400);// 将天转换成秒
mapLines.put(half.getName(), nuclideLines);
}
return mapLines;
}
}

View File

@ -2,8 +2,11 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.dto.GardsNuclLibDto;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.entity.vo.HalfData;
import org.jeecg.modules.entity.vo.NuclideLine;
import java.util.List;
@ -14,4 +17,11 @@ public interface GardsNuclLibMapper extends BaseMapper<GardsNuclLib> {
List<String> allName();
List<GardsNuclLib> getNucliLib();
List<String> findNuclidesAnalysis();
List<NuclideLine> getNuclideLines(@Param("name") String name);
HalfData getOneHalf(@Param("name") String name);
}

View File

@ -26,4 +26,27 @@
select a.NAME, a.num_lines, a.halflife, a.halflife_err from CONFIGURATION.GARDS_NUCL_LIB a
</select>
<select id="findNuclidesAnalysis" resultType="java.lang.String">
select NAME from CONFIGURATION.GARDS_NUCL_LIB
</select>
<select id="getNuclideLines" resultType="org.jeecg.modules.entity.vo.NuclideLine">
SELECT FULLNAME as fullName,
ENERGY as energy,
ENERGY_UNCERT as energyUncert,
YIELD as yield,
YIELD_UNCERT as yieldUncert,
KEY_FLAG as keyFlag
from CONFIGURATION.GARDS_NUCL_LINES_LIB WHERE NAME = #{name} ORDER BY ENERGY
</select>
<select id="getOneHalf" resultType="org.jeecg.modules.entity.vo.HalfData">
SELECT
NAME as name,
HALFLIFE as half
FROM
CONFIGURATION.GARDS_NUCL_LIB
WHERE NAME = #{name}
</select>
</mapper>

View File

@ -13,4 +13,7 @@ public interface IGardsNuclLibService extends IService<GardsNuclLib> {
List<String> allName();
void getNucliLib();
void getNuclideMap();
}

View File

@ -9,6 +9,9 @@ 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.entity.vo.HalfData;
import org.jeecg.modules.entity.vo.NuclideLine;
import org.jeecg.modules.entity.vo.NuclideLines;
import org.jeecg.modules.mapper.GardsNuclLibMapper;
import org.jeecg.modules.service.IGardsNuclLibService;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,8 +19,10 @@ 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.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -52,4 +57,42 @@ public class GardsNuclLibServiceImpl extends ServiceImpl<GardsNuclLibMapper, Gar
Map<String, GardsNuclLib> nuclLibMap = gardsNuclLibs.stream().collect(Collectors.toMap(GardsNuclLib::getName, Function.identity()));
redisUtil.set("nuclLibs", nuclLibMap);
}
@Override
public void getNuclideMap() {
List<String> nuclideLibs = this.baseMapper.findNuclidesAnalysis();
Map<String, NuclideLines> nuclideMap = GetNuclideLines(nuclideLibs);
redisUtil.set("AllNuclideMap", nuclideMap);
}
public Map<String, NuclideLines> GetNuclideLines(List<String> nuclideList) {
Map<String, NuclideLines> mapLines = new HashMap<>();
if (nuclideList.size() < 1) {
return mapLines;
}
for (String name : nuclideList) {
NuclideLines nlines = new NuclideLines();
List<NuclideLine> nuclideLineList = this.baseMapper.getNuclideLines(name);
for (int j = 0; j < nuclideLineList.size(); j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergyUncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYieldUncert());
if (Objects.nonNull(nuclideLineList.get(j).getKeyFlag()) && nuclideLineList.get(j).getKeyFlag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
}
}
mapLines.put(name, nlines);
}
for (String name:nuclideList) {
HalfData half = this.baseMapper.getOneHalf(name);
NuclideLines nuclideLines = mapLines.get(half.getName());
nuclideLines.setHalflife(half.getHalf() == null ? 0 : half.getHalf() * 86400);// 将天转换成秒
mapLines.put(half.getName(), nuclideLines);
}
return mapLines;
}
}