|
|
|
@ -60,9 +60,6 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
|
|
|
|
|
private final ISoeClient alarmClient; |
|
|
|
|
|
|
|
|
|
private final SoeClient soeClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
|
private String types; |
|
|
|
|
|
|
|
|
@ -119,10 +116,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
} else { |
|
|
|
|
historyAbnormalAlarmVos.stream().filter(s -> s.getEndTime() == null).forEach(s -> s.setEndTime(new Date())); |
|
|
|
|
} |
|
|
|
|
List<HistoryAbnormalAlarmVo> voList = historyAbnormalAlarmVos.parallelStream().map(s -> { |
|
|
|
|
s.setTimes((s.getEndTime().getTime() - s.getStartTime().getTime())); |
|
|
|
|
return s; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
List<HistoryAbnormalAlarmVo> voList = historyAbnormalAlarmVos.parallelStream().peek(s -> s.setTimes((s.getEndTime().getTime() - s.getStartTime().getTime()))).collect(Collectors.toList()); |
|
|
|
|
//次数统计
|
|
|
|
|
Map<String, Long> timesList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, |
|
|
|
|
Collectors.counting())); |
|
|
|
@ -166,7 +160,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
QueryWrapper<HistoryAbnormalAlarmEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
if (entity.getStationName() != null) { |
|
|
|
|
String[] list = entity.getStationName().split(","); |
|
|
|
|
queryWrapper.lambda().in(HistoryAbnormalAlarmEntity::getStationName, list); |
|
|
|
|
queryWrapper.lambda().in(HistoryAbnormalAlarmEntity::getStationName, Arrays.stream(list).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
if (entity.getType() != null) { |
|
|
|
|
queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getType, entity.getType()); |
|
|
|
@ -194,11 +188,10 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
} else { |
|
|
|
|
historyAbnormalAlarmVos.stream().filter(s -> s.getEndTime() == null).forEach(s -> s.setEndTime(new Date())); |
|
|
|
|
} |
|
|
|
|
voList= historyAbnormalAlarmVos.parallelStream().map(s -> { |
|
|
|
|
voList= historyAbnormalAlarmVos.parallelStream().peek(s -> { |
|
|
|
|
long duration = s.getEndTime().getTime() - s.getStartTime().getTime(); |
|
|
|
|
double v = BigDecimal.valueOf(duration / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
s.setDuration(v); |
|
|
|
|
return s; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
IPage<HistoryAbnormalAlarmVo> page = Condition.getPage(query); |
|
|
|
@ -225,24 +218,13 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询告警数据
|
|
|
|
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); |
|
|
|
|
/*if (StringUtils.isEmpty(param.getDate())) { |
|
|
|
|
condition.setBeginTime(LocalDateTime.parse( |
|
|
|
|
DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", format |
|
|
|
|
)); |
|
|
|
|
} else { |
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(param.getDate(), format)); |
|
|
|
|
}*/ |
|
|
|
|
// condition.setEndTime(LocalDateTime.now());
|
|
|
|
|
// FIXME 测试使用时间
|
|
|
|
|
condition.setBeginTime(LocalDateTime.parse("2023-04-01 00:00:00", format)); |
|
|
|
|
condition.setEndTime(LocalDateTime.parse("2023-04-11 00:00:00", format)); |
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00", DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
condition.setEndTime(LocalDateTime.now()); |
|
|
|
|
condition.setNeedPage(true); |
|
|
|
|
condition.setPage(param.getCurrent()); |
|
|
|
|
condition.setLimit(param.getSize()); |
|
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
//condition.setStationIds(Collections.singletonList("901900000234"));
|
|
|
|
|
List<String> types = Arrays.asList(param.getType().split(",")); |
|
|
|
|
condition.setTypes(types); |
|
|
|
|
Result<HzPage<SoeData>> result = alarmClient.getByStationsAndTime(condition); |
|
|
|
@ -314,7 +296,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format)); |
|
|
|
|
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format)); |
|
|
|
|
condition.setNeedPage(false); |
|
|
|
|
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).filter(StringUtils::isNotEmpty).collect(Collectors.toList())); |
|
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
|
condition.setTypes(Arrays.asList(types.split(","))); |
|
|
|
@ -323,10 +305,10 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
// 步骤3. TODO 过滤已处理告警
|
|
|
|
|
|
|
|
|
|
// 步骤4.遍历获取
|
|
|
|
|
return Arrays.asList(types.split(",")).stream().map(type->{ |
|
|
|
|
return Arrays.stream(types.split(",")).map(type->{ |
|
|
|
|
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); |
|
|
|
|
count.setType(type); |
|
|
|
|
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(type)]); |
|
|
|
|
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(type)]); |
|
|
|
|
if(result.isSuccess() && !ObjectUtil.isEmpty(result.getData())){ |
|
|
|
|
count.setCount(result.getData().getRecords().stream().filter(record->type.equals(record.getSoeType())).count()); |
|
|
|
|
}else { |
|
|
|
@ -363,7 +345,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format)); |
|
|
|
|
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format)); |
|
|
|
|
condition.setNeedPage(false); |
|
|
|
|
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).filter(StringUtils::isNotEmpty).collect(Collectors.toList())); |
|
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
|
condition.setTypes(type_list); |
|
|
|
@ -392,7 +374,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
// 步骤4.分页
|
|
|
|
|
page.setTotal(alarms.size()); |
|
|
|
|
page.setRecords(alarms.stream().sorted(Comparator.comparing(AlarmVo::getTs,Comparator.reverseOrder())) |
|
|
|
|
.skip((long) page.getSize() * (page.getCurrent() - 1)).limit(page.getSize()) |
|
|
|
|
.skip(page.getSize() * (page.getCurrent() - 1)).limit(page.getSize()) |
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
page.setPages((alarms.size() -1) / page.getSize() + 1); |
|
|
|
|
}else{ |
|
|
|
|