feat:修改分析结果报警条件逻辑
This commit is contained in:
parent
035e842240
commit
95a150122c
|
@ -1,13 +1,14 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DataTool {
|
||||
|
||||
private int counter = 1;
|
||||
|
||||
private final Map<String, Object> data = new HashMap<>();
|
||||
private final Map<String, Object> data = new LinkedHashMap<>();
|
||||
|
||||
public DataTool put(Object value) {
|
||||
data.put(String.format("p%d", counter), value);
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.base.enums;
|
|||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
|
@ -9,22 +10,19 @@ import cn.hutool.core.util.StrUtil;
|
|||
* @author nieziyan
|
||||
* @date 2023-06-30
|
||||
*/
|
||||
@Getter
|
||||
public enum SourceType {
|
||||
|
||||
EMAIL("Email"),
|
||||
DATABASE("Database"),
|
||||
SERVER("Server");
|
||||
|
||||
private String type;
|
||||
private final String type;
|
||||
|
||||
SourceType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static SourceType typeOf(String type){
|
||||
for (SourceType sourceType : SourceType.values()) {
|
||||
if (StrUtil.equals(sourceType.getType(),type))
|
||||
|
|
|
@ -14,6 +14,4 @@ import java.util.Set;
|
|||
public interface GardsNuclIdedAutoMapper extends BaseMapper<GardsNuclIded> {
|
||||
|
||||
List<ConcDto> getConc(Map<String,Object> param);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,4 @@ import java.util.Set;
|
|||
public interface GardsNuclIdedManMapper extends BaseMapper<GardsNuclIded> {
|
||||
|
||||
List<ConcDto> getConc(Map<String,Object> param);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,4 @@ import java.util.Set;
|
|||
public interface GardsXeResultsAutoMapper extends BaseMapper<GardsXeResults> {
|
||||
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,4 @@ import java.util.Set;
|
|||
public interface GardsXeResultsManMapper extends BaseMapper<GardsXeResults> {
|
||||
|
||||
List<ConcDtoXe> getConc(Map<String,Object> params);
|
||||
|
||||
List<String> nuclideNames(Set<String> nuclideNames);
|
||||
}
|
||||
|
|
|
@ -23,18 +23,4 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="nuclideNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
NUCLIDENAME
|
||||
FROM
|
||||
RNAUTO.GARDS_NUCL_IDED
|
||||
WHERE
|
||||
NUCLIDENAME IN
|
||||
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
|
||||
#{nuclideName}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
NUCLIDENAME
|
||||
</select>
|
||||
</mapper>
|
|
@ -23,18 +23,4 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="nuclideNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
NUCLIDENAME
|
||||
FROM
|
||||
RNMAN.GARDS_NUCL_IDED
|
||||
WHERE
|
||||
NUCLIDENAME IN
|
||||
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
|
||||
#{nuclideName}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
NUCLIDENAME
|
||||
</select>
|
||||
</mapper>
|
|
@ -23,18 +23,4 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="nuclideNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
NUCLIDE_NAME
|
||||
FROM
|
||||
RNAUTO.GARDS_XE_RESULTS
|
||||
WHERE
|
||||
NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
|
||||
#{nuclideName}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
NUCLIDE_NAME
|
||||
</select>
|
||||
</mapper>
|
|
@ -23,18 +23,4 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="nuclideNames" resultType="java.lang.String">
|
||||
SELECT
|
||||
NUCLIDE_NAME
|
||||
FROM
|
||||
RNMAN.GARDS_XE_RESULTS
|
||||
WHERE
|
||||
NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideNames" separator="," item="nuclideName" index="index" open="(" close=")">
|
||||
#{nuclideName}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
NUCLIDE_NAME
|
||||
</select>
|
||||
</mapper>
|
|
@ -156,6 +156,8 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
String betaOrGamma = info.getBetaOrGamma();
|
||||
String datasource = info.getDatasource();
|
||||
String stationId = info.getStationId();
|
||||
String sampleId = info.getSampleId();
|
||||
String sampleName = info.getSampleName();
|
||||
// 获取谱文件采样日期 如果为null 则默认为LocalDate.now()
|
||||
LocalDate collDate = ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() :
|
||||
info.getCollectionDate().toLocalDate();
|
||||
|
@ -163,7 +165,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
List<String> conditions = ListUtil.toList(conditionStr.split(COMMA));
|
||||
List<String> firstDetected = new ArrayList<>(); // 首次发现
|
||||
List<NuclideInfo> moreThanAvg = new ArrayList<>(); // 超浓度均值
|
||||
List<String> meanwhile = new ArrayList<>(); // 同时出现两种及以上核素
|
||||
List<String> meanWhile = new ArrayList<>(); // 同时出现两种及以上核素
|
||||
for (String con : conditions) {
|
||||
Condition condition = Condition.valueOf1(con);
|
||||
if (ObjectUtil.isNull(condition)) continue;
|
||||
|
@ -175,8 +177,8 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
moreThanAvg = moreThanAvg(datasource, stationId, collDate, nuclidesCross);
|
||||
break;
|
||||
case MEANWHILE: // 同时出现两种及以上核素
|
||||
if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2)
|
||||
meanwhile.addAll(nuclideNames);
|
||||
meanWhile = meanWhile(betaOrGamma, datasource, nuclideNames);
|
||||
if (meanWhile.size() < 2) meanWhile = ListUtil.empty();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -192,10 +194,13 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
|
||||
dataTool.put("moreThanAvg", above);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(meanwhile))
|
||||
dataTool.put("meanwhile", CollUtil.join(meanwhile, StrUtil.COMMA + StrUtil.SPACE));
|
||||
if (CollUtil.isNotEmpty(meanWhile))
|
||||
dataTool.put("meanwhile", CollUtil.join(meanWhile, StrUtil.COMMA + StrUtil.SPACE));
|
||||
// 如果报警数据为空 则不需要发送报警信息和生成报警日志
|
||||
if (MapUtil.isEmpty(dataTool.get())) return;
|
||||
// 台站信息和Sample信息
|
||||
dataTool.put("stationId", stationId).put("sampleId", sampleId).put("sampleName", sampleName);
|
||||
// 构建预警信息实例 准备发送预警信息
|
||||
MessageDTO messageDTO = TemplateUtil.parse1(ANALYSIS_NUCLIDE.getCode(), dataTool.get());
|
||||
// 保存报警日志
|
||||
AlarmAnalysisLog logInfo = new AlarmAnalysisLog();
|
||||
|
@ -216,12 +221,12 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
/**
|
||||
* 首次发现该核素
|
||||
*/
|
||||
private List<String> firstDetected(String betaOrGamma,
|
||||
String dataSourceType,
|
||||
Set<String> nuclideNames){
|
||||
private List<String> firstDetected(String betaOrGamma, String dataSourceType, Set<String> nuclideNames){
|
||||
// 查询用户关注的核素是否存在 如果不存在则为首次发现该核素
|
||||
// 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
|
||||
List<String> existNames = analysisResultService
|
||||
.nuclideNames(betaOrGamma, dataSourceType, nuclideNames);
|
||||
// 两个集合元素相减
|
||||
// 两个集合元素相减则为不存在的核素 即为首次出现的核素
|
||||
return CollUtil.subtractToList(nuclideNames, existNames);
|
||||
}
|
||||
|
||||
|
@ -260,6 +265,15 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
return nuclideInfos;
|
||||
}
|
||||
|
||||
/*
|
||||
* 是否同时存在两种及以上核素
|
||||
* */
|
||||
private List<String> meanWhile(String betaOrGamma, String dataSourceType, Set<String> nuclideNames){
|
||||
// 查询用户关注的核素是否存在 如果不存在则为首次发现该核素
|
||||
// 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
|
||||
return analysisResultService.nuclideNames(betaOrGamma, dataSourceType, nuclideNames);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// start 生成临时Token到线程中
|
||||
UserTokenContext.setToken(getTempToken());
|
||||
|
|
|
@ -33,7 +33,7 @@ public class AnalysisResultServiceImpl implements AnalysisResultService {
|
|||
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
|
||||
return nuclIdedAutoService.nuclideNames(nuclideNames);
|
||||
}else {
|
||||
return ListUtil.toList(nuclideNames);
|
||||
return ListUtil.empty();
|
||||
}
|
||||
} else if (CommonConstant.ARMDRRR.equals(dataSourceType)) {
|
||||
if (CommonConstant.BETA.equals(betaOrGamma)){
|
||||
|
@ -41,10 +41,10 @@ public class AnalysisResultServiceImpl implements AnalysisResultService {
|
|||
}else if (CommonConstant.GAMMA.equals(betaOrGamma)){
|
||||
return nuclIdedManService.nuclideNames(nuclideNames);
|
||||
}else {
|
||||
return ListUtil.toList(nuclideNames);
|
||||
return ListUtil.empty();
|
||||
}
|
||||
}else {
|
||||
return ListUtil.toList(nuclideNames);
|
||||
return ListUtil.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
|
@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
@ -31,6 +34,16 @@ public class GardsNuclIdedAutoServiceImpl extends ServiceImpl<GardsNuclIdedAutoM
|
|||
|
||||
@Override
|
||||
public List<String> nuclideNames(Set<String> nuclideNames) {
|
||||
return baseMapper.nuclideNames(nuclideNames);
|
||||
LambdaQueryWrapper<GardsNuclIded> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(GardsNuclIded::getNuclideName, nuclideNames);
|
||||
List<GardsNuclIded> nuclIdeds = this.list(wrapper);
|
||||
// 判断核素是否存在的条件: 该核素Conc值是否大于MDC值
|
||||
Set<String> existNuclides = nuclIdeds.stream()
|
||||
.filter(item -> NumberUtil.isNumber(item.getConcentration()))
|
||||
.filter(item -> NumberUtil.isNumber(item.getMdc()))
|
||||
.filter(item ->NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc())))
|
||||
.map(GardsNuclIded::getNuclideName)
|
||||
.collect(Collectors.toSet());
|
||||
return ListUtil.toList(existNuclides);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.modules.base.dto.ConcDto;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsNuclIded;
|
||||
import org.jeecg.modules.mapper.GardsNuclIdedManMapper;
|
||||
import org.jeecg.modules.service.IGardsNuclIdedManService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
@ -29,6 +31,16 @@ public class GardsNuclIdedManServiceImpl extends ServiceImpl<GardsNuclIdedManMap
|
|||
|
||||
@Override
|
||||
public List<String> nuclideNames(Set<String> nuclideNames) {
|
||||
return baseMapper.nuclideNames(nuclideNames);
|
||||
LambdaQueryWrapper<GardsNuclIded> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(GardsNuclIded::getNuclideName, nuclideNames);
|
||||
List<GardsNuclIded> nuclIdeds = this.list(wrapper);
|
||||
// 判断核素是否存在的条件: 该核素Conc值是否大于MDC值
|
||||
Set<String> existNuclides = nuclIdeds.stream()
|
||||
.filter(item -> NumberUtil.isNumber(item.getConcentration()))
|
||||
.filter(item -> NumberUtil.isNumber(item.getMdc()))
|
||||
.filter(item ->NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc())))
|
||||
.map(GardsNuclIded::getNuclideName)
|
||||
.collect(Collectors.toSet());
|
||||
return ListUtil.toList(existNuclides);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
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;
|
||||
|
@ -52,6 +53,15 @@ public class GardsXeResultsAutoServiceImpl extends ServiceImpl<GardsXeResultsAut
|
|||
|
||||
@Override
|
||||
public List<String> nuclideNames(Set<String> nuclideNames) {
|
||||
return baseMapper.nuclideNames(nuclideNames);
|
||||
LambdaQueryWrapper<GardsXeResults> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(GardsXeResults::getNuclideName, nuclideNames);
|
||||
List<GardsXeResults> xeResults = this.list(wrapper);
|
||||
// 判断核素是否存在的条件: 该核素NidFlag值是否为1
|
||||
Set<String> existNuclides = xeResults.stream()
|
||||
.filter(item -> ObjectUtil.isNotNull(item.getNidFlag()))
|
||||
.filter(item -> item.getNidFlag() == 1)
|
||||
.map(GardsXeResults::getNuclideName)
|
||||
.collect(Collectors.toSet());
|
||||
return ListUtil.toList(existNuclides);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
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;
|
||||
|
@ -52,6 +53,15 @@ public class GardsXeResultsManServiceImpl extends ServiceImpl<GardsXeResultsManM
|
|||
|
||||
@Override
|
||||
public List<String> nuclideNames(Set<String> nuclideNames) {
|
||||
return baseMapper.nuclideNames(nuclideNames);
|
||||
LambdaQueryWrapper<GardsXeResults> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(GardsXeResults::getNuclideName, nuclideNames);
|
||||
List<GardsXeResults> xeResults = this.list(wrapper);
|
||||
// 判断核素是否存在的条件: 该核素NidFlag值是否为1
|
||||
Set<String> existNuclides = xeResults.stream()
|
||||
.filter(item -> ObjectUtil.isNotNull(item.getNidFlag()))
|
||||
.filter(item -> item.getNidFlag() == 1)
|
||||
.map(GardsXeResults::getNuclideName)
|
||||
.collect(Collectors.toSet());
|
||||
return ListUtil.toList(existNuclides);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user