From 8792ae9fb642187d41484f0b8d8c0ee9b09410be Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Wed, 1 Nov 2023 13:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=85=B3=E8=BD=A6=E9=97=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E8=B0=83=E6=95=B4=EF=BC=8C=E4=B8=80=E9=94=AE=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E6=95=B0=E6=8D=AE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../line3/rep/DeviceStatusChangeResponse.java | 5 +- .../ats/warn/AxleLedAlertListener.java | 9 +- .../ats/warn/PlatformAlertMonitoringTask.java | 88 ++++++++++++------- .../ats/warn/TrainReacrdAlertListener.java | 6 +- .../xiannccda/mock/message/MockLoadData.java | 4 +- .../xiannccda/service/AlertRecordService.java | 1 + src/main/resources/application-local.yml | 2 + src/main/resources/application-master.yml | 5 +- 8 files changed, 75 insertions(+), 45 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java index 5c46bc9..2818c2d 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java @@ -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); diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/AxleLedAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/AxleLedAlertListener.java index 486973c..afb1d60 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/AxleLedAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/AxleLedAlertListener.java @@ -52,10 +52,10 @@ public class AxleLedAlertListener implements AlertSourceEventListener d); boolean orange = orangeList.size() == axleSection.getChildrenList().size() && orangeList.stream().allMatch(d -> d); - log.info("区段光带 区段 线路[{}] 区段[{}] 红光带占用[{}] 橙光带占用[{}]", trackBuild.getLineId(), trackBuild.getId(), ledRed, orange); + 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); } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java index 86d1bb0..30f0aab 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java @@ -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 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 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); } } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java index 8fd656f..4dddb93 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java @@ -24,10 +24,10 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener { // 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() { diff --git a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java index 5f8a772..3097108 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java @@ -164,6 +164,7 @@ public class AlertRecordService { } public void failAlarm(List 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)); diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index a111624..7e7e191 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -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 diff --git a/src/main/resources/application-master.yml b/src/main/resources/application-master.yml index daf65ec..b66eda9 100644 --- a/src/main/resources/application-master.yml +++ b/src/main/resources/application-master.yml @@ -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 \ No newline at end of file +loadAlertTaskDelayMin: 0 \ No newline at end of file