Commit dbe0aaf4 authored by chenzhao's avatar chenzhao

预警代码调整

parent 90908b5e
...@@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -80,17 +81,24 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -80,17 +81,24 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate);
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper);
if (null == healthIndices ){
return;
}
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address);
LambdaQueryWrapper<IdxBizPvWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisType,"按小时"); queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisType,"按时刻");
queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq()); queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq());
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
if (null == idxBizPvWarningRuleSets ){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
...@@ -103,15 +111,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -103,15 +111,15 @@ public class HealthStatusIndicatorServiceImpl {
for (IdxBizPvWarningRuleSet e : idxBizPvWarningRuleSets) { for (IdxBizPvWarningRuleSet e : idxBizPvWarningRuleSets) {
switch (e.getWarningName()){ switch (e.getWarningName()){
case "警告": case "警告":
healthValueWarn = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueWarn = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
case "危险": case "危险":
healthValueRisk = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueRisk = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
case "注意": case "注意":
healthValueNotice = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueNotice = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
} }
...@@ -184,6 +192,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -184,6 +192,10 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate);
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper);
if (null == healthIndices ){
return;
}
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
...@@ -197,6 +209,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -197,6 +209,10 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
if (null == idxBizPvWarningRuleSets ){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
...@@ -292,6 +308,11 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -292,6 +308,11 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate);
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper);
if (null == healthIndices ){
return;
}
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
...@@ -305,6 +326,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -305,6 +326,10 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
if (null == idxBizPvWarningRuleSets ){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
...@@ -378,7 +403,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -378,7 +403,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
@Scheduled(cron = "0 0/5 * * * ?") @Scheduled(cron = "0 0 */1 * * ?")
@Async("async") @Async("async")
public void healthWarningMinute() { public void healthWarningMinute() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -392,6 +417,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -392,6 +417,10 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){
return;
}
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
...@@ -404,6 +433,10 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -404,6 +433,10 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets)){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
...@@ -416,15 +449,15 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -416,15 +449,15 @@ public class HealthStatusIndicatorServiceImpl {
for (IdxBizFanWarningRuleSet e : idxBizPvWarningRuleSets) { for (IdxBizFanWarningRuleSet e : idxBizPvWarningRuleSets) {
switch (e.getWarningName()){ switch (e.getWarningName()){
case "警告": case "警告":
healthValueWarn = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueWarn = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
case "危险": case "危险":
healthValueRisk = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueRisk = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
case "注意": case "注意":
healthValueNotice = Double.parseDouble(e.getWarningIf().substring(e.getWarningIf().length()-2)); healthValueNotice = Double.parseDouble(e.getWarningIf().substring(2));
healthValueMinCount =Long.parseLong(e.getWarningCycle()); healthValueMinCount =Long.parseLong(e.getWarningCycle());
break; break;
} }
...@@ -500,6 +533,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -500,6 +533,9 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){
return;
}
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
...@@ -511,7 +547,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -511,7 +547,9 @@ public class HealthStatusIndicatorServiceImpl {
queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq()); queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets)){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
...@@ -607,7 +645,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -607,7 +645,9 @@ public class HealthStatusIndicatorServiceImpl {
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime())); wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime()));
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){
return;
}
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress)));
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId);
...@@ -619,7 +659,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -619,7 +659,9 @@ public class HealthStatusIndicatorServiceImpl {
queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq()); queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets)){
break;
}
Double healthValueWarn = 0.0; Double healthValueWarn = 0.0;
Double healthValueRisk = 0.0; Double healthValueRisk = 0.0;
Double healthValueNotice = 0.0; Double healthValueNotice = 0.0;
......
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