Commit 64b87016 authored by wujiang's avatar wujiang

修改分析告警不准确

parent 57fd373a
...@@ -149,6 +149,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -149,6 +149,9 @@ public class HealthStatusIndicatorServiceImpl {
@Autowired @Autowired
private PvWaringRecordMapper pvWaringRecordMapper; private PvWaringRecordMapper pvWaringRecordMapper;
@Value("${analyse.cycle.offset:1}")
private Integer AnalyseOffset;
/*** /***
* 每一小时获取一次最大粒度内的指数异常数据 * 每一小时获取一次最大粒度内的指数异常数据
...@@ -169,7 +172,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -169,7 +172,7 @@ public class HealthStatusIndicatorServiceImpl {
// 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"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfMinutes(); Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfMinutes()+AnalyseOffset;
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10)); date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10));
LambdaQueryWrapper<PvHealthIndexMoment> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PvHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
...@@ -252,7 +255,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -252,7 +255,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
Double finalHealthValueNotice = healthValueNotice; Double finalHealthValueNotice = healthValueNotice;
if(healthIndex.size()>=healthValueNoticeCount){ if(healthIndex.size()>=healthValueNoticeCount){
List<Double> healthIndexList = healthIndex.subList(healthIndex.size()-healthValueWarnCount,healthIndex.size()); List<Double> healthIndexList = healthIndex.subList(healthIndex.size()-healthValueNoticeCount,healthIndex.size());
noticeNum = (int) healthIndexList.stream().filter(e -> e <= finalHealthValueNotice).count(); noticeNum = (int) healthIndexList.stream().filter(e -> e <= finalHealthValueNotice).count();
} }
String level = ""; String level = "";
...@@ -534,7 +537,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -534,7 +537,7 @@ public class HealthStatusIndicatorServiceImpl {
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5); // calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfHour(); Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfHour()+AnalyseOffset;
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetHour(date,0-maxWaringCycle); date =DateUtil.offsetHour(date,0-maxWaringCycle);
...@@ -722,7 +725,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -722,7 +725,7 @@ public class HealthStatusIndicatorServiceImpl {
// 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); // calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfDay(); Integer maxWaringCycle = idxBizPvWarningRuleSetMapper.getMaxWaringCycleOfDay()+AnalyseOffset;
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetDay(date,0-maxWaringCycle); date =DateUtil.offsetDay(date,0-maxWaringCycle);
...@@ -907,7 +910,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -907,7 +910,7 @@ public class HealthStatusIndicatorServiceImpl {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 用ts字段查询时需要减8小时 // 用ts字段查询时需要减8小时
// Date date = DateUtils.dateAddHours(time, -8); // Date date = DateUtils.dateAddHours(time, -8);
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfMinutes(); Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfMinutes()+AnalyseOffset;
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10)); date =DateUtil.offsetMinute(date,0-(maxWaringCycle*10));
LambdaQueryWrapper<FanHealthIndexMoment> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FanHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
...@@ -915,6 +918,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -915,6 +918,7 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.eq(FanHealthIndexMoment::getAnalysisObjType, "测点"); wrapper.eq(FanHealthIndexMoment::getAnalysisObjType, "测点");
wrapper.ge(FanHealthIndexMoment::getTs, date); wrapper.ge(FanHealthIndexMoment::getTs, date);
wrapper.orderByDesc(FanHealthIndexMoment::getTs); wrapper.orderByDesc(FanHealthIndexMoment::getTs);
//查询最大连续时间规则的测点对象
List<FanHealthIndexMoment> healthIndices = fanHealthIndexMomentMapper.selectList(wrapper); List<FanHealthIndexMoment> healthIndices = fanHealthIndexMomentMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){ if (ObjectUtils.isEmpty(healthIndices)){
...@@ -941,6 +945,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -941,6 +945,7 @@ public class HealthStatusIndicatorServiceImpl {
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<FanHealthIndexMoment>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<FanHealthIndexMoment>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
//获取指定测点的健康指数列表
List<FanHealthIndexMoment> idxBizFanHealthIndices = healthDataMaps.get(address); List<FanHealthIndexMoment> idxBizFanHealthIndices = healthDataMaps.get(address);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
...@@ -981,7 +986,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -981,7 +986,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
//获取指定测点的健康指数列表
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexMoment::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexMoment::getHealthIndex).collect(Collectors.toList());
// Double finalHealthValueRisk = healthValueRisk; // Double finalHealthValueRisk = healthValueRisk;
// long riskNum = healthIndex.subList(healthIndex.size()>healthValueRiskCount? (int) (healthIndex.size() - healthValueRiskCount) :0,healthIndex.size()).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();
...@@ -1001,7 +1006,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1001,7 +1006,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
Double finalHealthValueNotice = healthValueNotice; Double finalHealthValueNotice = healthValueNotice;
if(healthIndex.size()>=healthValueNoticeCount){ if(healthIndex.size()>=healthValueNoticeCount){
List<Double> healthIndexList = healthIndex.subList(healthIndex.size()-healthValueWarnCount,healthIndex.size()); List<Double> healthIndexList = healthIndex.subList(healthIndex.size()-healthValueNoticeCount,healthIndex.size());
noticeNum = (int) healthIndexList.stream().filter(e -> e <= finalHealthValueNotice).count(); noticeNum = (int) healthIndexList.stream().filter(e -> e <= finalHealthValueNotice).count();
} }
String level = ""; String level = "";
...@@ -1105,7 +1110,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1105,7 +1110,7 @@ public class HealthStatusIndicatorServiceImpl {
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5); // calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour(); Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour()+AnalyseOffset;
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetHour(date,0-(maxWaringCycle)); date =DateUtil.offsetHour(date,0-(maxWaringCycle));
LambdaQueryWrapper<FanHealthIndexHour> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FanHealthIndexHour> wrapper = new LambdaQueryWrapper<>();
...@@ -1295,7 +1300,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1295,7 +1300,7 @@ public class HealthStatusIndicatorServiceImpl {
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3); // calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour(); Integer maxWaringCycle = idxBizFanWarningRuleSetMapper.getMaxWaringCycleOfHour()+AnalyseOffset;
Date date =DateUtil.offsetHour(time,-8); Date date =DateUtil.offsetHour(time,-8);
date =DateUtil.offsetDay(date,0-(maxWaringCycle)); date =DateUtil.offsetDay(date,0-(maxWaringCycle));
......
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