Compare commits

...

43 Commits

Author SHA1 Message Date
tiger_zhou
953294ea31 初始化用户
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m18s
2024-11-20 11:46:36 +08:00
tiger_zhou
e93948bdd1 ats数据收集调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m16s
2024-11-20 09:00:53 +08:00
tiger_zhou
05ad69fc8f ats数据收集调整
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Failing after 34s
2024-11-20 08:55:36 +08:00
tiger_zhou
e3bf6d927d ats数据收集调整 2024-11-20 08:55:03 +08:00
tiger_zhou
d785915902 故障统计
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 3m59s
2024-11-19 15:33:53 +08:00
tiger_zhou
3005199df1 应急处置ncc
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m23s
2024-11-15 16:32:03 +08:00
tiger_zhou
a051e6d8a1 应急处置ncc
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m22s
2024-11-15 14:40:03 +08:00
tiger_zhou
5790fd2cfb 调整,添加4号线设备名称处理
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m16s
2024-11-14 17:41:45 +08:00
tiger_zhou
1155aa023a 添加故障类型 2024-11-14 10:52:31 +08:00
tiger_zhou
3003639596 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m16s
2024-11-08 17:55:21 +08:00
tiger_zhou
d1775b570a 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m11s
2024-11-08 16:24:19 +08:00
tiger_zhou
cbd25c0db1 调整,添加故障查询功能
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s
2024-11-07 17:59:51 +08:00
tiger_zhou
28727c9eac 调整,添加故障查询功能
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m14s
2024-11-07 17:49:46 +08:00
tiger_zhou
cc5ab22cb1 调整,添加故障查询功能
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s
2024-11-07 16:40:42 +08:00
tiger_zhou
38c2005d82 调整,添加故障查询功能
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m14s
2024-11-07 09:42:47 +08:00
tiger_zhou
eb06bcf1c9 调整,添加故障查询功能
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m12s
2024-11-07 09:37:52 +08:00
tiger_zhou
fda0e3ff79 调整,添加故障查询功能
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Failing after 32s
2024-11-07 09:32:09 +08:00
tiger_zhou
046e765a1d 挤岔类型 2024-11-05 10:33:32 +08:00
tiger_zhou
58609211ee 调整,添加站台急停告警
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 3m46s
2024-11-01 14:00:56 +08:00
tiger_zhou
37d5260ee8 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m19s
2024-10-25 17:28:37 +08:00
tiger_zhou
4e5c8f0726 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m12s
2024-10-24 16:10:10 +08:00
tiger_zhou
fa1a3c9f51 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s
2024-10-24 14:24:51 +08:00
tiger_zhou
69eed1fc96 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s
2024-10-23 14:47:43 +08:00
tiger_zhou
b29a5fb5aa 告警添加line_type 属性 2024-10-22 15:30:46 +08:00
tiger_zhou
ec69eebe65 角色初始化调整,修改分页日志插入数据集问题,修改用户名称不能查询问题
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m17s
2024-10-21 15:26:08 +08:00
tiger_zhou
3c138d6e39 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m11s
2024-10-18 17:45:45 +08:00
tiger_zhou
fa9316fcf0 调整 2024-10-18 16:41:06 +08:00
tiger_zhou
515ce249bd 修改swagger信息,决策辅助信息管理添加线路,及线路类型
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m11s
2024-10-18 15:35:30 +08:00
tiger_zhou
5eedf3ea64 docker
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m14s
2024-10-18 13:45:56 +08:00
tiger_zhou
0c00132192 docker
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m39s
2024-10-18 11:42:27 +08:00
tiger_zhou
4cd8d0c2e5 docker
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Failing after 1m10s
2024-10-18 11:40:30 +08:00
tiger_zhou
3a79ff3942 用户权限调整,及用户token刷新,日志记录
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Failing after 1m15s
2024-10-18 10:59:37 +08:00
tiger_zhou
615b83a681 用户权限调整,及用户token刷新,日志记录 2024-10-18 10:46:39 +08:00
tiger_zhou
11ae9ea755 结构调整 2024-10-12 17:41:56 +08:00
tiger_zhou
dfdc33b313 操作日志收集 2024-09-29 18:20:10 +08:00
tiger_zhou
37267e56b8 操作时间大致结构
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m29s
2024-09-06 19:57:34 +08:00
tiger_zhou
0d47e4af3c sql 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m28s
2024-09-06 11:12:01 +08:00
tiger_zhou
f4145b43de sql 调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m23s
2024-09-05 17:45:38 +08:00
tiger_zhou
6fff56eddc 资源,角色,角色绑定资源,用户绑定角色
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 8m24s
2024-09-05 17:13:14 +08:00
tiger_zhou
fe2b7611da 资源,角色,角色绑定资源,用户绑定角色
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Has been cancelled
2024-09-05 17:09:02 +08:00
tiger_zhou
f25a536d55 资源,角色,角色绑定资源,用户绑定角色
Some checks failed
local-test分支构建docker并发布运行 / Docker-Build (push) Has been cancelled
2024-09-05 16:25:28 +08:00
8867818832 添加local-test环境配置
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m44s
2024-03-28 10:31:19 +08:00
ea41232bc6 修改submodule url
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 16m54s
添加local-test工作流构建发布
2024-03-28 09:54:47 +08:00
214 changed files with 7469 additions and 718 deletions

View 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
View File

@ -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
View 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
View File

@ -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>

View File

@ -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;
} }

View File

@ -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 -> {
return "I"; return "I";
} }
case PLATFORM_EMERG_STOP -> {
return "II";
}
default -> throw new IllegalStateException("Unexpected value: " + alertType); default -> throw new IllegalStateException("Unexpected value: " + alertType);
} }
} }

View File

@ -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" -> {

View 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;
}
}

View File

@ -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());
} }
}); });
} }

View File

@ -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,10 +12,12 @@ 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;
@ -23,6 +26,7 @@ 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;
@ -145,43 +149,47 @@ public class LineGraphicDataRepository {
} }
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()));
} }
} }
} }
@ -195,7 +203,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 +212,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) {
@ -405,7 +418,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 +442,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 +499,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 +561,7 @@ public class LineGraphicDataRepository {
} }
} }
}); });
}); });*/
} }
/** /**
@ -515,19 +571,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 +687,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 +749,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);

View 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;
}
}

View File

@ -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;
}
} }

View File

@ -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;
}
}
} }

View File

@ -178,9 +178,9 @@ public enum MessageId {
/** /**
* 消息对象创建接口 * 消息对象创建接口
*/ */
OccMessageCreate omc; public OccMessageCreate omc;
interface OccMessageCreate { public interface OccMessageCreate {
MessageData create(); MessageData create();
} }

View File

@ -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;
} }
} }

View File

@ -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();
} }

View File

@ -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 {
@ -22,17 +28,12 @@ public class OccMessageDecoder extends ByteToMessageDecoder {
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);
} }
} }
} }

View File

@ -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());
} }
} }

View File

@ -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连接.... 是否监控cpulineId:{} 内存信息:{} 是否连接:{}", 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());
}
});
} }
} }

View File

@ -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;
@ -54,13 +55,16 @@ public class OccTcpClientConnection {
@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 +72,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)
@ -117,7 +122,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 +129,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);
} }

View File

@ -1,14 +1,12 @@
package club.joylink.xiannccda.ats.message; package club.joylink.xiannccda.ats.message;
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.LoadDeviceStatusRequest;
import java.time.LocalDateTime; import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
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 +19,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)
*/ */
@ -58,7 +54,7 @@ public class XianOccMessagingClient {
} }
public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) { /* public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) {
this.host = host; this.host = host;
this.lineId = lineId; this.lineId = lineId;
this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout); this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout);
@ -67,6 +63,17 @@ public class XianOccMessagingClient {
this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false); this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false);
this.timeOutHandler.addConnection(this.rtConnection); this.timeOutHandler.addConnection(this.rtConnection);
this.timeOutHandler.addConnection(this.nrtConnection); this.timeOutHandler.addConnection(this.nrtConnection);
}*/
public XianOccMessagingClient(Integer lineId, OccClientMessage clientMessage) {
this.host = clientMessage.getServerHost();
this.lineId = lineId;
this.requestBaseTime = TimeUnit.HOURS.toMillis(clientMessage.getReceiveMsgTimeout());
// 创建实时和非实时消息连接
this.rtConnection = new OccTcpClientConnection(this, host, clientMessage.getRealPort(), clientMessage.getCollectorData(), true, clientMessage.getNameChanger());
this.nrtConnection = new OccTcpClientConnection(this, host, clientMessage.getUnRealPort(), false, false, clientMessage.getNameChanger());
this.timeOutHandler.addConnection(this.rtConnection);
this.timeOutHandler.addConnection(this.nrtConnection);
} }
@ -85,8 +92,9 @@ 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 dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
this.send(dataRequest, false); LoadDeviceStatusRequest dataRequest = new LoadDeviceStatusRequest((short) this.lineId);
this.send(dataRequest, true);
} }
} }
@ -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() {

View File

@ -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);

View File

@ -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 {};
}

View File

@ -0,0 +1,8 @@
package club.joylink.xiannccda.ats.message.changer;
public enum NameChangerEnum {
NONE,
//通用
UNIVERSAL,
LINE_4
}

View File

@ -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;

View File

@ -0,0 +1,25 @@
package club.joylink.xiannccda.ats.message.changer.line4;
public class Line4NameUtil {
public static String convertLine4Name(String line4Name) {
try {
StringBuilder sb = new StringBuilder();
byte[] bb = line4Name.getBytes("ISO-8859-1");
for (int i = 0; i < bb.length; i++) {
byte b = bb[i];
if (i + 1 < bb.length) {
if (b == 0 && bb[i + 1] == 63) {
break;
}
}
sb.append((char) b);
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
return line4Name;
}
}
}

View File

@ -0,0 +1,30 @@
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 java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
public class SignalChanger {
/**
* X10301 /XR
*/
@NameChanger(value = {NameChangerEnum.LINE_4})
public static class Signal1Changer implements NameChangerFilter {
@Override
public DeviceType deviceType() {
return DeviceType.DEVICE_TYPE_SIGNAL;
}
@Override
public String changeDeviceName(String sourceName) {
return Line4NameUtil.convertLine4Name(sourceName);
}
}
}

View File

@ -0,0 +1,35 @@
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 java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* P09301
*/
public class SwitchChanger {
/**
* 道岔物理区段转换
*/
@NameChanger(value = {NameChangerEnum.LINE_4})
public static class SwitchDGChanger implements NameChangerFilter {
@Override
public DeviceType deviceType() {
return DeviceType.DEVICE_TYPE_SWITCH;
}
@Override
public String changeDeviceName(String sourceName) {
return Line4NameUtil.convertLine4Name(sourceName);
}
}
}

View File

@ -0,0 +1,30 @@
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 java.util.regex.Matcher;
import java.util.regex.Pattern;
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) {
return Line4NameUtil.convertLine4Name(sourceName);
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
} }

View File

@ -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;
@ -48,14 +49,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));
} }
} }

View File

@ -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,22 +61,20 @@ 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))) {
@ -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);

View File

@ -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.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;
@ -46,10 +47,10 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor {
} }
@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);

View File

@ -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);
} }

View File

@ -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(),

View File

@ -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);

View File

@ -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);

View File

@ -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(),

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -20,6 +20,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;
@ -52,6 +53,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))));

View File

@ -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());

View File

@ -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;
} }

View File

@ -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;
@ -69,14 +70,14 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
} }
@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());

View File

@ -2,25 +2,21 @@ 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;
import org.apache.commons.lang3.StringUtils;
/** /**
* 2.7.5 设备状态变化消息 * 2.7.5 设备状态变化消息
@ -91,12 +87,12 @@ public class DeviceStatusChangeResponse extends MessageResponse {
@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 +108,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);
} }

View File

@ -2,10 +2,13 @@ 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.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
public class EntityParseUtil { public class EntityParseUtil {
@ -30,7 +33,8 @@ 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 interface ReadData<T> { public interface ReadData<T> {

View File

@ -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;
@ -83,7 +84,7 @@ public class InusedScheduleResponse extends MessageResponse {
} }
@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();

View File

@ -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;
@ -48,7 +49,7 @@ public class TrainBlockInfoResponse extends MessageResponse {
} }
@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();

View File

@ -1,10 +1,11 @@
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.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 +55,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,7 +76,7 @@ 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) {
//车辆在道岔时转换对应的设备类型 //车辆在道岔时转换对应的设备类型

View File

@ -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) {
//车辆在道岔时转换对应的设备类型 //车辆在道岔时转换对应的设备类型

View File

@ -1,10 +1,11 @@
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.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;
@ -20,7 +21,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 +127,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());
@ -148,7 +148,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
} }
// 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) {
//车辆在道岔时转换对应的设备类型 //车辆在道岔时转换对应的设备类型

View File

@ -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());

View File

@ -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);
} }
} }

View File

@ -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")) {

View File

@ -25,12 +25,12 @@ import org.springframework.stereotype.Component;
@Component @Component
@Slf4j @Slf4j
public class SwitchLostTask implements AlertMonitoringTask { public class SwitchLostAndJammedTask implements AlertMonitoringTask {
private DeviceGuardConfigService configService; private DeviceGuardConfigService configService;
private AlertInfoService alertInfoService; private AlertInfoService alertInfoService;
public SwitchLostTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) { public SwitchLostAndJammedTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
this.configService = configService; this.configService = configService;
this.alertInfoService = alertInfoService; this.alertInfoService = alertInfoService;
} }
@ -63,23 +63,44 @@ public class SwitchLostTask implements AlertMonitoringTask {
private void handle(Builder deviceBuild) { private void handle(Builder deviceBuild) {
if (deviceBuild instanceof Switch.Builder switchBuild) { if (deviceBuild instanceof Switch.Builder switchBuild) {
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId()); Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication(); String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) { this.checkLost(switchBuild, layoutId);
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class); this.checkJammed(switchBuild, layoutId);
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());
}
} }
} }
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) {
if (switchBuild.getIpSingleSwitchStusJammed()) {
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());
}
}
} }

View File

@ -57,12 +57,23 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
this.trainRecordMap.put(trainRecord.getTrainId(), trainRecord); this.trainRecordMap.put(trainRecord.getTrainId(), trainRecord);
} }
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());
} }
@ -171,15 +182,15 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
@Override @Override
public void run() { public void run() {
for (Builder record : this.trainRecordMap.values()) { for (Builder record : this.trainRecordMap.values()) {
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue(); 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 +202,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);

View File

@ -0,0 +1,74 @@
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.datasource.DeviceStatusData;
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.LayoutGraphicsProto;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.vo.AreaConfigVO;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class PlatformEmergStopTask implements AlertMonitoringTask {
@Autowired
private AlertInfoService alertInfoService;
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
private final AlertManager alertManager = AlertManager.getDefault();
@Override
public String getName() {
return "PLATFORM_EMERG_STOP_ALTER";
}
@Override
public void run() {
Set<String> allLineSet = DeviceDataRepository.getAllLines();
for (String lineIdStr : allLineSet) {
Integer lineIdInt = Integer.parseInt(lineIdStr);
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineIdStr, DataTypeEnum.DEVICE);
List<LayoutGraphicsProto.Platform> giPlatformList = LineGraphicDataRepository.getDevices(lineIdInt, LayoutGraphicsProto.Platform.class).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());
if (platformBuild.getEmergstop()) {
if (alertDataSource.putAlterDevice(lineIdInt, this.getName(), platformBuild.getId())) {
Integer layOutId = giPlatform.getCommon().getId();
Station station = LineGraphicDataRepository.getDeviceByCode(lineIdInt, 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(lineIdInt, this.getName(), platformBuild.getId());
}
}
}
}
}
}

View File

@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
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.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 lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -17,8 +17,7 @@ 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;
@ -37,6 +36,7 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainR
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);
} }
} }

View File

@ -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,35 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
} }
} }
private final static String TRAIN_INTEGRITY_NAME = "TRAIN_INTEGRITY";
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>
@ -116,13 +147,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
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) {
if (section.getSectionType() == SectionType.Physical) {
} else {
}
}*/
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());

View File

@ -1,8 +1,8 @@
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.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;
@ -20,7 +20,6 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask; private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) { public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) {
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask; this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
} }
@ -29,6 +28,8 @@ 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);
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(),

View File

@ -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("无权限");
}
}
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -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);
} }

View File

@ -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();
}

View File

@ -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
}
}

View File

@ -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,
;
}

View File

@ -0,0 +1,5 @@
package club.joylink.xiannccda.constants.common;
public enum LineTypeEnum {
NCC, OCC;
}

View File

@ -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
}
}

View File

@ -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);
} }

View File

@ -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);

View File

@ -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));
} }

View File

@ -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";

View File

@ -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";

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
} }
} }

View 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;
}

View File

@ -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;
}
}

View File

@ -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;
/** /**

View File

@ -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;

View File

@ -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;
} }

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -1,6 +1,7 @@
package club.joylink.xiannccda.dto.config; package club.joylink.xiannccda.dto.config;
import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import club.joylink.xiannccda.dto.CommonPage;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.entity.DeviceAreaConfig; import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.entity.DeviceGuardConfig; import club.joylink.xiannccda.entity.DeviceGuardConfig;
@ -9,7 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@Data @Data
public class DeviceAreaConfigQueryDto extends PageDTO<DeviceAreaConfig> { public class DeviceAreaConfigQueryDto extends CommonPage {
@Schema(description = "设备类型") @Schema(description = "设备类型")

View File

@ -0,0 +1,37 @@
package club.joylink.xiannccda.dto.event;
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import lombok.Data;
@Data
public class EventLogPageDTO {
private Long id;
@Schema(description = "线路id")
private Integer lineId;
@Schema(description = "接口名称")
private String faceName;
@Schema(description = "接口请求大类")
private CommonLogTypeEnum eventType;
@Schema(description = "接口请求类别")
private CommonLogTypeEnum.SubEventType subEventType;
@Schema(description = "接口uri")
private String uri;
@Schema(description = "接口uri method")
private String method;
@Schema(description = "接口请求参数")
private String parameters;
@Schema(description = "接口执行结果0=失败,1=成功")
private Integer requestSuccess;
@Schema(description = "操作人姓名")
private String userName;
@Schema(description = "操作人id")
private Long fromUserId;
@Schema(description = "操作人电话")
private String mobile;
@Schema(description = "操作时间")
private LocalDateTime createDateTime;
}

View File

@ -0,0 +1,20 @@
package club.joylink.xiannccda.dto.event;
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
import club.joylink.xiannccda.entity.EventLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import java.time.LocalDateTime;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@Data
public class EventLogQueryDTO extends PageDTO<EventLog> {
private CommonLogTypeEnum logType;
private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime beginDate;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDate;
}

View File

@ -0,0 +1,65 @@
package club.joylink.xiannccda.dto.fq;
import club.joylink.xiannccda.entity.FaultQuery;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.Data;
@Data
public class FaultQueryNcc {
public FaultQueryNcc() {
}
public FaultQueryNcc(String typeName, List<FaultQuery> fqList) {
this.nccTypeName = typeName;
Map<String, List<FaultQuery>> dataMapList = fqList.stream().collect(Collectors.groupingBy(FaultQuery::getFaultDriverShower, Collectors.collectingAndThen(Collectors.toList(), lists -> {
lists.sort(Comparator.comparingLong(FaultQuery::getId));
return lists;
})));
List<NccData> tl = Lists.newArrayList();
dataMapList.forEach((k, v) -> {
NccData nd = new NccData(k, v.stream().map(FaultQuery::getResultMsg).collect(Collectors.toList()));
nd.setOrderId(v.get(0).getId());
tl.add(nd);
});
this.orderId = fqList.get(0).getId();
tl.sort(Comparator.comparingLong(NccData::getOrderId));
this.nccData = tl;
}
private String nccTypeName;
@JsonIgnore
private Long orderId;
private List<NccData> nccData;
@Data
public static class NccData {
public NccData() {
}
public NccData(String action, List<String> datas) {
this.action = action;
this.datas = datas;
}
@JsonIgnore
private Long orderId;
private String action;
private List<String> datas;
}
}

View File

@ -0,0 +1,15 @@
package club.joylink.xiannccda.dto.fq;
import club.joylink.xiannccda.constants.common.FaultQueryType;
import club.joylink.xiannccda.dto.CommonPage;
import java.util.List;
import lombok.Data;
@Data
public class FaultQueryReqDTO extends CommonPage {
private Integer lineId;
private String faultType;
private String faultName;
}

View File

@ -0,0 +1,29 @@
package club.joylink.xiannccda.dto.fq;
import club.joylink.xiannccda.constants.common.FaultQueryType;
import java.util.List;
import lombok.Data;
@Data
public class FaultType {
private Integer lineId;
private List<FaultTypeDetail> fts;
public FaultType(Integer lineId, List<FaultTypeDetail> fts) {
this.lineId = lineId;
this.fts = fts;
}
@Data
public static class FaultTypeDetail {
private String faultType;
private String typeName;
public FaultTypeDetail(FaultQueryType qt, String name) {
this.faultType = qt.name();
this.typeName = name;
}
}
}

View File

@ -19,7 +19,10 @@ public abstract class NewAlertMockDTO {
public MessageId parseMessageId() { public MessageId parseMessageId() {
if (alertType == AlertType.TRAIN_EB_ATP) { if (alertType == AlertType.TRAIN_EB_ATP) {
return MessageId.TRAIN_INDICATION_UPDATE; return MessageId.TRAIN_INDICATION_UPDATE;
} else if (alertType == AlertType.TRAIN_RECORD) {
return MessageId.TRAIN_RECORD;
} }
return MessageId.DEVICE_STATUS_CHANGE; return MessageId.DEVICE_STATUS_CHANGE;
} }

Some files were not shown because too many files have changed in this diff Show More