调整计轴告警

This commit is contained in:
tiger_zhou 2023-12-22 16:41:54 +08:00
parent 8f6ce0a0d7
commit a0d9d82f11
4 changed files with 141 additions and 7 deletions

View File

@ -36,11 +36,12 @@ public class DeviceChangeStatusConvertor extends DefaultConvertor {
/* if (builder instanceof Rtu.Builder rtuBuild) { /* if (builder instanceof Rtu.Builder rtuBuild) {
alertManager.emit(new BlueDisplayAlertEvent(rtuBuild)); alertManager.emit(new BlueDisplayAlertEvent(rtuBuild));
} else*/ } else*/
if (builder instanceof Track.Builder trackBuild) { // if (builder instanceof Track.Builder trackBuild) {
// alertManager.emit(new SwitchAndTrackLedAlertEvent(trackBuild)); // alertManager.emit(new SwitchAndTrackLedAlertEvent(trackBuild));
alertManager.emit(new AxleLedAlertEvent(trackBuild)); // alertManager.emit(new AxleLedAlertEvent(trackBuild));
} else if (builder instanceof Switch.Builder switchBuild) { // } else
if (builder instanceof Switch.Builder switchBuild) {
alertManager.emit(new SwitchLostAlertEvent(switchBuild)); alertManager.emit(new SwitchLostAlertEvent(switchBuild));
// alertManager.emit(new SwitchAndTrackLedAlertEvent(switchBuild)); // alertManager.emit(new SwitchAndTrackLedAlertEvent(switchBuild));
alertManager.emit(new AxleLedAlertEvent(switchBuild)); alertManager.emit(new AxleLedAlertEvent(switchBuild));

View File

@ -36,10 +36,11 @@ public class DeviceInitConvertor extends DefaultConvertor {
/* if (builder instanceof Rtu.Builder rtuBuild) { /* if (builder instanceof Rtu.Builder rtuBuild) {
alertManager.emit(new BlueDisplayAlertEvent(rtuBuild)); alertManager.emit(new BlueDisplayAlertEvent(rtuBuild));
} else */ } else */
if (builder instanceof Track.Builder trackBuild) { // if (builder instanceof Track.Builder trackBuild) {
// alertManager.emit(new SwitchAndTrackLedAlertEvent(trackBuild)); // alertManager.emit(new SwitchAndTrackLedAlertEvent(trackBuild));
alertManager.emit(new AxleLedAlertEvent(trackBuild)); // alertManager.emit(new AxleLedAlertEvent(trackBuild));
} else if (builder instanceof Switch.Builder switchBuild) { // } else
if (builder instanceof Switch.Builder switchBuild) {
// alertManager.emit(new SwitchAndTrackLedAlertEvent(switchBuild)); // alertManager.emit(new SwitchAndTrackLedAlertEvent(switchBuild));
alertManager.emit(new AxleLedAlertEvent(switchBuild)); alertManager.emit(new AxleLedAlertEvent(switchBuild));
alertManager.emit(new SwitchLostAlertEvent(switchBuild)); alertManager.emit(new SwitchLostAlertEvent(switchBuild));

View File

@ -32,7 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component //@Component
@Deprecated
@Slf4j @Slf4j
public class AxleLedAlertListener implements AlertSourceEventListener<AxleLedAlertEvent> { public class AxleLedAlertListener implements AlertSourceEventListener<AxleLedAlertEvent> {

View File

@ -0,0 +1,131 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.vo.AreaConfigVO;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import com.google.protobuf.GeneratedMessageV3;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class AxleMonitoringTask implements AlertMonitoringTask {
private final AlertInfoService alertInfoService;
public AxleMonitoringTask(AlertInfoService alertInfoService) {
this.alertInfoService = alertInfoService;
}
private final AlertManager alertManager = AlertManager.getDefault();
@Override
public String getName() {
return "BULE_DISPLAY";
}
private final String ALL_BULE_DISPLAY_NAME = "ALL_BULE_DISPLAY";
private Map<String, GeneratedMessageV3.Builder> findRtuDeviceSource(String lineIdStr) {
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineIdStr, DataTypeEnum.DEVICE);
if (deviceStatusData.getAllDeviceMap().isEmpty()) {
return Collections.emptyMap();
}
Map<String, GeneratedMessageV3.Builder> builderMap = deviceStatusData.getAllDeviceMap().get(Rtu.getDescriptor().getName());
if (CollectionUtils.isEmpty(builderMap)) {
return Collections.emptyMap();
}
return builderMap;
}
private List<RtuWarnVO> findRtuBuild(Integer lineId, Map<String, GeneratedMessageV3.Builder> builderMap) {
List<RtuWarnVO> collectRtuList2 = Lists.newArrayList();
List<AreaConfigVO> allRtuArea = this.alertInfoService.findDevice2(AlertType.BLUE_DISPLAY, AlertDeviceType.DEVICE_TYPE_RTU, lineId);
for (AreaConfigVO areaConfigVO : allRtuArea) {
for (Integer data : areaConfigVO.getDatas()) {
Station station = LineGraphicDataRepository.getDeviceByCode(lineId, data.toString(), Station.class);
Rtu.Builder rtuBuild = (Rtu.Builder) builderMap.get(station.getCode());
collectRtuList2.add(new RtuWarnVO(rtuBuild, station, areaConfigVO));
}
}
return collectRtuList2;
}
@Override
public void run() {
Set<String> allLineSet = DeviceDataRepository.getAllLines();
for (String lineIdStr : allLineSet) {
Integer lineId = Integer.parseInt(lineIdStr);
Map<String, GeneratedMessageV3.Builder> builderMap = this.findRtuDeviceSource(lineIdStr);
List<RtuWarnVO> collectRtuList = this.findRtuBuild(lineId, builderMap);
Map<Long, List<RtuWarnVO>> rtuVOMapList = collectRtuList.stream().collect(Collectors.groupingBy(d -> d.areaConfigVO.getId()));
int interLockCount = rtuVOMapList.keySet().size();
List<Boolean> allShutdownList = rtuVOMapList.values().stream().map(Collection::stream).map(ls -> ls.anyMatch(r -> Objects.nonNull(r.rtu) && r.rtu.getIpRtuStusDown())).toList();
if (allShutdownList.size() == interLockCount && allShutdownList.stream().allMatch(d -> d)) {
if (alertManager.putAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All")) {
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(null, AlertType.ALL_LINE_BLUE_DISPLAY, lineId, LocalDateTime.now(), "全线蓝线", null,
AlertDeviceType.DEVICE_TYPE_RTU, false);
alertManager.emit(alertInfo);
}
} else {
for (List<RtuWarnVO> rwvVOist : rtuVOMapList.values()) {
Optional<RtuWarnVO> rwVO = rwvVOist.stream().filter(d -> Objects.nonNull(d.rtu) && d.rtu.getIpRtuStusDown()).findAny();
if (rwVO.isPresent()) {
RtuWarnVO rtuVO = rwVO.get();
if (alertManager.putAlterDevice(lineId, this.getName(), rtuVO.areaConfigVO.getAreaName())) {
String alertInfoMostName = rtuVO.areaConfigVO.getAreaName();
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(rtuVO.areaConfigVO.getId(), AlertType.BLUE_DISPLAY, rtuVO.rtu, alertInfoMostName,
rtuVO.station.getCommon().getId(),
AlertDeviceType.DEVICE_TYPE_RTU, false);
alertManager.emit(alertInfo);
}
} else {
alertManager.removeAlterDevice(lineId, this.getName(), rwvVOist.get(0).areaConfigVO.getAreaName());
alertManager.removeAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All");
}
}
}
}
}
@Getter
public static class RtuWarnVO {
Rtu.Builder rtu;
Station station;
AreaConfigVO areaConfigVO;
public RtuWarnVO(Rtu.Builder rtu, Station station, AreaConfigVO areaConfigVO) {
this.rtu = rtu;
this.station = station;
this.areaConfigVO = areaConfigVO;
}
}
}