代码调整

This commit is contained in:
tiger_zhou 2023-09-04 15:13:50 +08:00
parent d72eedf7b7
commit 0038a63ecb
6 changed files with 23 additions and 41 deletions

View File

@ -3,15 +3,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.PlatformAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent; import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import com.google.protobuf.GeneratedMessageV3.Builder; import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List; import java.util.List;

View File

@ -35,21 +35,12 @@ public class DeviceStatusData extends AbstractData {
try { try {
lock.lock(); lock.lock();
if (CollectionUtils.isNotEmpty(this.statusVOMap)) { if (CollectionUtils.isNotEmpty(this.statusVOMap)) {
Map<String, Message> lineDeviceStatus = this.statusVOMap.get(lineId);
this.statusVOMap.get(lineId).clear(); if (CollectionUtils.isNotEmpty(lineDeviceStatus)) {
} lineDeviceStatus.clear();
/*statusMap = this.statusVOMap.get(field);
if (Objects.nonNull(statusMap)) {
for (String key : keys) {
if (StringUtils.isNotEmpty(key)) {
statusMap.remove(key);
}
} }
}*/ }
}/* catch (Exception e) { } finally {
e.printStackTrace();
} */ finally {
lock.unlock(); lock.unlock();
} }
} }

View File

@ -38,7 +38,7 @@ public class TrainDataSource extends AbstractData {
/** /**
* 列车groupId 与所在设备的双向映射 * 列车groupId 与所在设备的双向映射
*/ */
private BiMap<String, String> trainOnDeviceTrackMap = HashBiMap.create(); private BiMap<String, String> trainOnDeviceTrackMap = Maps.synchronizedBiMap(HashBiMap.create());
private final static String TRAIN_INFO_NAME = "TrainInfo"; private final static String TRAIN_INFO_NAME = "TrainInfo";
private final static String TRAIN_INFO_ID = "groupId"; private final static String TRAIN_INFO_ID = "groupId";
@ -87,7 +87,8 @@ public class TrainDataSource extends AbstractData {
*/ */
private void putTrainDeviceMapper(MessageOrBuilder trainInfo) { private void putTrainDeviceMapper(MessageOrBuilder trainInfo) {
if (trainInfo instanceof TrainInfo.Builder trainBuild) { if (trainInfo instanceof TrainInfo.Builder trainBuild) {
trainOnDeviceTrackMap.put(trainBuild.getGroupId(), trainBuild.getDevName());
trainOnDeviceTrackMap.forcePut(trainBuild.getGroupId(), trainBuild.getDevName());
} }
} }

View File

@ -88,7 +88,10 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
if (CollectionUtils.isNotEmpty(builderMap)) { if (CollectionUtils.isNotEmpty(builderMap)) {
GeneratedMessageV3.Builder builder = builderMap.get(platformCode); GeneratedMessageV3.Builder builder = builderMap.get(platformCode);
if (Objects.nonNull(builder)) { if (Objects.nonNull(builder)) {
return (Platform.Builder) builder; Platform.Builder platformBuild = (Platform.Builder) builder;
log.info("车站报点未找到对应的屏蔽门信息,线路[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 屏蔽门状态[{}]"
, record.getLineId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild);
return platformBuild;
} }
log.info("车站报点未找到对应的屏蔽门信息,线路[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]" log.info("车站报点未找到对应的屏蔽门信息,线路[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
, record.getLineId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformCode); , record.getLineId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformCode);
@ -101,7 +104,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
private void handle(TrainRecord.Builder record, boolean isUpWay) { private void handle(TrainRecord.Builder record, boolean isUpWay) {
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay); Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
if (Objects.isNull(platformBuild)) { if (Objects.isNull(platformBuild) || Objects.equals(false, platformBuild.getTrainberth())) {
return; return;
} }
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN); InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
@ -112,20 +115,19 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
, record.getLineId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId()); , record.getLineId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId());
return; return;
} }
int lineId = platformBuild.getLineId(); int lineId = platformBuild.getLineId();
GuardConfig guardConfig = configService.getGuardConfig(lineId); GuardConfig guardConfig = configService.getGuardConfig(lineId);
long stayTimeSecond = planBuild.getDTime() - planBuild.getATime(); long stayTimeSecond = planBuild.getDTime() - planBuild.getATime();
LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(lineId, platformBuild.getId(), LayoutGraphicsProto.Platform.class); LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(lineId, platformBuild.getId(), LayoutGraphicsProto.Platform.class);
if (platformBuild.getTrainberth()) { boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId()); boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId()); if (!isOpen && !isClose && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) {
if (!isOpen && !isClose && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) { this.alert(platform, platformBuild, AlertType.PLATFORM_DOOR_CANNOT_OPEN, PLATFORM_IS_OPEN, isUpWay);
this.alert(platform, platformBuild, AlertType.PLATFORM_DOOR_CANNOT_OPEN, PLATFORM_IS_OPEN, isUpWay); } else if (isOpen && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) {
} else if (isOpen && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) { this.alert(platform, platformBuild, AlertType.PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_IS_CLOSE, isUpWay);
this.alert(platform, platformBuild, AlertType.PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_IS_CLOSE, isUpWay); } else if (platformBuild.getPsdOpen()) {
} else if (platformBuild.getPsdOpen()) { alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_OPEN, platformBuild.getId());
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_OPEN, platformBuild.getId());
}
} }
} }

View File

@ -21,7 +21,7 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainR
if (trainRecord.getTrainType() == TrainTypeEnum.PlannedTrain.getType()) { if (trainRecord.getTrainType() == TrainTypeEnum.PlannedTrain.getType()) {
this.platformAlertMonitoringTask.putTrainRecord(trainRecord); this.platformAlertMonitoringTask.putTrainRecord(trainRecord);
} else { } else {
this.platformAlertMonitoringTask.remoceTrainRecord(trainRecord);
} }
} }
} }

View File

@ -71,10 +71,6 @@ public class LineTrainMessageServer implements IMessageServer {
} }
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder(); WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) { for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
// aaa(trainInfo);
// trainInfoData.fillTypeStatusAndRemove(trainInfo, TrainTypeStatus.TRAIN_BLOCK);
// trainInfoData.fillTypeStatusAndRemove(trainInfo, TrainTypeStatus.TRAIN_REMOVE);
// trainInfoData.fillTypeStatusAndRemove(trainInfo, TrainTypeStatus.TRAIN_RECORD);
trainInfoData.fillTypeStatusAndRemove(trainInfo); trainInfoData.fillTypeStatusAndRemove(trainInfo);
trainInfoData.reput(trainInfo); trainInfoData.reput(trainInfo);
trainMessage.addTrainInfo(trainInfo); trainMessage.addTrainInfo(trainInfo);