feat:nuclideConcAvg计算
This commit is contained in:
parent
12f2f1e23e
commit
bbe1ba7110
|
@ -19,6 +19,14 @@ public class AlarmAnalysisNuclideAvg extends JeecgEntity {
|
|||
this.val = val;
|
||||
}
|
||||
|
||||
public AlarmAnalysisNuclideAvg(String stationId ,String nuclide, String val) {
|
||||
this.stationId = stationId;
|
||||
this.nuclide = nuclide;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private String stationId;
|
||||
|
||||
/** 核素名称 */
|
||||
private String nuclide;
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND nucl.NUCLIDENAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND nucl.NUCLIDENAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?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.mapper.GardsXeResultsAutoMapper">
|
||||
|
||||
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
|
||||
SELECT
|
||||
xe.NUCLIDE_NAME,
|
||||
|
@ -14,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND xe.NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<where>
|
||||
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND to_date(#{endDate},'yyyy-mm-dd hh24:mi:ss')
|
||||
AND samp.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
|
||||
AND samp.STATION_ID = #{stationId}
|
||||
<if test="nuclideName != null and nuclideName.size() > 0">
|
||||
AND xe.NUCLIDE_NAME IN
|
||||
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
|
||||
|
|
|
@ -53,14 +53,29 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
public boolean calcAndSave() {
|
||||
try {
|
||||
String comma = SymbolConstant.COMMA;
|
||||
// 获取所有生效的报警规则
|
||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||
Set<String> nuclideNames = analysisRules.stream()
|
||||
.map(AlarmAnalysisRule::getNuclides)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||
.collect(Collectors.toSet());
|
||||
// 对所有报警规则的关注台站和关注核素进行统计
|
||||
Map<String, Set<String>> nuclideMap = new HashMap<>(); // key:台站code value:核素列表
|
||||
for (AlarmAnalysisRule analysisRule : analysisRules) {
|
||||
String stationStr = analysisRule.getStations();
|
||||
String nuclideStr = analysisRule.getNuclides();
|
||||
// 获取关注台站
|
||||
List<String> stations = ListUtil.toList(StrUtil.split(stationStr, comma));
|
||||
// 获取关注核素
|
||||
Set<String> nuclides = new HashSet<>(ListUtil.toList(StrUtil.split(nuclideStr, comma)));
|
||||
for (String station : stations) {
|
||||
if (nuclideMap.containsKey(station)){
|
||||
Set<String> partNuclides = new HashSet<>(nuclideMap.get(station));
|
||||
partNuclides.addAll(nuclides);
|
||||
nuclideMap.put(station, partNuclides);
|
||||
}else {
|
||||
nuclideMap.put(station, nuclides);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 核素浓度值查询参数准备
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("nuclideName",nuclideNames);
|
||||
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
||||
BigDecimal index = paramLatest.getIndex();
|
||||
Integer days = paramLatest.getDays();
|
||||
|
@ -71,38 +86,62 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
String endDate = dayAgo.format(formatter);
|
||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||
/* Auto自动处理 */
|
||||
// beta-gamma
|
||||
List<ConcDtoXe> xeConcAuto = xeResultsAutoService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
||||
|
||||
Map<String,String> autoResult = new HashMap<>();
|
||||
autoResult.putAll(calculate(concDto(xeConcAuto), index));
|
||||
autoResult.putAll(calculate(nuclConcAuto, index));
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
||||
// 遍历所有台站 计算每个台站的所有核素浓度均值
|
||||
/* Auto自动处理 */
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = new ArrayList<>();
|
||||
for (Map.Entry<String, Set<String>> entry : nuclideMap.entrySet()) {
|
||||
String station = entry.getKey();
|
||||
Set<String> nuclides = entry.getValue();
|
||||
// 查询指定台站的所有的核素浓度 并计算核素浓度均值
|
||||
params.put("nuclideName", nuclides);
|
||||
params.put("stationId", station);
|
||||
List<ConcDtoXe> xeConcAuto = xeResultsAutoService.getConc(params); // beta-gamma
|
||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params); // gamma
|
||||
Map<String, String> autoResult = new HashMap<>();
|
||||
autoResult.putAll(calculate(concDto(xeConcAuto), index));
|
||||
autoResult.putAll(calculate(nuclConcAuto, index));
|
||||
|
||||
for (String nuclide : nuclides) {
|
||||
String val = autoResult.get(nuclide);
|
||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDARR);
|
||||
autoAvgs.add(analysisNuclideAvg);
|
||||
}
|
||||
}
|
||||
/* Man人工交互 */
|
||||
// beta-gamma
|
||||
List<ConcDtoXe> xeConcMan = xeResultsManService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
||||
Map<String,String> manResult = new HashMap<>();
|
||||
manResult.putAll(calculate(concDto(xeConcMan), index));
|
||||
manResult.putAll(calculate(nuclConcMan, index));
|
||||
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
||||
manAvgs.addAll(autoAvgs);
|
||||
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("nuclideName", nuclides);
|
||||
params.put("stationId", station);
|
||||
List<ConcDtoXe> xeConcMan = xeResultsManService.getConc(params); // beta-gamma
|
||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params); // gamma
|
||||
Map<String,String> manResult = new HashMap<>();
|
||||
manResult.putAll(calculate(concDto(xeConcMan), index));
|
||||
manResult.putAll(calculate(nuclConcMan, index));
|
||||
|
||||
for (String nuclide : nuclides) {
|
||||
String val = manResult.get(nuclide);
|
||||
AlarmAnalysisNuclideAvg analysisNuclideAvg = new AlarmAnalysisNuclideAvg(station, nuclide, val);
|
||||
analysisNuclideAvg.setDataSourceType(CommonConstant.ARMDRRR);
|
||||
manAvgs.add(analysisNuclideAvg);
|
||||
}
|
||||
}
|
||||
// 自动处理和人工交互库的台站核素浓度均值结果合并
|
||||
List<AlarmAnalysisNuclideAvg> allAvgs = new ArrayList<>();
|
||||
allAvgs.addAll(autoAvgs);
|
||||
allAvgs.addAll(manAvgs);
|
||||
|
||||
// 计算周期和计算日期
|
||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
allAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
|
||||
// 记录日志
|
||||
log.info(log(manAvgs));
|
||||
return nuclideAvgService.saveBatch(manAvgs);
|
||||
log.info(log(allAvgs));
|
||||
return nuclideAvgService.saveBatch(allAvgs);
|
||||
}catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
log.error("核素浓度计算过程异常: {}", e.getMessage());
|
||||
|
|
Loading…
Reference in New Issue
Block a user