开关车门逻辑调整,一键误报数据校验

This commit is contained in:
tiger_zhou 2023-11-01 13:12:28 +08:00
parent d965607ab7
commit 8792ae9fb6
8 changed files with 75 additions and 45 deletions

View File

@ -101,8 +101,9 @@ public class DeviceStatusChangeResponse extends MessageResponse {
// this.type = DeviceType.DEVICE_TYPE_TRACK;
// }
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(this.type, this.deviceStatus);
if (this.type == DeviceType.DEVICE_TYPE_PLATFORM) {
log.info("接受屏蔽门变更 屏蔽门[{}] 状态[{}] 接受时间[{}]", occName, this.deviceStatus, this.getTime());
if (log.isDebugEnabled()) {
log.info("设备状态变更 设备类型[{}] 设备名称[{}] 状态[{}] 接受时间[{}]", this.type.name(), occName, this.deviceStatus, this.getTime());
}
// DeviceStatusConvertor.fillField(builder, "id", this.devName);
DeviceStatusConvertor.fillField(builder, "id", occName);

View File

@ -52,10 +52,10 @@ public class AxleLedAlertListener implements AlertSourceEventListener<AxleLedAle
@Override
public void accept(AxleLedAlertEvent event) {
Builder o = event.getSource();
String receiveBuildType = o.getDescriptorForType().getName();
// String receiveBuildType = o.getDescriptorForType().getName();
Integer lineId = DeviceStatusDataOperate.findFieldVal(o, "lineId", Integer.class);
String id = DeviceStatusDataOperate.findFieldVal(o, "id", String.class);
log.info("区段光带检测 线路[{}] 设备[{}] 接受类型[{}]", lineId, id, receiveBuildType);
// log.info("区段光带检测 线路[{}] 设备[{}] 接受类型[{}]", lineId, id, receiveBuildType);
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.TRAIN);
@ -102,7 +102,10 @@ public class AxleLedAlertListener implements AlertSourceEventListener<AxleLedAle
}
boolean ledRed = redList.size() == axleSection.getChildrenList().size() && redList.stream().allMatch(d -> d);
boolean orange = orangeList.size() == axleSection.getChildrenList().size() && orangeList.stream().allMatch(d -> d);
if (log.isDebugEnabled()) {
log.info("区段光带 区段 线路[{}] 区段[{}] 红光带占用[{}] 橙光带占用[{}]", trackBuild.getLineId(), trackBuild.getId(), ledRed, orange);
}
this.emit(ledRed, trackBuild, axleSection, AlertType.AXLE_LED_RED);
this.emit(orange, trackBuild, axleSection, AlertType.AXLE_LED_ORANGE);
}

View File

@ -102,53 +102,42 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
return null;
}
private void handle(TrainRecord.Builder record, boolean isUpWay, Platform.Builder platformBuild) {
private void handle(TrainRecord.Builder record, boolean isUpWay, Platform.Builder platformBuild, boolean isOpen, boolean isClose, Plan.Builder planBuild) {
int lineId = record.getLineId();
boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
if (isOpen && isClose && Objects.equals(false, platformBuild.getTrainberth())) {
log.info(
"列车开关过屏蔽门车辆离站,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] 是否靠站[{}]",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId()
, isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), platformBuild.getTrainberth());
this.removeTrainRecord(record);
return;
}
if (isOpen && isClose) {
log.info(
"列车开关过屏蔽门只是等待,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] ",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime());
// this.removeTrainRecordOnly(record);
return;
}
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay);
if (planBuildOpt.isEmpty()) {
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId());
return;
}
Plan.Builder planBuild = planBuildOpt.get();
GuardConfig guardConfig = configService.getGuardConfig(lineId);
long stayTimeSecond = planBuild.getDTime() - planBuild.getATime();
log.info(
"列车是否开关门检测,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}], 到达时间[{}] 计划离站时间[{}],开门[{}],关门[{}] 计划等待时间[{}]",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), planBuild.getATime(),
"列车是否开关门检测,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],屏蔽门是否打开[{}],是否停靠[{}],接收时间[{}], 到达时间[{}] 计划离站时间[{}],开门[{}],关门[{}] 计划等待时间[{}]",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId()
, platformBuild.getPsdOpen(), platformBuild.getTrainberth(),
platformBuild.getReceiveTime(), planBuild.getATime(),
planBuild.getDTime(), isOpen, isClose, stayTimeSecond);
if (!isOpen && !isClose && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) {
if (!isOpen && platformBuild.getTrainberth() && platformBuild.getPsdOpen()) {
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_OPEN, platformBuild.getId());
} else if (isOpen && Objects.equals(false, platformBuild.getPsdOpen())) {
//开门后在阈值内关门
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_CLOSE, platformBuild.getId());
} else if (isOpen && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) {
//车辆停靠只开门 超过等待时间+阈值时间
this.alert(platformBuild, AlertType.PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_IS_CLOSE, isUpWay, record);
} else if (!isOpen && !isClose && platformBuild.getTrainberth() && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) {
//车辆停靠超时,车辆停靠没关门没开门
this.alert(platformBuild, AlertType.PLATFORM_DOOR_CANNOT_OPEN, PLATFORM_IS_OPEN, isUpWay, record);
}
/*if (!isOpen && !isClose && platformBuild.getTrainberth() && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) {
//车辆停靠超时,车辆停靠没关门没开门
this.alert(platformBuild, AlertType.PLATFORM_DOOR_CANNOT_OPEN, PLATFORM_IS_OPEN, isUpWay, record);
} else if (isOpen && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) {
//车辆停靠只开门 超过等待时间+阈值时间
this.alert(platformBuild, AlertType.PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_IS_CLOSE, isUpWay, record);
// this.removeTrainRecordOnly(record);
} else if (platformBuild.getPsdOpen()) {
} else if (!isOpen && platformBuild.getPsdOpen()) {
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_OPEN, platformBuild.getId());
} else if (isOpen && Objects.equals(false, platformBuild.getPsdOpen())) {
//开门后在阈值内关门
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_CLOSE, platformBuild.getId());
}
}*/
}
private void alert(Platform.Builder platformBuild, AlertType alertType, String customName, boolean isUpWay, TrainRecord.Builder record) {
@ -181,7 +170,38 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
if (Objects.nonNull(platformBuild)) {
this.handle(record, isUpWay, platformBuild);
int lineId = record.getLineId();
boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
if (isOpen && isClose && Objects.equals(false, platformBuild.getTrainberth())) {
if (log.isDebugEnabled()) {
log.info(
"列车开关过屏蔽门车辆离站,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] 是否靠站[{}]",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId()
, isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), platformBuild.getTrainberth());
}
this.removeTrainRecord(record);
continue;
}
if (isOpen && isClose) {
if (log.isDebugEnabled()) {
log.info(
"列车开关过屏蔽门只是等待,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] ",
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime());
}
continue;
}
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay);
if (planBuildOpt.isEmpty()) {
if (log.isDebugEnabled()) {
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId());
}
continue;
}
Plan.Builder planBuild = planBuildOpt.get();
this.handle(record, isUpWay, platformBuild, isOpen, isClose, planBuild);
}
}
}

View File

@ -24,10 +24,10 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainR
public void accept(TrainRecordAlertEvent event) {
TrainRecord.Builder trainRecord = event.getSource();
/*log.info("列车报点,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
trainRecord.getRecordType());*/
if (trainRecord.getTrainType() == TrainTypeEnum.PlannedTrain.getType() && trainRecord.getRecordType()) {
log.info("列车报点,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
trainRecord.getRecordType());
this.platformAlertMonitoringTask.putTrainRecord(trainRecord);
} /*
西安3号线正线报点只有到站信息没有离站信息

View File

@ -34,7 +34,7 @@ public class MockLoadData implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
this.nccMockDataService.reset(10);
this.nccMockDataService.reset(20);
AtomicInteger ai = new AtomicInteger(0);
CIRCLE_QUERY_THREAD.scheduleAtFixedRate(() -> {
// this.nccMockDataService.skip(170L, 1100L, 1180L);
@ -42,7 +42,7 @@ public class MockLoadData implements ApplicationRunner {
// return;
// }
loadData();
}, 2500, 2500, TimeUnit.MILLISECONDS);
}, 300, 300, TimeUnit.MILLISECONDS);
}
private void loadData() {

View File

@ -164,6 +164,7 @@ public class AlertRecordService {
}
public void failAlarm(List<Long> recordId) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(CollectionUtils.isNotEmpty(recordId), "请选择对应的报警信息");
this.alertRecordRepository.update(Wrappers.lambdaUpdate(AlertRecord.class)
.set(AlertRecord::getAlarmStatus, 0).in(AlertRecord::getId, recordId)
.isNull(AlertRecord::getAlarmStatus));

View File

@ -8,9 +8,11 @@ spring:
logging:
level:
root: info
club.joylink.xiannccda.ats: info
club.joylink.xiannccda.mapper: debug
file:
path: /usr/xianncc
max-size: 40MB
occ:
host: 127.0.0.1

View File

@ -13,8 +13,11 @@ spring-doc:
logging:
file:
path: /home/joylink/logs/ncc
max-size: 50MB
level:
root: "info"
club.joylink.xiannccda.ats: info
club.joylink.xiannccda.mapper: debug
occ:
host: 10.255.11.15
@ -25,4 +28,4 @@ occ:
mock-alert-test: false
load-mock-history-data: false
#延时加载告警处理
loadAlertTaskDelayMin: 5
loadAlertTaskDelayMin: 0