代码调整

This commit is contained in:
tiger_zhou 2023-09-14 16:25:05 +08:00
parent 9923d4bc9a
commit 0f3c9b1d00
12 changed files with 19 additions and 43 deletions

View File

@ -1,10 +1,8 @@
package club.joylink.xiannccda.ats.message.line3.rep; 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.MessageResponse;
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
import com.google.protobuf.GeneratedMessageV3.Builder;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;

View File

@ -1,10 +1,8 @@
package club.joylink.xiannccda.ats.message.line3.rep; 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.MessageResponse;
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
import com.google.protobuf.GeneratedMessageV3.Builder;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;

View File

@ -4,29 +4,14 @@ import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType; import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener; 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.AllLineBlueAlertListener.AllLineBlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu.Builder; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu.Builder;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.service.AlertInfoService; 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.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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -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.DeviceInfoProto;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track; 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;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType; 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.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.GeneratedMessageV3;
import com.google.protobuf.GeneratedMessageV3.Builder; import com.google.protobuf.GeneratedMessageV3.Builder;
import com.google.protobuf.MessageOrBuilder;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;

View File

@ -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.DeviceStatusProto.Switch.Builder;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig; import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout; 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.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService; import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component

View File

@ -17,9 +17,7 @@ import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> { public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
private PlatformAlertMonitoringTask platformAlertMonitoringTask; private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) { public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
this.platformAlertMonitoringTask = platformAlertMonitoringTask; this.platformAlertMonitoringTask = platformAlertMonitoringTask;

View File

@ -80,6 +80,6 @@ public class AlertRecordController {
@Operation(summary = "报警统计") @Operation(summary = "报警统计")
@ApiResponse(description = "报警统计") @ApiResponse(description = "报警统计")
public List<AlertRecordReportResponseDTO> reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) { public List<AlertRecordReportResponseDTO> reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) {
return this.alertRecordService.report(lineId, reportDTO); return this.alertRecordRepository.report(lineId, reportDTO);
} }
} }

View File

@ -1,9 +1,12 @@
package club.joylink.xiannccda.repository; package club.joylink.xiannccda.repository;
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; 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.entity.AlertRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* <p> * <p>
@ -16,4 +19,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface IAlertRecordRepository extends IService<AlertRecord> { public interface IAlertRecordRepository extends IService<AlertRecord> {
Page<AlertRecord> page(AlertRecordQueryDTO queryDTO); Page<AlertRecord> page(AlertRecordQueryDTO queryDTO);
List<AlertRecordReportResponseDTO> report(Integer lineId, AlertRecordReportDTO reportDTO);
} }

View File

@ -1,6 +1,8 @@
package club.joylink.xiannccda.repository.impl; package club.joylink.xiannccda.repository.impl;
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO; 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.entity.AlertRecord;
import club.joylink.xiannccda.mapper.AlertRecordMapper; import club.joylink.xiannccda.mapper.AlertRecordMapper;
import club.joylink.xiannccda.repository.IAlertRecordRepository; 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.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -33,4 +36,9 @@ public class AlertRecordRepository extends ServiceImpl<AlertRecordMapper, AlertR
queryWrapper.orderByDesc(AlertRecord::getAlertTime); queryWrapper.orderByDesc(AlertRecord::getAlertTime);
return page(queryDTO, queryWrapper); return page(queryDTO, queryWrapper);
} }
@Override
public List<AlertRecordReportResponseDTO> report(Integer lineId, AlertRecordReportDTO reportDTO) {
return this.getBaseMapper().report(reportDTO, lineId);
}
} }

View File

@ -2,16 +2,13 @@ package club.joylink.xiannccda.service;
import club.joylink.xiannccda.alert.NccAlertInfo; import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType; 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.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.record.AlertRecordReportDTO; import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO;
import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO;
import club.joylink.xiannccda.entity.AlertRecord; import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.entity.AlertTip; import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum; import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import club.joylink.xiannccda.repository.IAlertRecordRepository; import club.joylink.xiannccda.repository.IAlertRecordRepository;
import club.joylink.xiannccda.repository.impl.AlertRecordRepository;
import club.joylink.xiannccda.repository.impl.AlertTipRepository; import club.joylink.xiannccda.repository.impl.AlertTipRepository;
import club.joylink.xiannccda.service.config.DeviceAreaConfigService; import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -31,14 +28,14 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class AlertRecordService { public class AlertRecordService {
private final AlertRecordRepository alertRecordRepository; private final IAlertRecordRepository alertRecordRepository;
private final AlertTipRepository alertTipRepository; private final AlertTipRepository alertTipRepository;
private final DeviceAreaConfigService areaConfigService; private final DeviceAreaConfigService areaConfigService;
public AlertRecordService(AlertRecordRepository alertRecordRepository, AlertTipRepository alertTipRepository, DeviceAreaConfigService areaConfigService) { public AlertRecordService(IAlertRecordRepository alertRecordRepository, AlertTipRepository alertTipRepository, DeviceAreaConfigService areaConfigService) {
this.alertRecordRepository = alertRecordRepository; this.alertRecordRepository = alertRecordRepository;
this.alertTipRepository = alertTipRepository; this.alertTipRepository = alertTipRepository;
this.areaConfigService = areaConfigService; this.areaConfigService = areaConfigService;
@ -125,11 +122,4 @@ public class AlertRecordService {
return nccPage; return nccPage;
} }
public List<AlertRecordReportResponseDTO> 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);
}
} }

View File

@ -37,7 +37,7 @@ public class AlertRecordServiceTest {
public void reportDate() { public void reportDate() {
AlertRecordReportDTO dto = new AlertRecordReportDTO(); AlertRecordReportDTO dto = new AlertRecordReportDTO();
// dto.setAlertTypes(List.of(AlertType.AXLE_LED_RED)); // 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()); dto.setEndDateTime(LocalDateTime.now());
List<AlertRecordReportResponseDTO> list = this.alertRecordService.report(3, dto); List<AlertRecordReportResponseDTO> list = this.alertRecordService.report(3, dto);
System.out.println(JSON.toJSONString(list, Feature.PrettyFormat, Feature.WriteEnumsUsingName)); System.out.println(JSON.toJSONString(list, Feature.PrettyFormat, Feature.WriteEnumsUsingName));