告警调整
This commit is contained in:
parent
1f9de574e6
commit
5e7ecd3272
@ -31,14 +31,14 @@ public class NccAlertInfo implements AlertInfo {
|
||||
|
||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
||||
Integer lineId, String alertObject, String locatorDeviceId,
|
||||
Long alertLocationId) {
|
||||
Long alertLocationId, boolean mockData) {
|
||||
this.alertTime = alertTime;
|
||||
this.alertType = alertType;
|
||||
this.lineId = lineId;
|
||||
this.alertObject = alertObject;
|
||||
this.locatorDeviceId = locatorDeviceId;
|
||||
this.alertLocationId = alertLocationId;
|
||||
this.mock = false;
|
||||
this.mock = mockData;
|
||||
this.level = buildLevel();
|
||||
}
|
||||
|
||||
|
@ -106,11 +106,11 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
|
||||
|
||||
if (light) {
|
||||
if (alertManager.putAlterDevice(lineId, ledName, id)) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
if (Objects.nonNull(ledMostName) && alertManager.needMostShow(lineId, ledMostName, overNums)) {
|
||||
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode());
|
||||
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode(), false);
|
||||
alertManager.emit(alertInfoMost);
|
||||
}
|
||||
} else {
|
||||
|
@ -51,7 +51,7 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
|
||||
if (alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, rtu.getId())) {
|
||||
Optional<DeviceAreaConfig> alertInfoOpt = this.alertInfoService.findAreaDevice(AlertType.BLUE_DISPLAY, AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(),
|
||||
rtu.getLineId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, station.getName());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, station.getName(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
|
||||
}
|
||||
@ -59,7 +59,7 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
|
||||
if (alertManager.needMostShow(rtu.getLineId(), BLUE_DISPLAY_NAME, allControlStationSize)
|
||||
&& alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, ALL_BLUE_DISPLAY_VAL)
|
||||
) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
|
@ -77,7 +77,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
if (this.timeOver(build.getReceiveTime(), timeOut)
|
||||
&& alertManager.putAlterDevice(build.getLineId(), CUSTOM_NAME, build.getId())) {
|
||||
LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(build.getLineId(), build.getId(), LayoutGraphicsProto.Platform.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), build, platform.getCode());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), build, platform.getCode(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
platformMap.remove(build.getId());
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
if (saveIsLost && this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
//失表超时
|
||||
if (alertManager.putAlterDevice(savedSwitchBuild.getLineId(), oneName, savedSwitchBuild.getId())) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, savedSwitchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, savedSwitchBuild.getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
this.deviceMap.remove(savedSwitchBuild.getId());
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
//检测大面积失表
|
||||
if (alertInfoMostOpt.isPresent() && alertManager.needMostShow(savedSwitchBuild.getLineId(), alertInfoMostOpt.get().getAreaName(), guardConfig.getSwitchLostMostNums())) {
|
||||
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, savedSwitchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, savedSwitchBuild.getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
}
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode, Section.class);
|
||||
if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId())) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, trainInfo.getGroupId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, trainInfo.getGroupId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,12 +1,17 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.dto.AlertMockDTO;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.service.AlertMockService;
|
||||
import club.joylink.xiannccda.service.AlertMockService.AlertMockDeviceInfo;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -28,6 +33,15 @@ public class AlertMockController {
|
||||
@ApiResponse(description = "设置模拟故障")
|
||||
@PostMapping("/set")
|
||||
public void setAlert(@RequestBody @Validated AlertMockDTO alertMockDTO) {
|
||||
alertMockService.setAlert(alertMockDTO);
|
||||
alertMockService.setAlert2(alertMockDTO);
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "获取设备")
|
||||
@ApiResponse(description = "获取设备")
|
||||
@PostMapping("/find/{lineId}/{alertType}")
|
||||
public List<AlertMockDeviceInfo> findDevice(@PathVariable("lineId") Integer lineId, @PathVariable("alertType") AlertType alertType) {
|
||||
return this.alertMockService.findAlertType(lineId, alertType);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,27 @@
|
||||
package club.joylink.xiannccda.dto;
|
||||
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import com.google.common.base.Joiner;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlertMockDTO {
|
||||
|
||||
@NotNull(message = "线路id不能为null")
|
||||
private Integer lineId;
|
||||
@NotNull(message = "故障类型不能为null")
|
||||
private AlertType alertType;
|
||||
@NotNull(message = "故障code不能为null")
|
||||
private List<String> deviceCodes;
|
||||
|
||||
public String getFrist() {
|
||||
return this.deviceCodes.get(0);
|
||||
}
|
||||
|
||||
public String getAll() {
|
||||
return Joiner.on(",").join(this.deviceCodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,23 +59,23 @@ public class AlertInfoService {
|
||||
return findList;
|
||||
}
|
||||
|
||||
public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String targetDeviceCode) {
|
||||
public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String targetDeviceCode, boolean mockData) {
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class);
|
||||
Optional<DeviceAreaConfig> areaConfigOptional = this.findAreaDevice(alertType, dt, layoutId, lineId);
|
||||
return this.createAlert2(areaConfigOptional, alertType, mb, targetDeviceCode);
|
||||
return this.createAlert2(areaConfigOptional, alertType, mb, targetDeviceCode, mockData);
|
||||
}
|
||||
|
||||
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String targetDeviceCode) {
|
||||
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String targetDeviceCode, boolean mockData) {
|
||||
Long timestamp = DeviceStatusDataOperate.findFieldVal(mb, "timestamp", Long.class);
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class);
|
||||
String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "id", String.class);
|
||||
LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.of("+8"));
|
||||
DeviceAreaConfig areaConfig = areaConfigOpt.orElse(null);
|
||||
if (Objects.isNull(areaConfig)) {
|
||||
return new NccAlertInfo(createTime, alertType, lineId, targetDeviceCode, deviceCode, null);
|
||||
return new NccAlertInfo(createTime, alertType, lineId, targetDeviceCode, deviceCode, null, mockData);
|
||||
}
|
||||
String alertObject = String.format("%s-设备[%s]", areaConfig.getAreaName(), targetDeviceCode);
|
||||
return new NccAlertInfo(createTime, alertType, lineId, alertObject, deviceCode, areaConfig.getId());
|
||||
return new NccAlertInfo(createTime, alertType, lineId, alertObject, deviceCode, areaConfig.getId(), mockData);
|
||||
}
|
||||
|
||||
/* @Deprecated
|
||||
|
@ -5,20 +5,35 @@ import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
import club.joylink.xiannccda.dto.AlertMockDTO;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -40,6 +55,132 @@ public class AlertMockService {
|
||||
alertManager.emit(alertDetail);
|
||||
}
|
||||
|
||||
public void setAlert2(AlertMockDTO alertMockDTO) {
|
||||
NccAlertInfo alertInfo = this.buildNccAlert2(alertMockDTO);
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
|
||||
public NccAlertInfo buildNccAlert2(AlertMockDTO dto) {
|
||||
int lineId = dto.getLineId();
|
||||
switch (dto.getAlertType()) {
|
||||
case BLUE_DISPLAY -> {
|
||||
Optional<Station> stationOptional = LineGraphicDataRepository.getDevices(lineId, Station.class).filter(Station::getConcentrationStations)
|
||||
.filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
Station station = stationOptional.orElse(null);
|
||||
Rtu.Builder bb = Rtu.newBuilder();
|
||||
bb.setLineId(dto.getLineId());
|
||||
bb.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
bb.setId(dto.getFrist());
|
||||
bb.setIpRtuStusDown(true);
|
||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(), bb, station.getName(), true);
|
||||
}
|
||||
case PLATFORM_DOOR_CANNOT_OPEN -> {
|
||||
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
DeviceStatusProto.Platform.Builder platform = DeviceStatusProto.Platform.newBuilder();
|
||||
platform.setId(dto.getFrist());
|
||||
platform.setTrainberth(true);
|
||||
platform.setLineId(dto.getLineId());
|
||||
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
Platform pf = pfOptional.orElse(null);
|
||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), true);
|
||||
}
|
||||
case PLATFORM_DOOR_CANNOT_CLOSE -> {
|
||||
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
DeviceStatusProto.Platform.Builder platform = DeviceStatusProto.Platform.newBuilder();
|
||||
platform.setId(dto.getFrist());
|
||||
platform.setPsdOpen(true);
|
||||
platform.setTrainberth(true);
|
||||
platform.setLineId(dto.getLineId());
|
||||
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
Platform pf = pfOptional.orElse(null);
|
||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), true);
|
||||
}
|
||||
/* case SWITCH_LOST -> {
|
||||
Optional<Turnout> turnoutOptional = LineGraphicDataRepository.getDevices(lineId, Turnout.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
Switch.Builder switchs = Switch.newBuilder();
|
||||
switchs.setId(dto.getFrist());
|
||||
switchs.setLineId(dto.getLineId());
|
||||
switchs.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
switchs.setIpSingleSwitchStusLostIndication(true);
|
||||
switchs.setReceiveTime(System.currentTimeMillis());
|
||||
Turnout turnout = turnoutOptional.orElse(null);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, switchs.getId(), true);
|
||||
}*/
|
||||
case SWITCH_LOST, SWITCH_LOST_MOST -> {
|
||||
Optional<Turnout> turnoutOptional = LineGraphicDataRepository.getDevices(lineId, Turnout.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
Switch.Builder switchs = Switch.newBuilder();
|
||||
switchs.setId(dto.getFrist());
|
||||
switchs.setLineId(dto.getLineId());
|
||||
switchs.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
switchs.setReceiveTime(System.currentTimeMillis());
|
||||
switchs.setIpSingleSwitchStusLostIndication(true);
|
||||
Turnout turnout = turnoutOptional.orElse(null);
|
||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, dto.getAll(), true);
|
||||
}
|
||||
case AXLE_LED_RED, AXLE_LED_ORANGE -> {
|
||||
Optional<LogicSection> lsOptional = LineGraphicDataRepository.getDevices(lineId, LogicSection.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
Track.Builder track = Track.newBuilder();
|
||||
track.setId(dto.getFrist());
|
||||
track.setLineId(dto.getLineId());
|
||||
track.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
LogicSection ls = lsOptional.orElse(null);
|
||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_TRACK, ls.getCommon().getId(), track, dto.getAll(), true);
|
||||
}
|
||||
case TRAIN_EB_ATP -> {
|
||||
|
||||
Optional<LogicSection> lsOptional = LineGraphicDataRepository.getDevices(lineId, LogicSection.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||
|
||||
Track.Builder track = Track.newBuilder();
|
||||
track.setId(dto.getFrist());
|
||||
track.setLineId(dto.getLineId());
|
||||
track.setTimestamp(System.currentTimeMillis() / 1000);
|
||||
LogicSection ls = lsOptional.orElse(null);
|
||||
|
||||
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, ls.getCommon().getId(), track, "测试车组号", true);
|
||||
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + dto.getAlertType());
|
||||
}
|
||||
}
|
||||
|
||||
public List<AlertMockDeviceInfo> findAlertType(int lineId, AlertType alertType) {
|
||||
Collection<? extends GeneratedMessageV3> messages = this.findDevice(lineId, alertType);
|
||||
List<AlertMockDeviceInfo> amList = messages.stream().sorted((o1, o2) -> {
|
||||
String code1 = DeviceStatusDataOperate.findFieldVal(o1, "code", String.class);
|
||||
String code2 = DeviceStatusDataOperate.findFieldVal(o2, "code", String.class);
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(code1, code2);
|
||||
}).map(d -> {
|
||||
String name = DeviceStatusDataOperate.findFieldVal(d, "name", String.class);
|
||||
String code = DeviceStatusDataOperate.findFieldVal(d, "code", String.class);
|
||||
return new AlertMockDeviceInfo(name, code);
|
||||
}).collect(Collectors.toList());
|
||||
return amList;
|
||||
}
|
||||
|
||||
|
||||
private Collection<? extends GeneratedMessageV3> findDevice(int lineId, AlertType alertType) {
|
||||
switch (alertType) {
|
||||
case BLUE_DISPLAY -> {
|
||||
return LineGraphicDataRepository.getDevices(lineId, Station.class).filter(Station::getConcentrationStations)
|
||||
.collect(Collectors.toMap(d -> d.getCommon().getId(), Function.identity(), (v1, v2) -> v1)).values();
|
||||
}
|
||||
case PLATFORM_DOOR_CANNOT_OPEN, PLATFORM_DOOR_CANNOT_CLOSE -> {
|
||||
return LineGraphicDataRepository.getDevices(lineId, Platform.class)
|
||||
.collect(Collectors.toMap(d -> d.getCommon().getId(), Function.identity(), (v1, v2) -> v1)).values();
|
||||
}
|
||||
case SWITCH_LOST, SWITCH_LOST_MOST -> {
|
||||
return LineGraphicDataRepository.getDevices(lineId, Turnout.class).collect(Collectors.toMap(d -> d.getCommon().getId(), Function.identity(), (v1, v2) -> v1)).values();
|
||||
}
|
||||
case AXLE_LED_RED, AXLE_LED_ORANGE, TRAIN_EB_ATP -> {
|
||||
return LineGraphicDataRepository.getDevices(lineId, LogicSection.class)
|
||||
.collect(Collectors.toMap(d -> d.getCommon().getId(), Function.identity(), (v1, v2) -> v1)).values();
|
||||
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
||||
}
|
||||
}
|
||||
|
||||
private NccAlertInfo buildNccAlert(AlertType alertType, int lineId) {
|
||||
MessageOrBuilder messageOrBuilder;
|
||||
switch (alertType) {
|
||||
@ -59,7 +200,7 @@ public class AlertMockService {
|
||||
switchBuild.setIpSingleSwitchStusLocked(true);
|
||||
switchBuild.setReceiveTime(System.currentTimeMillis());
|
||||
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, switchBuild.getId(), Turnout.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchBuild, switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchBuild, switchBuild.getId(), true);
|
||||
alertInfo.setMock(true);
|
||||
return alertInfo;
|
||||
}
|
||||
@ -71,7 +212,7 @@ public class AlertMockService {
|
||||
track.setLineId(lineId);
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A");
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, section.getCommon().getId(), track, track.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, section.getCommon().getId(), track, track.getId(), true);
|
||||
alertInfo.setMock(true);
|
||||
return alertInfo;
|
||||
}
|
||||
@ -84,7 +225,7 @@ public class AlertMockService {
|
||||
track.setLineId(lineId);
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A");
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.AXLE_LED_ORANGE, AlertDeviceType.DEVICE_TYPE_TRACK, section.getCommon().getId(), track, track.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.AXLE_LED_ORANGE, AlertDeviceType.DEVICE_TYPE_TRACK, section.getCommon().getId(), track, track.getId(), true);
|
||||
alertInfo.setMock(true);
|
||||
return alertInfo;
|
||||
}
|
||||
@ -93,7 +234,7 @@ public class AlertMockService {
|
||||
platform.setLineId(lineId);
|
||||
platform.setId("PF02301").setReceiveTime(System.currentTimeMillis()).setTrainberth(true);
|
||||
LayoutGraphicsProto.Platform platform2 = LineGraphicDataRepository.getDeviceByCode(lineId, platform.getId(), LayoutGraphicsProto.Platform.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(), true);
|
||||
alertInfo.setMock(true);
|
||||
return alertInfo;
|
||||
}
|
||||
@ -102,16 +243,11 @@ public class AlertMockService {
|
||||
platform.setLineId(lineId);
|
||||
platform.setId("PF02301").setReceiveTime(System.currentTimeMillis()).setTrainberth(true).setPsdOpen(true);
|
||||
LayoutGraphicsProto.Platform platform2 = LineGraphicDataRepository.getDeviceByCode(lineId, platform.getId(), LayoutGraphicsProto.Platform.class);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(), true);
|
||||
alertInfo.setMock(true);
|
||||
return alertInfo;
|
||||
}
|
||||
/* case TRAIN_EB_ATP -> {
|
||||
|
||||
}*/
|
||||
/*case TRAIN_DELAY_2, TRAIN_DELAY_10 -> {
|
||||
messageOrBuilder = null;
|
||||
}*/
|
||||
case PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL -> {
|
||||
Stream<Platform> stream = LineGraphicDataRepository.getDevices(lineId, Platform.class);
|
||||
messageOrBuilder = stream.findFirst()
|
||||
@ -122,4 +258,20 @@ public class AlertMockService {
|
||||
return alertDetailFactory.getAlertDetail(LocalDateTime.now(), alertType, lineId, true,
|
||||
messageOrBuilder);
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public static class AlertMockDeviceInfo {
|
||||
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
public AlertMockDeviceInfo(String name, String code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
this.name = this.code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class AlertRecordService {
|
||||
|
||||
public AlertTip confirm(Long recordId, String tipType, Long locationId) {
|
||||
LambdaQueryWrapper<AlertTip> qw = Wrappers.lambdaQuery(AlertTip.class).eq(AlertTip::getAlertType, tipType);
|
||||
if (Objects.nonNull(locationId)) {
|
||||
if (Objects.nonNull(locationId) && locationId > 0L) {
|
||||
qw.eq(AlertTip::getAreaConfigId, locationId);
|
||||
}
|
||||
AlertTip tip = alertTipRepository.getOne(qw);
|
||||
|
Loading…
Reference in New Issue
Block a user