|
|
|
@ -35,6 +35,7 @@ import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
@ -59,6 +60,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
|
|
|
|
|
private final ISoeClient alarmClient; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
|
private String types; |
|
|
|
|
|
|
|
|
@ -233,44 +236,62 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
|
return new AlarmReustVo(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询当天类型处理告警
|
|
|
|
|
List<AlarmHandleEntity> handles = handleService.handles(types.stream().map(Long::parseLong).collect(Collectors.toList()),AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
|
|
|
|
|
// 返回数据
|
|
|
|
|
AlarmReustVo response = new AlarmReustVo(); |
|
|
|
|
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)) { |
|
|
|
|
if(types.size() > 1){ |
|
|
|
|
response.setCount((int) result.getData().getTotal()); |
|
|
|
|
response.setTotal(result.getData().getTotal()); |
|
|
|
|
response.setSoeList(result.getData().getRecords().stream().map(alarm -> { |
|
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
|
// 继承类属性拷贝
|
|
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
|
|
record.setStationCode(alarm.getStation()); |
|
|
|
|
record.setContent(alarm.getSoeExplain()); |
|
|
|
|
record.setType(alarm.getSoeType()); |
|
|
|
|
record.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(alarm.getSoeType())]); |
|
|
|
|
record.setStationName((String) redisTemplate.opsForValue().get("alarm:station:" + alarm.getStation())); |
|
|
|
|
record.setServeType("2"); |
|
|
|
|
record.setAlarmType(AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
return record; |
|
|
|
|
} |
|
|
|
|
record.setStationName(filter.get(0).getName()); |
|
|
|
|
record.setServeType(filter.get(0).getServeType()); |
|
|
|
|
record.setAlarmType(AbnormalAlarmConstant.SYSTEM_ALARM); |
|
|
|
|
return record; |
|
|
|
|
}).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()); |
|
|
|
|
}).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; |
|
|
|
|
}).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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取处理数据ID集合 |
|
|
|
|
* @return |
|
|
|
@ -391,6 +412,11 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
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) { |
|
|
|
|