fix: 核素分析规则 解决识别多个核素报错问题

This commit is contained in:
xiaoguangbin 2025-01-13 16:04:26 +08:00
parent 3761c0deba
commit 14c1ee3468
2 changed files with 9 additions and 6 deletions

View File

@ -132,14 +132,12 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
Set<String> names = nuclides.keySet(); Set<String> names = nuclides.keySet();
List<String> follow = ListUtil.toList(nuclidesStr.split(COMMA)); List<String> follow = ListUtil.toList(nuclidesStr.split(COMMA));
// 因数据库 Xe核素名称 M大小写不统一先统一大小写再进行比较 // 因数据库 Xe核素名称 M大小写不统一先统一大小写再进行比较
Collection<String> followLower = follow.stream().map(String::toLowerCase).collect(Collectors.toList()); Collection<String> follows = follow.stream().map(f->f.replace("M", "m")).collect(Collectors.toList());
Collection<String> namesLower = names.stream().map(String::toLowerCase).collect(Collectors.toList());
// 推送过来的核素集合与所关注核素集合取交集 // 推送过来的核素集合与所关注核素集合取交集
Collection<String> cross = CollectionUtil.intersection(namesLower, followLower); Collection<String> cross = CollectionUtil.intersection(names, follows);
Collection<String> crossNew = cross.stream().map(f->f.replace("x", "X")).collect(Collectors.toList());
if (CollUtil.isEmpty(cross)) continue; if (CollUtil.isEmpty(cross)) continue;
Map<String, String> nuclidesCross = nuclides.entrySet().stream() Map<String, String> nuclidesCross = nuclides.entrySet().stream()
.filter(entry -> crossNew.contains(entry.getKey())) .filter(entry -> cross.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// 开始对交集中的核素进行条件判断 // 开始对交集中的核素进行条件判断
info.setRuleId(rule.getId()); info.setRuleId(rule.getId());
@ -221,6 +219,8 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
if (ObjectUtil.isNotNull(sampleType)) if (ObjectUtil.isNotNull(sampleType))
logInfo.setSampleType(sampleType.getValue()); logInfo.setSampleType(sampleType.getValue());
logInfo.setAlarmInfo(messageDTO.getContent()); logInfo.setAlarmInfo(messageDTO.getContent());
if (CollUtil.isNotEmpty(moreThanAvg))
logInfo.setNuclideInfoList(moreThanAvg);
if (CollUtil.isNotEmpty(moreThanAvg)) if (CollUtil.isNotEmpty(moreThanAvg))
logInfo.setNuclideInfoList(moreThanAvg); logInfo.setNuclideInfoList(moreThanAvg);
logService.saveLog(logInfo); logService.saveLog(logInfo);
@ -239,6 +239,9 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/ */
String detectorId = systemClient.getDetectorId(sampleId); String detectorId = systemClient.getDetectorId(sampleId);
if (StrUtil.isBlank(detectorId)) {
throw new RuntimeException("detectorId is null or empty");
}
return analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId, return analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId,
detectorId, sampleId, nuclideNames); detectorId, sampleId, nuclideNames);
} }

View File

@ -155,7 +155,7 @@ public class AlarmAnalysisRuleServiceImpl extends ServiceImpl<AlarmAnalysisRuleM
String original = getById(id).getName(); String original = getById(id).getName();
if (null != alarmAnalysisRule.getIdentifyNuclides() && !alarmAnalysisRule.getConditions().contains("4")) { if (null != alarmAnalysisRule.getIdentifyNuclides() && !alarmAnalysisRule.getConditions().contains("4")) {
alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions() + ",4"); alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions() + ",4");
} else if(null == alarmAnalysisRule.getIdentifyNuclides() && !alarmAnalysisRule.getConditions().contains("4")) { } else if(null == alarmAnalysisRule.getIdentifyNuclides() && alarmAnalysisRule.getConditions().contains("4")) {
alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions().replace("4", "")); alarmAnalysisRule.setConditions(alarmAnalysisRule.getConditions().replace("4", ""));
} }
if (!StrUtil.equalsIgnoreCase(name,original)){ if (!StrUtil.equalsIgnoreCase(name,original)){