Commit ffa2b430 authored by caotao's avatar caotao

1.智能分析光伏、风电 按时刻、按小时、按天生成预警规则由原来的写死调整为动态获取。

parent d126b575
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
......@@ -17,4 +18,11 @@ public interface IdxBizFanWarningRuleSetMapper extends BaseMapper<IdxBizFanWarni
List<Map<String,Object>> queryList(int current,int size);
int queryListCount();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按时刻'")
Integer getMaxWaringCycleOfMinutes();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_fan_warning_rule_set WHERE ANALYSIS_TYPE = '按天'")
Integer getMaxWaringCycleOfDay();
}
......@@ -2,6 +2,9 @@ package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import io.swagger.models.auth.In;
import javafx.beans.binding.DoubleExpression;
import org.apache.ibatis.annotations.Select;
/**
* Mapper 接口
......@@ -11,4 +14,10 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
*/
public interface IdxBizPvWarningRuleSetMapper extends BaseMapper<IdxBizPvWarningRuleSet> {
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按时刻'")
Integer getMaxWaringCycleOfMinutes();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按小时'")
Integer getMaxWaringCycleOfHour();
@Select("SELECT MAX(WARNING_CYCLE) FROM idx_biz_pv_warning_rule_set WHERE ANALYSIS_TYPE = '按天'")
Integer getMaxWaringCycleOfDay();
}
......@@ -1475,7 +1475,7 @@ public class CommonServiceImpl {
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("风机---------------------健康指数时间----" + time);
Calendar calendar = Calendar.getInstance();
// Calendar calendar = Calendar.getInstance();
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
......@@ -1730,7 +1730,8 @@ public class CommonServiceImpl {
logger.info("------------------------------------------调用健康指数计算算法结束----------------------------------------");
logger.info("------------------------------------------开始计算预警----------------------------------------");
healthStatusIndicatorService.healthWarningMinute(calendar, time);
// healthStatusIndicatorService.healthWarningMinute(calendar, time);
healthStatusIndicatorService.healthWarningMinute(time);
} catch (Exception e) {
throw new RuntimeException(e);
......@@ -1774,7 +1775,7 @@ public class CommonServiceImpl {
if (!openHealth) {
return;
}
Calendar calendar = Calendar.getInstance();
// Calendar calendar = Calendar.getInstance();
Date time = new Date();
time = DateUtil.offsetMinute(time,-DateUtil.minute(time)%10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
......@@ -2005,7 +2006,8 @@ public class CommonServiceImpl {
} catch (Exception e) {
throw new RuntimeException(e);
}
healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
// healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
healthStatusIndicatorService.healthWarningMinuteGF(time);
}
......
......@@ -155,18 +155,20 @@ public class HealthStatusIndicatorServiceImpl {
// @Scheduled(cron = "0 0 */1 * * ?")
@Async("async")
public void healthWarningMinuteGF(Calendar calendar,Date time ) {
public void healthWarningMinuteGF(Date time ) {
if (!openHealth){
return;
}
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date = DateUtils.dateAddHours(time, -8);
// Date date = DateUtils.dateAddHours(time, -8);
log.info("光伏---------------------预警时间----"+time);
// Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfMinutes();
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10));
LambdaQueryWrapper<PvHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(PvHealthIndexMoment::getHealthLevel,"安全");
wrapper.ge(PvHealthIndexMoment::getTs,date);
......@@ -232,25 +234,25 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexMoment::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_notice_minute","notice");
level ="注意";
num = ""+healthValueNotice;
content = healthValueNotice*10 + "分钟";
}else if (warnNum >= healthValueWarnCount ){
}else if (warnNum == healthValueWarnCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_warn_minute","warn");
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount*10 + "分钟";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_risk_minute","risk");
level ="危险";
num = ""+healthValueRisk;
......@@ -301,7 +303,7 @@ public class HealthStatusIndicatorServiceImpl {
}
}
}
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
......@@ -318,19 +320,22 @@ public class HealthStatusIndicatorServiceImpl {
*
*/
@Scheduled(cron = "0 0 0/1 * * ?")
// @Scheduled(cron = "0 0 0/1 * * ?")
@Scheduled(cron = "0 0/5 * * * ?")
@Async("async")
public void healthWarningHourGF() {
if (!openHealth){
return;
}
// if (!openHealth){
// return;
// }
Date time = new Date();
Date date = DateUtils.dateAddHours(time, -13);
// Date date = DateUtils.dateAddHours(time, -13);
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfHour();
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetHour(date,0-maxWaringCycle);
LambdaQueryWrapper<PvHealthIndexHour> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(PvHealthIndexHour::getHealthLevel,"安全");
......@@ -396,28 +401,27 @@ public class HealthStatusIndicatorServiceImpl {
}
}
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexHour::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
level ="注意";
num = ""+healthValueNotice;
content = healthValueNoticeCount + "小时";
}else if (warnNum >= healthValueWarnCount ){
}else if (warnNum == healthValueWarnCount ){
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount + "小时";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
level ="危险";
num = ""+healthValueRisk;
content = healthValueRiskCount + "小时";
......@@ -467,7 +471,7 @@ public class HealthStatusIndicatorServiceImpl {
}
}
}
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
pvWaringRecordMapper.saveBatchWarningRecords(tdPvWarningRecordList);
......@@ -491,11 +495,13 @@ public class HealthStatusIndicatorServiceImpl {
// Calendar calendar = Calendar.getInstance();
Date time = new Date();
//三天 + 8小时
Date date = DateUtils.dateAddHours(time, -80);
// Date date = DateUtils.dateAddHours(time, -80);
// calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfDay();
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetDay(date,0-maxWaringCycle);
LambdaQueryWrapper<PvHealthIndexDay> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(PvHealthIndexDay::getHealthLevel, "安全");
wrapper.eq(PvHealthIndexDay::getAnalysisObjType, "测点");
......@@ -560,26 +566,26 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexDay::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_notice_day","notice");
level ="注意";
num = ""+healthValueNotice;
content = healthValueNoticeCount + "天";
}else if (warnNum >= healthValueWarnCount ){
}else if (warnNum == healthValueWarnCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_warn_day","warn");
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount + "天";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_risk_day","risk");
level ="危险";
num = ""+healthValueRisk;
......@@ -630,7 +636,7 @@ public class HealthStatusIndicatorServiceImpl {
}
}
}
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
// idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
pvWaringRecordMapper.saveBatchWarningRecords(tdPvWarningRecordList);
......@@ -641,19 +647,22 @@ public class HealthStatusIndicatorServiceImpl {
}
// @Scheduled(cron = "0 0 */1 * * ?")
// @Scheduled(cron = "0 0 */1 * * ?")
@Async("async")
public void healthWarningMinute(Calendar calendar ,Date time) {
public void healthWarningMinute(Date time) {
if (!openHealth){
return;
}
// Calendar calendar = Calendar.getInstance();
log.info("风机---------------------预警时间----"+time);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 用ts字段查询时需要减8小时
Date date = DateUtils.dateAddHours(time, -8);
// Date date = DateUtils.dateAddHours(time, -8);
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfMinutes();
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10));
LambdaQueryWrapper<FanHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(FanHealthIndexMoment::getHealthLevel,"安全");
wrapper.eq(FanHealthIndexMoment::getAnalysisObjType, "测点");
......@@ -725,27 +734,27 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexMoment::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_notice_day","notice");
level ="注意";
num = ""+healthValueNotice;
content = healthValueNoticeCount*10 + "分钟";
}
else if (warnNum >= healthValueWarnCount ){
else if (warnNum == healthValueWarnCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_warn_day","warn");
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount*10 + "分钟";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_risk_day","risk");
level ="危险";
num = ""+healthValueRisk;
......@@ -800,7 +809,7 @@ public class HealthStatusIndicatorServiceImpl {
}
}
}
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// tdengine插入
// fanWarningRecordService.saveBatch(tdFanWarningRecordList);
......@@ -825,11 +834,13 @@ public class HealthStatusIndicatorServiceImpl {
}
Date time = new Date();
String format = DateUtil.format(time, "yyyy-MM-dd HH:00:00");
Date date = DateUtils.dateAddHours(time, -13);
// Date date = DateUtils.dateAddHours(time, -13);
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour();
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetHour(date,0-(maxWaringCycle));
LambdaQueryWrapper<FanHealthIndexHour> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FanHealthIndexHour::getAnalysisObjType, "测点");
wrapper.ne(FanHealthIndexHour::getHealthLevel, "安全");
......@@ -894,28 +905,26 @@ public class HealthStatusIndicatorServiceImpl {
}
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexHour::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
level ="注意";
num = ""+healthValueNotice;
content = healthValueNoticeCount + "小时";
}else if (warnNum >= healthValueWarnCount ){
}else if (warnNum == healthValueWarnCount ){
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount + "小时";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
level ="危险";
num = ""+healthValueRisk;
content = healthValueRiskCount + "小时";
......@@ -964,10 +973,12 @@ public class HealthStatusIndicatorServiceImpl {
}
}
}
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
if(CollUtil.isNotEmpty(tdFanWarningRecordList)) {
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录
fetchDataFan(tdFanWarningRecordList, stationMap);
}
......@@ -987,10 +998,13 @@ public class HealthStatusIndicatorServiceImpl {
Date time = new Date();
String format = DateUtil.format(time, "yyyy-MM-dd 00:00:00");
//三天 + 8小时
Date date = DateUtils.dateAddHours(time, -80);
// Date date = DateUtils.dateAddHours(time, -80);
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour();
Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetDay(date,0-(maxWaringCycle));
LambdaQueryWrapper<FanHealthIndexDay> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(FanHealthIndexDay::getHealthLevel,"安全");
......@@ -1061,26 +1075,26 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexDay::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn;
long warnNum = healthIndex.stream().filter(e -> e <= finalHealthValueWarn).count();
long warnNum = healthIndex.subList(healthIndex.size()>healthValueWarnCount? (int) (healthIndex.size() - healthValueWarnCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueWarn).count();
Double finalHealthValueNotice = healthValueNotice;
long noticeNum = healthIndex.stream().filter(e -> e <= finalHealthValueNotice).count();
long noticeNum = healthIndex.subList(healthIndex.size()>healthValueNoticeCount? (int) (healthIndex.size() - healthValueNoticeCount) :0,healthIndex.size()).stream().filter(e -> e <= finalHealthValueNotice).count();
String level = "";
String content = "";
String num = "";
if (noticeNum >= healthValueNoticeCount ){
if (noticeNum == healthValueNoticeCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_notice_day","notice");
level ="注意";
num = ""+healthValueNotice;
content = healthValueNoticeCount + "天";
}else if (warnNum >= healthValueWarnCount ){
}else if (warnNum == healthValueWarnCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_warn_day","warn");
level ="警告";
num = ""+healthValueWarn;
content = healthValueWarnCount + "天";
}else if (riskNum >= healthValueRiskCount ){
}else if (riskNum == healthValueRiskCount ){
// redisUtils.set(gateWayId+"_"+address+"_health_risk_day","risk");
level ="危险";
num = ""+healthValueRisk;
......@@ -1131,10 +1145,12 @@ public class HealthStatusIndicatorServiceImpl {
}
}
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
if(CollUtil.isNotEmpty(tdFanWarningRecordList)) {
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录
fetchDataFan(tdFanWarningRecordList, stationMap);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment