代码调整
This commit is contained in:
parent
922cb14c08
commit
417dc8b3dd
@ -44,7 +44,7 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(NccAlertInfo alertInfo) {
|
public void accept(NccAlertInfo alertInfo) {
|
||||||
/*if (!alertInfo.isMock()) {
|
/* if (!alertInfo.isMock()) {
|
||||||
AlertRecord record = convertToRecord(alertInfo);
|
AlertRecord record = convertToRecord(alertInfo);
|
||||||
alertRecordRepository.save(record);
|
alertRecordRepository.save(record);
|
||||||
alertInfo.setId(record.getId());
|
alertInfo.setId(record.getId());
|
||||||
|
@ -110,7 +110,7 @@ public class AlertMockService {
|
|||||||
bb.setTimestamp(System.currentTimeMillis() / 1000);
|
bb.setTimestamp(System.currentTimeMillis() / 1000);
|
||||||
bb.setId(dto.getFrist());
|
bb.setId(dto.getFrist());
|
||||||
bb.setIpRtuStusDown(true);
|
bb.setIpRtuStusDown(true);
|
||||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(), bb, station.getName(), AlertDeviceType.DEVICE_TYPE_RTU, false);
|
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(), bb, station.getName(), AlertDeviceType.DEVICE_TYPE_RTU, true);
|
||||||
}
|
}
|
||||||
case PLATFORM_DOOR_CANNOT_OPEN -> {
|
case PLATFORM_DOOR_CANNOT_OPEN -> {
|
||||||
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||||
@ -121,7 +121,7 @@ public class AlertMockService {
|
|||||||
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
||||||
Platform pf = pfOptional.orElse(null);
|
Platform pf = pfOptional.orElse(null);
|
||||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
|
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
|
||||||
false);
|
true);
|
||||||
}
|
}
|
||||||
case PLATFORM_DOOR_CANNOT_CLOSE -> {
|
case PLATFORM_DOOR_CANNOT_CLOSE -> {
|
||||||
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||||
@ -133,7 +133,7 @@ public class AlertMockService {
|
|||||||
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
platform.setTimestamp(System.currentTimeMillis() / 1000);
|
||||||
Platform pf = pfOptional.orElse(null);
|
Platform pf = pfOptional.orElse(null);
|
||||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
|
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
|
||||||
false);
|
true);
|
||||||
}
|
}
|
||||||
/* case SWITCH_LOST -> {
|
/* case SWITCH_LOST -> {
|
||||||
Optional<Turnout> turnoutOptional = LineGraphicDataRepository.getDevices(lineId, Turnout.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
Optional<Turnout> turnoutOptional = LineGraphicDataRepository.getDevices(lineId, Turnout.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||||
@ -155,7 +155,7 @@ public class AlertMockService {
|
|||||||
switchs.setReceiveTime(System.currentTimeMillis());
|
switchs.setReceiveTime(System.currentTimeMillis());
|
||||||
switchs.setIpSingleSwitchStusLostIndication(true);
|
switchs.setIpSingleSwitchStusLostIndication(true);
|
||||||
Turnout turnout = turnoutOptional.orElse(null);
|
Turnout turnout = turnoutOptional.orElse(null);
|
||||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, dto.getAll(), AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, dto.getAll(), AlertDeviceType.DEVICE_TYPE_SWITCH, true);
|
||||||
}
|
}
|
||||||
case AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST -> {
|
case AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST -> {
|
||||||
Optional<LogicSection> lsOptional = LineGraphicDataRepository.getDevices(lineId, LogicSection.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
Optional<LogicSection> lsOptional = LineGraphicDataRepository.getDevices(lineId, LogicSection.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
|
||||||
@ -164,7 +164,7 @@ public class AlertMockService {
|
|||||||
track.setLineId(dto.getLineId());
|
track.setLineId(dto.getLineId());
|
||||||
track.setTimestamp(System.currentTimeMillis() / 1000);
|
track.setTimestamp(System.currentTimeMillis() / 1000);
|
||||||
LogicSection ls = lsOptional.orElse(null);
|
LogicSection ls = lsOptional.orElse(null);
|
||||||
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_TRACK, ls.getCommon().getId(), track, dto.getAll(), AlertDeviceType.DEVICE_TYPE_TRACK, false);
|
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_TRACK, ls.getCommon().getId(), track, dto.getAll(), AlertDeviceType.DEVICE_TYPE_TRACK, true);
|
||||||
}
|
}
|
||||||
case TRAIN_EB_ATP -> {
|
case TRAIN_EB_ATP -> {
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public class AlertMockService {
|
|||||||
track.setTimestamp(System.currentTimeMillis() / 1000);
|
track.setTimestamp(System.currentTimeMillis() / 1000);
|
||||||
LogicSection ls = lsOptional.orElse(null);
|
LogicSection ls = lsOptional.orElse(null);
|
||||||
|
|
||||||
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, ls.getCommon().getId(), track, "测试车组号", AlertDeviceType.DEVICE_TYPE_TRAIN, false);
|
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, ls.getCommon().getId(), track, "测试车组号", AlertDeviceType.DEVICE_TYPE_TRAIN, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + dto.getAlertType());
|
default -> throw new IllegalStateException("Unexpected value: " + dto.getAlertType());
|
||||||
|
@ -87,22 +87,25 @@ public class AlertRecordService {
|
|||||||
private static final List<String> FILTER_LIST = List.of(TipTimeConfig.EVENING_PEARK.name(), TipTimeConfig.MORN_PEAK.name()/*, TipTimeConfig.NORMAL_UNPEARK.name()*/);
|
private static final List<String> FILTER_LIST = List.of(TipTimeConfig.EVENING_PEARK.name(), TipTimeConfig.MORN_PEAK.name()/*, TipTimeConfig.NORMAL_UNPEARK.name()*/);
|
||||||
|
|
||||||
private AlertTip findTipFromAlertTime(AlertRecord ar, String tipType, Long areaConfigId, boolean hasAreaConfigId) {
|
private AlertTip findTipFromAlertTime(AlertRecord ar, String tipType, Long areaConfigId, boolean hasAreaConfigId) {
|
||||||
int hour = LocalDateTime.now().getHour();
|
|
||||||
if (Objects.nonNull(ar.getAlertTime())) {
|
|
||||||
hour = ar.getAlertTime().getHour();
|
|
||||||
}
|
|
||||||
Collection<AlertTipTimeConfig> collection = this.timeConfigService.getCache();
|
Collection<AlertTipTimeConfig> collection = this.timeConfigService.getCache();
|
||||||
if (CollectionUtils.isEmpty(collection)) {
|
if (CollectionUtils.isEmpty(collection)) {
|
||||||
log.info("高低峰配置数据为空,返回默认的辅助消息");
|
log.info("高低峰配置数据为空,返回默认的辅助消息");
|
||||||
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
|
} else if (Objects.isNull(ar)) {
|
||||||
|
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
} else {
|
} else {
|
||||||
|
int hour = LocalDateTime.now().getHour();
|
||||||
|
if (Objects.nonNull(ar.getAlertTime())) {
|
||||||
|
hour = ar.getAlertTime().getHour();
|
||||||
|
}
|
||||||
int finalHour = hour;
|
int finalHour = hour;
|
||||||
Optional<AlertTipTimeConfig> normalOptional = collection.stream().filter(d -> StringUtils.equals(TipTimeConfig.NORMAL_UNPEARK.name(), d.getTimeType())).findFirst();
|
Optional<AlertTipTimeConfig> normalOptional = collection.stream().filter(d -> StringUtils.equals(TipTimeConfig.NORMAL_UNPEARK.name(), d.getTimeType())).findFirst();
|
||||||
Optional<AlertTipTimeConfig> tipTimeConfigOptional = collection.stream().filter(d -> FILTER_LIST.contains(d.getTimeType()) && finalHour >= d.getStartHour() && finalHour <= d.getEndHour())
|
Optional<AlertTipTimeConfig> tipTimeConfigOptional = collection.stream().filter(d -> FILTER_LIST.contains(d.getTimeType()) && finalHour >= d.getStartHour() && finalHour <= d.getEndHour())
|
||||||
.findAny();
|
.findAny();
|
||||||
if (tipTimeConfigOptional.isEmpty() && normalOptional.isEmpty()) {
|
if (tipTimeConfigOptional.isEmpty() && normalOptional.isEmpty()) {
|
||||||
//高低峰都没有找到
|
//高低峰都没有找到
|
||||||
log.info("高低峰均未匹配,告警时间(小时) {}", finalHour);
|
log.info("高低峰均未匹配,告警时间(小时) {}", hour);
|
||||||
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
return this.findAlertTip(tipType, areaConfigId, Optional.empty(), hasAreaConfigId);
|
||||||
} else if (tipTimeConfigOptional.isPresent()) {
|
} else if (tipTimeConfigOptional.isPresent()) {
|
||||||
//匹配上高峰
|
//匹配上高峰
|
||||||
@ -135,24 +138,39 @@ public class AlertRecordService {
|
|||||||
|
|
||||||
public AlertTip confirm(Long recordId, String tipType, Long areaConfigId) {
|
public AlertTip confirm(Long recordId, String tipType, Long areaConfigId) {
|
||||||
AlertRecord ar = this.alertRecordRepository.getById(recordId);
|
AlertRecord ar = this.alertRecordRepository.getById(recordId);
|
||||||
Long newAreaConfigId = this.findAreaConfig(ar, tipType);
|
Long newAreaConfigId = null;
|
||||||
if (Objects.isNull(newAreaConfigId)) {
|
if (Objects.nonNull(ar)) {
|
||||||
newAreaConfigId = areaConfigId;
|
newAreaConfigId = this.findAreaConfig(ar, tipType);
|
||||||
|
if (Objects.isNull(newAreaConfigId)) {
|
||||||
|
newAreaConfigId = areaConfigId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasAreaConfigId = Objects.nonNull(newAreaConfigId) && newAreaConfigId > 0L;
|
boolean hasAreaConfigId = Objects.nonNull(newAreaConfigId) && newAreaConfigId > 0L;
|
||||||
AlertTip tip = this.findTipFromAlertTime(ar, tipType, newAreaConfigId, hasAreaConfigId);
|
AlertTip tip = this.findTipFromAlertTime(ar, tipType, newAreaConfigId, hasAreaConfigId);
|
||||||
this.alertRecordRepository.update(Wrappers.lambdaUpdate(AlertRecord.class)
|
if (ar.getMock()) {
|
||||||
.set(AlertRecord::getAlertTipId, tip.getId()).set(AlertRecord::getAlarmStatus, 1)
|
this.alertRecordRepository.removeById(ar.getId());
|
||||||
.set(hasAreaConfigId, AlertRecord::getAlertLocationId, newAreaConfigId)
|
} else {
|
||||||
.set(AlertRecord::getAlertType, tipType)
|
this.alertRecordRepository.update(Wrappers.lambdaUpdate(AlertRecord.class)
|
||||||
.eq(AlertRecord::getId, recordId).isNull(AlertRecord::getAlarmStatus));
|
.set(AlertRecord::getAlertTipId, tip.getId()).set(AlertRecord::getAlarmStatus, 1)
|
||||||
|
.set(hasAreaConfigId, AlertRecord::getAlertLocationId, newAreaConfigId)
|
||||||
|
.set(AlertRecord::getAlertType, tipType)
|
||||||
|
.eq(AlertRecord::getId, recordId).isNull(AlertRecord::getAlarmStatus));
|
||||||
|
}
|
||||||
|
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void failAlarm(Long recordId) {
|
public void failAlarm(Long recordId) {
|
||||||
this.alertRecordRepository.update(Wrappers.lambdaUpdate(AlertRecord.class)
|
AlertRecord ar = this.alertRecordRepository.getById(recordId);
|
||||||
.set(AlertRecord::getAlarmStatus, 0)
|
if (ar.getMock()) {
|
||||||
.eq(AlertRecord::getId, recordId).isNull(AlertRecord::getAlarmStatus));
|
this.alertRecordRepository.removeById(ar.getId());
|
||||||
|
} else {
|
||||||
|
this.alertRecordRepository.update(Wrappers.lambdaUpdate(AlertRecord.class)
|
||||||
|
.set(AlertRecord::getAlarmStatus, 0)
|
||||||
|
.eq(AlertRecord::getId, recordId).isNull(AlertRecord::getAlarmStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user