From 0f3c9b1d0023f6d2000d7ee85dd033e0faba64c3 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Thu, 14 Sep 2023 16:25:05 +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 --- .../message/line3/rep/ActionReportResponse.java | 2 -- .../message/line3/rep/AlarmReportResponse.java | 2 -- .../ats/warn/AllLineBlueAlertListener.java | 15 --------------- .../warn/AxleSwitchTrackLedAlertListener.java | 4 ---- .../ats/warn/SwitchLostAlertMonitoringTask.java | 2 -- .../ats/warn/SwitchLostMostAlertListener.java | 2 -- .../ats/warn/TrainReacrdAlertListener.java | 2 +- .../controller/AlertRecordController.java | 2 +- .../repository/IAlertRecordRepository.java | 5 +++++ .../repository/impl/AlertRecordRepository.java | 8 ++++++++ .../xiannccda/service/AlertRecordService.java | 16 +++------------- .../service/AlertRecordServiceTest.java | 2 +- 12 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/ActionReportResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/ActionReportResponse.java index 7c92b0f..0e4ee4a 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/ActionReportResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/ActionReportResponse.java @@ -1,10 +1,8 @@ package club.joylink.xiannccda.ats.message.line3.rep; -import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; -import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.time.LocalDateTime; import java.util.Arrays; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/AlarmReportResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/AlarmReportResponse.java index 8e5903e..0901b1d 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/AlarmReportResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/AlarmReportResponse.java @@ -1,10 +1,8 @@ package club.joylink.xiannccda.ats.message.line3.rep; -import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; -import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.time.LocalDateTime; import java.util.Arrays; diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/AllLineBlueAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/AllLineBlueAlertListener.java index 354aea4..7e06398 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/AllLineBlueAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/AllLineBlueAlertListener.java @@ -4,29 +4,14 @@ import club.joylink.xiannccda.alert.NccAlertInfo; import club.joylink.xiannccda.alert.core.AlertDeviceType; import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.alert.core.AlertSourceEventListener; -import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository; import club.joylink.xiannccda.ats.warn.AllLineBlueAlertListener.AllLineBlueDisplayAlertEvent; -import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu.Builder; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station; -import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.service.AlertInfoService; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import com.google.common.base.Strings; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java index 966658b..3723fea 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java @@ -15,15 +15,11 @@ import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.DeviceInfoProto; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track; -import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType; -import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.service.AlertInfoService; -import club.joylink.xiannccda.service.config.DeviceGuardConfigService; import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.GeneratedMessageV3.Builder; -import com.google.protobuf.MessageOrBuilder; import java.util.Map; import java.util.Objects; import java.util.Optional; diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java index c72b719..ca2a1d6 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java @@ -11,14 +11,12 @@ import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch.Builder; import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout; -import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.service.AlertInfoService; import club.joylink.xiannccda.service.config.DeviceGuardConfigService; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @Component 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 a39f105..60a81bd 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostMostAlertListener.java @@ -17,9 +17,7 @@ import club.joylink.xiannccda.service.config.DeviceGuardConfigService; import com.google.common.collect.Lists; import java.util.List; import java.util.Optional; -import lombok.Getter; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; 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 c010225..da9a44a 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/TrainReacrdAlertListener.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; @Component public class TrainReacrdAlertListener implements AlertSourceEventListener { - private PlatformAlertMonitoringTask platformAlertMonitoringTask; + private final PlatformAlertMonitoringTask platformAlertMonitoringTask; public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) { this.platformAlertMonitoringTask = platformAlertMonitoringTask; diff --git a/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java b/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java index 3baf1f4..d1042dc 100644 --- a/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java +++ b/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java @@ -80,6 +80,6 @@ public class AlertRecordController { @Operation(summary = "报警统计") @ApiResponse(description = "报警统计") public List reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) { - return this.alertRecordService.report(lineId, reportDTO); + return this.alertRecordRepository.report(lineId, reportDTO); } } diff --git a/src/main/java/club/joylink/xiannccda/repository/IAlertRecordRepository.java b/src/main/java/club/joylink/xiannccda/repository/IAlertRecordRepository.java index bb059f7..456f83d 100644 --- a/src/main/java/club/joylink/xiannccda/repository/IAlertRecordRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/IAlertRecordRepository.java @@ -1,9 +1,12 @@ package club.joylink.xiannccda.repository; import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; +import club.joylink.xiannccda.dto.record.AlertRecordReportDTO; +import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO; import club.joylink.xiannccda.entity.AlertRecord; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; /** *

@@ -16,4 +19,6 @@ import com.baomidou.mybatisplus.extension.service.IService; public interface IAlertRecordRepository extends IService { Page page(AlertRecordQueryDTO queryDTO); + + List report(Integer lineId, AlertRecordReportDTO reportDTO); } 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 5795e19..36c8efb 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/AlertRecordRepository.java @@ -1,6 +1,8 @@ package club.joylink.xiannccda.repository.impl; import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; +import club.joylink.xiannccda.dto.record.AlertRecordReportDTO; +import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO; import club.joylink.xiannccda.entity.AlertRecord; import club.joylink.xiannccda.mapper.AlertRecordMapper; import club.joylink.xiannccda.repository.IAlertRecordRepository; @@ -8,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.List; import org.springframework.stereotype.Service; /** @@ -33,4 +36,9 @@ public class AlertRecordRepository extends ServiceImpl report(Integer lineId, AlertRecordReportDTO reportDTO) { + return this.getBaseMapper().report(reportDTO, lineId); + } } diff --git a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java index 027560b..cae19b0 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java @@ -2,16 +2,13 @@ package club.joylink.xiannccda.service; import club.joylink.xiannccda.alert.NccAlertInfo; import club.joylink.xiannccda.alert.core.AlertDeviceType; -import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; -import club.joylink.xiannccda.dto.record.AlertRecordReportDTO; -import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO; +import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; import club.joylink.xiannccda.entity.AlertRecord; import club.joylink.xiannccda.entity.AlertTip; import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum; import club.joylink.xiannccda.repository.IAlertRecordRepository; -import club.joylink.xiannccda.repository.impl.AlertRecordRepository; import club.joylink.xiannccda.repository.impl.AlertTipRepository; import club.joylink.xiannccda.service.config.DeviceAreaConfigService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -31,14 +28,14 @@ import org.springframework.stereotype.Service; @Slf4j public class AlertRecordService { - private final AlertRecordRepository alertRecordRepository; + private final IAlertRecordRepository alertRecordRepository; private final AlertTipRepository alertTipRepository; private final DeviceAreaConfigService areaConfigService; - public AlertRecordService(AlertRecordRepository alertRecordRepository, AlertTipRepository alertTipRepository, DeviceAreaConfigService areaConfigService) { + public AlertRecordService(IAlertRecordRepository alertRecordRepository, AlertTipRepository alertTipRepository, DeviceAreaConfigService areaConfigService) { this.alertRecordRepository = alertRecordRepository; this.alertTipRepository = alertTipRepository; this.areaConfigService = areaConfigService; @@ -125,11 +122,4 @@ public class AlertRecordService { return nccPage; } - public List report(Integer lineId, AlertRecordReportDTO reportDTO) { -/* if (Objects.nonNull(reportDTO.getBeginDateTime()) && Objects.nonNull(reportDTO.getEndDateTime())) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(reportDTO.getEndDateTime().isAfter(reportDTO.getBeginDateTime()), "开始时间不能大于结束时间"); - }*/ - - return this.alertRecordRepository.getBaseMapper().report(reportDTO, lineId); - } } diff --git a/src/test/java/club/joylink/xiannccda/service/AlertRecordServiceTest.java b/src/test/java/club/joylink/xiannccda/service/AlertRecordServiceTest.java index 1dc396e..72eddd9 100644 --- a/src/test/java/club/joylink/xiannccda/service/AlertRecordServiceTest.java +++ b/src/test/java/club/joylink/xiannccda/service/AlertRecordServiceTest.java @@ -37,7 +37,7 @@ public class AlertRecordServiceTest { public void reportDate() { AlertRecordReportDTO dto = new AlertRecordReportDTO(); // dto.setAlertTypes(List.of(AlertType.AXLE_LED_RED)); - dto.setBeginDateTime(LocalDateTime.parse("2023-09-05 13:21:46", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); +// dto.setBeginDateTime(LocalDateTime.parse("2023-09-05 13:21:46", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); dto.setEndDateTime(LocalDateTime.now()); List list = this.alertRecordService.report(3, dto); System.out.println(JSON.toJSONString(list, Feature.PrettyFormat, Feature.WriteEnumsUsingName));