|
|
@ -35,7 +35,6 @@ import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Field; |
|
|
@ -60,8 +59,6 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
|
|
|
|
|
|
|
|
private final ISoeClient alarmClient; |
|
|
|
private final ISoeClient alarmClient; |
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
private String types; |
|
|
|
private String types; |
|
|
|
|
|
|
|
|
|
|
@ -121,10 +118,10 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
List<HistoryAbnormalAlarmVo> voList = historyAbnormalAlarmVos.parallelStream().peek(s -> s.setTimes((s.getEndTime().getTime() - s.getStartTime().getTime()))).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, |
|
|
|
Map<String, Long> timesList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, |
|
|
|
Collectors.counting())); |
|
|
|
Collectors.counting())); |
|
|
|
//时间统计
|
|
|
|
//时间统计
|
|
|
|
Map<String, Long> durationList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, |
|
|
|
Map<String, Long> durationList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, |
|
|
|
Collectors.summingLong(HistoryAbnormalAlarmVo::getTimes))); |
|
|
|
Collectors.summingLong(HistoryAbnormalAlarmVo::getTimes))); |
|
|
|
List<HistoryAbnormalAlarmVo> res = new ArrayList<>(); |
|
|
|
List<HistoryAbnormalAlarmVo> res = new ArrayList<>(); |
|
|
|
for (Map.Entry<String, Long> entry : durationList.entrySet()) { |
|
|
|
for (Map.Entry<String, Long> entry : durationList.entrySet()) { |
|
|
|
//累计时长
|
|
|
|
//累计时长
|
|
|
@ -144,8 +141,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
} |
|
|
|
} |
|
|
|
//根据电站名字排序
|
|
|
|
//根据电站名字排序
|
|
|
|
res = res.stream(). |
|
|
|
res = res.stream(). |
|
|
|
sorted(Comparator.comparing(HistoryAbnormalAlarmVo::getStationName)) |
|
|
|
sorted(Comparator.comparing(HistoryAbnormalAlarmVo::getStationName)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
IPage<HistoryAbnormalAlarmVo> page = Condition.getPage(query); |
|
|
|
IPage<HistoryAbnormalAlarmVo> page = Condition.getPage(query); |
|
|
|
page.setTotal(res.size()); |
|
|
|
page.setTotal(res.size()); |
|
|
|
if (entityIsNull(query)) { |
|
|
|
if (entityIsNull(query)) { |
|
|
@ -236,62 +233,44 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
return new AlarmReustVo(); |
|
|
|
return new AlarmReustVo(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询当天类型处理告警
|
|
|
|
|
|
|
|
List<AlarmHandleEntity> handles = handleService.handles(types.stream().map(Long::parseLong).collect(Collectors.toList()),AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
|
|
|
|
|
|
|
// 返回数据
|
|
|
|
// 返回数据
|
|
|
|
AlarmReustVo response = new AlarmReustVo(); |
|
|
|
AlarmReustVo response = new AlarmReustVo(); |
|
|
|
if(types.size() > 1){ |
|
|
|
List<AlarmDataVo> datas = result.getData().getRecords().stream().map(alarm -> { |
|
|
|
response.setCount((int) result.getData().getTotal()); |
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
response.setTotal(result.getData().getTotal()); |
|
|
|
// 继承类属性拷贝
|
|
|
|
response.setSoeList(result.getData().getRecords().stream().map(alarm -> { |
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
if(CollectionUtil.isEmpty(handles)){ |
|
|
|
// 继承类属性拷贝
|
|
|
|
record.setIsHandle(false); |
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
|
}else{ |
|
|
|
record.setStationCode(alarm.getStation()); |
|
|
|
record.setIsHandle(handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(String.valueOf(alarm.getId()))); |
|
|
|
record.setContent(alarm.getSoeExplain()); |
|
|
|
} |
|
|
|
record.setType(alarm.getSoeType()); |
|
|
|
record.setStationCode(alarm.getStation()); |
|
|
|
record.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(alarm.getSoeType())]); |
|
|
|
record.setContent(alarm.getSoeExplain()); |
|
|
|
record.setStationName((String) redisTemplate.opsForValue().get("alarm:station:" + alarm.getStation())); |
|
|
|
record.setType(alarm.getSoeType()); |
|
|
|
record.setServeType("2"); |
|
|
|
record.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(alarm.getSoeType())]); |
|
|
|
record.setAlarmType(AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
List<StationEntity> filter = stations.stream().filter(station -> station.getCode().equals(alarm.getStation())).collect(Collectors.toList()); |
|
|
|
return record; |
|
|
|
if (CollectionUtil.isEmpty(filter)) { |
|
|
|
}).sorted(Comparator.comparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList())); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// 查询当天类型处理告警
|
|
|
|
|
|
|
|
List<AlarmHandleEntity> handles = handleService.handles(types.stream().map(Long::parseLong).collect(Collectors.toList()),AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<AlarmDataVo> datas = result.getData().getRecords().stream().map(alarm -> { |
|
|
|
|
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
|
|
|
|
// 继承类属性拷贝
|
|
|
|
|
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(handles)){ |
|
|
|
|
|
|
|
record.setIsHandle(false); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
record.setIsHandle(handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(String.valueOf(alarm.getId()))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
record.setStationCode(alarm.getStation()); |
|
|
|
|
|
|
|
record.setContent(alarm.getSoeExplain()); |
|
|
|
|
|
|
|
record.setType(alarm.getSoeType()); |
|
|
|
|
|
|
|
record.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(alarm.getSoeType())]); |
|
|
|
|
|
|
|
List<StationEntity> filter = stations.stream().filter(station -> station.getCode().equals(alarm.getStation())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(filter)) { |
|
|
|
|
|
|
|
return record; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
record.setStationName(filter.get(0).getName()); |
|
|
|
|
|
|
|
record.setServeType(filter.get(0).getServeType()); |
|
|
|
|
|
|
|
record.setAlarmType(AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
|
|
|
return record; |
|
|
|
return record; |
|
|
|
}).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) |
|
|
|
} |
|
|
|
.thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); |
|
|
|
record.setStationName(filter.get(0).getName()); |
|
|
|
|
|
|
|
record.setServeType(filter.get(0).getServeType()); |
|
|
|
response.setCount((int) (result.getData().getTotal() - handles.size())); |
|
|
|
record.setAlarmType(AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
response.setSoeList(datas); |
|
|
|
return record; |
|
|
|
response.setTotal(result.getData().getTotal()); |
|
|
|
}).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) |
|
|
|
} |
|
|
|
.thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setCount((int) (result.getData().getTotal() - handles.size())); |
|
|
|
|
|
|
|
response.setSoeList(datas); |
|
|
|
|
|
|
|
response.setTotal(result.getData().getTotal()); |
|
|
|
return response; |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取处理数据ID集合 |
|
|
|
* 获取处理数据ID集合 |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -397,8 +376,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
// 步骤4.分页
|
|
|
|
// 步骤4.分页
|
|
|
|
page.setTotal(alarms.size()); |
|
|
|
page.setTotal(alarms.size()); |
|
|
|
page.setRecords(alarms.stream().sorted(Comparator.comparing(AlarmVo::getTs,Comparator.reverseOrder())) |
|
|
|
page.setRecords(alarms.stream().sorted(Comparator.comparing(AlarmVo::getTs,Comparator.reverseOrder())) |
|
|
|
.skip(page.getSize() * (page.getCurrent() - 1)).limit(page.getSize()) |
|
|
|
.skip(page.getSize() * (page.getCurrent() - 1)).limit(page.getSize()) |
|
|
|
.collect(Collectors.toList())); |
|
|
|
.collect(Collectors.toList())); |
|
|
|
page.setPages((alarms.size() -1) / page.getSize() + 1); |
|
|
|
page.setPages((alarms.size() -1) / page.getSize() + 1); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
page.setTotal(0); |
|
|
|
page.setTotal(0); |
|
|
@ -412,11 +391,6 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
return this.baseMapper.getStationName(); |
|
|
|
return this.baseMapper.getStationName(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void stations() { |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(); |
|
|
|
|
|
|
|
stations.forEach(item-> redisTemplate.opsForValue().set("alarm:station:" + item.getCode(),item.getName())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Boolean entityIsNull(Object object) { |
|
|
|
private Boolean entityIsNull(Object object) { |
|
|
|