fix: 核素分析规则 增加核素识别报警,求平均值的周期和系数都整合到规则中

This commit is contained in:
xiaoguangbin 2025-01-13 10:23:11 +08:00
parent 635545cb86
commit 3761c0deba
7 changed files with 193 additions and 131 deletions

View File

@ -88,6 +88,7 @@ public class AlarmAnalysisRule extends JeecgEntity {
private Integer days; private Integer days;
@TableField(value = "identify_nuclides", updateStrategy = FieldStrategy.IGNORED)
private String identifyNuclides; private String identifyNuclides;
/** 备注 */ /** 备注 */
private String remark; private String remark;

View File

@ -15,6 +15,7 @@ public class NucliedAvgJob implements Job{
@Override @Override
@Scheduled(cron = "${task.period-avg:0 2 0 * * ?}") @Scheduled(cron = "${task.period-avg:0 2 0 * * ?}")
// @Scheduled(cron = "${task.period-avg:0/59 0/1 * * * ? }")
public void execute() { public void execute() {
calculateConcService.calcAndSave(); calculateConcService.calcAndSave();
} }

View File

@ -12,7 +12,7 @@
INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = nucl.IDANALYSIS INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = nucl.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = nucl.SAMPLE_ID INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = nucl.SAMPLE_ID
INNER JOIN RNAUTO.GARDS_QC_CHECK qc ON samp.SAMPLE_ID = qc.SAMPLE_ID INNER JOIN RNAUTO.GARDS_QC_CHECK qc ON samp.SAMPLE_ID = qc.SAMPLE_ID
<where> <trim prefix="where" suffixOverrides="or">
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss') ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
AND to_date(#{endDate},'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.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
@ -24,31 +24,37 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="colTime != null and colTime.size() > 0"> <if test="(colTime != null and colTime.size() > 0) || (acqTime != null and acqTime.size() > 0) ||
AND (qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) airFlow != null || decayTime != null || sampVol != null || be7FWHM != null || ba140MDC != null || xe133MDC != null">
<trim prefix="and(" suffixOverrides="or" suffix=")">
<if test="colTime != null and colTime.size() > 0">
(qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) or
</if>
<if test="acqTime != null and acqTime.size() > 0">
(qc.qc_name = 'acq_time' and qc.qc_value = #{acqTime[0]}) or
</if>
<if test="airFlow != null">
(qc.qc_name = 'airFlow' and qc.qc_value &lt; #{airFlow} ) or
</if>
<if test="decayTime != null">
(qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} ) or
</if>
<if test="sampVol != null">
(qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} ) or
</if>
<if test="be7FWHM != null">
(qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} ) or
</if>
<if test="ba140MDC != null">
(qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} ) or
</if>
<if test="xe133MDC != null">
(qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} ) or
</if>
</trim>
</if> </if>
<if test="acqTime != null and acqTime.size() > 0">
AND (qc.qc_name = 'acq_time' and qc.qc_value between #{acqTime[0]} and #{acqTime[1]} ) </trim>
</if>
<if test="airFlow != null">
AND (qc.qc_name = 'air_flow' and qc.qc_value &lt; #{airFlow} )
</if>
<if test="decayTime != nul">
AND (qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} )
</if>
<if test="sampVol != null">
AND (qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} )
</if>
<if test="be7FWHM != null">
AND (qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} )
</if>
<if test="ba140MDC != null">
AND (qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} )
</if>
<if test="xe133MDC != null">
AND (qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} )
</if>
</where>
</select> </select>
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl"> <select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT SELECT

View File

@ -24,29 +24,34 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="colTime != null and colTime.size() > 0"> <if test="(colTime != null and colTime.size() > 0) || (acqTime != null and acqTime.size() > 0) ||
AND (qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) airFlow != null || decayTime != null || sampVol != null || be7FWHM != null || ba140MDC != null || xe133MDC != null">
</if> <trim prefix="and(" suffixOverrides="or" suffix=")">
<if test="acqTime != null and acqTime.size() > 0"> <if test="colTime != null and colTime.size() > 0">
AND (qc.qc_name = 'acq_time' and qc.qc_value between #{acqTime[0]} and #{acqTime[1]} ) (qc.qc_name = 'col_time' and qc.qc_value between #{colTime[0]} and #{colTime[1]} ) or
</if> </if>
<if test="airFlow != null"> <if test="acqTime != null and acqTime.size() > 0">
AND (qc.qc_name = 'air_flow' and qc.qc_value &lt; #{airFlow} ) (qc.qc_name = 'acq_time' and qc.qc_value = #{acqTime[0]}) or
</if> </if>
<if test="decayTime != nul"> <if test="airFlow != null">
AND (qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} ) (qc.qc_name = 'airFlow' and qc.qc_value &lt; #{airFlow} ) or
</if> </if>
<if test="sampVol != null"> <if test="decayTime != null">
AND (qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} ) (qc.qc_name = 'decay_time' and qc.qc_value &lt; #{decayTime} ) or
</if> </if>
<if test="be7FWHM != null"> <if test="sampVol != null">
AND (qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} ) (qc.qc_name = 'samp_vol' and qc.qc_value &lt; #{sampVol} ) or
</if> </if>
<if test="ba140MDC != null"> <if test="be7FWHM != null">
AND (qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} ) (qc.qc_name = 'Be7-FWHM' and qc.qc_value &lt; #{be7FWHM} ) or
</if> </if>
<if test="xe133MDC != null"> <if test="ba140MDC != null">
AND (qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} ) (qc.qc_name = 'Ba140-MDC' and qc.qc_value &lt; #{ba140MDC} ) or
</if>
<if test="xe133MDC != null">
(qc.qc_name = 'Xe133-MDC' and qc.qc_value &lt; #{xe133MDC} ) or
</if>
</trim>
</if> </if>
</where> </where>
</select> </select>

View File

@ -2,53 +2,78 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <mapper namespace="org.jeecg.modules.mapper.GardsXeResultsAutoMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe"> <select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT SELECT * FROM (
DISTINCT samp.SAMPLE_ID, SELECT
samp.SAMPLE_ID,
xe.NUCLIDE_NAME, xe.NUCLIDE_NAME,
xe.CONC, xe.CONC,
ana.ANALYSISBEGIN ana.ANALYSISBEGIN,
FROM xe.NID_FLAG
FROM
RNAUTO.GARDS_XE_RESULTS xe RNAUTO.GARDS_XE_RESULTS xe
INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS INNER JOIN RNAUTO.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID
<where> <where>
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss') ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
AND to_date(#{endDate},'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.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
AND samp.STATION_ID = #{stationId} AND samp.STATION_ID = #{stationId}
AND samp.SPECTRAL_QUALIFIE = 'FULL' AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0"> <if test="nuclideName != null and nuclideName.size() > 0">
AND xe.NUCLIDE_NAME IN AND xe.NUCLIDE_NAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=","> <foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="colTime != null and colTime.size() > 0"> <if test="colTime != null and colTime.size() > 0">
and ((TO_NUMBER(samp.COLLECT_STOP - samp.COLLECT_START) * 24) between #{colTime[0]} and #{colTime[1]} ) and ((TO_NUMBER(samp.COLLECT_STOP - samp.COLLECT_START) * 24) between #{colTime[0]} and #{colTime[1]} )
</if> </if>
<if test="acqTime != null and acqTime.size() > 0"> <if test="acqTime != null and acqTime.size() > 0">
and (samp.ACQUISITION_LIVE_SEC / 3600 between #{colTime[0]} and #{colTime[1]} ) and (samp.ACQUISITION_LIVE_SEC / 3600 between #{colTime[0]} and #{colTime[1]} )
</if> </if>
<if test="XeVol != null"> <if test="XeVol != null">
AND (aux.XE_VOLUME &gt; #{XeVol} ) AND (aux.XE_VOLUME &gt; #{XeVol} )
</if> </if>
<if test="Xe133MDC != null and Xe133MDC.size() > 0"> <if test="Xe133MDC != null and Xe133MDC.size() > 0">
AND (xe.NUCLIDE_NAME = 'Xe133m' AND MDC between #{Xe133MDC[0]} AND #{Xe133MDC[1]} ) AND (xe.NUCLIDE_NAME = 'Xe133m' AND MDC between #{Xe133MDC[0]} AND #{Xe133MDC[1]} )
</if> </if>
<if test="Xe133mFlag != null"> </where>
AND (xe.NUCLIDE_NAME = 'Xe133m' AND xe.NID_FLAG = 1 ) ) a
</if> <trim prefix="where" suffixOverrides="or">
<if test="Xe133Flag != null"> <choose>
AND (xe.NUCLIDE_NAME = 'Xe133' AND xe.NID_FLAG = 1 ) <when test="Xe133mFlag != null">
</if> (a.NUCLIDE_NAME = 'Xe133m' AND a.NID_FLAG = 1 ) or
<if test="Xe131mFlag != null"> </when>
AND (xe.NUCLIDE_NAME = 'Xe131m' AND xe.NID_FLAG = 1 ) <otherwise>
</if> (a.NUCLIDE_NAME = 'Xe133m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
<if test="Xe135Flag != null "> </otherwise>
AND (xe.NUCLIDE_NAME = 'Xe135' AND xe.NID_FLAG = 1 ) </choose>
</if> <choose>
</where> <when test="Xe133Flag != null">
(a.NUCLIDE_NAME = 'Xe133' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe131mFlag != null">
(a.NUCLIDE_NAME = 'Xe131m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe131m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe135Flag != null">
(a.NUCLIDE_NAME = 'Xe135' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe135' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
</trim>
</select> </select>
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl"> <select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT SELECT

View File

@ -2,41 +2,66 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsXeResultsManMapper"> <mapper namespace="org.jeecg.modules.mapper.GardsXeResultsManMapper">
<select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe"> <select id="getConc" resultType="org.jeecg.modules.base.dto.ConcDtoXe">
SELECT SELECT * FROM (
DISTINCT samp.SAMPLE_ID, SELECT
samp.SAMPLE_ID,
xe.NUCLIDE_NAME, xe.NUCLIDE_NAME,
xe.CONC, xe.CONC,
ana.ANALYSISBEGIN ana.ANALYSISBEGIN,
FROM xe.NID_FLAG
FROM
RNMAN.GARDS_XE_RESULTS xe RNMAN.GARDS_XE_RESULTS xe
INNER JOIN RNMAN.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS INNER JOIN RNMAN.GARDS_ANALYSES ana ON ana.IDANALYSIS = xe.IDANALYSIS
INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID INNER JOIN ORIGINAL.GARDS_SAMPLE_DATA samp ON samp.SAMPLE_ID = xe.SAMPLE_ID
INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID INNER JOIN ORIGINAL.GARDS_SAMPLE_AUX aux ON samp.SAMPLE_ID = aux.SAMPLE_ID
<where> <where>
ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss') ana.ANALYSISBEGIN BETWEEN to_date(#{startDate},'yyyy-mm-dd hh24:mi:ss')
AND to_date(#{endDate},'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.DATA_TYPE = 'S' AND samp.STATUS IN ('P', 'R')
AND samp.STATION_ID = #{stationId} AND samp.STATION_ID = #{stationId}
AND samp.SPECTRAL_QUALIFIE = 'FULL' AND samp.SPECTRAL_QUALIFIE = 'FULL'
<if test="nuclideName != null and nuclideName.size() > 0"> <if test="nuclideName != null and nuclideName.size() > 0">
AND xe.NUCLIDE_NAME IN AND xe.NUCLIDE_NAME IN
<foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=","> <foreach collection="nuclideName" open="(" close=")" index="index" item="item" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="colTime != null and colTime.size() > 0"> </where>
and ((TO_NUMBER(samp.COLLECT_STOP - samp.COLLECT_START) * 24) between #{colTime[0]} and #{colTime[1]} ) )a
</if> <trim prefix="where" suffixOverrides="or">
<if test="acqTime != null and acqTime.size() > 0"> <choose>
and (samp.ACQUISITION_LIVE_SEC / 3600 between #{colTime[0]} and #{colTime[1]} ) <when test="Xe133mFlag != null">
</if> (a.NUCLIDE_NAME = 'Xe133m' AND a.NID_FLAG = 1 ) or
<if test="XeVol != null"> </when>
AND (aux.XE_VOLUME &gt; #{XeVol} ) <otherwise>
</if> (a.NUCLIDE_NAME = 'Xe133m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
<if test="Xe133MDC != null and Xe133MDC.size() > 0"> </otherwise>
AND (xe.NUCLIDE_NAME = 'Xe133m' AND MDC between #{Xe133MDC[0]} AND #{Xe133MDC[1]} ) </choose>
</if> <choose>
</where> <when test="Xe133Flag != null">
(a.NUCLIDE_NAME = 'Xe133' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe133' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe131mFlag != null">
(a.NUCLIDE_NAME = 'Xe131m' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe131m' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
<choose>
<when test="Xe135Flag != null">
(a.NUCLIDE_NAME = 'Xe135' AND a.NID_FLAG = 1 ) or
</when>
<otherwise>
(a.NUCLIDE_NAME = 'Xe135' AND (a.NID_FLAG = 1 AND a.NID_FLAG = 0) ) or
</otherwise>
</choose>
</trim>
</select> </select>
<select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl"> <select id="sampNucl" resultType="org.jeecg.modules.base.dto.SampNucl">
SELECT SELECT

View File

@ -92,7 +92,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
redisStreamUtil.del(streamKey, recordId.getValue()); redisStreamUtil.del(streamKey, recordId.getValue());
} }
}catch (Exception e){ }catch (Exception e){
log.error("AnalysisConsumer消费异常: {}", e.getMessage()); log.error("AnalysisConsumer消费异常: ", e);
}finally { }finally {
destroy(); destroy();
} }
@ -145,9 +145,11 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
info.setRuleId(rule.getId()); info.setRuleId(rule.getId());
info.setGroupId(rule.getContactGroup()); info.setGroupId(rule.getContactGroup());
info.setConditions(rule.getConditions()); info.setConditions(rule.getConditions());
String[] inSplit = rule.getIdentifyNuclides().split(","); if (null != rule.getIdentifyNuclides()) {
if (inSplit.length > 1) { String[] inSplit = rule.getIdentifyNuclides().split(",");
info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f->f.replace("M", "m")).collect(Collectors.toSet())); if (inSplit.length >= 1) {
info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f->f.replace("M", "m")).collect(Collectors.toSet()));
}
} }
judge(info, nuclidesCross); judge(info, nuclidesCross);
} }
@ -182,9 +184,6 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross); moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross);
break; break;
case MEANWHILE: // 同时出现两种及以上核素 case MEANWHILE: // 同时出现两种及以上核素
for (String nuclideName : nuclideNames) {
nuclideNames.add(nuclideName.replace("m","M"));
}
meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclideNames); meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclideNames);
if (meanWhile.size() < 2) meanWhile = ListUtil.empty(); if (meanWhile.size() < 2) meanWhile = ListUtil.empty();
break; break;