feat:核素浓度均值台站类型过滤
This commit is contained in:
parent
6e54bce336
commit
6ac9576cb1
|
@ -9,4 +9,8 @@ public interface DictConstant {
|
||||||
String ANALYSE_SOURCE = "alarm_analyse_rule_source";
|
String ANALYSE_SOURCE = "alarm_analyse_rule_source";
|
||||||
|
|
||||||
String DATASOURCE_TYPE = "database_type";
|
String DATASOURCE_TYPE = "database_type";
|
||||||
|
|
||||||
|
String NOBLE_GAS_BETAGAMMA = "Noble Gas Beta-Gamma";
|
||||||
|
|
||||||
|
String NOBLE_GAS_HPGE = "Noble Gas HPGe";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jeecg.modules.base.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public enum StationType {
|
||||||
|
BETA, GAMMA, NULL
|
||||||
|
}
|
|
@ -2,16 +2,25 @@ package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.jeecg.common.constant.DateConstant;
|
import org.jeecg.common.constant.DateConstant;
|
||||||
|
import org.jeecg.common.constant.DictConstant;
|
||||||
import org.jeecg.common.constant.SymbolConstant;
|
import org.jeecg.common.constant.SymbolConstant;
|
||||||
|
import org.jeecg.common.system.vo.DictModel;
|
||||||
|
import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.modules.base.dto.ConcDto;
|
import org.jeecg.modules.base.dto.ConcDto;
|
||||||
import org.jeecg.modules.base.dto.ConcDtoXe;
|
import org.jeecg.modules.base.dto.ConcDtoXe;
|
||||||
|
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
|
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideParam;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
|
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
|
||||||
|
import org.jeecg.modules.base.enums.StationType;
|
||||||
|
import org.jeecg.modules.feignclient.SystemClient;
|
||||||
import org.jeecg.modules.service.*;
|
import org.jeecg.modules.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -24,6 +33,8 @@ import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CalculateConcServiceImpl implements CalculateConcService {
|
public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
|
@ -49,6 +60,16 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemClient systemClient;
|
||||||
|
|
||||||
|
private List<String> beta;
|
||||||
|
|
||||||
|
private Map<String, GardsStations> stations;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calcAndSave() {
|
public void calcAndSave() {
|
||||||
try {
|
try {
|
||||||
|
@ -87,42 +108,54 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||||
|
|
||||||
|
List<AlarmAnalysisNuclideAvg> autoAvgs = new ArrayList<>(); // Auto
|
||||||
|
List<AlarmAnalysisNuclideAvg> manAvgs = new ArrayList<>(); // Man
|
||||||
// 遍历所有台站 计算每个台站的所有核素浓度均值
|
// 遍历所有台站 计算每个台站的所有核素浓度均值
|
||||||
/* Auto自动处理 */
|
init();
|
||||||
List<AlarmAnalysisNuclideAvg> autoAvgs = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, Set<String>> entry : nuclideMap.entrySet()) {
|
for (Map.Entry<String, Set<String>> entry : nuclideMap.entrySet()) {
|
||||||
String station = entry.getKey();
|
String station = entry.getKey();
|
||||||
Set<String> nuclides = entry.getValue();
|
Set<String> nuclides = entry.getValue();
|
||||||
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
|
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
|
||||||
params.put("stationId", station);
|
params.put("stationId", station);
|
||||||
List<ConcDtoXe> xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma
|
StationType stationType = stationType(station);
|
||||||
|
List<ConcDtoXe> xeConcAuto = new ArrayList<>();
|
||||||
|
List<ConcDtoXe> xeConcMan = new ArrayList<>();
|
||||||
|
List<ConcDto> nuclConcAuto = new ArrayList<>();
|
||||||
|
List<ConcDto> nuclConcMan = new ArrayList<>();
|
||||||
|
switch (stationType){
|
||||||
|
case BETA:
|
||||||
|
xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma Auto
|
||||||
|
xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma Man
|
||||||
|
break;
|
||||||
|
case GAMMA:
|
||||||
params.put("nuclideName", nuclides);
|
params.put("nuclideName", nuclides);
|
||||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma
|
nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma Auto
|
||||||
|
nuclConcMan = nuclIdedManService.getConc(params); // gamma Man
|
||||||
|
break;
|
||||||
|
case NULL:
|
||||||
|
xeConcAuto = xeResultsAutoService.getConc(params, nuclides); // beta-gamma Auto
|
||||||
|
xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma Man
|
||||||
|
params.put("nuclideName", nuclides);
|
||||||
|
nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma Auto
|
||||||
|
nuclConcMan = nuclIdedManService.getConc(params); // gamma Man
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Auto
|
||||||
Map<String, String> autoResult = new HashMap<>();
|
Map<String, String> autoResult = new HashMap<>();
|
||||||
autoResult.putAll(calculate(concDto(xeConcAuto), index));
|
autoResult.putAll(calculate(concDto(xeConcAuto), index));
|
||||||
autoResult.putAll(calculate(nuclConcAuto, index));
|
autoResult.putAll(calculate(nuclConcAuto, index));
|
||||||
|
|
||||||
for (String nuclide : nuclides) {
|
for (String nuclide : nuclides) {
|
||||||
String val = autoResult.get(nuclide);
|
String val = autoResult.get(nuclide);
|
||||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||||
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDARR);
|
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDARR);
|
||||||
autoAvgs.add(analysisNuclideAvg);
|
autoAvgs.add(analysisNuclideAvg);
|
||||||
}
|
}
|
||||||
}
|
// Man
|
||||||
/* Man人工交互 */
|
|
||||||
List<AlarmAnalysisNuclideAvg> manAvgs = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, Set<String>> entry : nuclideMap.entrySet()) {
|
|
||||||
String station = entry.getKey();
|
|
||||||
Set<String> nuclides = entry.getValue();
|
|
||||||
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
|
|
||||||
params.put("stationId", station);
|
|
||||||
List<ConcDtoXe> xeConcMan = xeResultsManService.getConc(params, nuclides); // beta-gamma
|
|
||||||
params.put("nuclideName", nuclides);
|
|
||||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params); // gamma
|
|
||||||
Map<String,String> manResult = new HashMap<>();
|
Map<String,String> manResult = new HashMap<>();
|
||||||
manResult.putAll(calculate(concDto(xeConcMan), index));
|
manResult.putAll(calculate(concDto(xeConcMan), index));
|
||||||
manResult.putAll(calculate(nuclConcMan, index));
|
manResult.putAll(calculate(nuclConcMan, index));
|
||||||
|
|
||||||
for (String nuclide : nuclides) {
|
for (String nuclide : nuclides) {
|
||||||
String val = manResult.get(nuclide);
|
String val = manResult.get(nuclide);
|
||||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||||
|
@ -149,6 +182,7 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index) {
|
public Map<String, String> calculate(List<ConcDto> concDtos, BigDecimal index) {
|
||||||
Map<String, String> result = new HashMap<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(concDtos)) return result;
|
||||||
// 按照核素名进行分组
|
// 按照核素名进行分组
|
||||||
Map<String, List<ConcDto>> concDtoMap = concDtos.stream()
|
Map<String, List<ConcDto>> concDtoMap = concDtos.stream()
|
||||||
.collect(Collectors.groupingBy(ConcDto::getNuclideName));
|
.collect(Collectors.groupingBy(ConcDto::getNuclideName));
|
||||||
|
@ -186,4 +220,32 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
String nuclide = CollUtil.join(nuclideNames, ",");
|
String nuclide = CollUtil.join(nuclideNames, ",");
|
||||||
return "核素 [" + nuclide + "] 进行了浓度均值计算";
|
return "核素 [" + nuclide + "] 进行了浓度均值计算";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init(){
|
||||||
|
try {
|
||||||
|
stations = (Map<String, GardsStations>) redisUtil.get("stationInfoMap");
|
||||||
|
UserTokenContext.setToken(getTempToken());
|
||||||
|
// 获取Beta台站类型字典
|
||||||
|
beta = systemClient.getItems(DictConstant.NOBLE_GAS_BETAGAMMA).stream()
|
||||||
|
.map(DictModel::getValue).collect(Collectors.toList());
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("核素浓度均值计算时, 获取台站类型字典异常: {}", e.getMessage());
|
||||||
|
}finally {
|
||||||
|
UserTokenContext.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private StationType stationType(String stationId){
|
||||||
|
if (MapUtil.isEmpty(stations))
|
||||||
|
return StationType.NULL;
|
||||||
|
GardsStations station = stations.get(stationId);
|
||||||
|
if (ObjectUtil.isNull(station) || StrUtil.isBlank(station.getType()))
|
||||||
|
return StationType.NULL;
|
||||||
|
if (CollUtil.isEmpty(beta))
|
||||||
|
return StationType.NULL;
|
||||||
|
String stationType = station.getType();
|
||||||
|
if (CollUtil.contains(beta, stationType))
|
||||||
|
return StationType.BETA;
|
||||||
|
return StationType.GAMMA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user