Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4408103aaa | ||
|
953294ea31 | ||
|
e93948bdd1 | ||
|
05ad69fc8f | ||
|
e3bf6d927d | ||
|
d785915902 | ||
|
3005199df1 | ||
|
a051e6d8a1 | ||
|
5790fd2cfb | ||
|
1155aa023a | ||
|
3003639596 | ||
|
d1775b570a | ||
|
cbd25c0db1 | ||
|
28727c9eac | ||
|
cc5ab22cb1 | ||
|
38c2005d82 | ||
|
eb06bcf1c9 | ||
|
fda0e3ff79 | ||
|
046e765a1d | ||
|
58609211ee | ||
|
37d5260ee8 | ||
|
4e5c8f0726 | ||
|
fa1a3c9f51 | ||
|
69eed1fc96 | ||
|
b29a5fb5aa | ||
|
ec69eebe65 | ||
|
3c138d6e39 | ||
|
fa9316fcf0 | ||
|
515ce249bd | ||
|
5eedf3ea64 | ||
|
0c00132192 | ||
|
4cd8d0c2e5 | ||
|
3a79ff3942 | ||
|
615b83a681 | ||
|
11ae9ea755 | ||
|
dfdc33b313 | ||
|
37267e56b8 | ||
|
0d47e4af3c | ||
|
f4145b43de | ||
|
6fff56eddc | ||
|
fe2b7611da | ||
|
f25a536d55 | ||
8867818832 | |||
ea41232bc6 |
61
.gitea/workflows/CICD_local_test.yaml
Normal file
61
.gitea/workflows/CICD_local_test.yaml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: local-test分支构建docker并发布运行
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- local-test
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Docker-Build:
|
||||||
|
runs-on: joylink-local233
|
||||||
|
steps:
|
||||||
|
- name: 检出代码
|
||||||
|
uses: https://gitea.joylink.club/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: 设置java环境
|
||||||
|
uses: https://gitea.joylink.club/actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'zulu'
|
||||||
|
cache: 'maven'
|
||||||
|
cache-dependency-path: './pom.xml'
|
||||||
|
- name: 设置Maven环境
|
||||||
|
uses: https://gitea.joylink.club/actions/local-setup-maven@v0.1.1
|
||||||
|
with:
|
||||||
|
maven-version: 3.8.8
|
||||||
|
- name: 构建
|
||||||
|
run: |
|
||||||
|
mvn -Dmaven.test.skip=true clean package
|
||||||
|
- name: 设置 Docker
|
||||||
|
uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1
|
||||||
|
- name: 设置 Docker Buildx
|
||||||
|
uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3
|
||||||
|
- name: docker登录gitea.joylink.club
|
||||||
|
uses: https://gitea.joylink.club/docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.joylink.club
|
||||||
|
username: shengxuqiang
|
||||||
|
password: ${{ secrets.SHENGXUQIANG_PASSWORD }}
|
||||||
|
- name: Docker Build and push
|
||||||
|
uses: https://gitea.joylink.club/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||||
|
- name: 发布到本地测试环境
|
||||||
|
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.LOCAL_233_SSH_HOST }}
|
||||||
|
port: ${{ secrets.LOCAL_233_SSH_PORT }}
|
||||||
|
username: ${{ secrets.LOCAL_233_SSH_USER }}
|
||||||
|
password: ${{ secrets.LOCAL_233_SSH_PASSWORD }}
|
||||||
|
script: |
|
||||||
|
docker rm -f xian-ncc-da-service || echo "xian-ncc-da-service not exist"
|
||||||
|
docker pull gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||||
|
docker run --name xian-ncc-da-service --restart=always --network net --ip 192.168.53.181 -d -e APP_ENV=local-test -p 9081:9081 -v /usr/local/joylink/logs/xianncc:/usr/local/joylink/logs/xianncc gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||||
|
- name: 清理tag为none的镜像
|
||||||
|
run: |
|
||||||
|
docker rmi $(docker images --filter "dangling=true" -q)
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "xian-ncc-da-message"]
|
[submodule "xian-ncc-da-message"]
|
||||||
path = xian-ncc-da-message
|
path = xian-ncc-da-message
|
||||||
url = https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-message.git
|
url = https://gitea.joylink.club/joylink/xian-ncc-da-message.git
|
||||||
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM azul/zulu-openjdk-alpine:17
|
||||||
|
|
||||||
|
ADD target/xian-ncc-da-0.1.jar xian-ncc-da.jar
|
||||||
|
|
||||||
|
ENV APP_ENV=prd
|
||||||
|
EXPOSE 9081
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
CMD java -jar -Dfile.encoding=UTF-8 -Dspring.profiles.active=$APP_ENV /xian-ncc-da.jar
|
39
pom.xml
39
pom.xml
@ -44,7 +44,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
@ -149,8 +152,40 @@
|
|||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>31.1-jre</version>
|
<version>31.1-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-core</artifactId>
|
||||||
|
<version>5.8.33</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>aliyun-central</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/central</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>aliyun-snapshots</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/snapshots</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>aliyun-central</id>
|
||||||
|
<url>https://maven.aliyun.com/repository/central</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -2,12 +2,24 @@ package club.joylink.xiannccda.alert;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||||
|
import club.joylink.xiannccda.ats.cache.config.LineConfig;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.entity.AlertRecord;
|
import club.joylink.xiannccda.entity.AlertRecord;
|
||||||
import club.joylink.xiannccda.event.Listener;
|
import club.joylink.xiannccda.event.Listener;
|
||||||
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
||||||
|
import club.joylink.xiannccda.service.LineInfoService;
|
||||||
import club.joylink.xiannccda.ws.NccAlertMessageServer;
|
import club.joylink.xiannccda.ws.NccAlertMessageServer;
|
||||||
import club.joylink.xiannccda.ws.WsMessageServerManager;
|
import club.joylink.xiannccda.ws.WsMessageServerManager;
|
||||||
|
import io.netty.util.internal.ObjectUtil;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -19,11 +31,14 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
|
|
||||||
private final WsMessageServerManager wsMessageServerManager;
|
private final WsMessageServerManager wsMessageServerManager;
|
||||||
private final IAlertRecordRepository alertRecordRepository;
|
private final IAlertRecordRepository alertRecordRepository;
|
||||||
|
private final LineInfoService lineInfoService;
|
||||||
|
@Autowired
|
||||||
|
private OccServerProto serverProto;
|
||||||
|
|
||||||
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
|
public AlertListenerJob(WsMessageServerManager wsMessageServerManager, IAlertRecordRepository alertRecordRepository, LineInfoService lineInfoService) {
|
||||||
IAlertRecordRepository alertRecordRepository) {
|
|
||||||
this.wsMessageServerManager = wsMessageServerManager;
|
this.wsMessageServerManager = wsMessageServerManager;
|
||||||
this.alertRecordRepository = alertRecordRepository;
|
this.alertRecordRepository = alertRecordRepository;
|
||||||
|
this.lineInfoService = lineInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,13 +46,14 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
//添加报警事件监听器
|
//添加报警事件监听器
|
||||||
addAlertListeners();
|
addAlertListeners();
|
||||||
//注册西安NCC的报警ws消息发送服务
|
//注册西安NCC的报警ws消息发送服务
|
||||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getDefault());
|
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.NCC));
|
||||||
|
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.OCC));
|
||||||
//启动报警源事件监测任务
|
//启动报警源事件监测任务
|
||||||
AlertManager.getDefault().taskStart();
|
AlertManager.getDefault().taskStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAlertListeners() {
|
private void addAlertListeners() {
|
||||||
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
|
|
||||||
AlertManager alertManager = AlertManager.getDefault();
|
AlertManager alertManager = AlertManager.getDefault();
|
||||||
//添加消息
|
//添加消息
|
||||||
alertManager.on(new Listener<NccAlertInfo>() {
|
alertManager.on(new Listener<NccAlertInfo>() {
|
||||||
@ -51,10 +67,25 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
alertInfo.setId(idGenerator.decrementAndGet());
|
alertInfo.setId(idGenerator.decrementAndGet());
|
||||||
}*/
|
}*/
|
||||||
//不论是否mock 都保存数据库
|
//不论是否mock 都保存数据库
|
||||||
AlertRecord record = convertToRecord(alertInfo);
|
|
||||||
alertRecordRepository.save(record);
|
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
|
||||||
alertInfo.setId(record.getId());
|
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
|
||||||
nccAlertMessageServer.addMsg(alertInfo);
|
Optional<LineConfig> optional = lineInfoService.getLineConfig(alertInfo.getLineId());
|
||||||
|
if (optional.isPresent()) {
|
||||||
|
LineConfig lineConfig = optional.get();
|
||||||
|
if (lineConfig.alertTypeExist(lineType, alertInfo.getAlertType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NccAlertInfo cloned = alertInfo.clone2();
|
||||||
|
cloned.setLineType(lineType);
|
||||||
|
AlertRecord record = convertToRecord(cloned);
|
||||||
|
alertRecordRepository.save(record);
|
||||||
|
cloned.setId(record.getId());
|
||||||
|
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
|
||||||
|
nccAlertMessageServer.addMsg(cloned);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -70,6 +101,7 @@ public class AlertListenerJob implements ApplicationRunner {
|
|||||||
record.setAlertDeviceId(nccAlertInfo.getLocatorDeviceId());
|
record.setAlertDeviceId(nccAlertInfo.getLocatorDeviceId());
|
||||||
record.setMock(nccAlertInfo.isMock());
|
record.setMock(nccAlertInfo.isMock());
|
||||||
record.setAlarmStatus(AlertStatus.NOT_DO);
|
record.setAlarmStatus(AlertStatus.NOT_DO);
|
||||||
|
record.setLineType(nccAlertInfo.getLineType());
|
||||||
// record.setAlertLocation(nccAlertInfo.getAlertLocationName());
|
// record.setAlertLocation(nccAlertInfo.getAlertLocationName());
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.alert;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||||
import club.joylink.xiannccda.alert.core.AlertInfo;
|
import club.joylink.xiannccda.alert.core.AlertInfo;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||||
@ -10,8 +11,11 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class NccAlertInfo implements AlertInfo {
|
public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||||
|
|
||||||
|
public NccAlertInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@ -32,6 +36,8 @@ public class NccAlertInfo implements AlertInfo {
|
|||||||
@Setter
|
@Setter
|
||||||
private Integer alarmStatus;
|
private Integer alarmStatus;
|
||||||
private AlertDeviceType alertDeviceType;
|
private AlertDeviceType alertDeviceType;
|
||||||
|
@Setter
|
||||||
|
private LineTypeEnum lineType;
|
||||||
// private AlertType confirmAlertType;
|
// private AlertType confirmAlertType;
|
||||||
|
|
||||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
||||||
@ -50,6 +56,19 @@ public class NccAlertInfo implements AlertInfo {
|
|||||||
this.alertDeviceType = alertDeviceType;
|
this.alertDeviceType = alertDeviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object clone() throws CloneNotSupportedException {
|
||||||
|
return super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NccAlertInfo clone2() {
|
||||||
|
try {
|
||||||
|
return (NccAlertInfo) this.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
|
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
|
||||||
Integer lineId, String alertObject, String locatorDeviceId,
|
Integer lineId, String alertObject, String locatorDeviceId,
|
||||||
Long alertLocationId, AlertDeviceType alertDeviceType) {
|
Long alertLocationId, AlertDeviceType alertDeviceType) {
|
||||||
@ -114,9 +133,12 @@ public class NccAlertInfo implements AlertInfo {
|
|||||||
case BLUE_DISPLAY, PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_DOOR_CANNOT_OPEN,
|
case BLUE_DISPLAY, PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_DOOR_CANNOT_OPEN,
|
||||||
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, TRAIN_DELAY_10, SWITCH_LOST, SWITCH_FW_LOST, SWITCH_All_LOST, SWITCH_DW_LOST,
|
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, TRAIN_DELAY_10, SWITCH_LOST, SWITCH_FW_LOST, SWITCH_All_LOST, SWITCH_DW_LOST,
|
||||||
SWITCH_LOST_MOST, SWITCH_LOST_INTERLOCK_AREA, AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST, TRAIN_EB_ATP,
|
SWITCH_LOST_MOST, SWITCH_LOST_INTERLOCK_AREA, AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST, TRAIN_EB_ATP,
|
||||||
ALL_LINE_BLUE_DISPLAY, AXLE_LED_RED_INTERLOCK_AREA, AXLE_LED_ORANGE_INTERLOCK_AREA -> {
|
ALL_LINE_BLUE_DISPLAY, AXLE_LED_RED_INTERLOCK_AREA, AXLE_LED_ORANGE_INTERLOCK_AREA, SWITCH_JAMMED, PLATFORM_WAIT_TRAIN_MAX_RECORD, HOLD_PLATFORM_STAY_TRAIN_MORE -> {
|
||||||
return "I";
|
return "I";
|
||||||
}
|
}
|
||||||
|
case PLATFORM_EMERG_STOP -> {
|
||||||
|
return "II";
|
||||||
|
}
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,10 @@ public enum AlertDeviceType {
|
|||||||
/**
|
/**
|
||||||
* 列车设备
|
* 列车设备
|
||||||
*/
|
*/
|
||||||
DEVICE_TYPE_TRAIN
|
DEVICE_TYPE_TRAIN,
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站台扣车对应的区段
|
||||||
|
*/
|
||||||
|
LOGIC_DEVICE_TRACK_AREA_FOR_PLATFORM_HOLDER;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class AlertUtil {
|
public class AlertUtil {
|
||||||
|
|
||||||
|
|
||||||
public static Optional<AlertLocation> findLocationByRtuCode(String rtuCode) {
|
public static Optional<AlertLocation> findLocationByRtuCode(String rtuCode) {
|
||||||
switch (rtuCode) {
|
switch (rtuCode) {
|
||||||
case "1" -> {
|
case "1" -> {
|
||||||
|
131
src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java
Normal file
131
src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
package club.joylink.xiannccda.aop;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
|
import club.joylink.xiannccda.constants.SystemContext;
|
||||||
|
import club.joylink.xiannccda.event.OperateEvent;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.AfterThrowing;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.oauth2.jwt.Jwt;
|
||||||
|
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import org.springframework.web.util.UriTemplate;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SystemEventAspect {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtDecoder jwtDecoder;
|
||||||
|
|
||||||
|
@AfterReturning(value = "execution(public * club.joylink.xiannccda.controller..*.*(..))", returning = "returnObj")
|
||||||
|
public void watchRequest(JoinPoint joinPoint, Object returnObj) {
|
||||||
|
OperateEvent obj = this.parseRequestParameter(joinPoint);
|
||||||
|
if (Objects.nonNull(obj)) {
|
||||||
|
obj.setRequestSuccess(1);
|
||||||
|
if (obj.getType() == CommonLogTypeEnum.LOGIN && obj.getSubType() == SubEventType.LOGIN) {
|
||||||
|
Jwt jwt = jwtDecoder.decode(returnObj.toString());
|
||||||
|
String userId = jwt.getClaimAsString("sub");
|
||||||
|
obj.setUserId(Long.parseLong(userId));
|
||||||
|
}
|
||||||
|
SystemContext.publishEvent(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AfterThrowing(value = "execution(public * club.joylink.xiannccda.controller..*.*(..))", throwing = "e")
|
||||||
|
public void watchRequest(JoinPoint joinPoint, Exception e) {
|
||||||
|
OperateEvent oe = this.parseRequestParameter(joinPoint);
|
||||||
|
if (Objects.nonNull(oe)) {
|
||||||
|
oe.setRequestSuccess(0);
|
||||||
|
SystemContext.publishEvent(oe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getUri(String[] uriMapping, String requestUri) {
|
||||||
|
if (ArrayUtils.isEmpty(uriMapping)) {
|
||||||
|
return requestUri;
|
||||||
|
}
|
||||||
|
if (Arrays.stream(uriMapping).anyMatch(StringUtils::isEmpty)) {
|
||||||
|
return requestUri;
|
||||||
|
}
|
||||||
|
return uriMapping[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private OperateEvent parseRequestParameter(JoinPoint joinPoint) {
|
||||||
|
MethodSignature ms = (MethodSignature) joinPoint.getSignature();
|
||||||
|
CommonLogAnno commonLogAnno = ms.getMethod().getDeclaredAnnotation(CommonLogAnno.class);
|
||||||
|
if (Objects.nonNull(commonLogAnno)) {
|
||||||
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||||
|
String uri = request.getRequestURI();
|
||||||
|
String method = request.getMethod();
|
||||||
|
Long userId = this.userId(commonLogAnno.subLogType());
|
||||||
|
GetMapping getMapping = ms.getMethod().getDeclaredAnnotation(GetMapping.class);
|
||||||
|
PostMapping postMapping = ms.getMethod().getDeclaredAnnotation(PostMapping.class);
|
||||||
|
DeleteMapping deleteMapping = ms.getMethod().getDeclaredAnnotation(DeleteMapping.class);
|
||||||
|
Map<String, Object> params = Map.of();
|
||||||
|
if (Objects.nonNull(getMapping)) {
|
||||||
|
String requestURI = this.getUri(getMapping.value(), uri);
|
||||||
|
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||||
|
} else if (Objects.nonNull(postMapping)) {
|
||||||
|
String requestURI = this.getUri(postMapping.value(), uri);
|
||||||
|
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||||
|
|
||||||
|
} else if (Objects.nonNull(deleteMapping)) {
|
||||||
|
String requestURI = this.getUri(deleteMapping.value(), uri);
|
||||||
|
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||||
|
}
|
||||||
|
return new OperateEvent(commonLogAnno.name(), commonLogAnno.logType(), commonLogAnno.subLogType(), uri, method, params, userId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long userId(SubEventType subEventType) {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Long userId = null;
|
||||||
|
if (subEventType != SubEventType.LOGIN) {
|
||||||
|
userId = Long.valueOf(authentication.getName());
|
||||||
|
}
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> getRequestParam(String uriMap, Object[] args) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
int argsIndex = 0;
|
||||||
|
Map<String, Object> uriParamMap = new HashMap<>();
|
||||||
|
UriTemplate ut = new UriTemplate(uriMap);
|
||||||
|
for (String vn : ut.getVariableNames()) {
|
||||||
|
uriParamMap.put(vn, args[argsIndex]);
|
||||||
|
argsIndex++;
|
||||||
|
}
|
||||||
|
params.put("uriParam", uriParamMap);
|
||||||
|
for (; argsIndex < args.length; argsIndex++) {
|
||||||
|
params.put("param", args[argsIndex]);
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ public class LineGraphicDataManage implements ApplicationRunner {
|
|||||||
list.forEach(d -> {
|
list.forEach(d -> {
|
||||||
LineGraphicDataRepository.putLineGraph(d);
|
LineGraphicDataRepository.putLineGraph(d);
|
||||||
if (!SystemContext.getMasterEnv()) {
|
if (!SystemContext.getMasterEnv()) {
|
||||||
LineGraphicDataRepository.initDeviceStationCenter();
|
LineGraphicDataRepository.initDeviceStationCenter(d.getLineId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package club.joylink.xiannccda.ats.cache;
|
package club.joylink.xiannccda.ats.cache;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
@ -11,29 +12,36 @@ import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
|
|||||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer;
|
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.Turnout;
|
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.Turnout;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.AxleCounting;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RtssGraphicStorage;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RtssGraphicStorage;
|
||||||
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.dto.protos.LayoutGraphicsProto.Station;
|
||||||
import club.joylink.xiannccda.entity.PublishedGi;
|
import club.joylink.xiannccda.entity.PublishedGi;
|
||||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.google.common.collect.HashBasedTable;
|
import com.google.common.collect.HashBasedTable;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||||
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.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.MessageOrBuilder;
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -79,7 +87,9 @@ public class LineGraphicDataRepository {
|
|||||||
|
|
||||||
private static final Table<Integer, String, String> TURNOUT_TO_TURNOUT_TRACK = HashBasedTable.create();
|
private static final Table<Integer, String, String> TURNOUT_TO_TURNOUT_TRACK = HashBasedTable.create();
|
||||||
private static final Table<Integer, String, String> LOGIC_SECTION_TO_AXLE_TABLE = HashBasedTable.create();
|
private static final Table<Integer, String, String> LOGIC_SECTION_TO_AXLE_TABLE = HashBasedTable.create();
|
||||||
|
private static final Table<Integer, String, String> turnout_to_switch = HashBasedTable.create();
|
||||||
|
|
||||||
|
public static final Map<Integer, List<Integer>> STATION_SORTS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存线路数据信息
|
* 缓存线路数据信息
|
||||||
@ -88,6 +98,7 @@ public class LineGraphicDataRepository {
|
|||||||
*/
|
*/
|
||||||
public static void putLineGraph(PublishedGi publishGi) {
|
public static void putLineGraph(PublishedGi publishGi) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (publishGi.getLineId() != null) {
|
if (publishGi.getLineId() != null) {
|
||||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
||||||
@ -109,18 +120,15 @@ public class LineGraphicDataRepository {
|
|||||||
|
|
||||||
// 填充line_code_table
|
// 填充line_code_table
|
||||||
fillLineCodeTable(publishGi.getLineId(), storage);
|
fillLineCodeTable(publishGi.getLineId(), storage);
|
||||||
|
|
||||||
Map<String, Map<Integer, Builder>> tmpMaper = lineGraphMap.get(publishGi.getLineId());
|
Map<String, Map<Integer, Builder>> tmpMaper = lineGraphMap.get(publishGi.getLineId());
|
||||||
if (CollectionUtils.isEmpty(tmpMaper)) {
|
if (CollectionUtils.isEmpty(tmpMaper)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<Integer, Builder> turnoutMap = tmpMaper.get(DeviceType.Turnout.name());
|
Map<Integer, Builder> turnoutMap = tmpMaper.get(DeviceType.Turnout.name());
|
||||||
|
|
||||||
Map<Integer, Builder> builderMap = tmpMaper.get(DeviceType.Section.name());
|
Map<Integer, Builder> builderMap = tmpMaper.get(DeviceType.Section.name());
|
||||||
|
|
||||||
for (Section section : storage.getSectionList()) {
|
for (Section section : storage.getSectionList()) {
|
||||||
if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
||||||
|
|
||||||
for (Integer childId : section.getChildrenList()) {
|
for (Integer childId : section.getChildrenList()) {
|
||||||
Builder b = turnoutMap.get(childId);
|
Builder b = turnoutMap.get(childId);
|
||||||
if (b instanceof DeviceInfoProto.Turnout.Builder logicSection) {
|
if (b instanceof DeviceInfoProto.Turnout.Builder logicSection) {
|
||||||
@ -138,54 +146,70 @@ public class LineGraphicDataRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATION_SORTS.computeIfAbsent(publishGi.getLineId(), lineId -> {
|
||||||
|
List<Station> allStation = LineGraphicDataRepository.getDevices(publishGi.getLineId(), LayoutGraphicsProto.Station.class)
|
||||||
|
.filter(d -> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(d.getCode())).toList();
|
||||||
|
List<Integer> stationCodeList = allStation.stream().map(d -> Integer.valueOf(d.getCode())).distinct().sorted().toList();
|
||||||
|
return stationCodeList;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InvalidProtocolBufferException e) {
|
} catch (InvalidProtocolBufferException e) {
|
||||||
log.error("反序列化信息失败", e);
|
log.error("反序列化信息失败", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initDeviceStationCenter() {
|
|
||||||
|
public static void initDeviceStationCenter(Integer lineId) {
|
||||||
log.info("开始初始化地图中设备集中站的归属。。。");
|
log.info("开始初始化地图中设备集中站的归属。。。");
|
||||||
|
|
||||||
for (Integer lineId : line_code_table.rowKeySet()) {
|
DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE);
|
||||||
DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE);
|
InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK);
|
||||||
InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK);
|
;
|
||||||
for (MessageOrBuilder mb : line_code_table.values()) {
|
// for (MessageOrBuilder mb : line_code_table.values()) {
|
||||||
String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class);
|
for (MessageOrBuilder mb : line_code_table.row(lineId).values()) {
|
||||||
Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
|
String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class);
|
||||||
if (Objects.isNull(deviceId) || deviceId == 0) {
|
Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
|
||||||
continue;
|
if (Objects.isNull(deviceId) || deviceId == 0) {
|
||||||
}
|
continue;
|
||||||
Integer rtuId = getStationCenterById(lineId, deviceId.toString());
|
}
|
||||||
if (Objects.isNull(rtuId)) {
|
Integer rtuId = getStationCenterById(lineId, deviceId.toString());
|
||||||
continue;
|
if (Objects.isNull(rtuId)) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
// List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
// List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||||
if (mb instanceof LayoutGraphicsProto.Turnout) {
|
if (mb instanceof LayoutGraphicsProto.Turnout) {
|
||||||
List<GeneratedMessageV3.Builder> sl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SWITCH, deviceCode, rtuId.shortValue());
|
List<GeneratedMessageV3.Builder> sl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SWITCH, deviceCode, rtuId.shortValue());
|
||||||
List<GeneratedMessageV3.Builder> tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue());
|
List<GeneratedMessageV3.Builder> tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue());
|
||||||
dsd.addDevice(sl);
|
dsd.addDevice(sl);
|
||||||
dsd.addDevice(tl);
|
dsd.addDevice(tl);
|
||||||
interLock.addDevice(sl);
|
interLock.addDevice(sl);
|
||||||
}/* else if (mb instanceof LogicSection logicSection) {
|
}/* else if (mb instanceof LogicSection logicSection) {
|
||||||
builders.addAll(this.createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue()));
|
builders.addAll(this.createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue()));
|
||||||
}*/ else if (mb instanceof LayoutGraphicsProto.Section section) {
|
}*/ else if (mb instanceof LayoutGraphicsProto.Section section) {
|
||||||
if (section.getSectionType() == SectionType.Physical) {
|
if (section.getSectionType() == SectionType.Physical) {
|
||||||
for (Integer childId : section.getChildrenList()) {
|
for (Integer childId : section.getChildrenList()) {
|
||||||
MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString());
|
|
||||||
String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString());
|
||||||
dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue()));
|
String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
||||||
interLock.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue()));
|
dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue()));
|
||||||
}
|
interLock.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue()));
|
||||||
}
|
}
|
||||||
} else if (mb instanceof LayoutGraphicsProto.Signal) {
|
|
||||||
dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SIGNAL, deviceCode, rtuId.shortValue()));
|
|
||||||
}
|
}
|
||||||
|
} else if (mb instanceof LayoutGraphicsProto.Signal) {
|
||||||
|
dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SIGNAL, deviceCode, rtuId.shortValue()));
|
||||||
|
} else if (mb instanceof LayoutGraphicsProto.Platform) {
|
||||||
|
dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_PLATFORM, deviceCode, rtuId.shortValue()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Integer> allStation(Integer lineId) {
|
||||||
|
return STATION_SORTS.get(lineId);
|
||||||
|
}
|
||||||
|
|
||||||
private static List<GeneratedMessageV3.Builder> createMsg(Integer lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType dt, String devName, short rtuId) {
|
private static List<GeneratedMessageV3.Builder> createMsg(Integer lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType dt, String devName, short rtuId) {
|
||||||
DeviceStatusChangeResponse statusChange = new DeviceStatusChangeResponse();
|
DeviceStatusChangeResponse statusChange = new DeviceStatusChangeResponse();
|
||||||
@ -195,7 +219,7 @@ public class LineGraphicDataRepository {
|
|||||||
statusChange.setType(dt);
|
statusChange.setType(dt);
|
||||||
statusChange.setDeviceStatus(0);
|
statusChange.setDeviceStatus(0);
|
||||||
statusChange.setRtuId(rtuId);
|
statusChange.setRtuId(rtuId);
|
||||||
return statusChange.generateProto();
|
return statusChange.generateProto(DeviceNameChangerManage.findNameChanger(lineId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getStationCenterById(Integer lineId, String deviceId) {
|
public static Integer getStationCenterById(Integer lineId, String deviceId) {
|
||||||
@ -204,8 +228,13 @@ public class LineGraphicDataRepository {
|
|||||||
if (StringUtils.isEmpty(rtuCode)) {
|
if (StringUtils.isEmpty(rtuCode)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Integer.parseInt(rtuCode);
|
try {
|
||||||
|
return Integer.parseInt(rtuCode);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<Platform> findLayoutPlatformFromSection(Integer lineId, String sectionName) {
|
public static Optional<Platform> findLayoutPlatformFromSection(Integer lineId, String sectionName) {
|
||||||
@ -225,6 +254,12 @@ public class LineGraphicDataRepository {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Collection<Integer> getAllLines() {
|
||||||
|
return lineGraphMap.keySet();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取线路上区段名为【sectionName】的公里标
|
* 获取线路上区段名为【sectionName】的公里标
|
||||||
*
|
*
|
||||||
@ -263,21 +298,42 @@ public class LineGraphicDataRepository {
|
|||||||
|
|
||||||
public static MessageOrBuilder getDeviceByCodeNotException(int lineId, String code) {
|
public static MessageOrBuilder getDeviceByCodeNotException(int lineId, String code) {
|
||||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
|
return mob;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageOrBuilder getDeviceByCode2(int lineId, String code, String t) {
|
||||||
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
||||||
|
String.format("线路[%s]code[%s] deviceid[%s]", lineId, code, t));
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageOrBuilder getDeviceByCode(int lineId, String code) {
|
public static MessageOrBuilder getDeviceByCode(int lineId, String code) {
|
||||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
|
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
||||||
String.format("线路[%s]code[%s]", lineId, code));
|
String.format("线路[%s]code[%s]", lineId, code));
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据道岔code 查找对应的道岔区段
|
||||||
|
*
|
||||||
|
* @param lineId
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String findTurnoutSectionFromTurnoutCode(int lineId, String code) {
|
public static String findTurnoutSectionFromTurnoutCode(int lineId, String code) {
|
||||||
return TURNOUT_TO_TURNOUT_TRACK.get(lineId, code);
|
return TURNOUT_TO_TURNOUT_TRACK.get(lineId, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T getDeviceByCodeNotException(int lineId, String code, Class<T> cls) {
|
||||||
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
|
return (T) mob;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <T> Optional<T> getDeviceOptByCode(int lineId, String code, Class<T> cls) {
|
public static <T> Optional<T> getDeviceOptByCode(int lineId, String code, Class<T> cls) {
|
||||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
if (Objects.isNull(mob)) {
|
if (Objects.isNull(mob)) {
|
||||||
@ -405,7 +461,17 @@ public class LineGraphicDataRepository {
|
|||||||
Map<String, CoordinateConvertor> convertorMap =
|
Map<String, CoordinateConvertor> convertorMap =
|
||||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||||
Map<Integer, Builder> cacheSwitchMap = new HashMap<>(storage.getTurnoutsList().size());
|
Map<Integer, Builder> cacheSwitchMap = new HashMap<>(storage.getTurnoutsList().size());
|
||||||
storage.getTurnoutsList().stream()
|
for (LayoutGraphicsProto.Turnout t : storage.getTurnoutsList()) {
|
||||||
|
List<KilometerSystem> systemList = t.getKilometerSystemList().stream().filter(k -> StringUtils.isNotEmpty(k.getCoordinateSystem())).toList();
|
||||||
|
DeviceInfoProto.Turnout.Builder turnoutBuilder = DeviceInfoProto.Turnout.newBuilder();
|
||||||
|
turnoutBuilder.setId(t.getCommon().getId());
|
||||||
|
turnoutBuilder.setCode(t.getCode());
|
||||||
|
turnoutBuilder.setKilometer(initKilometer(systemList));
|
||||||
|
cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder);
|
||||||
|
convertorCoordinateByTurnoutKM(convertorMap, systemList);
|
||||||
|
}
|
||||||
|
dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap);
|
||||||
|
/* storage.getTurnoutsList().stream()
|
||||||
.forEach(
|
.forEach(
|
||||||
t -> {
|
t -> {
|
||||||
List<KilometerSystem> systemList =
|
List<KilometerSystem> systemList =
|
||||||
@ -419,7 +485,7 @@ public class LineGraphicDataRepository {
|
|||||||
cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder);
|
cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder);
|
||||||
convertorCoordinateByTurnoutKM(convertorMap, systemList);
|
convertorCoordinateByTurnoutKM(convertorMap, systemList);
|
||||||
});
|
});
|
||||||
dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap);
|
dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,7 +542,40 @@ public class LineGraphicDataRepository {
|
|||||||
initConvertorCoordinate(lineId, dataMap, storage);
|
initConvertorCoordinate(lineId, dataMap, storage);
|
||||||
Map<Integer, Builder> sectionMap = dataMap.getOrDefault(DeviceType.Section.name(), Map.of());
|
Map<Integer, Builder> sectionMap = dataMap.getOrDefault(DeviceType.Section.name(), Map.of());
|
||||||
Map<Integer, Builder> turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
Map<Integer, Builder> turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of());
|
||||||
storage.getAxleCountingsList().stream()
|
for (AxleCounting ac : storage.getAxleCountingsList()) {
|
||||||
|
if (StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem())) {
|
||||||
|
long mainLineCoordinate = doConvertorCoordinate(lineId, ac.getKilometerSystem());
|
||||||
|
for (RelatedRef ref : ac.getAxleCountingRefList()) {
|
||||||
|
if (Objects.equals(DeviceType.Section, ref.getDeviceType())) {
|
||||||
|
DeviceInfoProto.Section.Builder b = findSection(sectionMap, ref.getId());
|
||||||
|
if (b != null) {
|
||||||
|
DeviceInfoProto.DeviceKilometer.Builder k = b.getKilometerBuilder();
|
||||||
|
updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate);
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(DeviceType.Turnout, ref.getDeviceType())) {
|
||||||
|
DeviceInfoProto.Turnout.Builder b = findTurnout(turnoutMap, ref.getId());
|
||||||
|
if (b != null) {
|
||||||
|
DeviceInfoProto.DeviceKilometer.Builder k = b.getKilometerBuilder();
|
||||||
|
// 更新道岔自身的公里标数据
|
||||||
|
for (KilometerSystem s : k.getKilometerSystemList()) {
|
||||||
|
long mc = doConvertorCoordinate(lineId, s);
|
||||||
|
updateMinAndMaxKilometer(k, mc);
|
||||||
|
}
|
||||||
|
// 放入当前计轴信息
|
||||||
|
/* updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate);
|
||||||
|
k.getKilometerSystemList()
|
||||||
|
.forEach(
|
||||||
|
s ->
|
||||||
|
updateMinAndMaxKilometer(
|
||||||
|
k, doConvertorCoordinate(lineId, s)));
|
||||||
|
// 放入当前计轴信息
|
||||||
|
updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* storage.getAxleCountingsList().stream()
|
||||||
.filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem()))
|
.filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem()))
|
||||||
.forEach(
|
.forEach(
|
||||||
ac -> {
|
ac -> {
|
||||||
@ -505,7 +604,7 @@ public class LineGraphicDataRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -515,19 +614,76 @@ public class LineGraphicDataRepository {
|
|||||||
* @param dataMap 设备集合
|
* @param dataMap 设备集合
|
||||||
* @param storage 地图信息
|
* @param storage 地图信息
|
||||||
*/
|
*/
|
||||||
private static void initConvertorCoordinate(
|
private static void initConvertorCoordinate(Integer lineId, Map<String, Map<Integer, Builder>> dataMap, LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||||
Integer lineId,
|
|
||||||
Map<String, Map<Integer, Builder>> dataMap,
|
|
||||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
|
||||||
// 强制转换道岔
|
// 强制转换道岔
|
||||||
Map<Integer, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
Map<Integer, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
||||||
if (CollectionUtils.isEmpty(turnoutMap)) {
|
if (CollectionUtils.isEmpty(turnoutMap)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, CoordinateConvertor> convertorMap =
|
|
||||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
Map<String, CoordinateConvertor> convertorMap = lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||||
// 从计轴中转换信息
|
// 从计轴中转换信息
|
||||||
storage
|
for (AxleCounting axle : storage.getAxleCountingsList()) {
|
||||||
|
|
||||||
|
// 筛选出道岔的公里标坐标系
|
||||||
|
List<KilometerSystem> kilometerSystemList = Lists.newArrayList();
|
||||||
|
for (RelatedRef ref : axle.getAxleCountingRefList()) {
|
||||||
|
if (DeviceType.Turnout.equals(ref.getDeviceType()) && turnoutMap.containsKey(ref.getId())) {
|
||||||
|
DeviceInfoProto.Turnout.Builder t = (DeviceInfoProto.Turnout.Builder) turnoutMap.get(ref.getId());
|
||||||
|
if (t.getKilometer().getKilometerSystemCount() > 0) {
|
||||||
|
kilometerSystemList.add(t.getKilometer().getKilometerSystemList().get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* List<KilometerSystem> kilometerSystemList =
|
||||||
|
axle.getAxleCountingRefList().stream()
|
||||||
|
.filter(
|
||||||
|
ref ->
|
||||||
|
DeviceType.Turnout.equals(ref.getDeviceType())
|
||||||
|
&& turnoutMap.containsKey(ref.getId()))
|
||||||
|
.map(ref -> (DeviceInfoProto.Turnout.Builder) turnoutMap.get(ref.getId()))
|
||||||
|
.filter(t -> t.getKilometer().getKilometerSystemCount() > 0)
|
||||||
|
.map(t -> t.getKilometer().getKilometerSystemList().get(0))
|
||||||
|
.toList();*/
|
||||||
|
// 如果关联多个道岔
|
||||||
|
if (kilometerSystemList.size() > 1) {
|
||||||
|
KilometerSystem axleSystem = axle.getKilometerSystem();
|
||||||
|
KilometerSystem sameSystem =
|
||||||
|
kilometerSystemList.stream()
|
||||||
|
.filter(
|
||||||
|
k ->
|
||||||
|
Objects.equals(
|
||||||
|
k.getCoordinateSystem(), axleSystem.getCoordinateSystem()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
KilometerSystem diffSystem =
|
||||||
|
kilometerSystemList.stream()
|
||||||
|
.filter(
|
||||||
|
k ->
|
||||||
|
!Objects.equals(
|
||||||
|
k.getCoordinateSystem(), axleSystem.getCoordinateSystem()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
// 存在不同的坐标系再做处理
|
||||||
|
if (sameSystem != null && diffSystem != null) {
|
||||||
|
String convertorKey =
|
||||||
|
CoordinateConvertor.generateConvertorKey(
|
||||||
|
axleSystem.getCoordinateSystem(), diffSystem.getCoordinateSystem());
|
||||||
|
if (!convertorMap.containsKey(convertorKey)) {
|
||||||
|
// 计轴与相同坐标系岔心之间差值
|
||||||
|
long diffValue = axleSystem.getKilometer() - sameSystem.getKilometer();
|
||||||
|
// 俩岔心到计轴的距离相同,所以另一坐标系的公里标相减差值就是计轴在另一个坐标系的位置
|
||||||
|
// a - x = y - b (x,y为计轴在两坐标系上的坐标)
|
||||||
|
long convertKilometer = diffSystem.getKilometer() - diffValue;
|
||||||
|
// 求出坐标系0点位置
|
||||||
|
CoordinateConvertor convertor =
|
||||||
|
CoordinateConvertor.generate(axleSystem, diffSystem.getCoordinateSystem(), convertKilometer);
|
||||||
|
convertorMap.put(convertorKey, convertor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* storage
|
||||||
.getAxleCountingsList()
|
.getAxleCountingsList()
|
||||||
.forEach(
|
.forEach(
|
||||||
axle -> {
|
axle -> {
|
||||||
@ -574,13 +730,12 @@ public class LineGraphicDataRepository {
|
|||||||
long convertKilometer = diffSystem.getKilometer() - diffValue;
|
long convertKilometer = diffSystem.getKilometer() - diffValue;
|
||||||
// 求出坐标系0点位置
|
// 求出坐标系0点位置
|
||||||
CoordinateConvertor convertor =
|
CoordinateConvertor convertor =
|
||||||
CoordinateConvertor.generate(
|
CoordinateConvertor.generate(axleSystem, diffSystem.getCoordinateSystem(), convertKilometer);
|
||||||
axleSystem, diffSystem.getCoordinateSystem(), convertKilometer);
|
|
||||||
convertorMap.put(convertorKey, convertor);
|
convertorMap.put(convertorKey, convertor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -637,11 +792,9 @@ public class LineGraphicDataRepository {
|
|||||||
return kilometer.getKilometer();
|
return kilometer.getKilometer();
|
||||||
}
|
}
|
||||||
Map<String, CoordinateConvertor> convertorMap = lineCoordinateMain.get(lineId);
|
Map<String, CoordinateConvertor> convertorMap = lineCoordinateMain.get(lineId);
|
||||||
String convertorKey =
|
String convertorKey = CoordinateConvertor.generateConvertorKey(kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE);
|
||||||
CoordinateConvertor.generateConvertorKey(
|
|
||||||
kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE);
|
|
||||||
if (CollectionUtils.isEmpty(convertorMap) || !convertorMap.containsKey(convertorKey)) {
|
if (CollectionUtils.isEmpty(convertorMap) || !convertorMap.containsKey(convertorKey)) {
|
||||||
log.error("无坐标转换规则" + convertorKey);
|
log.error("无坐标转换规则 lineId:{},规则:{}", lineId, convertorKey);
|
||||||
return kilometer.getKilometer();
|
return kilometer.getKilometer();
|
||||||
}
|
}
|
||||||
return convertorMap.get(convertorKey).convertorKilometer(kilometer, CoordinateEnum.MAIN_LINE);
|
return convertorMap.get(convertorKey).convertorKilometer(kilometer, CoordinateEnum.MAIN_LINE);
|
||||||
|
47
src/main/java/club/joylink/xiannccda/ats/cache/config/LineConfig.java
vendored
Normal file
47
src/main/java/club/joylink/xiannccda/ats/cache/config/LineConfig.java
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package club.joylink.xiannccda.ats.cache.config;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
|
import club.joylink.xiannccda.dto.PublishedGIDTO.LineType;
|
||||||
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LineConfig {
|
||||||
|
|
||||||
|
private List<WarnConfig> warnConfig;
|
||||||
|
|
||||||
|
public List<AlertType> getExcludedAlertType(LineTypeEnum lineType) {
|
||||||
|
for (WarnConfig config : this.warnConfig) {
|
||||||
|
if (config.lineType == lineType) {
|
||||||
|
return config.excludeWarn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean alertTypeExist(LineTypeEnum lineType, AlertType alertType) {
|
||||||
|
List<AlertType> atList = this.getExcludedAlertType(lineType);
|
||||||
|
if (CollectionUtils.isEmpty(atList)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return atList.contains(alertType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class WarnConfig {
|
||||||
|
|
||||||
|
|
||||||
|
private LineTypeEnum lineType;
|
||||||
|
private List<AlertType> excludeWarn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ public class FrameSchema {
|
|||||||
* (Multi-flag)为帧标识位,占1字节,值为0或者1,分别表示下面的意思: 1:表示在这帧数据中,一个完整的消息没有发送结束,有后续帧; 0:表示在这帧数据中,消息完整发送,没有后续帧。同样,几个消息可合并成一帧数据发送
|
* (Multi-flag)为帧标识位,占1字节,值为0或者1,分别表示下面的意思: 1:表示在这帧数据中,一个完整的消息没有发送结束,有后续帧; 0:表示在这帧数据中,消息完整发送,没有后续帧。同样,几个消息可合并成一帧数据发送
|
||||||
*/
|
*/
|
||||||
short multiFlag;
|
short multiFlag;
|
||||||
static final short Flag_Multi = 1;
|
public static final short Flag_Multi = 1;
|
||||||
/**
|
/**
|
||||||
* 消息内容,最长为1024字节。它可由一个或多个消息组成,也可以是一个消息的一部分。每个消息由消息标识和消息数据组成
|
* 消息内容,最长为1024字节。它可由一个或多个消息组成,也可以是一个消息的一部分。每个消息由消息标识和消息数据组成
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,9 @@ import io.netty.buffer.Unpooled;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -19,6 +22,8 @@ public class FrameSchemaParse {
|
|||||||
* key = 端口号(表明是实时还是非实时)
|
* key = 端口号(表明是实时还是非实时)
|
||||||
*/
|
*/
|
||||||
private static final Map<Integer, ByteBuf> PACKAGE_DATA_MAP = new ConcurrentHashMap<>();
|
private static final Map<Integer, ByteBuf> PACKAGE_DATA_MAP = new ConcurrentHashMap<>();
|
||||||
|
private static final Map<Integer, ByteBuf> SOURCE_PACKAGE_DATA_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/*private static final ByteBuf INPUT_DATA_BUF = Unpooled.buffer();
|
/*private static final ByteBuf INPUT_DATA_BUF = Unpooled.buffer();
|
||||||
|
|
||||||
public static List<MessageData> decode2(ByteBuf inByteBuf, Integer port) {
|
public static List<MessageData> decode2(ByteBuf inByteBuf, Integer port) {
|
||||||
@ -38,18 +43,27 @@ public class FrameSchemaParse {
|
|||||||
return null;
|
return null;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static List<MessageData> decode(ByteBuf inByteBuf, Integer port) {
|
|
||||||
|
public static DecodeResult decode(ByteBuf inByteBuf, Integer port) {
|
||||||
ByteBuf packageData = PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
ByteBuf packageData = PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
||||||
boolean readComplate = schemaParse(inByteBuf, packageData);
|
ByteBuf sourcePackageData = SOURCE_PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
||||||
|
boolean readComplate = schemaParse(inByteBuf, packageData, sourcePackageData);
|
||||||
if (readComplate) {
|
if (readComplate) {
|
||||||
try {
|
try {
|
||||||
|
DecodeResult dr = new DecodeResult();
|
||||||
List<MessageData> messageDataList = Lists.newArrayList();
|
List<MessageData> messageDataList = Lists.newArrayList();
|
||||||
messageDecode(packageData, messageDataList);
|
messageDecode(packageData, messageDataList);
|
||||||
return messageDataList;
|
dr.data = messageDataList;
|
||||||
|
byte[] data = new byte[sourcePackageData.readableBytes()];
|
||||||
|
sourcePackageData.readBytes(data);
|
||||||
|
dr.sourceData = data;
|
||||||
|
|
||||||
|
return dr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("OCC消息解析异常", e);
|
log.error("OCC消息解析异常", e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
sourcePackageData.clear();
|
||||||
packageData.clear();
|
packageData.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,7 +96,7 @@ public class FrameSchemaParse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean schemaParse(ByteBuf inByteBuf, ByteBuf packageData) {
|
private static boolean schemaParse(ByteBuf inByteBuf, ByteBuf packageData, ByteBuf sourcePackageData) {
|
||||||
inByteBuf.markReaderIndex();
|
inByteBuf.markReaderIndex();
|
||||||
int totalReadables = inByteBuf.readableBytes();
|
int totalReadables = inByteBuf.readableBytes();
|
||||||
if (totalReadables < 4) {
|
if (totalReadables < 4) {
|
||||||
@ -100,9 +114,23 @@ public class FrameSchemaParse {
|
|||||||
log.error("可读内容不足 sysId[{}] totalLen[{}] flag[{}] contentLen[{}] readableBytes[{}]", sysId, totalLength, flag, contentLen, readables);
|
log.error("可读内容不足 sysId[{}] totalLen[{}] flag[{}] contentLen[{}] readableBytes[{}]", sysId, totalLength, flag, contentLen, readables);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// byte[] bb = new byte[contentLen];
|
byte[] bb = new byte[contentLen];
|
||||||
// inByteBuf.readBytes(bb);
|
inByteBuf.readBytes(bb);
|
||||||
packageData.writeBytes(inByteBuf, contentLen);
|
packageData.writeBytes(bb);
|
||||||
|
// packageData.writeBytes(inByteBuf, contentLen);
|
||||||
|
sourcePackageData.writeByte(sysId);
|
||||||
|
sourcePackageData.writeShort(totalLength);
|
||||||
|
sourcePackageData.writeByte(flag);
|
||||||
|
sourcePackageData.writeBytes(bb);
|
||||||
return flag != Flag_Multi;
|
return flag != Flag_Multi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class DecodeResult {
|
||||||
|
|
||||||
|
private List<MessageData> data;
|
||||||
|
private byte[] sourceData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -65,6 +66,7 @@ public abstract class MessageData {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void decode(ByteBuf buf) throws Exception {
|
public void decode(ByteBuf buf) throws Exception {
|
||||||
final int headerBytes = 10;
|
final int headerBytes = 10;
|
||||||
int readableBytes = buf.readableBytes();
|
int readableBytes = buf.readableBytes();
|
||||||
@ -92,7 +94,7 @@ public abstract class MessageData {
|
|||||||
*/
|
*/
|
||||||
public abstract void decode2(ByteBuf buf) throws Exception;
|
public abstract void decode2(ByteBuf buf) throws Exception;
|
||||||
|
|
||||||
public abstract List<GeneratedMessageV3.Builder> generateProto();
|
public abstract List<GeneratedMessageV3.Builder> generateProto(NameChangerEnum nameChanger);
|
||||||
|
|
||||||
|
|
||||||
public void encode(ByteBuf buf) {
|
public void encode(ByteBuf buf) {
|
||||||
@ -115,4 +117,18 @@ public abstract class MessageData {
|
|||||||
return this.length + 2;
|
return this.length + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class DecodeMessageData {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private List<MessageData> messages;
|
||||||
|
|
||||||
|
private byte[] sourceData;
|
||||||
|
|
||||||
|
public DecodeMessageData(Long id, List<MessageData> messages, byte[] sourceData) {
|
||||||
|
this.id = id;
|
||||||
|
this.messages = messages;
|
||||||
|
this.sourceData = sourceData;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,9 +178,9 @@ public enum MessageId {
|
|||||||
/**
|
/**
|
||||||
* 消息对象创建接口
|
* 消息对象创建接口
|
||||||
*/
|
*/
|
||||||
OccMessageCreate omc;
|
public OccMessageCreate omc;
|
||||||
|
|
||||||
interface OccMessageCreate {
|
public interface OccMessageCreate {
|
||||||
|
|
||||||
MessageData create();
|
MessageData create();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,7 +19,7 @@ public abstract class MessageRequest extends MessageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -13,8 +14,9 @@ public abstract class MessageResponse extends MessageData {
|
|||||||
|
|
||||||
public abstract Short getLineId();
|
public abstract Short getLineId();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.FrameSchemaParse.DecodeResult;
|
||||||
|
import club.joylink.xiannccda.ats.message.MessageData.DecodeMessageData;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class OccMessageDecoder extends ByteToMessageDecoder {
|
public class OccMessageDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
@ -21,18 +27,13 @@ public class OccMessageDecoder extends ByteToMessageDecoder {
|
|||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
connection.lastReceiveMessageTime = System.currentTimeMillis();
|
connection.lastReceiveMessageTime = System.currentTimeMillis();
|
||||||
connection.receiveMessageLatest = System.currentTimeMillis();
|
// connection.receiveMessageLatest = System.currentTimeMillis();
|
||||||
|
Long id = IdUtil.getSnowflake().nextId();
|
||||||
// List<MessageData> messages = FrameSchema.decode2(in);
|
DecodeResult dr = FrameSchemaParse.decode(in, this.connection.port);
|
||||||
List<MessageData> messages = FrameSchemaParse.decode(in, this.connection.port);
|
if (Objects.nonNull(dr) && CollectionUtils.isNotEmpty(dr.getData())) {
|
||||||
if (!(messages == null || messages.size() == 0)) {
|
out.add(List.of(new DecodeMessageData(id, dr.getData(), dr.getSourceData())));
|
||||||
// System.out.println(
|
|
||||||
// String.format(
|
|
||||||
// "收到OCC消息: %s 来自 port: %s", this.connection.port,
|
|
||||||
// JSON.toJSONString(
|
|
||||||
// messages.get(0), Feature.PrettyFormat, Feature.FieldBased, Feature.WriteNulls)));
|
|
||||||
|
|
||||||
out.add(messages);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.MessageData.DecodeMessageData;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertorManager;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertorManager;
|
||||||
import club.joylink.xiannccda.ats.message.collect.convertor.DeviceChangeStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.convertor.DeviceChangeStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.collect.convertor.DeviceInitConvertor;
|
import club.joylink.xiannccda.ats.message.collect.convertor.DeviceInitConvertor;
|
||||||
@ -21,7 +22,7 @@ import java.util.List;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageData>> {
|
public class OccMessageHandler extends SimpleChannelInboundHandler<List<DecodeMessageData>> {
|
||||||
|
|
||||||
OccTcpClientConnection connection;
|
OccTcpClientConnection connection;
|
||||||
boolean collectorData;
|
boolean collectorData;
|
||||||
@ -40,7 +41,7 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageD
|
|||||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainInitConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new TrainInitConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRemoveConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new TrainRemoveConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
// DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainUpdateConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new TrainUpdateConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new PlanScheduleConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new PlanScheduleConvertor());
|
||||||
DeviceStatusConvertorManager.addStatusConvertor(new InterLockDeviceBitMapConvertor());
|
DeviceStatusConvertorManager.addStatusConvertor(new InterLockDeviceBitMapConvertor());
|
||||||
@ -58,16 +59,17 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageD
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, List<MessageData> msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, List<DecodeMessageData> msg) throws Exception {
|
||||||
if (msg.stream().anyMatch(d -> d.getMsgId() == MessageId.MESSAGE_POLLING)) {
|
DecodeMessageData messageData = msg.get(0);
|
||||||
|
/* if (messageData.getMessages().stream().anyMatch(d -> d.getMsgId() == MessageId.MESSAGE_POLLING)) {
|
||||||
MessageData md = MessageId.MESSAGE_POLLING.create();
|
MessageData md = MessageId.MESSAGE_POLLING.create();
|
||||||
this.connection.write(md);
|
this.connection.write(md);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (this.collectorData) {
|
if (this.collectorData) {
|
||||||
MockAppContext.publish(msg);
|
MockAppContext.publishCollectorAtsData(messageData);
|
||||||
}
|
}
|
||||||
DeviceStatusConvertorManager.doConvertor(msg);
|
DeviceStatusConvertorManager.doConvertor(this.connection.getNameChanger(), messageData.getMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,35 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import com.google.common.collect.Maps;
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Setter;
|
||||||
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.Value;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import oshi.SystemInfo;
|
|
||||||
import oshi.software.os.OSProcess;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OCC客户端管理
|
* OCC客户端管理
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@Setter
|
||||||
|
@Order(1)
|
||||||
public class OccMessageManage implements ApplicationRunner {
|
public class OccMessageManage implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
@Value("${occ.host}")
|
private OccServerProto occServerProto;
|
||||||
private String serverHost;
|
|
||||||
@Value("${occ.realPort}")
|
|
||||||
private Integer realPort;
|
|
||||||
@Value("${occ.unRealPort}")
|
|
||||||
private Integer unRealPort;
|
|
||||||
@Value("${occ.lineId}")
|
|
||||||
private Integer lineId;
|
|
||||||
@Value("${occ.collectorData:false}")
|
|
||||||
private Boolean collectorData;
|
|
||||||
@Value("${receive-msg-timeout:6}")
|
|
||||||
private Integer receiveMsgTimeout;
|
|
||||||
|
|
||||||
@Value("${monitor-handware-change:false}")
|
|
||||||
private boolean monitorHandwareChange;
|
|
||||||
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
||||||
|
|
||||||
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
||||||
@ -48,6 +40,20 @@ public class OccMessageManage implements ApplicationRunner {
|
|||||||
client.send(md, isRealTime);
|
client.send(md, isRealTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
||||||
|
OccClientMessage clientMessage = this.occServerProto.getClientMessage(lineId);
|
||||||
|
if (Objects.isNull(clientMessage)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(clientMessage.getFilterRtuIds())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (clientMessage.rtuIdExists(rtuId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void registerClient(XianOccMessagingClient client) {
|
public void registerClient(XianOccMessagingClient client) {
|
||||||
clientMap.put(client.lineId, client);
|
clientMap.put(client.lineId, client);
|
||||||
@ -61,13 +67,21 @@ public class OccMessageManage implements ApplicationRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
log.info("初始化 occ tcp连接.... 是否监控cpu,内存信息:{}", this.monitorHandwareChange);
|
|
||||||
|
|
||||||
DeviceNameChangerManage.init();
|
DeviceNameChangerManage.init();
|
||||||
// 读取数据配置,创建客户端
|
this.occServerProto.getClientInfoMap().forEach((k, v) -> {
|
||||||
this.registerClient(new XianOccMessagingClient(this.lineId, this.realPort, this.unRealPort, this.serverHost, this.collectorData, receiveMsgTimeout));
|
log.info("初始化 occ tcp连接.... 是否监控cpu,lineId:{} 内存信息:{} 是否连接:{}", k, v.isMonitorHandwareChange(), v.isConnectionOcc());
|
||||||
for (XianOccMessagingClient client : this.clientMap.values()) {
|
DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger());
|
||||||
client.connect(this.monitorHandwareChange);
|
if (v.isConnectionOcc()) {
|
||||||
}
|
XianOccMessagingClient client = new XianOccMessagingClient(k, v);
|
||||||
|
this.registerClient(client);
|
||||||
|
client.connect(v.isMonitorHandwareChange());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.constants.SystemContext;
|
import club.joylink.xiannccda.constants.SystemContext;
|
||||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
||||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent.SystemWarnConnStateEvent;
|
import club.joylink.xiannccda.ws.msg.SystemWarnEvent.SystemWarnConnStateEvent;
|
||||||
@ -47,20 +48,28 @@ public class OccTcpClientConnection {
|
|||||||
/**
|
/**
|
||||||
* 最后一次接受到消息的时间
|
* 最后一次接受到消息的时间
|
||||||
*/
|
*/
|
||||||
long receiveMessageLatest;
|
// long receiveMessageLatest;
|
||||||
|
/**
|
||||||
|
* 最近一次连接occ 服务时间
|
||||||
|
*/
|
||||||
|
long connectionOccTimeLatest;
|
||||||
|
|
||||||
|
|
||||||
final ReconnectState reconnectState;
|
final ReconnectState reconnectState;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
final boolean isRealPort;
|
final boolean isRealPort;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
final NameChangerEnum nameChanger;
|
||||||
|
|
||||||
public void write(MessageData messageData) {
|
public void write(MessageData messageData) {
|
||||||
if (Objects.nonNull(this.channel)) {
|
if (Objects.nonNull(this.channel)) {
|
||||||
this.channel.writeAndFlush(List.of(messageData));
|
this.channel.writeAndFlush(List.of(messageData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OccTcpClientConnection(XianOccMessagingClient client, String host, int port, boolean collectorData, boolean isRealPort) {
|
public OccTcpClientConnection(XianOccMessagingClient client, String host, int port, boolean collectorData, boolean isRealPort, NameChangerEnum nameChanger) {
|
||||||
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
@ -68,6 +77,7 @@ public class OccTcpClientConnection {
|
|||||||
this.group = new NioEventLoopGroup(1);
|
this.group = new NioEventLoopGroup(1);
|
||||||
this.bootstrap = new Bootstrap();
|
this.bootstrap = new Bootstrap();
|
||||||
this.isRealPort = isRealPort;
|
this.isRealPort = isRealPort;
|
||||||
|
this.nameChanger = nameChanger;
|
||||||
OccTcpClientConnection self = this;
|
OccTcpClientConnection self = this;
|
||||||
bootstrap.group(group)
|
bootstrap.group(group)
|
||||||
.channel(NioSocketChannel.class)
|
.channel(NioSocketChannel.class)
|
||||||
@ -107,7 +117,8 @@ public class OccTcpClientConnection {
|
|||||||
this.lastReceiveMessageTime = System.currentTimeMillis();
|
this.lastReceiveMessageTime = System.currentTimeMillis();
|
||||||
this.channel = channelFuture.channel();
|
this.channel = channelFuture.channel();
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
// this.client.requestBaseData();
|
this.client.requestBaseData();
|
||||||
|
this.connectionOccTimeLatest = System.currentTimeMillis();
|
||||||
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -117,7 +128,6 @@ public class OccTcpClientConnection {
|
|||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.channel = null;
|
this.channel = null;
|
||||||
this.client.resetRequestBaseDataFlag();
|
this.client.resetRequestBaseDataFlag();
|
||||||
|
|
||||||
}
|
}
|
||||||
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
||||||
this.reconnectState.resetState();
|
this.reconnectState.resetState();
|
||||||
@ -125,7 +135,7 @@ public class OccTcpClientConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String hostPortInfo() {
|
String hostPortInfo() {
|
||||||
return String.format("host=%s, port=%s", this.host, this.port);
|
return String.format("lineId=%s,host=%s, port=%s", this.client.getLineId(), this.host, this.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package club.joylink.xiannccda.ats.message;
|
package club.joylink.xiannccda.ats.message;
|
||||||
|
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.req.LoadDeviceStatusRequest;
|
||||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
||||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -21,8 +22,6 @@ import oshi.hardware.GlobalMemory;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class XianOccMessagingClient {
|
public class XianOccMessagingClient {
|
||||||
|
|
||||||
// final int realTimePortBase = 2600;
|
|
||||||
// final int nonRealTimePortBase = 2700;
|
|
||||||
/**
|
/**
|
||||||
* 线路号 实时信息的侦听端口号为2600+line_id,非实时信息的侦听端口号为2700+line_id。 (如对于地铁1号线来说,实时信息的侦听端口号为2601,非实时信息的侦听端口号为2701)
|
* 线路号 实时信息的侦听端口号为2600+line_id,非实时信息的侦听端口号为2700+line_id。 (如对于地铁1号线来说,实时信息的侦听端口号为2601,非实时信息的侦听端口号为2701)
|
||||||
*/
|
*/
|
||||||
@ -45,7 +44,8 @@ public class XianOccMessagingClient {
|
|||||||
|
|
||||||
private final Long requestBaseTime;
|
private final Long requestBaseTime;
|
||||||
|
|
||||||
private final ConnectionTimeOutHandler timeOutHandler = new ConnectionTimeOutHandler();
|
private final ConnectionTimeOutHandler timeOutHandler;
|
||||||
|
|
||||||
|
|
||||||
public void send(MessageData md, boolean isRealTime) {
|
public void send(MessageData md, boolean isRealTime) {
|
||||||
OccTcpClientConnection conn = isRealTime ? rtConnection : nrtConnection;
|
OccTcpClientConnection conn = isRealTime ? rtConnection : nrtConnection;
|
||||||
@ -58,13 +58,15 @@ public class XianOccMessagingClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) {
|
public XianOccMessagingClient(Integer lineId, OccClientMessage clientMessage) {
|
||||||
this.host = host;
|
this.host = clientMessage.getServerHost();
|
||||||
this.lineId = lineId;
|
this.lineId = lineId;
|
||||||
this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout);
|
this.requestBaseTime = TimeUnit.HOURS.toMillis(clientMessage.getReceiveMsgTimeout());
|
||||||
// 创建实时和非实时消息连接
|
// 创建实时和非实时消息连接
|
||||||
this.rtConnection = new OccTcpClientConnection(this, host, realPort, collectorData, true);
|
this.rtConnection = new OccTcpClientConnection(this, host, clientMessage.getRealPort(), clientMessage.getCollectorData(), true, clientMessage.getNameChanger());
|
||||||
this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false);
|
this.nrtConnection = new OccTcpClientConnection(this, host, clientMessage.getUnRealPort(), false, false, clientMessage.getNameChanger());
|
||||||
|
this.timeOutHandler = new ConnectionTimeOutHandler(this.requestBaseTime);
|
||||||
|
|
||||||
this.timeOutHandler.addConnection(this.rtConnection);
|
this.timeOutHandler.addConnection(this.rtConnection);
|
||||||
this.timeOutHandler.addConnection(this.nrtConnection);
|
this.timeOutHandler.addConnection(this.nrtConnection);
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ public class XianOccMessagingClient {
|
|||||||
*/
|
*/
|
||||||
public void resetRequestBaseDataFlag() {
|
public void resetRequestBaseDataFlag() {
|
||||||
//实时数据客户端断开,并且最新的获取时间 + 2小时小于当前时间
|
//实时数据客户端断开,并且最新的获取时间 + 2小时小于当前时间
|
||||||
if (Objects.equals(false, this.rtConnection.connected) && (this.rtConnection.receiveMessageLatest + this.requestBaseTime) < System.currentTimeMillis()) {
|
if (Objects.equals(false, this.rtConnection.connected) /*&& (this.rtConnection.receiveMessageLatest + this.requestBaseTime) < System.currentTimeMillis()*/) {
|
||||||
this.requestBaseDataFlag.set(false);
|
this.requestBaseDataFlag.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +87,10 @@ public class XianOccMessagingClient {
|
|||||||
public void requestBaseData() {
|
public void requestBaseData() {
|
||||||
if (this.rtConnection.connected && this.nrtConnection.connected && this.requestBaseDataFlag.compareAndSet(false, true)) {
|
if (this.rtConnection.connected && this.nrtConnection.connected && this.requestBaseDataFlag.compareAndSet(false, true)) {
|
||||||
log.info("发送计划运行图请求 lineId[{}] host[{}] 实时接口[{}]", this.lineId, this.host, false);
|
log.info("发送计划运行图请求 lineId[{}] host[{}] 实时接口[{}]", this.lineId, this.host, false);
|
||||||
LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
// LoadHistoryTGDataRequest planData = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
||||||
this.send(dataRequest, false);
|
// this.send(planData, false);
|
||||||
|
LoadDeviceStatusRequest dataRequest = new LoadDeviceStatusRequest((short) this.lineId);
|
||||||
|
this.send(dataRequest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +141,11 @@ public class XianOccMessagingClient {
|
|||||||
Executor.shutdownNow();
|
Executor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionTimeOutHandler() {
|
//重新请求基础数据间隔
|
||||||
|
private Long requestBaseTime;
|
||||||
|
|
||||||
|
public ConnectionTimeOutHandler(Long requestBaseTime) {
|
||||||
|
this.requestBaseTime = requestBaseTime;
|
||||||
this.systemInfo = new SystemInfo();
|
this.systemInfo = new SystemInfo();
|
||||||
if (Executor.isShutdown()) {
|
if (Executor.isShutdown()) {
|
||||||
Executor = Executors.newSingleThreadScheduledExecutor();
|
Executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
@ -164,20 +172,6 @@ public class XianOccMessagingClient {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
/* GlobalMemory memory = systemInfo.getHardware().getMemory();
|
|
||||||
long totalMemory = memory.getTotal();
|
|
||||||
long availableMemory = memory.getAvailable();
|
|
||||||
long usedMemory = totalMemory - availableMemory;
|
|
||||||
if (Objects.isNull(this.osProcess)) {
|
|
||||||
return String.format("内存总内存:%s(MB) 使用:%s(MB) 可用:%s(MB)", (totalMemory / 1024 / 1024), (usedMemory / 1024 / 1024),
|
|
||||||
(availableMemory / 1024 / 1024));
|
|
||||||
} else {
|
|
||||||
OSProcess osp = this.systemInfo.getOperatingSystem().getProcess(this.processId);
|
|
||||||
|
|
||||||
double d2 = this.osProcess.getProcessCpuLoadBetweenTicks(osp);
|
|
||||||
return String.format("当前CPU使用:%d%% 内存总内存:%s(MB) 使用:%s(MB) 可用:%s(MB)", Math.round(d2 * 100), (totalMemory / 1024 / 1024), (usedMemory / 1024 / 1024),
|
|
||||||
(availableMemory / 1024 / 1024));
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@ -191,9 +185,13 @@ public class XianOccMessagingClient {
|
|||||||
for (OccTcpClientConnection cc : this.clientConnections) {
|
for (OccTcpClientConnection cc : this.clientConnections) {
|
||||||
if (cc.connected) {
|
if (cc.connected) {
|
||||||
long ctm = System.currentTimeMillis();
|
long ctm = System.currentTimeMillis();
|
||||||
if (cc.lastReceiveMessageTime + HeartBeatTimeout < ctm) {
|
|
||||||
|
/*if (cc.lastReceiveMessageTime + HeartBeatTimeout < ctm) {
|
||||||
log.info("超时未收到OCC消息,尝试断开重连 port :{} 最后一次获取数据时间:{}", cc.port, cc.lastReceiveMessageTime);
|
log.info("超时未收到OCC消息,尝试断开重连 port :{} 最后一次获取数据时间:{}", cc.port, cc.lastReceiveMessageTime);
|
||||||
cc.reconnect();
|
cc.reconnect();
|
||||||
|
}*/
|
||||||
|
if (cc.isRealPort && (cc.connectionOccTimeLatest + requestBaseTime) < ctm) {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cc.reconnect();
|
cc.reconnect();
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
package club.joylink.xiannccda.ats.message.changer;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import com.google.common.collect.HashBasedTable;
|
import com.google.common.collect.HashBasedTable;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -24,10 +26,14 @@ import org.springframework.util.CollectionUtils;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class DeviceNameChangerManage {
|
public class DeviceNameChangerManage {
|
||||||
|
|
||||||
final static Table<Integer, DeviceType, List<NameChangerFilter>> CHANGER_TABLE = HashBasedTable.create();
|
final static Table<NameChangerEnum, DeviceType, List<NameChangerFilter>> CHANGER_TABLE2 = HashBasedTable.create();
|
||||||
private final static Integer TMP_DEFAULT_LINEID = 3;
|
final static Map<Integer, NameChangerEnum> LINEID_NAMECHANGER_MAP = Maps.newHashMap();
|
||||||
|
|
||||||
public static String findMatch(DeviceType deviceType, String occName) {
|
|
||||||
|
public static String findMatch(NameChangerEnum nameChanger, DeviceType deviceType, String occName) {
|
||||||
|
if (nameChanger == NameChangerEnum.NONE) {
|
||||||
|
return occName;
|
||||||
|
}
|
||||||
if (Objects.isNull(deviceType)) {
|
if (Objects.isNull(deviceType)) {
|
||||||
log.debug("错误的设备类型 type[{}]", deviceType);
|
log.debug("错误的设备类型 type[{}]", deviceType);
|
||||||
return occName;
|
return occName;
|
||||||
@ -36,7 +42,7 @@ public class DeviceNameChangerManage {
|
|||||||
log.debug("错误的设备名称 occName[{}]", occName);
|
log.debug("错误的设备名称 occName[{}]", occName);
|
||||||
return occName;
|
return occName;
|
||||||
}
|
}
|
||||||
List<NameChangerFilter> filters = CHANGER_TABLE.get(TMP_DEFAULT_LINEID, deviceType);
|
List<NameChangerFilter> filters = CHANGER_TABLE2.get(nameChanger, deviceType);
|
||||||
if (CollectionUtils.isEmpty(filters)) {
|
if (CollectionUtils.isEmpty(filters)) {
|
||||||
log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
||||||
return occName;
|
return occName;
|
||||||
@ -51,18 +57,93 @@ public class DeviceNameChangerManage {
|
|||||||
return occName;
|
return occName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NameChangerEnum findNameChanger(Integer lineId) {
|
||||||
|
NameChangerEnum nameChanger = LINEID_NAMECHANGER_MAP.get(lineId);
|
||||||
|
if (Objects.isNull(nameChanger)) {
|
||||||
|
|
||||||
|
return NameChangerEnum.UNIVERSAL;
|
||||||
|
}
|
||||||
|
return nameChanger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String findMatch(Integer lineId, DeviceType deviceType, String occName) {
|
||||||
|
NameChangerEnum nameChanger = LINEID_NAMECHANGER_MAP.get(lineId);
|
||||||
|
if (Objects.isNull(nameChanger)) {
|
||||||
|
log.debug("错误的设备类型 type[{}]", deviceType);
|
||||||
|
return occName;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NameChangerFilter> filters = CHANGER_TABLE2.get(nameChanger, deviceType);
|
||||||
|
if (CollectionUtils.isEmpty(filters)) {
|
||||||
|
log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
||||||
|
return occName;
|
||||||
|
}
|
||||||
|
for (NameChangerFilter filter : filters) {
|
||||||
|
String newName = filter.changeDeviceName(occName);
|
||||||
|
if (Objects.nonNull(newName)) {
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.debug("不能转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
||||||
|
|
||||||
|
return occName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.line3.changer", NameChangerFilter.class);
|
List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.changer", NameChangerFilter.class);
|
||||||
List<NameChangerFilter> filters = Lists.newArrayList();
|
// List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.changer.universal", NameChangerFilter.class);
|
||||||
|
Map<NameChangerEnum, List<NameChangerFilter>> nameChnageFilterMapList = Maps.newHashMap();
|
||||||
|
|
||||||
|
for (Class clazz : classes) {
|
||||||
|
NameChanger nc = (NameChanger) clazz.getDeclaredAnnotation(NameChanger.class);
|
||||||
|
if (Objects.nonNull(nc)) {
|
||||||
|
for (NameChangerEnum ncVal : nc.value()) {
|
||||||
|
List<NameChangerFilter> filterList = nameChnageFilterMapList.computeIfAbsent(ncVal, d -> Lists.newArrayList());
|
||||||
|
Object obj = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
filterList.add((NameChangerFilter) obj);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("没有找到对应的配置信息 class:{}", clazz.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Entry<NameChangerEnum, List<NameChangerFilter>> entry : nameChnageFilterMapList.entrySet()) {
|
||||||
|
Map<DeviceType, List<NameChangerFilter>> deviceTypeListMap = entry.getValue().stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType));
|
||||||
|
deviceTypeListMap.forEach((k, v) -> {
|
||||||
|
Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex));
|
||||||
|
CHANGER_TABLE2.put(entry.getKey(), k, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List<NameChangerFilter> filters = Lists.newArrayList();
|
||||||
for (Class clazz : classes) {
|
for (Class clazz : classes) {
|
||||||
Object obj = clazz.getDeclaredConstructor().newInstance();
|
Object obj = clazz.getDeclaredConstructor().newInstance();
|
||||||
filters.add((NameChangerFilter) obj);
|
filters.add((NameChangerFilter) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<DeviceType, List<NameChangerFilter>> filteMaper = filters.stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType));
|
Map<DeviceType, List<NameChangerFilter>> filteMaper = filters.stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType));
|
||||||
filteMaper.forEach((k, v) -> {
|
filteMaper.forEach((k, v) -> {
|
||||||
Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex));
|
Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex));
|
||||||
CHANGER_TABLE.put(TMP_DEFAULT_LINEID, k, v);
|
for (NameChangerFilter ncf : v) {
|
||||||
});
|
NameChanger nc = ncf.getClass().getDeclaredAnnotation(NameChanger.class);
|
||||||
|
if (Objects.isNull(nc)) {
|
||||||
|
log.error("class:{} 没有找到对应的名称处理注解", ncf.getClass().getName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (NameChangerEnum nameChangerEnum : nc.value()) {
|
||||||
|
List<NameChangerFilter> tmpList = CHANGER_TABLE2.get(nameChangerEnum, k);
|
||||||
|
if (Objects.isNull(tmpList)) {
|
||||||
|
tmpList = Lists.newArrayList();
|
||||||
|
CHANGER_TABLE2.put(nameChangerEnum, k, tmpList);
|
||||||
|
}
|
||||||
|
tmpList.add(ncf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initLineIdNameCHanger(Integer lineId, NameChangerEnum nameChanger) {
|
||||||
|
LINEID_NAMECHANGER_MAP.put(lineId, nameChanger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Class> getClassFQName(String packgeName, Class clz) {
|
private static List<Class> getClassFQName(String packgeName, Class clz) {
|
||||||
@ -101,18 +182,18 @@ public class DeviceNameChangerManage {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
DeviceNameChangerManage.init();
|
DeviceNameChangerManage.init();
|
||||||
String d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T13301C");
|
String d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T13301C");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
||||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
||||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T04325G");
|
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T04325G");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
||||||
/*d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "TD_2DG");
|
/*d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "TD_2DG");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
||||||
|
|
||||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, "P02309");
|
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, "P02309");
|
||||||
System.out.println(d);*/
|
System.out.println(d);*/
|
||||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "S03305");
|
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_SIGNAL, "S03305");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
||||||
/* d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "XR");
|
/* d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "XR");
|
||||||
System.out.println(d);
|
System.out.println(d);
|
@ -0,0 +1,17 @@
|
|||||||
|
package club.joylink.xiannccda.ats.message.changer;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
public @interface NameChanger {
|
||||||
|
|
||||||
|
NameChangerEnum[] value() default {};
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package club.joylink.xiannccda.ats.message.changer;
|
||||||
|
|
||||||
|
public enum NameChangerEnum {
|
||||||
|
NONE,
|
||||||
|
//通用
|
||||||
|
UNIVERSAL,
|
||||||
|
LINE_4
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
package club.joylink.xiannccda.ats.message.changer;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
package club.joylink.xiannccda.ats.message.changer.line4;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
|
import cn.hutool.core.util.ReUtil;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class TrackChanger {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 3号线 区段位 T06301A 这样类似的格式
|
||||||
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.LINE_4})
|
||||||
|
public static class Track1Changer implements NameChangerFilter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceType deviceType() {
|
||||||
|
return DeviceType.DEVICE_TYPE_TRACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String changeDeviceName(String sourceName) {
|
||||||
|
if (StringUtils.startsWith(sourceName, "DG")) {
|
||||||
|
int flag = StringUtils.indexOf(sourceName, "-");
|
||||||
|
if (flag > 0) {
|
||||||
|
return sourceName.substring(0, flag);
|
||||||
|
}
|
||||||
|
return sourceName;
|
||||||
|
}
|
||||||
|
return sourceName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -10,6 +13,7 @@ public class SignalChanger {
|
|||||||
/**
|
/**
|
||||||
* X10301 /XR
|
* X10301 /XR
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class Signal1Changer implements NameChangerFilter {
|
public static class Signal1Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,6 +41,7 @@ public class SignalChanger {
|
|||||||
/**
|
/**
|
||||||
* X1506_L2
|
* X1506_L2
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class Signal2Changer implements NameChangerFilter {
|
public static class Signal2Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -13,6 +16,7 @@ public class SwitchChanger {
|
|||||||
/**
|
/**
|
||||||
* 道岔物理区段转换
|
* 道岔物理区段转换
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class SwitchDGChanger implements NameChangerFilter {
|
public static class SwitchDGChanger implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,6 +38,8 @@ public class SwitchChanger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
|
|
||||||
public static class Switch1Changer implements NameChangerFilter {
|
public static class Switch1Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -10,6 +13,7 @@ public class TrackChanger {
|
|||||||
/**
|
/**
|
||||||
* 处理 3号线 区段位 T06301A 这样类似的格式
|
* 处理 3号线 区段位 T06301A 这样类似的格式
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class Track1Changer implements NameChangerFilter {
|
public static class Track1Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,6 +36,7 @@ public class TrackChanger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
/**
|
/**
|
||||||
* 处理区段 T11301 这样类似的格式
|
* 处理区段 T11301 这样类似的格式
|
||||||
*/
|
*/
|
||||||
@ -63,6 +68,7 @@ public class TrackChanger {
|
|||||||
/**
|
/**
|
||||||
* 处理区段 TP_D33G 这样类似的格式
|
* 处理区段 TP_D33G 这样类似的格式
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class Track2Changer implements NameChangerFilter {
|
public static class Track2Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,6 +90,7 @@ public class TrackChanger {
|
|||||||
/**
|
/**
|
||||||
* 处理区段 T150406 这样类似的格式
|
* 处理区段 T150406 这样类似的格式
|
||||||
*/
|
*/
|
||||||
|
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||||
public static class Track3Changer implements NameChangerFilter {
|
public static class Track3Changer implements NameChangerFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -2,9 +2,13 @@ package club.joylink.xiannccda.ats.message.collect;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** 消息数据额外转换时间,比如:线路的数据转换为线网数据 */
|
/**
|
||||||
|
* 消息数据额外转换时间,比如:线路的数据转换为线网数据
|
||||||
|
*/
|
||||||
public abstract class DeviceStatusConvertor {
|
public abstract class DeviceStatusConvertor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,6 +18,8 @@ public abstract class DeviceStatusConvertor {
|
|||||||
*/
|
*/
|
||||||
public abstract MessageId getMessageId();
|
public abstract MessageId getMessageId();
|
||||||
|
|
||||||
/** 任务执行逻辑 */
|
/**
|
||||||
public abstract void run(List<MessageData> messageDataList);
|
* 任务执行逻辑
|
||||||
|
*/
|
||||||
|
public abstract void run(NameChangerEnum nameChanger, List<MessageData> messageDataList);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -13,6 +14,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class DeviceStatusConvertorManager {
|
public class DeviceStatusConvertorManager {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息类型,与转换列表
|
* 消息类型,与转换列表
|
||||||
*/
|
*/
|
||||||
@ -48,14 +50,14 @@ public class DeviceStatusConvertorManager {
|
|||||||
*
|
*
|
||||||
* @param dataList 消息数据列表
|
* @param dataList 消息数据列表
|
||||||
*/
|
*/
|
||||||
public static void doConvertor(List<MessageData> dataList) {
|
public static void doConvertor(NameChangerEnum nameChanger, List<MessageData> dataList) {
|
||||||
dataList.stream()
|
dataList.stream()
|
||||||
.filter(m -> CONVERTOR_MAP.containsKey(m.getMsgId()))
|
.filter(m -> CONVERTOR_MAP.containsKey(m.getMsgId()))
|
||||||
.collect(Collectors.groupingBy(MessageData::getMsgId))
|
.collect(Collectors.groupingBy(MessageData::getMsgId))
|
||||||
.forEach((k, v) -> CONVERTOR_MAP.get(k).values().forEach(c -> c.run(v)));
|
.forEach((k, v) -> CONVERTOR_MAP.get(k).values().forEach(c -> c.run(nameChanger, v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doConvertor(MessageData md) {
|
public static void doConvertor(NameChangerEnum nameChanger, MessageData md) {
|
||||||
doConvertor(Collections.singletonList(md));
|
doConvertor(nameChanger, Collections.singletonList(md));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
@ -60,25 +61,23 @@ public abstract class DeviceStatusDataOperate {
|
|||||||
.forEach(
|
.forEach(
|
||||||
(k, v) -> {
|
(k, v) -> {
|
||||||
// 当前的设备状态
|
// 当前的设备状态
|
||||||
Map<String, Builder> deviceStatusMap =
|
Map<String, Builder> deviceStatusMap = allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size()));
|
||||||
allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size()));
|
|
||||||
// 新的设备状态
|
// 新的设备状态
|
||||||
Map<String, Builder> newDeviceMap =
|
Map<String, Builder> newDeviceMap = v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> {
|
||||||
v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> {
|
Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class);
|
||||||
Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class);
|
Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class);
|
||||||
Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class);
|
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
||||||
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
if (collTime >= curTime) {
|
||||||
if (collTime >= curTime) {
|
|
||||||
return v2;
|
|
||||||
} else {
|
|
||||||
return v1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v2;
|
return v2;
|
||||||
}));
|
} else {
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return v2;
|
||||||
|
}));
|
||||||
// 对比结果
|
// 对比结果
|
||||||
Map<String, Message> compareMap = compare(deviceStatusMap, newDeviceMap);
|
Map<String, Message> compareMap = compare(deviceStatusMap, newDeviceMap);
|
||||||
if (!CollectionUtils.isEmpty(compareMap) && (!(data instanceof DeviceStatusData))) {
|
if (!CollectionUtils.isEmpty(compareMap)/* && ((data instanceof DeviceStatusData))*/) {
|
||||||
statusVOMap.put(k, compareMap);
|
statusVOMap.put(k, compareMap);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -177,6 +176,12 @@ public abstract class DeviceStatusDataOperate {
|
|||||||
Long collTime = DeviceStatusDataOperate.findFieldVal(v, "timestamp", Long.class);
|
Long collTime = DeviceStatusDataOperate.findFieldVal(v, "timestamp", Long.class);
|
||||||
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
||||||
if (collTime >= curTime) {
|
if (collTime >= curTime) {
|
||||||
|
if (v instanceof Platform.Builder pfb) {
|
||||||
|
Platform.Builder oldpfb = (Platform.Builder) curBuild;
|
||||||
|
pfb.setBizWaitTimerGoing(oldpfb.getBizWaitTimerGoing());
|
||||||
|
pfb.setBizWaitStartTimeSec(oldpfb.getBizWaitStartTimeSec());
|
||||||
|
pfb.setBizWaitTimerGoing(pfb.getBizWaitTimerGoing());
|
||||||
|
}
|
||||||
Message message = v.build();
|
Message message = v.build();
|
||||||
curMap.put(k, v.clone());
|
curMap.put(k, v.clone());
|
||||||
messageMap.put(k, message);
|
messageMap.put(k, message);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package club.joylink.xiannccda.ats.message.collect.convertor;
|
package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
@ -21,6 +23,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
||||||
|
|
||||||
@ -45,15 +48,37 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
|||||||
return responseList.stream().collect(Collectors.groupingBy(MessageResponse::getLineId));
|
return responseList.stream().collect(Collectors.groupingBy(MessageResponse::getLineId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tmpChangeLine4Name(Integer lineId, GeneratedMessageV3.Builder msg) {
|
||||||
|
|
||||||
|
if (lineId == 4 && msg instanceof TrainInfo.Builder ti) {
|
||||||
|
String deviceName = ti.getDevName();
|
||||||
|
if (StringUtils.startsWith(deviceName, "P")) {
|
||||||
|
String occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineId, deviceName);
|
||||||
|
if (StringUtils.isNotEmpty(occName)) {
|
||||||
|
ti.setDevName(occName);
|
||||||
|
}
|
||||||
|
} else if (StringUtils.startsWith(deviceName, "DG")) {
|
||||||
|
int flag = StringUtils.indexOf(deviceName, "-");
|
||||||
|
if (flag > 0) {
|
||||||
|
String newName = deviceName.substring(0, flag);
|
||||||
|
ti.setDevName(newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (lineId == 4 && msg instanceof TrainRemove.Builder re) {
|
||||||
|
System.out.println(re.getDevName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(List<MessageData> messageDataList) {
|
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||||
Map<Short, List<MessageResponse>> lineMapper = this.groupByLineId(messageDataList);
|
Map<Short, List<MessageResponse>> lineMapper = this.groupByLineId(messageDataList);
|
||||||
lineMapper.forEach((k, v) -> {
|
lineMapper.forEach((k, v) -> {
|
||||||
List<GeneratedMessageV3.Builder> builders = v.stream().map(MessageResponse::generateProto)
|
List<GeneratedMessageV3.Builder> builders = v.stream().map(d -> d.generateProto(nameChanger))
|
||||||
.flatMap(Collection::stream).filter(d -> {
|
.flatMap(Collection::stream).filter(d -> {
|
||||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class);
|
Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class);
|
||||||
Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class);
|
Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class);
|
||||||
if (d instanceof TrainInfo.Builder || d instanceof TrainRemove.Builder) {
|
if (d instanceof TrainInfo.Builder ti || d instanceof TrainRemove.Builder) {
|
||||||
|
tmpChangeLine4Name(lineId, d);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return SystemContext.notMatchRtu(lineId, rtuId);
|
return SystemContext.notMatchRtu(lineId, rtuId);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package club.joylink.xiannccda.ats.message.collect.convertor;
|
package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataRepository;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
|
import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer;
|
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer;
|
||||||
@ -56,10 +57,10 @@ public abstract class LineNetTrainComMethod {
|
|||||||
* @param type 所在设备类型
|
* @param type 所在设备类型
|
||||||
* @param deviceName 设备名称
|
* @param deviceName 设备名称
|
||||||
*/
|
*/
|
||||||
public static void setUpKilometerCode(
|
public static void setUpKilometerCode(NameChangerEnum nameChanger,
|
||||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj, DeviceType type, String deviceName) {
|
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj, DeviceType type, String deviceName) {
|
||||||
// 获取到当前区段公里标
|
// 获取到当前区段公里标
|
||||||
DeviceKilometer.Builder km = getDeviceKM(obj.getLineId(), type, deviceName);
|
DeviceKilometer.Builder km = getDeviceKM(nameChanger, obj.getLineId(), type, deviceName);
|
||||||
if (km != null) {
|
if (km != null) {
|
||||||
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), km));
|
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), km));
|
||||||
} else {
|
} else {
|
||||||
@ -76,14 +77,14 @@ public abstract class LineNetTrainComMethod {
|
|||||||
* @param type 设备类型
|
* @param type 设备类型
|
||||||
* @param name 设备名称
|
* @param name 设备名称
|
||||||
*/
|
*/
|
||||||
public static void setTrainDirectionAndKilometerCode(
|
public static void setTrainDirectionAndKilometerCode(NameChangerEnum nameChanger,
|
||||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
||||||
String globalId,
|
String globalId,
|
||||||
String destinationCode,
|
String destinationCode,
|
||||||
DeviceType type,
|
DeviceType type,
|
||||||
String name) {
|
String name) {
|
||||||
TrainRunDirection direction = null;
|
TrainRunDirection direction = null;
|
||||||
DeviceKilometer.Builder deviceKm = getDeviceKM(obj.getLineId(), type, name);
|
DeviceKilometer.Builder deviceKm = getDeviceKM(nameChanger, obj.getLineId(), type, name);
|
||||||
if (deviceKm != null && StringUtils.isNoneEmpty(destinationCode)) {
|
if (deviceKm != null && StringUtils.isNoneEmpty(destinationCode)) {
|
||||||
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
||||||
// 目的地最大公里标大于设备最大公里标,上行
|
// 目的地最大公里标大于设备最大公里标,上行
|
||||||
@ -120,13 +121,13 @@ public abstract class LineNetTrainComMethod {
|
|||||||
* @param name 设备名称
|
* @param name 设备名称
|
||||||
* @return 公里标列表
|
* @return 公里标列表
|
||||||
*/
|
*/
|
||||||
private static DeviceKilometer.Builder getDeviceKM(int lineId, DeviceType type, String name) {
|
private static DeviceKilometer.Builder getDeviceKM(NameChangerEnum nameChanger, int lineId, DeviceType type, String name) {
|
||||||
// 非区段、道岔直接返回
|
// 非区段、道岔直接返回
|
||||||
if (!DeviceType.DEVICE_TYPE_TRACK.equals(type) && !DeviceType.DEVICE_TYPE_SWITCH.equals(type)) {
|
if (!DeviceType.DEVICE_TYPE_TRACK.equals(type) && !DeviceType.DEVICE_TYPE_SWITCH.equals(type)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 转换成程序中的名称
|
// 转换成程序中的名称
|
||||||
String convertName = DeviceNameChangerManage.findMatch(type, name);
|
String convertName = DeviceNameChangerManage.findMatch(nameChanger, type, name);
|
||||||
// 获取到当前区段公里标
|
// 获取到当前区段公里标
|
||||||
return LineGraphicDataRepository.getKilometerCodeList(lineId, convertName);
|
return LineGraphicDataRepository.getKilometerCodeList(lineId, convertName);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse;
|
||||||
@ -13,16 +14,19 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/** 接收列车初始化消息,就收转换线网的列车数据 */
|
/**
|
||||||
|
* 接收列车初始化消息,就收转换线网的列车数据
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessageId getMessageId() {
|
public MessageId getMessageId() {
|
||||||
return MessageId.TRAIN_INDICATION_INIT;
|
return MessageId.TRAIN_INDICATION_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(List<MessageData> messageDataList) {
|
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||||
List<Builder> buildList = Lists.newArrayList();
|
List<Builder> buildList = Lists.newArrayList();
|
||||||
try {
|
try {
|
||||||
for (MessageData data : messageDataList) {
|
for (MessageData data : messageDataList) {
|
||||||
@ -35,7 +39,7 @@ public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
|||||||
offset.setLineId(response.getLineId()); // 线路id
|
offset.setLineId(response.getLineId()); // 线路id
|
||||||
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
||||||
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
||||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||||
offset,
|
offset,
|
||||||
trainCell.getGlobalId(),
|
trainCell.getGlobalId(),
|
||||||
trainCell.getDestinationId(),
|
trainCell.getDestinationId(),
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
@ -23,7 +24,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(List<MessageData> messageDataList) {
|
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||||
try {
|
try {
|
||||||
List<Builder> buildList = Lists.newArrayList();
|
List<Builder> buildList = Lists.newArrayList();
|
||||||
// 已存在的设备信息
|
// 已存在的设备信息
|
||||||
@ -37,7 +38,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
|||||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||||
offset.setDir(response.getDirection().getValue()); // 初始设置无运行方向
|
offset.setDir(response.getDirection().getValue()); // 初始设置无运行方向
|
||||||
// 设置公里标信息
|
// 设置公里标信息
|
||||||
LineNetTrainComMethod.setUpKilometerCode(
|
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||||
offset, DeviceType.DEVICE_TYPE_TRACK, response.getTrackName());
|
offset, DeviceType.DEVICE_TYPE_TRACK, response.getTrackName());
|
||||||
offset.setShow(offset.getKilometerCode() != 0);
|
offset.setShow(offset.getKilometerCode() != 0);
|
||||||
buildList.add(offset);
|
buildList.add(offset);
|
||||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
@ -17,7 +18,9 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/** 列车信息移除时,线网信息处理 */
|
/**
|
||||||
|
* 列车信息移除时,线网信息处理
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||||
|
|
||||||
@ -27,7 +30,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(List<MessageData> messageDataList) {
|
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||||
try {
|
try {
|
||||||
List<Builder> buildList = Lists.newArrayList();
|
List<Builder> buildList = Lists.newArrayList();
|
||||||
for (MessageData data : messageDataList) {
|
for (MessageData data : messageDataList) {
|
||||||
@ -39,7 +42,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
|||||||
offset.setGroupId(response.getGroupId());
|
offset.setGroupId(response.getGroupId());
|
||||||
offset.setTrainIndex(response.getTrainIndex());
|
offset.setTrainIndex(response.getTrainIndex());
|
||||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||||
LineNetTrainComMethod.setUpKilometerCode(
|
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||||
offset, response.getDevType(), response.getDevName());
|
offset, response.getDevType(), response.getDevName());
|
||||||
offset.setShow(false);
|
offset.setShow(false);
|
||||||
buildList.add(offset);
|
buildList.add(offset);
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
||||||
@ -12,7 +13,9 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/** 列车信息更新时,信息转换 */
|
/**
|
||||||
|
* 列车信息更新时,信息转换
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||||
|
|
||||||
@ -22,7 +25,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(List<MessageData> messageDataList) {
|
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||||
try {
|
try {
|
||||||
List<Builder> buildList = Lists.newArrayList();
|
List<Builder> buildList = Lists.newArrayList();
|
||||||
for (MessageData data : messageDataList) {
|
for (MessageData data : messageDataList) {
|
||||||
@ -34,7 +37,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
|||||||
offset.setTrainIndex(response.getTrainIndex()); // 列车标示号,全线唯一
|
offset.setTrainIndex(response.getTrainIndex()); // 列车标示号,全线唯一
|
||||||
offset.setGroupId(response.getGroupId()); // 车组号
|
offset.setGroupId(response.getGroupId()); // 车组号
|
||||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||||
offset,
|
offset,
|
||||||
response.getGlobalId(),
|
response.getGlobalId(),
|
||||||
response.getDestinationId(),
|
response.getDestinationId(),
|
||||||
|
@ -4,7 +4,7 @@ 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.atp.TrainModeAlertListener.TrainAlertEvent;
|
import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent;
|
||||||
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;
|
||||||
|
@ -4,7 +4,7 @@ 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.atp.TrainModeAlertListener.TrainAlertEvent;
|
import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -4,7 +4,7 @@ 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.atp.TrainModeAlertListener.TrainAlertEvent;
|
import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent;
|
||||||
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;
|
||||||
|
@ -7,7 +7,10 @@ import club.joylink.xiannccda.constants.SystemContext;
|
|||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
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.LayoutGraphicsProto;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||||
import club.joylink.xiannccda.vo.AreaConfigVO;
|
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||||
@ -20,6 +23,7 @@ import com.google.common.collect.Tables;
|
|||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import com.google.protobuf.MessageOrBuilder;
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -30,8 +34,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class InterLockData extends AbstractData {
|
public class InterLockData extends AbstractData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +58,9 @@ public class InterLockData extends AbstractData {
|
|||||||
|
|
||||||
private Map<AlertType, List<AreaConfigVO>> findInterLockAreaConfigData(Integer lineId) {
|
private Map<AlertType, List<AreaConfigVO>> findInterLockAreaConfigData(Integer lineId) {
|
||||||
List<AreaConfigVO> areaConfigVOList = this.deviceAreaConfigService.getCache(lineId, AlertDeviceType.DEVICE_TYPE_RTU);
|
List<AreaConfigVO> areaConfigVOList = this.deviceAreaConfigService.getCache(lineId, AlertDeviceType.DEVICE_TYPE_RTU);
|
||||||
|
if (CollectionUtils.isEmpty(areaConfigVOList)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
return areaConfigVOList.stream()
|
return areaConfigVOList.stream()
|
||||||
.filter(d -> d.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()))
|
.filter(d -> d.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()))
|
||||||
.collect(Collectors.groupingBy(d -> AlertType.valueOf(d.getAlertTypes().get(0))));
|
.collect(Collectors.groupingBy(d -> AlertType.valueOf(d.getAlertTypes().get(0))));
|
||||||
@ -88,11 +97,19 @@ public class InterLockData extends AbstractData {
|
|||||||
Integer max = Integer.parseInt(sortStationList.get(sortStationList.size() - 1).getCode());
|
Integer max = Integer.parseInt(sortStationList.get(sortStationList.size() - 1).getCode());
|
||||||
if (rtuId >= min && rtuId <= max) {
|
if (rtuId >= min && rtuId <= max) {
|
||||||
if (builder instanceof Track.Builder track) {
|
if (builder instanceof Track.Builder track) {
|
||||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, track.getId());
|
MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, track.getId());
|
||||||
|
if (section instanceof LayoutGraphicsProto.Section ss) {
|
||||||
|
if (ss.getSectionType() == SectionType.TurnoutPhysical) {
|
||||||
|
this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (section instanceof LayoutGraphicsProto.LogicSection) {
|
||||||
|
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, track.getId());
|
||||||
|
MessageOrBuilder sec = LineGraphicDataRepository.getDeviceByCode2(lineId, axleCode, track.getId());
|
||||||
|
this.put(sec, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, track.getId());
|
|
||||||
MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, axleCode);
|
|
||||||
this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
|
||||||
} else if (builder instanceof Switch.Builder switchs) {
|
} else if (builder instanceof Switch.Builder switchs) {
|
||||||
// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, switchs.getId());
|
// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, switchs.getId());
|
||||||
// this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_SWITCH, interlockArea, min, max, rtuId);
|
// this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_SWITCH, interlockArea, min, max, rtuId);
|
||||||
@ -147,7 +164,11 @@ public class InterLockData extends AbstractData {
|
|||||||
@Override
|
@Override
|
||||||
public void addDevice(List<Builder> dataList) {
|
public void addDevice(List<Builder> dataList) {
|
||||||
for (Builder builder : dataList) {
|
for (Builder builder : dataList) {
|
||||||
this.insert(builder);
|
try {
|
||||||
|
this.insert(builder);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,12 @@ public class TrainDataSource extends AbstractData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 增量的设备更新信息
|
* 增量的设备更新信息
|
||||||
|
* <p>
|
||||||
|
* k1 数据类型
|
||||||
|
* <p>
|
||||||
|
* k2 车组号
|
||||||
|
* <p>
|
||||||
|
* v 列车数据
|
||||||
*/
|
*/
|
||||||
private Table<String, String, Message> trainUpdate = Tables.synchronizedTable(HashBasedTable.create());
|
private Table<String, String, Message> trainUpdate = Tables.synchronizedTable(HashBasedTable.create());
|
||||||
|
|
||||||
@ -70,6 +76,7 @@ public class TrainDataSource extends AbstractData {
|
|||||||
if (Objects.nonNull(dbTime) && Objects.nonNull(collTime)) {
|
if (Objects.nonNull(dbTime) && Objects.nonNull(collTime)) {
|
||||||
if (collTime >= dbTime) {
|
if (collTime >= dbTime) {
|
||||||
DeviceStatusDataOperate.merge(trainBuild, message);
|
DeviceStatusDataOperate.merge(trainBuild, message);
|
||||||
|
|
||||||
// this.putTrainDeviceMapper(trainBuild);
|
// this.putTrainDeviceMapper(trainBuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,6 +85,10 @@ public class TrainDataSource extends AbstractData {
|
|||||||
trainInfo.clearBlock();
|
trainInfo.clearBlock();
|
||||||
trainInfo.clearRemove();
|
trainInfo.clearRemove();
|
||||||
trainInfo.clearRecord();
|
trainInfo.clearRecord();
|
||||||
|
if (builder instanceof TrainInfo.Builder oldTrain) {
|
||||||
|
trainInfo.setHasNextStation(oldTrain.getHasNextStation());
|
||||||
|
trainInfo.setTrainDelay(oldTrain.getTrainDelay());
|
||||||
|
}
|
||||||
allTrainInfoMaper.put(idVal.toString(), trainInfo);
|
allTrainInfoMaper.put(idVal.toString(), trainInfo);
|
||||||
if (SystemContext.notMatchRtu(trainInfo.getLineId(), trainInfo.getRtuId())) {
|
if (SystemContext.notMatchRtu(trainInfo.getLineId(), trainInfo.getRtuId())) {
|
||||||
this.putTrainDeviceMapper(trainInfo);
|
this.putTrainDeviceMapper(trainInfo);
|
||||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.line3;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,7 +19,7 @@ public class HeartBeatMsg extends MessageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class ActionReportResponse extends MessageResponse {
|
|||||||
this.totalMessage = buf.readShort();
|
this.totalMessage = buf.readShort();
|
||||||
this.messageSequence = buf.readShort();
|
this.messageSequence = buf.readShort();
|
||||||
this.count = buf.readShort();
|
this.count = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.count, buf, ActionReportEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.count, buf, ActionReportEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class ActionReportResponse extends MessageResponse {
|
|||||||
private String actionContent;
|
private String actionContent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionReportEntity read(ByteBuf buf) {
|
public ActionReportEntity read(Integer lineId, ByteBuf buf) {
|
||||||
ActionReportEntity entity = new ActionReportEntity();
|
ActionReportEntity entity = new ActionReportEntity();
|
||||||
|
|
||||||
entity.actionSite = ActionReportSiteEnum.of(buf.readByte());
|
entity.actionSite = ActionReportSiteEnum.of(buf.readByte());
|
||||||
|
@ -55,7 +55,7 @@ public class AlarmReportResponse extends MessageResponse {
|
|||||||
this.totalMessage = buf.readShort();
|
this.totalMessage = buf.readShort();
|
||||||
this.messageSequence = buf.readShort();
|
this.messageSequence = buf.readShort();
|
||||||
this.count = buf.readShort();
|
this.count = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.count, buf, AlarmReportEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.count, buf, AlarmReportEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,18 +128,18 @@ public class AlarmReportResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmReportEntity read(ByteBuf buf) {
|
public AlarmReportEntity read(Integer lineId, ByteBuf buf) {
|
||||||
AlarmReportEntity entity = new AlarmReportEntity();
|
AlarmReportEntity entity = new AlarmReportEntity();
|
||||||
entity.alamrSite = AlarmReportSiteEnum.of(buf.readByte());
|
entity.alamrSite = AlarmReportSiteEnum.of(buf.readByte());
|
||||||
entity.alarmSiteid = buf.readShort();
|
entity.alarmSiteid = buf.readShort();
|
||||||
entity.alarmNname = EntityParseUtil.convertStr(buf, 20);
|
entity.alarmNname = EntityParseUtil.convertStr(lineId, buf, 20);
|
||||||
|
|
||||||
entity.alarmTime = DateTimeUtil.convert(buf);
|
entity.alarmTime = DateTimeUtil.convert(buf);
|
||||||
entity.alarmType = AlarmTypeControlEnum.of(buf.readShort());
|
entity.alarmType = AlarmTypeControlEnum.of(buf.readShort());
|
||||||
entity.alarmSubType = buf.readShort();
|
entity.alarmSubType = buf.readShort();
|
||||||
entity.alarmLen = buf.readShort();
|
entity.alarmLen = buf.readShort();
|
||||||
|
|
||||||
entity.alarmContent = EntityParseUtil.convertStr(buf, entity.alarmLen);
|
entity.alarmContent = EntityParseUtil.convertStr(lineId, buf, entity.alarmLen);
|
||||||
|
|
||||||
entity.alarmAckSiteid = buf.readShort();
|
entity.alarmAckSiteid = buf.readShort();
|
||||||
entity.alarmAckSite = EntityParseUtil.convertStr(buf, 32);
|
entity.alarmAckSite = EntityParseUtil.convertStr(buf, 32);
|
||||||
|
@ -58,7 +58,7 @@ public class DepotPlanResponse extends MessageResponse {
|
|||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
this.date = DateTimeUtil.convert(buf);
|
this.date = DateTimeUtil.convert(buf);
|
||||||
this.depotCount = buf.readShort();
|
this.depotCount = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.depotCount, buf, DepotPlanEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.depotCount, buf, DepotPlanEntity.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +230,11 @@ public class DepotPlanResponse extends MessageResponse {
|
|||||||
private Integer inLocalSubid;
|
private Integer inLocalSubid;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DepotPlanEntity read(ByteBuf buf) {
|
public DepotPlanEntity read(Integer lineId, ByteBuf buf) {
|
||||||
DepotPlanEntity entity = new DepotPlanEntity();
|
DepotPlanEntity entity = new DepotPlanEntity();
|
||||||
entity.depotStation = buf.readShort();
|
entity.depotStation = buf.readShort();
|
||||||
entity.groupId = EntityParseUtil.convertStr(buf, 9);
|
entity.groupId = EntityParseUtil.convertStr(lineId, buf, 9);
|
||||||
entity.driverId = EntityParseUtil.convertStr(buf, 13);
|
entity.driverId = EntityParseUtil.convertStr(lineId, buf, 13);
|
||||||
entity.outFlag = buf.readShort() == 1;
|
entity.outFlag = buf.readShort() == 1;
|
||||||
entity.outSchedule = buf.readByte() == 1;
|
entity.outSchedule = buf.readByte() == 1;
|
||||||
entity.outTime = DateTimeUtil.convert(buf);
|
entity.outTime = DateTimeUtil.convert(buf);
|
||||||
|
@ -2,8 +2,9 @@ package club.joylink.xiannccda.ats.message.line3.rep;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
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.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||||
@ -65,18 +66,18 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
|||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
this.rtuId = buf.readShort();
|
this.rtuId = buf.readShort();
|
||||||
this.typeCnt = buf.readShort();
|
this.typeCnt = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.typeCnt, buf, DeviceTypeEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.typeCnt, buf, DeviceTypeEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
List<GeneratedMessageV3.Builder> msgBuildList = Lists.newArrayList();
|
List<GeneratedMessageV3.Builder> msgBuildList = Lists.newArrayList();
|
||||||
for (DeviceTypeEntity deviceTypeEntity : this.entityList) {
|
for (DeviceTypeEntity deviceTypeEntity : this.entityList) {
|
||||||
DeviceType dt = deviceTypeEntity.getType();
|
DeviceType dt = deviceTypeEntity.getType();
|
||||||
for (DeviceEntity deviceEntity : deviceTypeEntity.deviceList) {
|
for (DeviceEntity deviceEntity : deviceTypeEntity.deviceList) {
|
||||||
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(dt, deviceEntity.status);
|
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(dt, deviceEntity.status);
|
||||||
// DeviceStatusConvertor.fillField(builder, "id", deviceEntity.devName);
|
// DeviceStatusConvertor.fillField(builder, "id", deviceEntity.devName);
|
||||||
String newOccName = DeviceNameChangerManage.findMatch(dt, deviceEntity.devName);
|
String newOccName = DeviceNameChangerManage.findMatch(nameChanger, dt, deviceEntity.devName);
|
||||||
DeviceStatusConvertor.fillField(builder, "id", newOccName);
|
DeviceStatusConvertor.fillField(builder, "id", newOccName);
|
||||||
DeviceStatusConvertor.fillField(builder, "rtuId", this.rtuId);
|
DeviceStatusConvertor.fillField(builder, "rtuId", this.rtuId);
|
||||||
DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime());
|
DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime());
|
||||||
@ -87,7 +88,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
|||||||
DeviceStatusConvertor.convertForTrack(deviceEntity.getStatus(), builder);
|
DeviceStatusConvertor.convertForTrack(deviceEntity.getStatus(), builder);
|
||||||
DeviceStatusConvertor.convertForPlatform(deviceEntity.getStatus(), (Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare()), builder);
|
DeviceStatusConvertor.convertForPlatform(deviceEntity.getStatus(), (Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare()), builder);
|
||||||
DeviceStatusConvertor.convertForSwitch(Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare(), builder);
|
DeviceStatusConvertor.convertForSwitch(Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare(), builder);
|
||||||
log.info("接受全量状态设备类型:[{}] 对应状态[{}]", dt.name(), builder);
|
// log.info("接受全量状态设备类型:[{}] 对应状态[{}]", dt.name(), builder);
|
||||||
msgBuildList.add(builder);
|
msgBuildList.add(builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,12 +122,12 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
|||||||
private List<DeviceEntity> deviceList;
|
private List<DeviceEntity> deviceList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceTypeEntity read(ByteBuf buf) {
|
public DeviceTypeEntity read(Integer lineId, ByteBuf buf) {
|
||||||
DeviceTypeEntity entity = new DeviceTypeEntity();
|
DeviceTypeEntity entity = new DeviceTypeEntity();
|
||||||
|
|
||||||
entity.type = DeviceType.of(buf.readShort());
|
entity.type = DeviceType.of(buf.readShort());
|
||||||
entity.objCount = buf.readShort();
|
entity.objCount = buf.readShort();
|
||||||
entity.deviceList = EntityParseUtil.collect(entity.objCount, buf, DeviceEntity.class);
|
entity.deviceList = EntityParseUtil.collect(lineId, entity.objCount, buf, DeviceEntity.class);
|
||||||
/* for (DeviceEntity de : entity.deviceList) {
|
/* for (DeviceEntity de : entity.deviceList) {
|
||||||
de.devName = DeviceNameChangerManage.findMatch(entity.type, de.devName);
|
de.devName = DeviceNameChangerManage.findMatch(entity.type, de.devName);
|
||||||
}*/
|
}*/
|
||||||
@ -162,9 +163,9 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceEntity read(ByteBuf buf) {
|
public DeviceEntity read(Integer lineId, ByteBuf buf) {
|
||||||
DeviceEntity entity = new DeviceEntity();
|
DeviceEntity entity = new DeviceEntity();
|
||||||
entity.devName = EntityParseUtil.convertStr(buf, 24);
|
entity.devName = EntityParseUtil.convertStr(lineId, buf, 24);
|
||||||
entity.status = buf.readInt();
|
entity.status = buf.readInt();
|
||||||
entity.spare = buf.readInt();
|
entity.spare = buf.readInt();
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -2,21 +2,18 @@ package club.joylink.xiannccda.ats.message.line3.rep;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
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.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -83,20 +80,23 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
|||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
this.rtuId = buf.readShort();
|
this.rtuId = buf.readShort();
|
||||||
this.type = DeviceType.of(buf.readShort());
|
this.type = DeviceType.of(buf.readShort());
|
||||||
this.devName = EntityParseUtil.convertStr(buf, 24);
|
|
||||||
|
this.devName = EntityParseUtil.convertStr(Integer.valueOf(this.lineId), buf, 24);
|
||||||
this.deviceStatus = buf.readInt();
|
this.deviceStatus = buf.readInt();
|
||||||
this.spare = buf.readInt();
|
this.spare = buf.readInt();
|
||||||
|
|
||||||
// this.devName = DeviceNameChangerManage.findMatch(this.type, this.devName);
|
// this.devName = DeviceNameChangerManage.findMatch(this.type, this.devName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
if (Objects.isNull(this.type)) {
|
if (Objects.isNull(this.type)) {
|
||||||
log.error("设备变更状态类型为空:{}", JSON.toJSONString(this));
|
log.error("设备变更状态类型为空:{}", JSON.toJSONString(this));
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
String occName = DeviceNameChangerManage.findMatch(this.type, this.devName);
|
|
||||||
|
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.type, this.devName);
|
||||||
// if (this.type == DeviceType.DEVICE_TYPE_SWITCH && StringUtils.startsWith(occName, "DG")) {
|
// if (this.type == DeviceType.DEVICE_TYPE_SWITCH && StringUtils.startsWith(occName, "DG")) {
|
||||||
// this.type = DeviceType.DEVICE_TYPE_TRACK;
|
// this.type = DeviceType.DEVICE_TYPE_TRACK;
|
||||||
// }
|
// }
|
||||||
@ -112,7 +112,7 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
|||||||
DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder);
|
DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder);
|
||||||
DeviceStatusConvertor.convertForPlatform(this.deviceStatus, Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
DeviceStatusConvertor.convertForPlatform(this.deviceStatus, Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
||||||
DeviceStatusConvertor.convertForSwitch(Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
DeviceStatusConvertor.convertForSwitch(Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
||||||
log.info("接受设备状态设备类型[{}] 对应状态[{}]", this.type.name(), builder);
|
// log.info("接受设备状态设备类型[{}] 对应状态[{}]", this.type.name(), builder);
|
||||||
return List.of(builder);
|
return List.of(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,22 +2,27 @@ package club.joylink.xiannccda.ats.message.line3.rep;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EntityParseUtil {
|
public class EntityParseUtil {
|
||||||
|
|
||||||
public static <T> List<T> collect(int count, ByteBuf buf, Class<T> tClass) {
|
public static <T> List<T> collect(int lineId, int count, ByteBuf buf, Class<T> tClass) {
|
||||||
|
|
||||||
List<T> list = Lists.newArrayListWithCapacity(count);
|
List<T> list = Lists.newArrayListWithCapacity(count);
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
try {
|
try {
|
||||||
Object obj = tClass.getDeclaredConstructor().newInstance();
|
Object obj = tClass.getDeclaredConstructor().newInstance();
|
||||||
if (obj instanceof ReadData rd) {
|
if (obj instanceof ReadData rd) {
|
||||||
list.add((T) rd.read(buf));
|
list.add((T) rd.read(lineId, buf));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -30,12 +35,36 @@ public class EntityParseUtil {
|
|||||||
public static String convertStr(ByteBuf buf, int len) {
|
public static String convertStr(ByteBuf buf, int len) {
|
||||||
byte[] data = new byte[len];
|
byte[] data = new byte[len];
|
||||||
buf.readBytes(data);
|
buf.readBytes(data);
|
||||||
return new String(data, MessageCons.STRING_CHARSET).trim();
|
String name = new String(data, MessageCons.STRING_CHARSET).trim();
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertStr(Integer lineId, ByteBuf buf, int len) {
|
||||||
|
byte[] data = new byte[len];
|
||||||
|
buf.readBytes(data);
|
||||||
|
if (lineId == 3) {
|
||||||
|
return new String(data, MessageCons.STRING_CHARSET).trim();
|
||||||
|
} else {
|
||||||
|
int findIndex = 0;
|
||||||
|
for (; findIndex < data.length; findIndex++) {
|
||||||
|
byte dn = data[findIndex];
|
||||||
|
if (dn == 0) {
|
||||||
|
// findIndex = findIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
byte[] nameByte = new byte[findIndex];
|
||||||
|
System.arraycopy(data, 0, nameByte, 0, findIndex);
|
||||||
|
|
||||||
|
return new String(nameByte, Charset.forName("GBK"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ReadData<T> {
|
public interface ReadData<T> {
|
||||||
|
|
||||||
T read(ByteBuf buf);
|
T read(Integer lineId, ByteBuf buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static void fill(GeneratedMessageV3.Builder builder, String name, Object val) {
|
/* public static void fill(GeneratedMessageV3.Builder builder, String name, Object val) {
|
||||||
|
@ -66,7 +66,7 @@ public class HistoryScheduleResponse extends MessageResponse {
|
|||||||
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
||||||
this.groupId = EntityParseUtil.convertStr(buf, 9);
|
this.groupId = EntityParseUtil.convertStr(buf, 9);
|
||||||
this.recCnt = buf.readShort();
|
this.recCnt = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.recCnt, buf, HistoryScheduleEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.recCnt, buf, HistoryScheduleEntity.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ public class HistoryScheduleResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HistoryScheduleEntity read(ByteBuf buf) {
|
public HistoryScheduleEntity read(Integer lineId, ByteBuf buf) {
|
||||||
HistoryScheduleEntity entity = new HistoryScheduleEntity();
|
HistoryScheduleEntity entity = new HistoryScheduleEntity();
|
||||||
|
|
||||||
entity.stationId = buf.readShort();
|
entity.stationId = buf.readShort();
|
||||||
@ -134,8 +134,8 @@ public class HistoryScheduleResponse extends MessageResponse {
|
|||||||
entity.aTime = DateTimeUtil.convert(buf);
|
entity.aTime = DateTimeUtil.convert(buf);
|
||||||
entity.dTime = DateTimeUtil.convert(buf);
|
entity.dTime = DateTimeUtil.convert(buf);
|
||||||
entity.flag = buf.readShort();
|
entity.flag = buf.readShort();
|
||||||
entity.serviceId = EntityParseUtil.convertStr(buf, 9);
|
entity.serviceId = EntityParseUtil.convertStr(lineId, buf, 9);
|
||||||
entity.globalId = EntityParseUtil.convertStr(buf, 12);
|
entity.globalId = EntityParseUtil.convertStr(lineId, buf, 12);
|
||||||
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
||||||
|
|
||||||
entity.planType = buf.readShort() == 1;
|
entity.planType = buf.readShort() == 1;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.ScheduleSubIdType;
|
import club.joylink.xiannccda.ats.message.line3.device.ScheduleSubIdType;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||||
@ -74,16 +75,22 @@ public class InusedScheduleResponse extends MessageResponse {
|
|||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
this.date = DateTimeUtil.convert(buf);
|
this.date = DateTimeUtil.convert(buf);
|
||||||
this.subId = ScheduleSubIdType.of(buf.readShort());
|
this.subId = ScheduleSubIdType.of(buf.readShort());
|
||||||
|
/* if (this.subId == ScheduleSubIdType.HISTORY_BEGIN) {
|
||||||
|
System.out.println("aaaaaaaaaa");
|
||||||
|
}
|
||||||
|
if (this.subId == ScheduleSubIdType.HISTORY_STOP) {
|
||||||
|
System.out.println("bbbbbbbbbbbb");
|
||||||
|
}*/
|
||||||
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
||||||
|
|
||||||
this.trainId = EntityParseUtil.convertStr(buf, 9);
|
this.trainId = EntityParseUtil.convertStr(buf, 9);
|
||||||
this.tripCnt = buf.readShort();
|
this.tripCnt = buf.readShort();
|
||||||
this.entityList = EntityParseUtil.collect(this.tripCnt, buf, InusedScheduleEntity.class);
|
this.entityList = EntityParseUtil.collect(this.lineId, this.tripCnt, buf, InusedScheduleEntity.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GeneratedMessageV3.Builder> generateProto() {
|
public List<GeneratedMessageV3.Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
List<GeneratedMessageV3.Builder> planBuilds = Lists.newArrayList();
|
List<GeneratedMessageV3.Builder> planBuilds = Lists.newArrayList();
|
||||||
if (CollectionUtils.isEmpty(this.entityList)) {
|
if (CollectionUtils.isEmpty(this.entityList)) {
|
||||||
Plan.Builder planBuild = Plan.newBuilder();
|
Plan.Builder planBuild = Plan.newBuilder();
|
||||||
@ -150,14 +157,14 @@ public class InusedScheduleResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InusedScheduleEntity read(ByteBuf buf) {
|
public InusedScheduleEntity read(Integer lineId, ByteBuf buf) {
|
||||||
InusedScheduleEntity entity = new InusedScheduleEntity();
|
InusedScheduleEntity entity = new InusedScheduleEntity();
|
||||||
|
|
||||||
entity.globalId = EntityParseUtil.convertStr(buf, 12);
|
entity.globalId = EntityParseUtil.convertStr(buf, 12);
|
||||||
entity.groupId = EntityParseUtil.convertStr(buf, 9);
|
entity.groupId = EntityParseUtil.convertStr(buf, 9);
|
||||||
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
||||||
entity.recCnt = buf.readShort();
|
entity.recCnt = buf.readShort();
|
||||||
entity.recordList = EntityParseUtil.collect(entity.recCnt, buf, EntityRecord.class);
|
entity.recordList = EntityParseUtil.collect(lineId, entity.recCnt, buf, EntityRecord.class);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +210,7 @@ public class InusedScheduleResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityRecord read(ByteBuf buf) {
|
public EntityRecord read(Integer lineId, ByteBuf buf) {
|
||||||
EntityRecord record = new EntityRecord();
|
EntityRecord record = new EntityRecord();
|
||||||
|
|
||||||
record.stationId = buf.readShort();
|
record.stationId = buf.readShort();
|
||||||
|
@ -52,7 +52,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
|||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
this.rtuId = buf.readShort();
|
this.rtuId = buf.readShort();
|
||||||
this.singalCount = buf.readShort();
|
this.singalCount = buf.readShort();
|
||||||
this.signals = EntityParseUtil.collect(this.singalCount, buf, SignalStatusEntity.class);
|
this.signals = EntityParseUtil.collect(this.lineId, this.singalCount, buf, SignalStatusEntity.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,12 +90,12 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
|||||||
private List<RouteStatusEntity> routes;
|
private List<RouteStatusEntity> routes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SignalStatusEntity read(ByteBuf buf) {
|
public SignalStatusEntity read(Integer lineId, ByteBuf buf) {
|
||||||
SignalStatusEntity entity = new SignalStatusEntity();
|
SignalStatusEntity entity = new SignalStatusEntity();
|
||||||
|
|
||||||
entity.signalName = EntityParseUtil.convertStr(buf, 20);
|
entity.signalName = EntityParseUtil.convertStr(buf, 20);
|
||||||
entity.routeCount = buf.readByte();
|
entity.routeCount = buf.readByte();
|
||||||
entity.routes = EntityParseUtil.collect(entity.routeCount, buf, RouteStatusEntity.class);
|
entity.routes = EntityParseUtil.collect(lineId, entity.routeCount, buf, RouteStatusEntity.class);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,9 +121,9 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RouteStatusEntity read(ByteBuf buf) {
|
public RouteStatusEntity read(Integer lineId, ByteBuf buf) {
|
||||||
RouteStatusEntity entity = new RouteStatusEntity();
|
RouteStatusEntity entity = new RouteStatusEntity();
|
||||||
entity.routeName = EntityParseUtil.convertStr(buf, 64);
|
entity.routeName = EntityParseUtil.convertStr(lineId, buf, 64);
|
||||||
|
|
||||||
entity.routeStatus = RouteStatusEnum.of(buf.readByte());
|
entity.routeStatus = RouteStatusEnum.of(buf.readByte());
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
@ -15,6 +16,8 @@ import lombok.Getter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.extern.java.Log;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@Slf4j
|
||||||
public class TrainBlockInfoResponse extends MessageResponse {
|
public class TrainBlockInfoResponse extends MessageResponse {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,15 +44,19 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
|||||||
@Override
|
@Override
|
||||||
public void decode2(ByteBuf buf) throws Exception {
|
public void decode2(ByteBuf buf) throws Exception {
|
||||||
this.lineId = buf.readShort();
|
this.lineId = buf.readShort();
|
||||||
|
|
||||||
this.trainCnt = buf.readShort();
|
this.trainCnt = buf.readShort();
|
||||||
this.trains = new ArrayList<>(this.trainCnt);
|
this.trains = new ArrayList<>(this.trainCnt);
|
||||||
|
/*if (this.lineId == 4) {
|
||||||
|
log.warn("lineId:{} 阻塞数据量:{}", this.lineId, this.trainCnt);
|
||||||
|
}*/
|
||||||
for (int cnt = 0; cnt < this.trainCnt; cnt++) {
|
for (int cnt = 0; cnt < this.trainCnt; cnt++) {
|
||||||
this.trains.add(new TrainCell().decode(buf));
|
this.trains.add(new TrainCell().decode(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||||
for (TrainCell train : this.trains) {
|
for (TrainCell train : this.trains) {
|
||||||
TrainBlock.Builder builder = TrainBlock.newBuilder();
|
TrainBlock.Builder builder = TrainBlock.newBuilder();
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
@ -54,7 +56,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
List<Builder> msgBuildList = Lists.newArrayList();
|
List<Builder> msgBuildList = Lists.newArrayList();
|
||||||
for (TrainCell trainCell : this.trains) {
|
for (TrainCell trainCell : this.trains) {
|
||||||
TrainInfo.Builder builder = TrainInfo.newBuilder();
|
TrainInfo.Builder builder = TrainInfo.newBuilder();
|
||||||
@ -75,11 +77,17 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), ""));
|
// builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), ""));
|
||||||
String occName = DeviceNameChangerManage.findMatch(trainCell.getDevType(), trainCell.getDevName());
|
String occName = DeviceNameChangerManage.findMatch(nameChanger, trainCell.getDevType(), trainCell.getDevName());
|
||||||
builder.setDevName(occName);
|
builder.setDevName(occName);
|
||||||
if (trainCell.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
if (trainCell.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||||
//车辆在道岔时,转换对应的设备类型
|
//车辆在道岔时,转换对应的设备类型
|
||||||
builder.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
builder.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
||||||
|
/* if (lineId == 4) {
|
||||||
|
if (StringUtils.startsWith(trainCell.getDevName(), "P")) {
|
||||||
|
occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(this.lineId, trainCell.getDevName());
|
||||||
|
builder.setDevName(occName);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
builder.setTrainIndex(StringUtils.defaultString(trainCell.getTrainIndex(), ""));
|
builder.setTrainIndex(StringUtils.defaultString(trainCell.getTrainIndex(), ""));
|
||||||
builder.setGroupId(StringUtils.defaultString(trainCell.getGroupId(), ""));
|
builder.setGroupId(StringUtils.defaultString(trainCell.getGroupId(), ""));
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
||||||
@ -79,7 +80,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||||
trainRemove.setReceiveTime(System.currentTimeMillis());
|
trainRemove.setReceiveTime(System.currentTimeMillis());
|
||||||
if (Objects.nonNull(this.lineId)) {
|
if (Objects.nonNull(this.lineId)) {
|
||||||
@ -100,7 +101,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
|||||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||||
}
|
}
|
||||||
// trainRemove.setDevName(StringUtils.defaultString(this.devName, ""));
|
// trainRemove.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||||
String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName);
|
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName);
|
||||||
trainRemove.setDevName(occName);
|
trainRemove.setDevName(occName);
|
||||||
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||||
//车辆在道岔时,转换对应的设备类型
|
//车辆在道岔时,转换对应的设备类型
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto;
|
import club.joylink.xiannccda.dto.protos.TrainProto;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||||
@ -20,7 +23,6 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +129,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
||||||
train.setReceiveTime(System.currentTimeMillis());
|
train.setReceiveTime(System.currentTimeMillis());
|
||||||
|
|
||||||
@ -146,13 +148,18 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
|||||||
if (Objects.nonNull(this.devType)) {
|
if (Objects.nonNull(this.devType)) {
|
||||||
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// train.setDevName(StringUtils.defaultString(this.devName, ""));
|
// train.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||||
String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName);
|
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName);
|
||||||
train.setDevName(occName);
|
train.setDevName(occName);
|
||||||
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||||
//车辆在道岔时,转换对应的设备类型
|
//车辆在道岔时,转换对应的设备类型
|
||||||
train.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
train.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
||||||
|
/* if (lineId == 4) {
|
||||||
|
if (StringUtils.startsWith(this.devName, "P")) {
|
||||||
|
occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(this.lineId, this.devName);
|
||||||
|
train.setDevName(occName);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
train.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
train.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
||||||
train.setRollingStock(this.getRollingStock());
|
train.setRollingStock(this.getRollingStock());
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse.TrainCell;
|
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
@ -133,7 +130,7 @@ public class TrainRecordResponse extends MessageResponse {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||||
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
||||||
builder.setReceiveTime(System.currentTimeMillis());
|
builder.setReceiveTime(System.currentTimeMillis());
|
||||||
|
|
||||||
@ -164,7 +161,7 @@ public class TrainRecordResponse extends MessageResponse {
|
|||||||
builder.setSideId(this.getSideId());
|
builder.setSideId(this.getSideId());
|
||||||
}
|
}
|
||||||
builder.setTrackName(StringUtils.defaultString(this.trackName, ""));
|
builder.setTrackName(StringUtils.defaultString(this.trackName, ""));
|
||||||
String deviceName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, builder.getTrackName());
|
String deviceName = DeviceNameChangerManage.findMatch(nameChanger, DeviceType.DEVICE_TYPE_TRACK, builder.getTrackName());
|
||||||
builder.setTrackName(deviceName);
|
builder.setTrackName(deviceName);
|
||||||
if (this.getRecordType() != null) {
|
if (this.getRecordType() != null) {
|
||||||
builder.setRecordType(this.getRecordType());
|
builder.setRecordType(this.getRecordType());
|
||||||
|
@ -47,7 +47,7 @@ public class LoadDeviceStatusRequest extends MessageRequest {
|
|||||||
private Short lineId;
|
private Short lineId;
|
||||||
|
|
||||||
public LoadDeviceStatusRequest(Short lineId) {
|
public LoadDeviceStatusRequest(Short lineId) {
|
||||||
super(MessageId.LOAD_DEVICE_STATUS, 2);
|
super(MessageId.LOAD_DEVICE_STATUS, 2 + 1);
|
||||||
this.lineId = lineId;
|
this.lineId = lineId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,5 +55,6 @@ public class LoadDeviceStatusRequest extends MessageRequest {
|
|||||||
@Override
|
@Override
|
||||||
public void encode2(ByteBuf buf) {
|
public void encode2(ByteBuf buf) {
|
||||||
buf.writeShort(this.lineId);
|
buf.writeShort(this.lineId);
|
||||||
|
buf.writeByte(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import com.google.common.base.Joiner;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.MessageOrBuilder;
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -70,6 +71,7 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
|||||||
for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) {
|
for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) {
|
||||||
String rtuIdJoinStr = interLockDetail.getKey();
|
String rtuIdJoinStr = interLockDetail.getKey();
|
||||||
InterLockDetail detail = interLockDetail.getValue();
|
InterLockDetail detail = interLockDetail.getValue();
|
||||||
|
|
||||||
Optional<AxleInterLockSource> redOpt = this.handle(lineId, detail, AlertType.AXLE_LED_RED, AlertType.AXLE_LED_RED_INTERLOCK_AREA, rtuIdJoinStr);
|
Optional<AxleInterLockSource> redOpt = this.handle(lineId, detail, AlertType.AXLE_LED_RED, AlertType.AXLE_LED_RED_INTERLOCK_AREA, rtuIdJoinStr);
|
||||||
Optional<AxleInterLockSource> orangeOpt = this.handle(lineId, detail, AlertType.AXLE_LED_ORANGE, AlertType.AXLE_LED_ORANGE_INTERLOCK_AREA, rtuIdJoinStr);
|
Optional<AxleInterLockSource> orangeOpt = this.handle(lineId, detail, AlertType.AXLE_LED_ORANGE, AlertType.AXLE_LED_ORANGE_INTERLOCK_AREA, rtuIdJoinStr);
|
||||||
redOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource)));
|
redOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource)));
|
||||||
@ -82,6 +84,7 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
|||||||
private Optional<AxleInterLockSource> handle(String lineId, InterLockDetail detail, AlertType findWarnAlertType, AlertType warnAlertType, String rtuIdJoinStr) {
|
private Optional<AxleInterLockSource> handle(String lineId, InterLockDetail detail, AlertType findWarnAlertType, AlertType warnAlertType, String rtuIdJoinStr) {
|
||||||
int deviceCount = detail.getDevices().size();
|
int deviceCount = detail.getDevices().size();
|
||||||
Integer lineIdInt = Integer.parseInt(lineId);
|
Integer lineIdInt = Integer.parseInt(lineId);
|
||||||
|
|
||||||
//收集联锁下的所有所有区段设备
|
//收集联锁下的所有所有区段设备
|
||||||
List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices());
|
List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices());
|
||||||
List<String> occupidedDeviceList = resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).toList();
|
List<String> occupidedDeviceList = resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).toList();
|
||||||
@ -110,6 +113,10 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TrackOccupiedStatus> collectorLedWarDevices(AlertType alertType, String lineId, List<Integer> deviceLayoutIds) {
|
private List<TrackOccupiedStatus> collectorLedWarDevices(AlertType alertType, String lineId, List<Integer> deviceLayoutIds) {
|
||||||
|
if (CollectionUtils.isEmpty(deviceLayoutIds)) {
|
||||||
|
log.error("{}", lineId);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
Integer lineIdInt = Integer.parseInt(lineId);
|
Integer lineIdInt = Integer.parseInt(lineId);
|
||||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||||
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
|
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
|
||||||
@ -148,17 +155,21 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
|||||||
if (deviceStatus instanceof Track.Builder track) {
|
if (deviceStatus instanceof Track.Builder track) {
|
||||||
if (alertType == AlertType.AXLE_LED_RED) {
|
if (alertType == AlertType.AXLE_LED_RED) {
|
||||||
boolean red = track.getCiOccupied() && !track.getCbtcOccupied();
|
boolean red = track.getCiOccupied() && !track.getCbtcOccupied();
|
||||||
sectionStatusList.add(red);
|
sectionStatusList.add(this.isLight(red, track.getReceiveTime()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
boolean orange = track.getAtcInvalid();
|
boolean orange = track.getAtcInvalid();
|
||||||
sectionStatusList.add(orange);
|
sectionStatusList.add(this.isLight(orange, track.getReceiveTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sectionStatusList.stream().allMatch(d -> d);
|
return sectionStatusList.stream().allMatch(d -> d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLight(boolean ledLight, long deviceReceiveTime) {
|
||||||
|
return ledLight && (System.currentTimeMillis() - deviceReceiveTime) / 1000 > 3;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkTurnoutStatus(Integer lineId, Section section, AlertType alertType, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
|
private boolean checkTurnoutStatus(Integer lineId, Section section, AlertType alertType, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
|
||||||
List<Boolean> turnoutOccLList = Lists.newArrayListWithCapacity(section.getChildrenList().size());
|
List<Boolean> turnoutOccLList = Lists.newArrayListWithCapacity(section.getChildrenList().size());
|
||||||
for (Integer refTuronoutId : section.getChildrenList()) {
|
for (Integer refTuronoutId : section.getChildrenList()) {
|
||||||
@ -173,9 +184,9 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
|||||||
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied();
|
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied();
|
||||||
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
|
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
|
||||||
if (alertType == AlertType.AXLE_LED_RED) {
|
if (alertType == AlertType.AXLE_LED_RED) {
|
||||||
turnoutOccLList.add(ledRed);
|
turnoutOccLList.add(this.isLight(ledRed, switchBuild.getReceiveTime()));
|
||||||
} else {
|
} else {
|
||||||
turnoutOccLList.add(orange);
|
turnoutOccLList.add(this.isLight(orange, switchBuild.getReceiveTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,9 @@ public class BuleDisplayMonitoringTask implements AlertMonitoringTask {
|
|||||||
List<RtuWarnVO> collectRtuList = this.findRtuBuild(lineId, builderMap);
|
List<RtuWarnVO> collectRtuList = this.findRtuBuild(lineId, builderMap);
|
||||||
Map<Long, List<RtuWarnVO>> rtuVOMapList = collectRtuList.stream().collect(Collectors.groupingBy(d -> d.areaConfigVO.getId()));
|
Map<Long, List<RtuWarnVO>> rtuVOMapList = collectRtuList.stream().collect(Collectors.groupingBy(d -> d.areaConfigVO.getId()));
|
||||||
int interLockCount = rtuVOMapList.keySet().size();
|
int interLockCount = rtuVOMapList.keySet().size();
|
||||||
|
if (interLockCount == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
List<Boolean> allShutdownList = rtuVOMapList.values().stream().map(Collection::stream).map(ls -> ls.anyMatch(r -> Objects.nonNull(r.rtu) && r.rtu.getIpRtuStusDown())).toList();
|
List<Boolean> allShutdownList = rtuVOMapList.values().stream().map(Collection::stream).map(ls -> ls.anyMatch(r -> Objects.nonNull(r.rtu) && r.rtu.getIpRtuStusDown())).toList();
|
||||||
if (allShutdownList.size() == interLockCount && allShutdownList.stream().allMatch(d -> d)) {
|
if (allShutdownList.size() == interLockCount && allShutdownList.stream().allMatch(d -> d)) {
|
||||||
if (alertDataSource.putAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All")) {
|
if (alertDataSource.putAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All")) {
|
||||||
|
@ -0,0 +1,107 @@
|
|||||||
|
package club.joylink.xiannccda.ats.warn.lost;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
||||||
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||||
|
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
||||||
|
import club.joylink.xiannccda.service.AlertInfoService;
|
||||||
|
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class SwitchLostAndJammedTask implements AlertMonitoringTask {
|
||||||
|
|
||||||
|
private DeviceGuardConfigService configService;
|
||||||
|
private AlertInfoService alertInfoService;
|
||||||
|
|
||||||
|
public SwitchLostAndJammedTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||||
|
this.configService = configService;
|
||||||
|
this.alertInfoService = alertInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final AlertManager alertManager = AlertManager.getDefault();
|
||||||
|
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "SWITCH_LOST_ALTER";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Set<String> lineCollSet = DeviceDataRepository.getAllLines();
|
||||||
|
if (CollectionUtils.isEmpty(lineCollSet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String lineId : lineCollSet) {
|
||||||
|
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||||
|
Map<String, Builder> deviceBuildMap = deviceStatusData.getAllDeviceMap().get(Switch.getDescriptor().getName());
|
||||||
|
if (CollectionUtils.isNotEmpty(deviceBuildMap)) {
|
||||||
|
for (Builder deviceBuild : deviceBuildMap.values()) {
|
||||||
|
this.handle(deviceBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handle(Builder deviceBuild) {
|
||||||
|
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
||||||
|
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||||
|
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||||
|
this.checkLost(switchBuild, layoutId);
|
||||||
|
this.checkJammed(switchBuild, layoutId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkLost(Switch.Builder switchBuild, String layoutId) {
|
||||||
|
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||||
|
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||||
|
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||||
|
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||||
|
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||||
|
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||||
|
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||||
|
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final static String JAMMED_NAME = "JAMMED";
|
||||||
|
|
||||||
|
private void checkJammed(Switch.Builder switchBuild, String layoutId) {
|
||||||
|
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied();//&& !switchBuild.getIpSingleSwitchStusCbtcOccupied();
|
||||||
|
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
|
||||||
|
if (switchBuild.getIpSingleSwitchStusJammed() && (ledRed || orange)) {
|
||||||
|
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), JAMMED_NAME, switchBuild.getId())) {
|
||||||
|
String alertMsg = String.format("设备[%s]挤岔", switchBuild.getId());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_JAMMED, switchBuild, alertMsg, layoutId,
|
||||||
|
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertDataSource.removeAlterDevice(switchBuild.getLineId(), JAMMED_NAME, switchBuild.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,85 +0,0 @@
|
|||||||
package club.joylink.xiannccda.ats.warn.lost;
|
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
|
||||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
|
||||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
|
||||||
import club.joylink.xiannccda.service.AlertInfoService;
|
|
||||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class SwitchLostTask implements AlertMonitoringTask {
|
|
||||||
|
|
||||||
private DeviceGuardConfigService configService;
|
|
||||||
private AlertInfoService alertInfoService;
|
|
||||||
|
|
||||||
public SwitchLostTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
|
||||||
this.configService = configService;
|
|
||||||
this.alertInfoService = alertInfoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final AlertManager alertManager = AlertManager.getDefault();
|
|
||||||
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "SWITCH_LOST_ALTER";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Set<String> lineCollSet = DeviceDataRepository.getAllLines();
|
|
||||||
if (CollectionUtils.isEmpty(lineCollSet)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (String lineId : lineCollSet) {
|
|
||||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
|
||||||
Map<String, Builder> deviceBuildMap = deviceStatusData.getAllDeviceMap().get(Switch.getDescriptor().getName());
|
|
||||||
if (CollectionUtils.isNotEmpty(deviceBuildMap)) {
|
|
||||||
for (Builder deviceBuild : deviceBuildMap.values()) {
|
|
||||||
this.handle(deviceBuild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handle(Builder deviceBuild) {
|
|
||||||
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
|
||||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
|
||||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
|
||||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
|
||||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
|
||||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
|
||||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
|
||||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
|
||||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
|
||||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
|
||||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
|
||||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
|
||||||
alertManager.emit(alertInfo);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -10,24 +10,31 @@ import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
|||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||||
|
import club.joylink.xiannccda.dto.protos.AlertConstProto;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainDelayInfo;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainShedule.Plan;
|
import club.joylink.xiannccda.dto.protos.TrainShedule.Plan;
|
||||||
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 com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -57,12 +64,77 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
this.trainRecordMap.put(trainRecord.getTrainId(), trainRecord);
|
this.trainRecordMap.put(trainRecord.getTrainId(), trainRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findNexPlatform(TrainRecord.Builder tr) {
|
||||||
|
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_5.name(), tr.getGroupId());
|
||||||
|
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_15.name(), tr.getGroupId());
|
||||||
|
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_25.name(), tr.getGroupId());
|
||||||
|
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_55.name(), tr.getGroupId());
|
||||||
|
boolean upWay = PlatformAlertMonitoringTask.isUpWay(tr);
|
||||||
|
TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(String.valueOf(tr.getLineId()), DataTypeEnum.TRAIN);
|
||||||
|
TrainInfo.Builder ti = trainInfoData.getTrainInfo(tr.getGroupId());
|
||||||
|
if (Objects.isNull(ti)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Platform.Builder pf = PlatformAlertMonitoringTask.parsePlatform(tr, upWay);
|
||||||
|
|
||||||
|
if (Objects.isNull(pf)) {
|
||||||
|
ti.setHasNextStation(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LayoutGraphicsProto.Platform giPF = LineGraphicDataRepository.getDeviceByCode(pf.getLineId(), pf.getId(), LayoutGraphicsProto.Platform.class);
|
||||||
|
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCodeNotException(pf.getLineId(), String.valueOf(giPF.getRefStation()), LayoutGraphicsProto.Station.class);
|
||||||
|
if (Objects.isNull(station)) {
|
||||||
|
ti.setHasNextStation(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Integer> sortStations = LineGraphicDataRepository.allStation(pf.getLineId());
|
||||||
|
if (tr.getStationId() + 1 <= sortStations.get(sortStations.size() - 1) || tr.getStationId() - 1 >= sortStations.get(0)) {
|
||||||
|
Integer nextStationInt = tr.getStationId() + 1;
|
||||||
|
if (upWay == false) {
|
||||||
|
nextStationInt = tr.getStationId() - 1;
|
||||||
|
}
|
||||||
|
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(tr.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||||
|
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(ti.getTrainId(), ti.getGlobalId(), nextStationInt, upWay, tr.getSideId());
|
||||||
|
if (planBuildOpt.isEmpty()) {
|
||||||
|
ti.setHasNextStation(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String nextStationCode = Strings.padStart(String.valueOf(nextStationInt), 2, '0');
|
||||||
|
LayoutGraphicsProto.Station nextStation = LineGraphicDataRepository.getDevices(tr.getLineId(), LayoutGraphicsProto.Station.class).filter(d -> StringUtils.equals(d.getCode(), nextStationCode))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
if (nextStation == null) {
|
||||||
|
ti.setHasNextStation(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ti.setHasNextStation(true);
|
||||||
|
TrainDelayInfo.Builder tdbuild = TrainDelayInfo.newBuilder();
|
||||||
|
tdbuild.setNextStationName(nextStation.getName());
|
||||||
|
tdbuild.setNextStationName(nextStationCode);
|
||||||
|
tdbuild.setCurrentPlatfomrLayoutId(giPF.getCommon().getId());
|
||||||
|
tdbuild.setNextStationArriveTime(System.currentTimeMillis());
|
||||||
|
ti.setTrainDelay(tdbuild);
|
||||||
|
} else {
|
||||||
|
ti.setHasNextStation(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trainLeavePlatform(TrainRecord.Builder trainRecord) {
|
||||||
|
boolean isUpWay = trainRecord.getDir() == DirectionEnum.Up.getValue();
|
||||||
|
Platform.Builder platformBuild = this.parsePlatform(trainRecord, isUpWay);
|
||||||
|
if (Objects.nonNull(platformBuild)) {
|
||||||
|
platformBuild.setBizWaitTimerGoing(true);
|
||||||
|
platformBuild.setBizWaitStartTimeSec(System.currentTimeMillis() / 1000);
|
||||||
|
platformBuild.setBizWaitTimeSec(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeTrainRecord(TrainRecord.Builder trainRecord) {
|
public void removeTrainRecord(TrainRecord.Builder trainRecord) {
|
||||||
this.trainRecordMap.remove(trainRecord.getTrainId());
|
this.trainRecordMap.remove(trainRecord.getTrainId());
|
||||||
boolean isUpWay = trainRecord.getDir() == DirectionEnum.Up.getValue();
|
boolean isUpWay = trainRecord.getDir() == DirectionEnum.Up.getValue();
|
||||||
Platform.Builder platformBuild = this.parsePlatform(trainRecord, isUpWay);
|
Platform.Builder platformBuild = this.parsePlatform(trainRecord, isUpWay);
|
||||||
if (Objects.nonNull(platformBuild)) {
|
if (Objects.nonNull(platformBuild)) {
|
||||||
int lineId = trainRecord.getLineId();
|
int lineId = trainRecord.getLineId();
|
||||||
|
|
||||||
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||||
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||||
}
|
}
|
||||||
@ -81,7 +153,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
static Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
||||||
// String newTrackName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, record.getTrackName());
|
// String newTrackName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, record.getTrackName());
|
||||||
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(record.getLineId(), record.getTrackName());
|
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(record.getLineId(), record.getTrackName());
|
||||||
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
||||||
@ -95,7 +167,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
if (Objects.nonNull(builder)) {
|
if (Objects.nonNull(builder)) {
|
||||||
Platform.Builder platformBuild = (Platform.Builder) builder;
|
Platform.Builder platformBuild = (Platform.Builder) builder;
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("车站报对应的屏蔽门信息,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 屏蔽门是否开启[{}] 是否车辆停靠[{}]"
|
log.debug("未找到对应的站台信息,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 屏蔽门是否开启[{}] 是否车辆停靠[{}]"
|
||||||
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getPsdOpen(), platformBuild.getTrainberth());
|
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getPsdOpen(), platformBuild.getTrainberth());
|
||||||
}
|
}
|
||||||
return platformBuild;
|
return platformBuild;
|
||||||
@ -165,21 +237,47 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void trainDelayCheck(TrainInfo.Builder ti) {
|
||||||
|
if (ti.getHasNextStation() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrainDelayInfo.Builder td = ti.getTrainDelayBuilder();
|
||||||
|
this.trainDelayAlert(ti, 5, AlertType.TRAIN_DELAY_MIN_5);
|
||||||
|
this.trainDelayAlert(ti, 15, AlertType.TRAIN_DELAY_MIN_15);
|
||||||
|
this.trainDelayAlert(ti, 25, AlertType.TRAIN_DELAY_MIN_25);
|
||||||
|
this.trainDelayAlert(ti, 55, AlertType.TRAIN_DELAY_MIN_55);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void trainDelayAlert(TrainInfo.Builder ti, Integer min, AlertType at) {
|
||||||
|
TrainDelayInfo.Builder td = ti.getTrainDelayBuilder();
|
||||||
|
long delayTime = (System.currentTimeMillis() - td.getNextStationArriveTime()) / 1000;
|
||||||
|
if (delayTime >= TimeUnit.MINUTES.toSeconds(min) && alertDataSource.putAlterDevice(ti.getLineId(), at.name(), ti.getGroupId())) {
|
||||||
|
String msg = String.format("列车[%s] 已晚点超时%d", ti.getGroupId(), min);
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), at, ti, msg, String.valueOf(td.getCurrentPlatfomrLayoutId()),
|
||||||
|
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isUpWay(TrainRecord.Builder tr) {
|
||||||
|
return tr.getDir() == DirectionEnum.Up.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Builder record : this.trainRecordMap.values()) {
|
for (Builder record : this.trainRecordMap.values()) {
|
||||||
|
boolean isUpWay = isUpWay(record);
|
||||||
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
|
|
||||||
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
||||||
int lineId = record.getLineId();
|
|
||||||
if (Objects.isNull(platformBuild)) {
|
if (Objects.isNull(platformBuild)) {
|
||||||
this.removeTrainRecord(record);
|
this.removeTrainRecord(record);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (platformBuild.getBizWaitTimerGoing()) {
|
||||||
|
platformBuild.setBizWaitTimerGoing(false);
|
||||||
|
}
|
||||||
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||||
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay, record.getSideId());
|
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay, record.getSideId());
|
||||||
if (planBuildOpt.isEmpty()) {
|
if (planBuildOpt.isEmpty()) {
|
||||||
@ -191,6 +289,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Plan.Builder planBuild = planBuildOpt.get();
|
Plan.Builder planBuild = planBuildOpt.get();
|
||||||
|
int lineId = record.getLineId();
|
||||||
boolean isOpen = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
boolean isOpen = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||||
boolean isClose = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
boolean isClose = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||||
boolean handler = this.preDetection(isOpen, isClose, platformBuild, record);
|
boolean handler = this.preDetection(isOpen, isClose, platformBuild, record);
|
||||||
|
@ -0,0 +1,241 @@
|
|||||||
|
package club.joylink.xiannccda.ats.warn.platform;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
||||||
|
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||||
|
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||||
|
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
|
||||||
|
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.config.DeviceAreaConfigService;
|
||||||
|
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||||
|
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.protobuf.AbstractMessage;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@Order(30)
|
||||||
|
public class PlatformEmergStopTask implements AlertMonitoringTask {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AlertInfoService alertInfoService;
|
||||||
|
@Autowired
|
||||||
|
private DeviceAreaConfigService deviceAreaConfigService;
|
||||||
|
@Autowired
|
||||||
|
private DeviceGuardConfigService guardConfigService;
|
||||||
|
|
||||||
|
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
||||||
|
private final AlertManager alertManager = AlertManager.getDefault();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "PLATFORM_EMERG_STOP_ALTER";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void emergStop(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform) {
|
||||||
|
Integer lineId = platformBuild.getLineId();
|
||||||
|
if (platformBuild.getEmergstop()) {
|
||||||
|
if (alertDataSource.putAlterDevice(lineId, this.getName(), platformBuild.getId())) {
|
||||||
|
Integer layOutId = giPlatform.getCommon().getId();
|
||||||
|
Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefStation() + "", Station.class);
|
||||||
|
String upWay = giPlatform.getUp() ? "上行" : "下行";
|
||||||
|
String msg = String.format("%s-%s站台 应急触发", station.getName(), upWay);
|
||||||
|
// Optional<AreaConfigVO> optional = alertInfoService.findAreaDevice(AlertType.PLATFORM_EMERG_STOP, AlertDeviceType.DEVICE_TYPE_PLATFORM, layOutId, lineIdInt);
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.PLATFORM_EMERG_STOP, platformBuild, msg, layOutId.toString(),
|
||||||
|
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertDataSource.removeAlterDevice(lineId, this.getName(), platformBuild.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final static String PLATFORM_HOLD_ALERT_NAME = "platform_hold_alert";
|
||||||
|
|
||||||
|
private void stationPlatformHoldCheck(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform, List<Integer> stationCodeList) {
|
||||||
|
boolean upHold = platformBuild.getUpHold() || platformBuild.getUpOccHold();
|
||||||
|
boolean downHold = platformBuild.getDownHold() || platformBuild.getDownOccHold();
|
||||||
|
if (!upHold && !downHold) {
|
||||||
|
alertDataSource.removeAlterDevice(platformBuild.getLineId(), PLATFORM_HOLD_ALERT_NAME, platformBuild.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), String.valueOf(giPlatform.getRefStation()), LayoutGraphicsProto.Station.class);
|
||||||
|
Integer currentStationCodeInt = Integer.valueOf(station.getCode());
|
||||||
|
Integer startStationCodeInt = stationCodeList.get(0);
|
||||||
|
if (giPlatform.getUp() == false) {
|
||||||
|
startStationCodeInt = stationCodeList.get(stationCodeList.size() - 1);
|
||||||
|
}
|
||||||
|
if (!currentStationCodeInt.equals(startStationCodeInt)) {
|
||||||
|
LayoutGraphicsProto.Section startSection = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefSectionId() + "", LayoutGraphicsProto.Section.class);
|
||||||
|
LayoutGraphicsProto.RelatedRef sectionRef = startSection.getPaRef();
|
||||||
|
if (giPlatform.getUp() == false) {
|
||||||
|
sectionRef = startSection.getPbRef();
|
||||||
|
}
|
||||||
|
Map<Integer, GeneratedMessageV3> deviceMap = new HashMap<>();
|
||||||
|
deviceMap.put(startSection.getCommon().getId(), startSection);
|
||||||
|
findPlatformTrack(platformBuild, giPlatform.getUp(), sectionRef, deviceMap);
|
||||||
|
deviceMap.remove(startSection.getCommon().getId());//移除站台轨
|
||||||
|
List<LayoutGraphicsProto.Section> trackAreas = deviceMap.values().stream().filter(d -> d instanceof LayoutGraphicsProto.Section).map(d -> (LayoutGraphicsProto.Section) d).toList();
|
||||||
|
List<String> areaTrainGroups = this.findAreaTrain(trackAreas, platformBuild.getLineId());
|
||||||
|
if (areaTrainGroups.size() >= 2 && alertDataSource.putAlterDevice(platformBuild.getLineId(), PLATFORM_HOLD_ALERT_NAME, platformBuild.getId())) {
|
||||||
|
String pf = giPlatform.getUp() ? "上行站台" : "下行站台";
|
||||||
|
String msg = String.format("%s%s扣车此区间已驶入%d辆列车", station.getName(), pf, areaTrainGroups.size());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.HOLD_PLATFORM_STAY_TRAIN_MORE, platformBuild, msg, String.valueOf(giPlatform.getCommon().getId()),
|
||||||
|
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> findAreaTrain(List<LayoutGraphicsProto.Section> findTrackArea, Integer lineId) {
|
||||||
|
List<String> findAreaTrains = Lists.newArrayList();
|
||||||
|
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.TRAIN);
|
||||||
|
for (Section section : findTrackArea) {
|
||||||
|
if (section.getSectionType() == SectionType.Physical) {
|
||||||
|
for (Integer childSecionId : section.getChildrenList()) {
|
||||||
|
MessageOrBuilder childMB = LineGraphicDataRepository.getDeviceByCode(lineId, childSecionId.toString());
|
||||||
|
String deviceCode = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
||||||
|
String trainGroupId = trainDataSource.findTrainForDeviceName(deviceCode);
|
||||||
|
if (StringUtils.isNotEmpty(trainGroupId)) {
|
||||||
|
findAreaTrains.add(trainGroupId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
||||||
|
String trainGroupId = trainDataSource.findTrainForDeviceName(section.getCode());
|
||||||
|
if (StringUtils.isNotEmpty(trainGroupId)) {
|
||||||
|
findAreaTrains.add(trainGroupId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return findAreaTrains;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取站台所属的道轨
|
||||||
|
*
|
||||||
|
* @param platformBuild
|
||||||
|
* @param upway
|
||||||
|
* @param startRef
|
||||||
|
* @param deviceMap
|
||||||
|
*/
|
||||||
|
public void findPlatformTrack(Platform.Builder platformBuild, boolean upway, LayoutGraphicsProto.RelatedRef startRef, Map<Integer, GeneratedMessageV3> deviceMap) {
|
||||||
|
if (startRef.getDeviceType() == DeviceType.Turnout) {
|
||||||
|
LayoutGraphicsProto.Turnout turnout = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), startRef.getId() + "", LayoutGraphicsProto.Turnout.class);
|
||||||
|
String sectionCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(platformBuild.getLineId(), turnout.getCode());
|
||||||
|
LayoutGraphicsProto.Section turnoutSec = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), sectionCode + "", LayoutGraphicsProto.Section.class);
|
||||||
|
|
||||||
|
deviceMap.put(turnoutSec.getCommon().getId(), turnoutSec);
|
||||||
|
deviceMap.put(turnout.getCommon().getId(), turnout);
|
||||||
|
if (deviceMap.containsKey(turnout.getPaRef().getId())) {
|
||||||
|
this.findPlatformTrack(platformBuild, upway, turnout.getPbRef(), deviceMap);
|
||||||
|
} else {
|
||||||
|
this.findPlatformTrack(platformBuild, upway, turnout.getPaRef(), deviceMap);
|
||||||
|
}
|
||||||
|
} else if (startRef.getDeviceType() == DeviceType.Section) {
|
||||||
|
LayoutGraphicsProto.Section nextSection = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), startRef.getId() + "", LayoutGraphicsProto.Section.class);
|
||||||
|
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(platformBuild.getLineId(), nextSection.getCode());
|
||||||
|
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
||||||
|
if (StringUtils.isNotEmpty(platformCode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deviceMap.put(nextSection.getCommon().getId(), nextSection);
|
||||||
|
|
||||||
|
LayoutGraphicsProto.RelatedRef sectionRef = nextSection.getPaRef();
|
||||||
|
if (upway == false) {
|
||||||
|
sectionRef = nextSection.getPbRef();
|
||||||
|
}
|
||||||
|
this.findPlatformTrack(platformBuild, upway, sectionRef, deviceMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final static String PLATFORM_WAIT_MAX_TIME_ALERT_NAME = "platform_wait_max_time_alert";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查站台列车候车时间阈值
|
||||||
|
*
|
||||||
|
* @param platformBuild
|
||||||
|
*/
|
||||||
|
private void checkPlatformWithTimeOut(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform) {
|
||||||
|
if (platformBuild.getBizWaitTimerGoing() == false && platformBuild.getBizWaitStartTimeSec() > 0) {
|
||||||
|
long waitTimes = (System.currentTimeMillis() / 1000 - (platformBuild.getBizWaitStartTimeSec()));
|
||||||
|
GuardConfig config = this.guardConfigService.getGuardConfig(platformBuild.getLineId());
|
||||||
|
if (waitTimes > config.getPlatformWaitTimes()) {
|
||||||
|
|
||||||
|
if (alertDataSource.putAlterDevice(platformBuild.getLineId(), PLATFORM_WAIT_MAX_TIME_ALERT_NAME, platformBuild.getId())) {
|
||||||
|
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefStation() + "", LayoutGraphicsProto.Station.class);
|
||||||
|
String pf = giPlatform.getUp() ? "上行站台" : "下行站台";
|
||||||
|
String msg = String.format("%s%s乘客等待列车时间超过%d秒", station.getName(), pf, config.getPlatformWaitTimes());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.PLATFORM_WAIT_TRAIN_MAX_RECORD, platformBuild, msg, String.valueOf(giPlatform.getCommon().getId()),
|
||||||
|
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertDataSource.removeAlterDevice(platformBuild.getLineId(), PLATFORM_WAIT_MAX_TIME_ALERT_NAME, platformBuild.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Set<String> allLineSet = DeviceDataRepository.getAllLines();
|
||||||
|
for (String lineIdStr : allLineSet) {
|
||||||
|
Integer lineIdInt = Integer.parseInt(lineIdStr);
|
||||||
|
List<Integer> stationCodeList = LineGraphicDataRepository.allStation(lineIdInt);
|
||||||
|
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineIdStr, DataTypeEnum.DEVICE);
|
||||||
|
List<LayoutGraphicsProto.Platform> giPlatformList = LineGraphicDataRepository.getDevices(lineIdInt, LayoutGraphicsProto.Platform.class).distinct().toList();
|
||||||
|
for (LayoutGraphicsProto.Platform giPlatform : giPlatformList) {
|
||||||
|
Map<String, Builder> builderMap = deviceStatusData.getAllDeviceMap().get(DeviceStatusProto.Platform.getDescriptor().getName());
|
||||||
|
if (CollectionUtils.isNotEmpty(builderMap) && Objects.nonNull(builderMap.get(giPlatform.getCode()))) {
|
||||||
|
Platform.Builder platformBuild = (Platform.Builder) builderMap.get(giPlatform.getCode());
|
||||||
|
this.emergStop(platformBuild, giPlatform);
|
||||||
|
this.stationPlatformHoldCheck(platformBuild, giPlatform, stationCodeList);
|
||||||
|
this.checkPlatformWithTimeOut(platformBuild, giPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,29 @@
|
|||||||
package club.joylink.xiannccda.ats.warn.platform;
|
package club.joylink.xiannccda.ats.warn.platform;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||||
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.message.collect.DeviceDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||||
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
||||||
import club.joylink.xiannccda.ats.warn.platform.TrainReacrdAlertListener.TrainRecordAlertEvent;
|
import club.joylink.xiannccda.ats.warn.platform.TrainReacrdAlertListener.TrainRecordAlertEvent;
|
||||||
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainDelayInfo;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainShedule.Plan;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
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;
|
||||||
|
|
||||||
@ -17,26 +33,27 @@ import org.springframework.stereotype.Component;
|
|||||||
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
|
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
|
||||||
|
|
||||||
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||||
@Autowired
|
|
||||||
private OccNotHandlePros notHandlePros;
|
|
||||||
|
|
||||||
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||||
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(TrainRecordAlertEvent event) {
|
public void accept(TrainRecordAlertEvent event) {
|
||||||
TrainRecord.Builder trainRecord = event.getSource();
|
TrainRecord.Builder trainRecord = event.getSource();
|
||||||
|
|
||||||
if (trainRecord.getRecordType()) {
|
if (trainRecord.getRecordType()) {
|
||||||
log.info("列车报点,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
log.info("列车报点,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
||||||
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
||||||
trainRecord.getRecordType());
|
trainRecord.getRecordType());
|
||||||
|
this.platformAlertMonitoringTask.findNexPlatform(trainRecord);
|
||||||
this.platformAlertMonitoringTask.putTrainRecord(trainRecord);
|
this.platformAlertMonitoringTask.putTrainRecord(trainRecord);
|
||||||
} else {
|
} else {
|
||||||
log.info("列车报点驶离,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
log.info("列车报点驶离,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
||||||
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
||||||
trainRecord.getRecordType());
|
trainRecord.getRecordType());
|
||||||
|
this.platformAlertMonitoringTask.trainLeavePlatform(trainRecord);
|
||||||
this.platformAlertMonitoringTask.removeTrainRecord(trainRecord);
|
this.platformAlertMonitoringTask.removeTrainRecord(trainRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package club.joylink.xiannccda.ats.warn.atp;
|
package club.joylink.xiannccda.ats.warn.train;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||||
@ -19,9 +19,11 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo.Builder;
|
|||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||||
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 club.joylink.xiannccda.vo.AreaConfigVO;
|
||||||
import com.google.protobuf.MessageOrBuilder;
|
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.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -62,6 +64,41 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final static String TRAIN_INTEGRITY_NAME = "TRAIN_INTEGRITY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列车不完整直接报警
|
||||||
|
*
|
||||||
|
* @param trainInfo
|
||||||
|
*/
|
||||||
|
public void trainIntegrityAlarm(TrainInfo.Builder trainInfo) {
|
||||||
|
if (trainInfo.getMode().getIpModeTrainIntegrityAlarm()) {
|
||||||
|
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId())) {
|
||||||
|
|
||||||
|
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
|
// CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class);
|
||||||
|
String layoutDeviceId = null;
|
||||||
|
if (mb instanceof LogicSection) {
|
||||||
|
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
|
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class);
|
||||||
|
layoutDeviceId = String.valueOf(section.getCommon().getId());
|
||||||
|
} else if (mb instanceof Turnout) {
|
||||||
|
String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
|
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
||||||
|
layoutDeviceId = String.valueOf(section.getCommon().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
String alertMsg = String.format("列车[%s] 丢失完整性所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.TRAIN_INTEGRITY_ALARM, trainInfo, alertMsg, layoutDeviceId,
|
||||||
|
AlertDeviceType.DEVICE_TYPE_TRACK, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertDataSource.removeAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断紧致后发生atp切除并恢复
|
* 判断紧致后发生atp切除并恢复
|
||||||
* <p>
|
* <p>
|
||||||
@ -96,13 +133,12 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
return "TRAIN_EB_WITH_ATP_CUT_ALTER";
|
return "TRAIN_EB_WITH_ATP_CUT_ALTER";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Integer findTrainLocation(TrainInfo.Builder trainInfo) {
|
||||||
protected void trainAlert(TrainInfo.Builder trainInfo) {
|
|
||||||
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName());
|
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
if (!(mb instanceof LogicSection) && !(mb instanceof Turnout) && !(mb instanceof Section)) {
|
if (!(mb instanceof LogicSection) && !(mb instanceof Turnout) && !(mb instanceof Section)) {
|
||||||
log.error("线路[{}]列车[{}]所在未知设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
log.error("线路[{}]列车[{}]所在未知设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
||||||
this.trainInfoMap.remove(trainInfo.getGroupId());
|
this.trainInfoMap.remove(trainInfo.getGroupId());
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class);
|
CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class);
|
||||||
Integer layoutDeviceId = commonInfo.getId();
|
Integer layoutDeviceId = commonInfo.getId();
|
||||||
@ -110,20 +146,19 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class);
|
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class);
|
||||||
layoutDeviceId = section.getCommon().getId();
|
layoutDeviceId = section.getCommon().getId();
|
||||||
}
|
} else if (mb instanceof Turnout) {
|
||||||
if (mb instanceof Turnout) {
|
|
||||||
String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName());
|
String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
||||||
layoutDeviceId = section.getCommon().getId();
|
layoutDeviceId = section.getCommon().getId();
|
||||||
}
|
}
|
||||||
/* if (mb instanceof Section section) {
|
return layoutDeviceId;
|
||||||
if (section.getSectionType() == SectionType.Physical) {
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
protected void trainAlert(TrainInfo.Builder trainInfo) {
|
||||||
|
Integer layoutDeviceId = this.findTrainLocation(trainInfo);
|
||||||
|
if (Objects.isNull(layoutDeviceId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) {
|
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) {
|
||||||
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
||||||
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||||
@ -134,6 +169,21 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
this.trainInfoMap.remove(trainInfo.getGroupId());
|
this.trainInfoMap.remove(trainInfo.getGroupId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final static String TRAIN_LOST_LOCATION_ALERT_NAME = "train_lost_location_alert";
|
||||||
|
|
||||||
|
private void trainLostLocation(TrainInfo.Builder trainInfo) {
|
||||||
|
Integer layoutDeviceId = this.findTrainLocation(trainInfo);
|
||||||
|
if (Objects.isNull(layoutDeviceId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), TRAIN_LOST_LOCATION_ALERT_NAME, trainInfo.getGroupId())) {
|
||||||
|
String alertMsg = String.format("列车[%s] 定位丢失所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_LOST_LOCATION, AlertDeviceType.DEVICE_TYPE_TRACK, layoutDeviceId, trainInfo, alertMsg,
|
||||||
|
AlertDeviceType.DEVICE_TYPE_TRAIN, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Builder trainInfo : this.trainInfoMap.values()) {
|
for (Builder trainInfo : this.trainInfoMap.values()) {
|
||||||
@ -148,6 +198,12 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
} else if (timeOver) {
|
} else if (timeOver) {
|
||||||
this.trainInfoMap.remove(groupId);
|
this.trainInfoMap.remove(groupId);
|
||||||
}
|
}
|
||||||
|
if (trainInfo.getMode().getIpModeTrainDriveModeRmf()) {
|
||||||
|
//列车紧致导致rm模式
|
||||||
|
this.trainLostLocation(trainInfo);
|
||||||
|
} else if (trainInfo.getMode().getIpModeTrainDriveModeRmf() == false) {
|
||||||
|
alertDataSource.removeAlterDevice(trainInfo.getLineId(), TRAIN_LOST_LOCATION_ALERT_NAME, trainInfo.getGroupId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package club.joylink.xiannccda.ats.warn.atp;
|
package club.joylink.xiannccda.ats.warn.train;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||||
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
||||||
import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent;
|
import club.joylink.xiannccda.ats.warn.platform.PlatformAlertMonitoringTask;
|
||||||
|
import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||||
@ -18,10 +19,11 @@ import org.springframework.stereotype.Component;
|
|||||||
public class TrainModeAlertListener implements AlertSourceEventListener<TrainAlertEvent> {
|
public class TrainModeAlertListener implements AlertSourceEventListener<TrainAlertEvent> {
|
||||||
|
|
||||||
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
|
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
|
||||||
|
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||||
|
|
||||||
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) {
|
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask, PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||||
|
|
||||||
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
|
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
|
||||||
|
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,6 +31,10 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
|||||||
GeneratedMessageV3.Builder trainMsgBuild = event.getSource();
|
GeneratedMessageV3.Builder trainMsgBuild = event.getSource();
|
||||||
if (trainMsgBuild instanceof TrainInfo.Builder trainInfo) {
|
if (trainMsgBuild instanceof TrainInfo.Builder trainInfo) {
|
||||||
TrainMode trainMode = trainInfo.getMode();
|
TrainMode trainMode = trainInfo.getMode();
|
||||||
|
//列车不完整直接报警
|
||||||
|
this.atpCutAlertMonitoringTask.trainIntegrityAlarm(trainInfo);
|
||||||
|
//列车晚点超时
|
||||||
|
this.platformAlertMonitoringTask.trainDelayCheck(trainInfo);
|
||||||
if (trainMode.getIpModeTrainEbAlarm()) {
|
if (trainMode.getIpModeTrainEbAlarm()) {
|
||||||
//列车紧急制动
|
//列车紧急制动
|
||||||
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
|
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
|
||||||
@ -37,15 +43,16 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
|||||||
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
|
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
|
||||||
} else if (Objects.equals(false, trainMode.getIpModeTrainAtpCut())) {
|
} else if (Objects.equals(false, trainMode.getIpModeTrainAtpCut())) {
|
||||||
this.atpCutAlertMonitoringTask.recoverAtpCut(trainInfo);
|
this.atpCutAlertMonitoringTask.recoverAtpCut(trainInfo);
|
||||||
|
//TODo
|
||||||
} else {
|
} else {
|
||||||
this.atpCutAlertMonitoringTask.updateTrainInfo(trainInfo);
|
this.atpCutAlertMonitoringTask.updateTrainInfo(trainInfo);
|
||||||
}
|
}
|
||||||
} else if (trainMsgBuild instanceof TrainRemove.Builder trainRemove) {
|
} else if (trainMsgBuild instanceof TrainRemove.Builder trainRemove) {
|
||||||
this.atpCutAlertMonitoringTask.trainRemoveAllInfo(trainRemove);
|
this.atpCutAlertMonitoringTask.trainRemoveAllInfo(trainRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TrainAlertEvent extends DeviceAlertEvent<Builder> {
|
public static class TrainAlertEvent extends DeviceAlertEvent<Builder> {
|
||||||
|
|
||||||
public TrainAlertEvent(GeneratedMessageV3.Builder source) {
|
public TrainAlertEvent(GeneratedMessageV3.Builder source) {
|
@ -0,0 +1,61 @@
|
|||||||
|
package club.joylink.xiannccda.configuration;
|
||||||
|
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.LoginUserAttr;
|
||||||
|
import club.joylink.xiannccda.dto.auth.ApiPathCacheDTO;
|
||||||
|
import club.joylink.xiannccda.service.AuthService;
|
||||||
|
import jakarta.servlet.Filter;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.ServletRequest;
|
||||||
|
import jakarta.servlet.ServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|
||||||
|
import org.springframework.security.oauth2.jwt.Jwt;
|
||||||
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
|
||||||
|
//@Component
|
||||||
|
@Slf4j
|
||||||
|
public class AuthFilter implements Filter {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuthService authService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
HttpServletRequest req = (HttpServletRequest) request;
|
||||||
|
var finder = true;
|
||||||
|
if (Objects.nonNull(authentication) && authentication.isAuthenticated() && (authentication.getPrincipal() instanceof Jwt jwt)) {
|
||||||
|
if (Objects.isNull(jwt.getClaim(LoginUserAttr.DEFAULTS))) {
|
||||||
|
finder = false;
|
||||||
|
Object roleObj = jwt.getClaim(LoginUserAttr.ROLES);
|
||||||
|
var roleList = (List<Long>) roleObj;
|
||||||
|
for (Long roleId : roleList) {
|
||||||
|
var cacheList = this.authService.findByRoleId(roleId);
|
||||||
|
for (ApiPathCacheDTO cache : cacheList) {
|
||||||
|
AntPathRequestMatcher matcher = new AntPathRequestMatcher(cache.getUri());
|
||||||
|
if (matcher.matcher(req).isMatch() && cache.getMethods().contains(req.getMethod().toUpperCase())) {
|
||||||
|
finder = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finder) {
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
} else {
|
||||||
|
throw new AccessDeniedException("无权限");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -19,8 +19,6 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
|
|||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
||||||
import org.springframework.security.oauth2.jwt.JwtEncoder;
|
import org.springframework.security.oauth2.jwt.JwtEncoder;
|
||||||
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
|
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
|
||||||
@ -31,6 +29,7 @@ import org.springframework.security.oauth2.server.resource.authentication.JwtGra
|
|||||||
import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint;
|
import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationEntryPoint;
|
||||||
import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler;
|
import org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
import org.springframework.security.web.util.matcher.RequestMatcher;
|
import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
@ -52,7 +51,8 @@ public class SpringSecurityConfiguration {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CorsConfigurationSource corsConfigurationSource;
|
CorsConfigurationSource corsConfigurationSource;
|
||||||
|
/*@Autowired
|
||||||
|
private AuthFilter authFilter;*/
|
||||||
static List<RequestMatcher> AuthWhiteList = new ArrayList<>();
|
static List<RequestMatcher> AuthWhiteList = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -68,6 +68,7 @@ public class SpringSecurityConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
|
||||||
http
|
http
|
||||||
.authorizeHttpRequests((authorize) -> {
|
.authorizeHttpRequests((authorize) -> {
|
||||||
// authorize.requestMatchers("/favicon.ico", "/js2/**",
|
// authorize.requestMatchers("/favicon.ico", "/js2/**",
|
||||||
@ -79,10 +80,14 @@ public class SpringSecurityConfiguration {
|
|||||||
authorize.anyRequest().authenticated();
|
authorize.anyRequest().authenticated();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
// BearerTokenAuthenticationFilter
|
||||||
.cors(corsConfig -> corsConfig.configurationSource(corsConfigurationSource))
|
.cors(corsConfig -> corsConfig.configurationSource(corsConfigurationSource))
|
||||||
.csrf((csrf) -> csrf.disable())
|
.csrf((csrf) -> csrf.disable())
|
||||||
|
|
||||||
// .httpBasic(Customizer.withDefaults())
|
// .httpBasic(Customizer.withDefaults())
|
||||||
.oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt -> jwt.decoder(this.jwtDecoder())))
|
.oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt -> jwt.decoder(this.jwtDecoder())))
|
||||||
|
|
||||||
|
// .addFilterAfter(authFilter,FilterSecurityInterceptor.class)
|
||||||
.sessionManagement(
|
.sessionManagement(
|
||||||
(session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
(session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.exceptionHandling((exceptions) -> exceptions
|
.exceptionHandling((exceptions) -> exceptions
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package club.joylink.xiannccda.configuration;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.core.task.TaskExecutor;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableAsync
|
||||||
|
public class SystemSynTaskConfig {
|
||||||
|
|
||||||
|
@Bean("nsExecutor")
|
||||||
|
public TaskExecutor nsExecutor(Environment env) {
|
||||||
|
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
|
||||||
|
taskExecutor.setThreadNamePrefix("ns-executor-");
|
||||||
|
taskExecutor.setCorePoolSize(2);
|
||||||
|
taskExecutor.setMaxPoolSize(2);
|
||||||
|
taskExecutor.setQueueCapacity(100);
|
||||||
|
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
taskExecutor.initialize();
|
||||||
|
return taskExecutor;
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +0,0 @@
|
|||||||
package club.joylink.xiannccda.configuration.pros;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Component
|
|
||||||
@ConfigurationProperties(prefix = "occ-not-handle")
|
|
||||||
public class OccNotHandlePros {
|
|
||||||
|
|
||||||
private Integer lineId;
|
|
||||||
private List<Integer> filterRtuIds;
|
|
||||||
private Map<Integer, List<String>> trainRecordStation;
|
|
||||||
|
|
||||||
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
|
||||||
if (Objects.isNull(lineId) || Objects.isNull(rtuId)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(this.filterRtuIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.filterRtuIds.contains(rtuId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,55 @@
|
|||||||
|
package club.joylink.xiannccda.configuration.protos;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "occ-client")
|
||||||
|
public class OccServerProto {
|
||||||
|
|
||||||
|
private Map<Integer, OccClientMessage> clientInfoMap;
|
||||||
|
|
||||||
|
public OccClientMessage getClientMessage(Integer lineId) {
|
||||||
|
return this.clientInfoMap.get(lineId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getAllLineIds() {
|
||||||
|
return this.clientInfoMap.keySet();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class OccClientMessage {
|
||||||
|
|
||||||
|
private String serverHost;
|
||||||
|
|
||||||
|
private Integer realPort;
|
||||||
|
|
||||||
|
private Integer unRealPort;
|
||||||
|
|
||||||
|
private Boolean collectorData;
|
||||||
|
|
||||||
|
private Integer receiveMsgTimeout;
|
||||||
|
|
||||||
|
private boolean monitorHandwareChange;
|
||||||
|
|
||||||
|
private List<Integer> filterRtuIds;
|
||||||
|
private NameChangerEnum nameChanger;
|
||||||
|
|
||||||
|
private List<LineTypeEnum> lineTypes;
|
||||||
|
|
||||||
|
private boolean connectionOcc;
|
||||||
|
|
||||||
|
public boolean rtuIdExists(Integer rtiud) {
|
||||||
|
return this.filterRtuIds.contains(rtiud);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package club.joylink.xiannccda.constants;
|
package club.joylink.xiannccda.constants;
|
||||||
|
|
||||||
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
import club.joylink.xiannccda.ats.message.OccMessageManage;
|
||||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
@ -26,7 +26,7 @@ public class SystemContext implements ApplicationContextAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean notMatchRtu(Integer lineId, Integer rtuId) {
|
public static boolean notMatchRtu(Integer lineId, Integer rtuId) {
|
||||||
OccNotHandlePros cu = SystemContext.getAppContext().getBean(OccNotHandlePros.class);
|
OccMessageManage cu = SystemContext.getAppContext().getBean(OccMessageManage.class);
|
||||||
return cu.notMatchHandle(lineId, rtuId);
|
return cu.notMatchHandle(lineId, rtuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package club.joylink.xiannccda.constants.common;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import org.springframework.stereotype.Indexed;
|
||||||
|
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Indexed
|
||||||
|
public @interface CommonLogAnno {
|
||||||
|
|
||||||
|
String name() default "";
|
||||||
|
|
||||||
|
CommonLogTypeEnum logType();
|
||||||
|
|
||||||
|
CommonLogTypeEnum.SubEventType subLogType();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package club.joylink.xiannccda.constants.common;
|
||||||
|
|
||||||
|
public enum CommonLogTypeEnum {
|
||||||
|
//登录
|
||||||
|
LOGIN,
|
||||||
|
OPERATE,
|
||||||
|
WARN,
|
||||||
|
;
|
||||||
|
|
||||||
|
public enum SubEventType {
|
||||||
|
LOGIN, LOGOUT, QUERY, SAVE_OR_UPDATE, DELETE, WARN, NONE
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package club.joylink.xiannccda.constants.common;
|
||||||
|
|
||||||
|
public enum FaultQueryType {
|
||||||
|
// FAULT_EMERGENCY_GUIDE 开头是应急故障,FAULT_EXIT_SERVICE 开头是故障退出服务
|
||||||
|
// T 代表车辆,T后面代表车辆型号
|
||||||
|
|
||||||
|
FAULT_EMERGENCY_NCC,
|
||||||
|
FAULT_EMERGENCY_GUIDE,
|
||||||
|
FAULT_EXIT_SERVICE,
|
||||||
|
FAULT_EMERGENCY_GUIDE_T_DK37,
|
||||||
|
FAULT_EXIT_SERVICE_T_DK37,
|
||||||
|
|
||||||
|
FAULT_EMERGENCY_GUIDE_T_CCD_5037,
|
||||||
|
FAULT_EXIT_SERVICE_T_CCD_5037,
|
||||||
|
;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package club.joylink.xiannccda.constants.common;
|
||||||
|
|
||||||
|
public enum LineTypeEnum {
|
||||||
|
NCC, OCC;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package club.joylink.xiannccda.constants.common;
|
||||||
|
|
||||||
|
public class LoginUserAttr {
|
||||||
|
|
||||||
|
public static final String DEFAULTS = "default";
|
||||||
|
public static final String ROLES = "roles";
|
||||||
|
|
||||||
|
public enum DefaultUserRuleEnum {
|
||||||
|
ADMIN, USER
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,10 @@ package club.joylink.xiannccda.controller;
|
|||||||
|
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
|
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||||
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.AlertRecordReportDTO;
|
||||||
import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO;
|
import club.joylink.xiannccda.dto.record.AlertRecordReportResponseDTO;
|
||||||
@ -15,7 +19,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -48,6 +51,7 @@ public class AlertRecordController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "报警信息确认")
|
@Operation(summary = "报警信息确认")
|
||||||
@ApiResponse(description = "报警信息确认")
|
@ApiResponse(description = "报警信息确认")
|
||||||
|
@CommonLogAnno(name = "报警信息确认", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public AlertTip confirm(@PathVariable("recordId") Long recordId, @PathVariable("tipType") String tipType, @RequestParam(value = "alertLocationId", required = false) Long locationId) {
|
public AlertTip confirm(@PathVariable("recordId") Long recordId, @PathVariable("tipType") String tipType, @RequestParam(value = "alertLocationId", required = false) Long locationId) {
|
||||||
return this.alertRecordService.confirm(recordId, tipType, locationId);
|
return this.alertRecordService.confirm(recordId, tipType, locationId);
|
||||||
}
|
}
|
||||||
@ -56,6 +60,7 @@ public class AlertRecordController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "错误报警")
|
@Operation(summary = "错误报警")
|
||||||
@ApiResponse(description = "错误报警")
|
@ApiResponse(description = "错误报警")
|
||||||
|
@CommonLogAnno(name = "报警信息-人工确认", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public void batchAlarmWarn(@RequestBody List<Long> recordId) {
|
public void batchAlarmWarn(@RequestBody List<Long> recordId) {
|
||||||
this.alertRecordService.failAlarm(recordId, AlertStatus.PERSON_WARN_DO);
|
this.alertRecordService.failAlarm(recordId, AlertStatus.PERSON_WARN_DO);
|
||||||
}
|
}
|
||||||
@ -64,23 +69,28 @@ public class AlertRecordController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "错误报警")
|
@Operation(summary = "错误报警")
|
||||||
@ApiResponse(description = "错误报警")
|
@ApiResponse(description = "错误报警")
|
||||||
|
@CommonLogAnno(name = "报警信息-误报", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public void failAlarm(@PathVariable("recordId") Long recordId) {
|
public void failAlarm(@PathVariable("recordId") Long recordId) {
|
||||||
this.alertRecordService.failAlarm(List.of(recordId), AlertStatus.FAIL_DO);
|
this.alertRecordService.failAlarm(List.of(recordId), AlertStatus.FAIL_DO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/page")
|
/* @PostMapping("/page")
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "分页查询报警记录")
|
@Operation(summary = "分页查询报警记录")
|
||||||
@ApiResponse(description = "报警记录")
|
@ApiResponse(description = "报警记录")
|
||||||
|
@CommonLogAnno(name = "报警信息-列表数据", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public Page<AlertRecord> pageQuery(@RequestBody AlertRecordQueryDTO queryDTO) {
|
public Page<AlertRecord> pageQuery(@RequestBody AlertRecordQueryDTO queryDTO) {
|
||||||
return alertRecordRepository.page(queryDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/page/detail")
|
return alertRecordRepository.newPage(CommonPageRequest.defaultPage(), queryDTO);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/page/detail")
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "分页查询报警记录详情")
|
@Operation(summary = "分页查询报警记录详情")
|
||||||
@ApiResponse(description = "报警记录详情")
|
@ApiResponse(description = "报警记录详情")
|
||||||
public Page<NccAlertInfo> pageQueryAlertDetail(@RequestBody AlertRecordQueryDTO queryDTO) {
|
@CommonLogAnno(name = "报警信息-列表数据", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
|
public Page<NccAlertInfo> pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) {
|
||||||
return alertRecordService.pageQueryAlertDetail(queryDTO);
|
return alertRecordService.pageQueryAlertDetail(queryDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +99,7 @@ public class AlertRecordController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "报警统计")
|
@Operation(summary = "报警统计")
|
||||||
@ApiResponse(description = "报警统计")
|
@ApiResponse(description = "报警统计")
|
||||||
|
@CommonLogAnno(name = "报警信息-统计", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public List<AlertRecordReportResponseDTO> reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) {
|
public List<AlertRecordReportResponseDTO> reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) {
|
||||||
return this.alertRecordRepository.report(lineId, reportDTO);
|
return this.alertRecordRepository.report(lineId, reportDTO);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.controller;
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||||
@ -9,8 +12,6 @@ import club.joylink.xiannccda.service.AlertTipService;
|
|||||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService.AreaFinder;
|
import club.joylink.xiannccda.service.config.DeviceAreaConfigService.AreaFinder;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
@ -21,14 +22,13 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 报警时的提示信息 前端控制器
|
* 决策信息
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author walker-sheng
|
* @author walker-sheng
|
||||||
@ -52,6 +52,7 @@ public class AlertTipController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "插入报警提示信息")
|
@Operation(summary = "插入报警提示信息")
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
|
@CommonLogAnno(name = "决策信息-保存修改", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public void save(@RequestBody @Validated AlertTipSaveDTO saveDTO) {
|
public void save(@RequestBody @Validated AlertTipSaveDTO saveDTO) {
|
||||||
alertTipService.save(saveDTO);
|
alertTipService.save(saveDTO);
|
||||||
}
|
}
|
||||||
@ -60,6 +61,7 @@ public class AlertTipController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "根据id查询数据")
|
@Operation(summary = "根据id查询数据")
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
|
@CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public AlertTip getById(@PathVariable int id) {
|
public AlertTip getById(@PathVariable int id) {
|
||||||
return alertTipRepository.getById(id);
|
return alertTipRepository.getById(id);
|
||||||
}
|
}
|
||||||
@ -68,6 +70,7 @@ public class AlertTipController {
|
|||||||
@Operation(summary = "分页查询报警提示信息")
|
@Operation(summary = "分页查询报警提示信息")
|
||||||
@ApiResponse(description = "报警提示信息分页")
|
@ApiResponse(description = "报警提示信息分页")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
@CommonLogAnno(name = "决策信息-分页列表", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public IPage<AlertTipInfoDto> pageAlertTips(AlertTipQueryDTO alertTipQueryDTO) {
|
public IPage<AlertTipInfoDto> pageAlertTips(AlertTipQueryDTO alertTipQueryDTO) {
|
||||||
return this.alertTipService.page(alertTipQueryDTO);
|
return this.alertTipService.page(alertTipQueryDTO);
|
||||||
}
|
}
|
||||||
@ -77,13 +80,15 @@ public class AlertTipController {
|
|||||||
@Operation(summary = "根据id删除数据")
|
@Operation(summary = "根据id删除数据")
|
||||||
@ApiResponse(description = "是否确实删除掉了一条数据")
|
@ApiResponse(description = "是否确实删除掉了一条数据")
|
||||||
@DeleteMapping("/id/{id}")
|
@DeleteMapping("/id/{id}")
|
||||||
|
@CommonLogAnno(name = "决策信息-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||||
public boolean deleteById(@PathVariable int id) {
|
public boolean deleteById(@PathVariable int id) {
|
||||||
return this.alertTipRepository.removeById(id);
|
return this.alertTipRepository.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "绑定对应的错误类型")
|
@Operation(summary = "绑定对应的错误类型")
|
||||||
@PostMapping("/find/type/{lineId}/{alertType}")
|
@PostMapping(value = "/find/type/{lineId}/{alertType}")
|
||||||
|
@CommonLogAnno(name = "决策信息-类型绑定查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public List<AreaFinder> findAlertType(@PathVariable("lineId") Integer lineId, @PathVariable("alertType") String alertType) {
|
public List<AreaFinder> findAlertType(@PathVariable("lineId") Integer lineId, @PathVariable("alertType") String alertType) {
|
||||||
return this.areaConfigService.findAlertType(lineId, alertType);
|
return this.areaConfigService.findAlertType(lineId, alertType);
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.controller;
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipTimeQueryDTO;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipTimeQueryDTO;
|
||||||
import club.joylink.xiannccda.entity.AlertTipTimeConfig;
|
import club.joylink.xiannccda.entity.AlertTipTimeConfig;
|
||||||
import club.joylink.xiannccda.repository.impl.AlertTipTimeConfigRepository;
|
import club.joylink.xiannccda.repository.impl.AlertTipTimeConfigRepository;
|
||||||
@ -8,6 +11,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.time.Instant;
|
||||||
|
import org.springframework.security.oauth2.jwt.JwtClaimNames;
|
||||||
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -15,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 前端控制器
|
* 决策信息时间类型配置
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author walker-sheng
|
* @author walker-sheng
|
||||||
@ -36,6 +43,7 @@ public class AlertTipTimeConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "保存修改")
|
@Operation(summary = "保存修改")
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
|
@CommonLogAnno(name = "决策信息时间-类型保存", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public void save(@RequestBody AlertTipTimeConfig dto) {
|
public void save(@RequestBody AlertTipTimeConfig dto) {
|
||||||
this.timeConfigService.saveOrUpdate(dto);
|
this.timeConfigService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
@ -43,8 +51,8 @@ public class AlertTipTimeConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "保存修改")
|
@Operation(summary = "保存修改")
|
||||||
@PostMapping("page")
|
@PostMapping("page")
|
||||||
|
@CommonLogAnno(name = "决策信息时间-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public IPage<AlertTipTimeConfig> page(AlertTipTimeQueryDTO dto) {
|
public IPage<AlertTipTimeConfig> page(AlertTipTimeQueryDTO dto) {
|
||||||
|
|
||||||
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
|
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package club.joylink.xiannccda.controller;
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigDto;
|
import club.joylink.xiannccda.dto.config.DeviceAreaConfigDto;
|
||||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigPageDto;
|
import club.joylink.xiannccda.dto.config.DeviceAreaConfigPageDto;
|
||||||
import club.joylink.xiannccda.dto.config.DeviceAreaConfigQueryDto;
|
import club.joylink.xiannccda.dto.config.DeviceAreaConfigQueryDto;
|
||||||
import club.joylink.xiannccda.entity.DeviceAreaConfig;
|
|
||||||
import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository;
|
|
||||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService.AreaFinder;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
@ -25,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 前端控制器
|
* 设备区域配置
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author walker-sheng
|
* @author walker-sheng
|
||||||
@ -45,6 +42,7 @@ public class DeviceAreaConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "保存修改")
|
@Operation(summary = "保存修改")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
|
@CommonLogAnno(name = "决策信息设备区域配置-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public String save(@RequestBody DeviceAreaConfigDto dto) {
|
public String save(@RequestBody DeviceAreaConfigDto dto) {
|
||||||
this.areaConfigService.saveOrUpdate(dto);
|
this.areaConfigService.saveOrUpdate(dto);
|
||||||
return "ok";
|
return "ok";
|
||||||
@ -53,23 +51,17 @@ public class DeviceAreaConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "绑定对应的错误类型")
|
@Operation(summary = "绑定对应的错误类型")
|
||||||
@PostMapping("/bind/{id}")
|
@PostMapping("/bind/{id}")
|
||||||
|
@CommonLogAnno(name = "决策信息设备区域配置-信息绑定", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public String bindAlertType(@PathVariable("id") Long id, @RequestBody List<String> alertTypes) {
|
public String bindAlertType(@PathVariable("id") Long id, @RequestBody List<String> alertTypes) {
|
||||||
this.areaConfigService.bindAlertType(id, alertTypes);
|
this.areaConfigService.bindAlertType(id, alertTypes);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @SecurityRequirement(name = "jwt")
|
|
||||||
@Operation(summary = "绑定对应的错误类型")
|
|
||||||
@PostMapping("/find/type/{lineId}/{alertType}")
|
|
||||||
public List<AreaFinder> findAlertType(@PathVariable("lineId") Integer lineId, @PathVariable("alertType") String alertType) {
|
|
||||||
return this.areaConfigService.findAlertType(lineId, alertType);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "获取详情数据")
|
@Operation(summary = "获取详情数据")
|
||||||
@GetMapping("/page/{lineId}")
|
@GetMapping("/page/{lineId}")
|
||||||
|
@CommonLogAnno(name = "决策信息设备区域配置-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public Page<DeviceAreaConfigPageDto> page(@PathVariable("lineId") Integer lineId, DeviceAreaConfigQueryDto queryDto) {
|
public Page<DeviceAreaConfigPageDto> page(@PathVariable("lineId") Integer lineId, DeviceAreaConfigQueryDto queryDto) {
|
||||||
return this.areaConfigService.page(queryDto, lineId);
|
return this.areaConfigService.page(queryDto, lineId);
|
||||||
}
|
}
|
||||||
@ -77,6 +69,7 @@ public class DeviceAreaConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "获取详情数据")
|
@Operation(summary = "获取详情数据")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
|
@CommonLogAnno(name = "决策信息设备区域配置-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public DeviceAreaConfigDto findById(@PathVariable("id") Long id) {
|
public DeviceAreaConfigDto findById(@PathVariable("id") Long id) {
|
||||||
return this.areaConfigService.findInfo(id);
|
return this.areaConfigService.findInfo(id);
|
||||||
}
|
}
|
||||||
@ -84,6 +77,7 @@ public class DeviceAreaConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "获取详情数据")
|
@Operation(summary = "获取详情数据")
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@CommonLogAnno(name = "决策信息设备区域配置-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||||
public String delete(@PathVariable("id") Long id) {
|
public String delete(@PathVariable("id") Long id) {
|
||||||
this.areaConfigService.delete(id);
|
this.areaConfigService.delete(id);
|
||||||
return "ok";
|
return "ok";
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package club.joylink.xiannccda.controller;
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
import club.joylink.xiannccda.entity.DeviceGuardConfig;
|
import club.joylink.xiannccda.entity.DeviceGuardConfig;
|
||||||
import club.joylink.xiannccda.repository.IDeviceGuardConfigRepository;
|
import club.joylink.xiannccda.repository.IDeviceGuardConfigRepository;
|
||||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||||
@ -8,7 +11,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -17,7 +19,10 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Tag(name = "设备保护配置接口")
|
/**
|
||||||
|
* 决策信息阈值管理
|
||||||
|
*/
|
||||||
|
@Tag(name = "决策信息阈值管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/config/device")
|
@RequestMapping("/api/config/device")
|
||||||
public class DeviceGuardConfigController {
|
public class DeviceGuardConfigController {
|
||||||
@ -32,6 +37,7 @@ public class DeviceGuardConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "initData")
|
@Operation(summary = "initData")
|
||||||
@GetMapping("/initData/{lineId}")
|
@GetMapping("/initData/{lineId}")
|
||||||
|
@CommonLogAnno(name = "决策信息阈值管理-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public DeviceGuardConfig initData(@PathVariable("lineId") Integer lineId) {
|
public DeviceGuardConfig initData(@PathVariable("lineId") Integer lineId) {
|
||||||
LambdaQueryWrapper<DeviceGuardConfig> qw = Wrappers.lambdaQuery(DeviceGuardConfig.class);
|
LambdaQueryWrapper<DeviceGuardConfig> qw = Wrappers.lambdaQuery(DeviceGuardConfig.class);
|
||||||
qw.eq(DeviceGuardConfig::getLineId, lineId);
|
qw.eq(DeviceGuardConfig::getLineId, lineId);
|
||||||
@ -41,6 +47,7 @@ public class DeviceGuardConfigController {
|
|||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "保存修改")
|
@Operation(summary = "保存修改")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
|
@CommonLogAnno(name = "决策信息阈值管理-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
public String saveOrUpdate(@RequestBody DeviceGuardConfig dto) {
|
public String saveOrUpdate(@RequestBody DeviceGuardConfig dto) {
|
||||||
this.configService.saveOrUpdate(dto);
|
this.configService.saveOrUpdate(dto);
|
||||||
return "ok";
|
return "ok";
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||||
|
import club.joylink.xiannccda.dto.event.EventLogPageDTO;
|
||||||
|
import club.joylink.xiannccda.dto.event.EventLogQueryDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserEditDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||||
|
import club.joylink.xiannccda.entity.User;
|
||||||
|
import club.joylink.xiannccda.entity.User.Register;
|
||||||
|
import club.joylink.xiannccda.repository.IEventLogRepository;
|
||||||
|
import club.joylink.xiannccda.repository.IUserRepository;
|
||||||
|
import club.joylink.xiannccda.service.UserService;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户管理接口
|
||||||
|
*
|
||||||
|
* @author walker-sheng
|
||||||
|
* @since 2023-06-01
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/log")
|
||||||
|
@Tag(name = "事件查看")
|
||||||
|
public class EventLogController {
|
||||||
|
|
||||||
|
private IEventLogRepository eventLogRepository;
|
||||||
|
|
||||||
|
public EventLogController(IEventLogRepository eventLogRepository) {
|
||||||
|
this.eventLogRepository = eventLogRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/paging")
|
||||||
|
@Operation(summary = "分页数据")
|
||||||
|
@ApiResponse(description = "事件操作")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
public Page<EventLogPageDTO> register(EventLogQueryDTO dto) {
|
||||||
|
return this.eventLogRepository.detailPage(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
|
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||||
|
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||||
|
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||||
|
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultQueryNcc;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultType;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultType.FaultTypeDetail;
|
||||||
|
import club.joylink.xiannccda.entity.AlertTip;
|
||||||
|
import club.joylink.xiannccda.entity.FaultQuery;
|
||||||
|
import club.joylink.xiannccda.repository.IFaultQueryRepository;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author walker-sheng
|
||||||
|
* @since 2024-11-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/fault/query")
|
||||||
|
@Tag(name = "故障查询管理")
|
||||||
|
public class FaultQueryController {
|
||||||
|
|
||||||
|
|
||||||
|
private IFaultQueryRepository faultQueryRepository;
|
||||||
|
|
||||||
|
public FaultQueryController(IFaultQueryRepository faultQueryRepository) {
|
||||||
|
this.faultQueryRepository = faultQueryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "查询故障类型")
|
||||||
|
@GetMapping("/type")
|
||||||
|
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
|
public List<FaultType> faultType() {
|
||||||
|
return List.of(new FaultType(3,
|
||||||
|
List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE, "车辆故障应急处置指导关键点"), new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE, "车辆故障退出服务地点")
|
||||||
|
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||||
|
, new FaultType(4, List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_DK37, "车辆故障应急处置指导关键点-DK37车型"),
|
||||||
|
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_DK37, "车辆故障退出服务地点-DK37车型")
|
||||||
|
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_CCD_5037, "车辆故障应急处置指导关键点CCD-5037车型"),
|
||||||
|
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_CCD_5037, "车辆故障退出服务地点CCD-5037车型"), new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "保存故障查询")
|
||||||
|
@PostMapping("/ncc")
|
||||||
|
public List<FaultQueryNcc> queryFQForNcc() {
|
||||||
|
return this.faultQueryRepository.fqNcc();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "保存故障查询")
|
||||||
|
@PostMapping()
|
||||||
|
// @CommonLogAnno(name = "决策信息-保存修改", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||||
|
public void save(@RequestBody @Validated FaultQuery fq) {
|
||||||
|
this.faultQueryRepository.newSaveOrUpdate(fq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "根据id查询数据")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
|
public FaultQuery getById(@PathVariable int id) {
|
||||||
|
return faultQueryRepository.getById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "分页查询故障信息")
|
||||||
|
@ApiResponse(description = "分页查询故障信息")
|
||||||
|
@GetMapping("/page")
|
||||||
|
// @CommonLogAnno(name = "决策信息-分页列表", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
|
public IPage<FaultQuery> pageAlertTips(FaultQueryReqDTO req) {
|
||||||
|
return this.faultQueryRepository.page(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "根据id删除数据")
|
||||||
|
@ApiResponse(description = "是否确实删除掉了一条数据")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
// @CommonLogAnno(name = "决策信息-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||||
|
public boolean deleteById(@PathVariable int id) {
|
||||||
|
return this.faultQueryRepository.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/mock/ats")
|
||||||
|
@Tag(name = "线路信息管理接口")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MockLoadAtsDataController {
|
||||||
|
|
||||||
|
@PostMapping("")
|
||||||
|
public void startLoad() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping()
|
||||||
|
public void delete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||||
|
import club.joylink.xiannccda.dto.auth.AuthApiPathQueryDTO;
|
||||||
|
import club.joylink.xiannccda.dto.auth.AuthRoleDTO;
|
||||||
|
import club.joylink.xiannccda.dto.auth.AuthRoleQueryDTO;
|
||||||
|
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO;
|
||||||
|
import club.joylink.xiannccda.entity.AlertRecord;
|
||||||
|
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||||
|
import club.joylink.xiannccda.entity.AuthApiPath.AuthApi;
|
||||||
|
import club.joylink.xiannccda.entity.AuthRole;
|
||||||
|
import club.joylink.xiannccda.entity.User;
|
||||||
|
import club.joylink.xiannccda.entity.User.Register;
|
||||||
|
import club.joylink.xiannccda.repository.IAuthApiPathRepository;
|
||||||
|
import club.joylink.xiannccda.repository.IAuthRoleRepository;
|
||||||
|
import club.joylink.xiannccda.service.AuthService;
|
||||||
|
import club.joylink.xiannccda.service.UserService;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户管理接口
|
||||||
|
*
|
||||||
|
* @author walker-sheng
|
||||||
|
* @since 2023-06-01
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/role")
|
||||||
|
@Tag(name = "角色权限资源")
|
||||||
|
public class RoleAuthController {
|
||||||
|
|
||||||
|
private IAuthApiPathRepository authPathRepository;
|
||||||
|
private IAuthRoleRepository authRoleRepository;
|
||||||
|
private AuthService authService;
|
||||||
|
|
||||||
|
public RoleAuthController(IAuthApiPathRepository authPathRepository, IAuthRoleRepository authRoleRepository, AuthService authService) {
|
||||||
|
this.authPathRepository = authPathRepository;
|
||||||
|
this.authRoleRepository = authRoleRepository;
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/res/page")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "分页api资源")
|
||||||
|
@ApiResponse(description = "api资源")
|
||||||
|
public Page<AuthApiPath> pageQuery(AuthApiPathQueryDTO queryDTO) {
|
||||||
|
return authPathRepository.page(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/res/saveOrUpdate")
|
||||||
|
@Operation(summary = "保存编辑资源")
|
||||||
|
@ApiResponse(description = "保存编辑资源")
|
||||||
|
public void saveOrUpdate(@RequestBody @Validated(AuthApi.class) AuthApiPath apiPath) {
|
||||||
|
this.authPathRepository.saveOrUpdate(apiPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/res/{id}")
|
||||||
|
@Operation(summary = "保存编辑资源")
|
||||||
|
@ApiResponse(description = "保存编辑资源")
|
||||||
|
public void deleteRes(@PathVariable("id") Long id) {
|
||||||
|
this.authPathRepository.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/role/page")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "角色分页")
|
||||||
|
@ApiResponse(description = "角色分页")
|
||||||
|
public Page<AuthRoleDTO> rulePage(AuthRoleQueryDTO queryDTO) {
|
||||||
|
return this.authRoleRepository.roleApiPage(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/role/saveOrUpdate")
|
||||||
|
@Operation(summary = "角色编辑")
|
||||||
|
@ApiResponse(description = "角色编辑")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
public void roleSaveOrUpdate(@RequestBody AuthRoleDTO dto) {
|
||||||
|
this.authService.saveOrUpdate(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/config/{id}")
|
||||||
|
@Operation(summary = "角色配置")
|
||||||
|
@ApiResponse(description = "角色配置")
|
||||||
|
public void roleConfig(@PathVariable("id") Long id, AuthRoleDTO configStr) {
|
||||||
|
this.authRoleRepository.roleConfig(id, configStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,15 +1,23 @@
|
|||||||
package club.joylink.xiannccda.controller;
|
package club.joylink.xiannccda.controller;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||||
|
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||||
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||||
import club.joylink.xiannccda.entity.User;
|
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||||
import club.joylink.xiannccda.entity.User.Register;
|
import club.joylink.xiannccda.dto.user.UserEditDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserInfoAuthDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||||
|
import club.joylink.xiannccda.dto.user.UserTokenDTO;
|
||||||
|
import club.joylink.xiannccda.repository.IUserRepository;
|
||||||
import club.joylink.xiannccda.service.UserService;
|
import club.joylink.xiannccda.service.UserService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import java.security.Principal;
|
||||||
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -28,31 +36,67 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
private IUserRepository userRepository;
|
||||||
|
|
||||||
public UserController(UserService userService) {
|
public UserController(UserService userService, IUserRepository userRepository) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
/* @PostMapping("/register")
|
||||||
@Operation(summary = "用户注册")
|
@Operation(summary = "用户注册")
|
||||||
@ApiResponse(description = "用户注册结果")
|
@ApiResponse(description = "用户注册结果")
|
||||||
public String register(@RequestBody @Validated(Register.class) User user) {
|
public String register(@RequestBody @Validated(Register.class) User user) {
|
||||||
return this.userService.register(user);
|
return this.userService.register(user);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@PostMapping("/info")
|
||||||
|
@Operation(summary = "用户信息")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@ApiResponse(description = "用户信息")
|
||||||
|
public UserInfoAuthDTO userInfo(Principal user) {
|
||||||
|
return this.userService.userInfo((JwtAuthenticationToken) user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@Operation(summary = "用户登录")
|
@Operation(summary = "用户登录")
|
||||||
@ApiResponse(description = "授权的jwt")
|
@ApiResponse(description = "授权的jwt")
|
||||||
|
@CommonLogAnno(name = "用户登录", logType = CommonLogTypeEnum.LOGIN, subLogType = SubEventType.LOGIN)
|
||||||
public String login(@RequestBody LoginInfoDTO loginInfo) {
|
public String login(@RequestBody LoginInfoDTO loginInfo) {
|
||||||
return this.userService.login(loginInfo);
|
return this.userService.login(loginInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/logout")
|
||||||
|
@Operation(summary = "用户登出")
|
||||||
|
@ApiResponse(description = "授权的jwt")
|
||||||
|
@CommonLogAnno(name = "用户登出", logType = CommonLogTypeEnum.LOGIN, subLogType = SubEventType.LOGOUT)
|
||||||
|
public String logout() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/refresh/token")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "用户刷新token")
|
||||||
|
@ApiResponse(description = "刷新jwt")
|
||||||
|
public UserTokenDTO refreshToken(Principal user) {
|
||||||
|
return this.userService.refreshToken((JwtAuthenticationToken) user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/edit")
|
||||||
|
@Operation(summary = "用户修改")
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@ApiResponse(description = "用户修改")
|
||||||
|
public void editUser(@RequestBody UserEditDTO dto) {
|
||||||
|
this.userService.editUser(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/paging")
|
@GetMapping("/paging")
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "分页查询用户")
|
@Operation(summary = "分页查询用户")
|
||||||
@ApiResponse(description = "用户列表")
|
@ApiResponse(description = "用户列表")
|
||||||
public Page<User> pageQuery() {
|
public Page<UserDetailDTO> pageQuery(UserQueryDTO dto) {
|
||||||
return this.userService.pageQuery();
|
return this.userRepository.userRolePage(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package club.joylink.xiannccda.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CommonPage {
|
||||||
|
|
||||||
|
@Schema(description = "当前页码")
|
||||||
|
private Integer current;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页条数
|
||||||
|
*/
|
||||||
|
@Schema(description = "每页条数")
|
||||||
|
private Integer size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序字段,字段驼峰名称,如:userName")
|
||||||
|
private String sortField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序方式
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序方式,升序:ASCEND;降序:DESCEND")
|
||||||
|
private String sortOrder;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||||
|
*
|
||||||
|
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||||
|
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||||
|
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||||
|
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||||
|
*/
|
||||||
|
package club.joylink.xiannccda.dto;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.util.CommonServletUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用分页请求
|
||||||
|
*
|
||||||
|
* @author xuyuxiang
|
||||||
|
* @date 2021/12/18 14:43
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class CommonPageRequest {
|
||||||
|
|
||||||
|
private static final String PAGE_SIZE_PARAM_NAME = "size";
|
||||||
|
|
||||||
|
private static final String PAGE_PARAM_NAME = "current";
|
||||||
|
|
||||||
|
private static final Integer PAGE_SIZE_MAX_VALUE = 100;
|
||||||
|
|
||||||
|
public static <T> Page<T> defaultPage() {
|
||||||
|
return defaultPage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Page<T> defaultPage(List<OrderItem> orderItemList) {
|
||||||
|
|
||||||
|
int size = 20;
|
||||||
|
|
||||||
|
int page = 1;
|
||||||
|
|
||||||
|
//每页条数
|
||||||
|
String pageSizeString = CommonServletUtil.getParamFromRequest(PAGE_SIZE_PARAM_NAME);
|
||||||
|
if (StringUtils.isNotEmpty(pageSizeString)) {
|
||||||
|
try {
|
||||||
|
size = Integer.parseInt(pageSizeString);
|
||||||
|
if (size > PAGE_SIZE_MAX_VALUE) {
|
||||||
|
size = PAGE_SIZE_MAX_VALUE;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(">>> 分页条数转换异常:", e);
|
||||||
|
size = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//第几页
|
||||||
|
String pageString = CommonServletUtil.getParamFromRequest(PAGE_PARAM_NAME);
|
||||||
|
if (StringUtils.isNotEmpty(pageString)) {
|
||||||
|
try {
|
||||||
|
page = Integer.parseInt(pageString);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(">>> 分页页数转换异常:", e);
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<T> objectPage = new Page<>(page, size);
|
||||||
|
if (Objects.nonNull(orderItemList)) {
|
||||||
|
objectPage.setOrders(orderItemList);
|
||||||
|
}
|
||||||
|
return objectPage;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package club.joylink.xiannccda.dto.alertTip;
|
package club.joylink.xiannccda.dto.alertTip;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.entity.AlertTip;
|
import club.joylink.xiannccda.entity.AlertTip;
|
||||||
import club.joylink.xiannccda.entity.AlertTipTimeConfig;
|
import club.joylink.xiannccda.entity.AlertTipTimeConfig;
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -19,12 +21,17 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
@Data
|
@Data
|
||||||
public class AlertTipInfoDto {
|
public class AlertTipInfoDto {
|
||||||
|
|
||||||
|
@Schema(description = "id")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
@Schema(description = "线路id")
|
||||||
|
private Integer lineId;
|
||||||
|
@Schema(description = "线路类型")
|
||||||
|
private LineTypeEnum lineType;
|
||||||
|
@Schema(description = "报警设备类型")
|
||||||
private String alertType;
|
private String alertType;
|
||||||
|
@Schema(description = "告警关联区域")
|
||||||
private Long areaConfigId;
|
private Long areaConfigId;
|
||||||
|
@Schema(description = "区域名称")
|
||||||
private String areaConfigName;
|
private String areaConfigName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package club.joylink.xiannccda.dto.alertTip;
|
package club.joylink.xiannccda.dto.alertTip;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
|
import club.joylink.xiannccda.dto.CommonPage;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.entity.AlertTip;
|
import club.joylink.xiannccda.entity.AlertTip;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -12,9 +15,13 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class AlertTipQueryDTO extends PageDTO<AlertTip> {
|
public class AlertTipQueryDTO extends CommonPage {
|
||||||
|
|
||||||
|
private Integer lineId;
|
||||||
|
private LineTypeEnum lineType;
|
||||||
|
@Schema(description = "告警类型")
|
||||||
private String alertType;
|
private String alertType;
|
||||||
|
@Schema(description = "时间类型")
|
||||||
private String timeType;
|
private String timeType;
|
||||||
private String locationType;
|
private String locationType;
|
||||||
private Long areaConfigId;
|
private Long areaConfigId;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package club.joylink.xiannccda.dto.alertTip;
|
package club.joylink.xiannccda.dto.alertTip;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
import club.joylink.xiannccda.alert.AlertTipTimeType;
|
||||||
|
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
|
||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -12,20 +15,33 @@ public class AlertTipSaveDTO {
|
|||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@NotNull(message = "报警类型不能为空")
|
@NotNull(message = "报警类型不能为空")
|
||||||
|
@Schema(description = "故障类型")
|
||||||
private AlertType alertType;
|
private AlertType alertType;
|
||||||
|
|
||||||
|
@Schema(description = "线路id", requiredMode = RequiredMode.REQUIRED)
|
||||||
|
private Integer lineId;
|
||||||
|
@Schema(description = "线路类型", requiredMode = RequiredMode.REQUIRED)
|
||||||
|
private LineTypeEnum lineType;
|
||||||
|
/*
|
||||||
|
@Deprecated
|
||||||
|
@Schema(description = "故障类型")
|
||||||
private AlertTipTimeType timeType;
|
private AlertTipTimeType timeType;
|
||||||
|
*/
|
||||||
|
|
||||||
// private AlertLocation locationType;
|
// private AlertLocation locationType;
|
||||||
|
@Schema(description = "地点位置关联")
|
||||||
private Long areaConfigId;
|
private Long areaConfigId;
|
||||||
/**
|
/**
|
||||||
* 行车方面提示信息
|
* 行车方面提示信息
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "行车方面信息")
|
||||||
private String drivingInfo;
|
private String drivingInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息报送方面提示信息
|
* 信息报送方面提示信息
|
||||||
*/
|
*/
|
||||||
|
@Schema(description = "信息报送")
|
||||||
private String submissionInfo;
|
private String submissionInfo;
|
||||||
|
@Schema(description = "高低峰关联")
|
||||||
private List<String> tipTimeIds;
|
private List<String> tipTimeIds;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package club.joylink.xiannccda.dto.auth;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ApiPathCacheDTO {
|
||||||
|
|
||||||
|
private String uri;
|
||||||
|
private List<String> methods;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package club.joylink.xiannccda.dto.auth;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AuthApiPathQueryDTO extends PageDTO<AuthApiPath> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package club.joylink.xiannccda.dto.auth;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.entity.AuthRole;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AuthRoleDTO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private List<Long> resList;
|
||||||
|
@JsonIgnore
|
||||||
|
private String apiIds;
|
||||||
|
private String roleConfigStr;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package club.joylink.xiannccda.dto.auth;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||||
|
import club.joylink.xiannccda.entity.AuthRole;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AuthRoleQueryDTO extends PageDTO<AuthRole> {
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user