From 6e83c145da8c262284c5bd53974b60f427632a36 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 3 Nov 2023 10:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/update.sql | 9 +++++++++ .../xiannccda/alert/AlertListenerJob.java | 2 ++ .../joylink/xiannccda/alert/NccAlertInfo.java | 9 +++++++++ .../alert/core/relieve/vo/RelieveVO.java | 18 ++++++++++++------ .../ats/warn/PlatformAlertMonitoringTask.java | 3 +++ .../ats/warn/SwitchLostMostAlertListener.java | 4 +++- .../dto/record/AlertRecordQueryDTO.java | 3 ++- .../dto/record/AlertRecordReportDTO.java | 2 +- .../joylink/xiannccda/entity/AlertRecord.java | 2 +- .../xiannccda/mock/message/MockLoadData.java | 4 ++-- .../repository/impl/AlertRecordRepository.java | 4 ++++ src/main/resources/application-local.yml | 8 ++++---- .../mybatis/mapper/AlertRecordMapper.xml | 3 +++ 13 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 sql/update.sql diff --git a/sql/update.sql b/sql/update.sql new file mode 100644 index 0000000..5ce177e --- /dev/null +++ b/sql/update.sql @@ -0,0 +1,9 @@ +-- 2023.11.1 begin 已经执行 +alter table alert_record add index alert_time_index(alert_time); +-- 2023.11.1 end + + +-- 2023.11.03 begin +update alert_record set alarm_status = -1 where alarm_status is null; +alter table alert_record add index alarm_status_index(alarm_status); +-- 2023.11.03 end diff --git a/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java b/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java index a6de86e..df91826 100644 --- a/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java +++ b/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.alert; +import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus; import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.entity.AlertRecord; import club.joylink.xiannccda.event.Listener; @@ -68,6 +69,7 @@ public class AlertListenerJob implements ApplicationRunner { record.setAlertDeviceType(nccAlertInfo.getAlertDeviceType().name()); record.setAlertDeviceId(nccAlertInfo.getLocatorDeviceId()); record.setMock(nccAlertInfo.isMock()); + record.setAlarmStatus(AlertStatus.NOT_DO); // record.setAlertLocation(nccAlertInfo.getAlertLocationName()); return record; } diff --git a/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java b/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java index 27b65f4..3e480a2 100644 --- a/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java +++ b/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java @@ -12,6 +12,7 @@ import lombok.Setter; @Getter public class NccAlertInfo implements AlertInfo { + @Setter private Integer id; private String level; @@ -119,4 +120,12 @@ public class NccAlertInfo implements AlertInfo { default -> throw new IllegalStateException("Unexpected value: " + alertType); } } + + public static class AlertStatus { + + public final static int NOT_DO = -1; + public final static int CONFIRM_DO = 1; + public final static int FAIL_DO = 0; + public final static int PERSON_WARN_DO = 2; + } } diff --git a/src/main/java/club/joylink/xiannccda/alert/core/relieve/vo/RelieveVO.java b/src/main/java/club/joylink/xiannccda/alert/core/relieve/vo/RelieveVO.java index fee9b3e..65a51f4 100644 --- a/src/main/java/club/joylink/xiannccda/alert/core/relieve/vo/RelieveVO.java +++ b/src/main/java/club/joylink/xiannccda/alert/core/relieve/vo/RelieveVO.java @@ -5,6 +5,7 @@ import club.joylink.xiannccda.dto.config.relieve.DeviceRelieveDTO; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.entity.RelieveDeviceShere; import club.joylink.xiannccda.entity.RelieveTimeShere; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.google.common.base.Splitter; import io.swagger.v3.oas.annotations.media.Schema; @@ -67,28 +68,33 @@ public class RelieveVO { super(ds); this.relieveName = ds.getRelieveName(); if (StringUtils.isNotEmpty(ds.getRelieveDeviceIds())) { - this.relieveDeviceIds = Splitter.on(StringPool.COMMA).omitEmptyStrings().splitToStream(ds.getRelieveDeviceIds()).sorted().toArray(String[]::new); +// this.relieveDeviceIds = Splitter.on(StringPool.COMMA).omitEmptyStrings().splitToStream(ds.getRelieveDeviceIds()).sorted().toArray(String[]::new); + this.relieveDeviceIds = Splitter.on(StringPool.COMMA).omitEmptyStrings().splitToList(ds.getRelieveDeviceIds()); } } @Schema(description = "设备类型") private String relieveName; @Schema(description = "设备ids") - private String[] relieveDeviceIds; + private List relieveDeviceIds; - public int findExistIndex(String layoutId) { + /*public int findExistIndex(String layoutId) { if (ArrayUtils.isEmpty(this.relieveDeviceIds)) { return -1; } return Arrays.binarySearch(this.relieveDeviceIds, layoutId); - } + }*/ public boolean isExist(String layoutId) { - int d = this.findExistIndex(layoutId); + if (CollectionUtils.isEmpty(this.relieveDeviceIds)) { + return false; + } + return this.relieveDeviceIds.contains(layoutId); + /*int d = this.findExistIndex(layoutId); if (d < 0) { return false; } - return true; + return true;*/ } } } 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 30f0aab..b1f20f0 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java @@ -169,6 +169,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask { for (Builder record : this.trainRecordMap.values()) { boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue(); Platform.Builder platformBuild = this.parsePlatform(record, isUpWay); + if (Objects.nonNull(platformBuild)) { int lineId = record.getLineId(); boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId()); @@ -202,6 +203,8 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask { } Plan.Builder planBuild = planBuildOpt.get(); this.handle(record, isUpWay, platformBuild, isOpen, isClose, planBuild); + } else { + this.removeTrainRecord(record); } } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java index 93c2412..c512736 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java @@ -55,7 +55,9 @@ public class SwitchLostMostAlertListener implements AlertSourceEventListener { private Integer lineId; private LocalDateTime beginDateTime; private LocalDateTime endDateTime; - + + private Integer alertStatus; } diff --git a/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordReportDTO.java b/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordReportDTO.java index d5dd942..bbd5fb1 100644 --- a/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordReportDTO.java +++ b/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordReportDTO.java @@ -11,5 +11,5 @@ public class AlertRecordReportDTO { private List alertTypes; private LocalDateTime beginDateTime; private LocalDateTime endDateTime; - + private Integer alertStatus; } diff --git a/src/main/java/club/joylink/xiannccda/entity/AlertRecord.java b/src/main/java/club/joylink/xiannccda/entity/AlertRecord.java index 095ef6e..50d29e5 100644 --- a/src/main/java/club/joylink/xiannccda/entity/AlertRecord.java +++ b/src/main/java/club/joylink/xiannccda/entity/AlertRecord.java @@ -38,7 +38,7 @@ public class AlertRecord { // private String alertLocation; private Long alertLocationId; private Long alertTipId; - + // 报告状态 null=未处理,0=误报,1=确认 private Integer alarmStatus; private String alertDeviceType; diff --git a/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java b/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java index 4c6b27a..197ea80 100644 --- a/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java +++ b/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java @@ -34,7 +34,7 @@ public class MockLoadData implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - this.nccMockDataService.reset(20); + this.nccMockDataService.reset(10); 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(); - }, 300, 300, TimeUnit.MILLISECONDS); + }, 1500, 1500, TimeUnit.MILLISECONDS); } private void loadData() { diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java index e5a152a..7a3bd1f 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java @@ -36,7 +36,11 @@ public class AlertRecordRepository extends ServiceImpl + + and alarm_status = #{dto.alertStatus} + and alert_time =]]> #{dto.beginDateTime}