Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
953294ea31 | ||
|
e93948bdd1 | ||
|
05ad69fc8f | ||
|
e3bf6d927d | ||
|
d785915902 | ||
|
3005199df1 | ||
|
a051e6d8a1 | ||
|
5790fd2cfb | ||
|
1155aa023a | ||
|
3003639596 | ||
|
d1775b570a | ||
|
cbd25c0db1 | ||
|
28727c9eac | ||
|
cc5ab22cb1 | ||
|
38c2005d82 | ||
|
eb06bcf1c9 | ||
|
fda0e3ff79 | ||
|
046e765a1d | ||
|
58609211ee | ||
|
37d5260ee8 | ||
|
4e5c8f0726 | ||
|
fa1a3c9f51 | ||
|
69eed1fc96 | ||
|
b29a5fb5aa | ||
|
ec69eebe65 | ||
|
3c138d6e39 | ||
|
fa9316fcf0 | ||
|
515ce249bd | ||
|
5eedf3ea64 | ||
|
0c00132192 | ||
|
4cd8d0c2e5 | ||
|
3a79ff3942 | ||
|
615b83a681 | ||
|
11ae9ea755 | ||
|
dfdc33b313 | ||
|
37267e56b8 | ||
|
0d47e4af3c | ||
|
f4145b43de | ||
|
6fff56eddc | ||
|
fe2b7611da | ||
|
f25a536d55 | ||
8867818832 | |||
ea41232bc6 |
61
.gitea/workflows/CICD_local_test.yaml
Normal file
61
.gitea/workflows/CICD_local_test.yaml
Normal file
@ -0,0 +1,61 @@
|
||||
name: local-test分支构建docker并发布运行
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- local-test
|
||||
|
||||
jobs:
|
||||
Docker-Build:
|
||||
runs-on: joylink-local233
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: https://gitea.joylink.club/actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: 设置java环境
|
||||
uses: https://gitea.joylink.club/actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'zulu'
|
||||
cache: 'maven'
|
||||
cache-dependency-path: './pom.xml'
|
||||
- name: 设置Maven环境
|
||||
uses: https://gitea.joylink.club/actions/local-setup-maven@v0.1.1
|
||||
with:
|
||||
maven-version: 3.8.8
|
||||
- name: 构建
|
||||
run: |
|
||||
mvn -Dmaven.test.skip=true clean package
|
||||
- name: 设置 Docker
|
||||
uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1
|
||||
- name: 设置 Docker Buildx
|
||||
uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3
|
||||
- name: docker登录gitea.joylink.club
|
||||
uses: https://gitea.joylink.club/docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.joylink.club
|
||||
username: shengxuqiang
|
||||
password: ${{ secrets.SHENGXUQIANG_PASSWORD }}
|
||||
- name: Docker Build and push
|
||||
uses: https://gitea.joylink.club/docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||
- name: 发布到本地测试环境
|
||||
uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.LOCAL_233_SSH_HOST }}
|
||||
port: ${{ secrets.LOCAL_233_SSH_PORT }}
|
||||
username: ${{ secrets.LOCAL_233_SSH_USER }}
|
||||
password: ${{ secrets.LOCAL_233_SSH_PASSWORD }}
|
||||
script: |
|
||||
docker rm -f xian-ncc-da-service || echo "xian-ncc-da-service not exist"
|
||||
docker pull gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||
docker run --name xian-ncc-da-service --restart=always --network net --ip 192.168.53.181 -d -e APP_ENV=local-test -p 9081:9081 -v /usr/local/joylink/logs/xianncc:/usr/local/joylink/logs/xianncc gitea.joylink.club/joylink/xian-ncc-da-service:local-test
|
||||
- name: 清理tag为none的镜像
|
||||
run: |
|
||||
docker rmi $(docker images --filter "dangling=true" -q)
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
||||
[submodule "xian-ncc-da-message"]
|
||||
path = xian-ncc-da-message
|
||||
url = https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-message.git
|
||||
url = https://gitea.joylink.club/joylink/xian-ncc-da-message.git
|
||||
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM azul/zulu-openjdk-alpine:17
|
||||
|
||||
ADD target/xian-ncc-da-0.1.jar xian-ncc-da.jar
|
||||
|
||||
ENV APP_ENV=prd
|
||||
EXPOSE 9081
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
CMD java -jar -Dfile.encoding=UTF-8 -Dspring.profiles.active=$APP_ENV /xian-ncc-da.jar
|
39
pom.xml
39
pom.xml
@ -44,7 +44,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
@ -149,8 +152,40 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>31.1-jre</version>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -2,12 +2,24 @@ package club.joylink.xiannccda.alert;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo.AlertStatus;
|
||||
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.event.Listener;
|
||||
import club.joylink.xiannccda.repository.IAlertRecordRepository;
|
||||
import club.joylink.xiannccda.service.LineInfoService;
|
||||
import club.joylink.xiannccda.ws.NccAlertMessageServer;
|
||||
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 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.ApplicationRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@ -19,11 +31,14 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
|
||||
private final WsMessageServerManager wsMessageServerManager;
|
||||
private final IAlertRecordRepository alertRecordRepository;
|
||||
private final LineInfoService lineInfoService;
|
||||
@Autowired
|
||||
private OccServerProto serverProto;
|
||||
|
||||
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
|
||||
IAlertRecordRepository alertRecordRepository) {
|
||||
public AlertListenerJob(WsMessageServerManager wsMessageServerManager, IAlertRecordRepository alertRecordRepository, LineInfoService lineInfoService) {
|
||||
this.wsMessageServerManager = wsMessageServerManager;
|
||||
this.alertRecordRepository = alertRecordRepository;
|
||||
this.lineInfoService = lineInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,13 +46,14 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
//添加报警事件监听器
|
||||
addAlertListeners();
|
||||
//注册西安NCC的报警ws消息发送服务
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getDefault());
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.NCC));
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.OCC));
|
||||
//启动报警源事件监测任务
|
||||
AlertManager.getDefault().taskStart();
|
||||
}
|
||||
|
||||
private void addAlertListeners() {
|
||||
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
|
||||
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
//添加消息
|
||||
alertManager.on(new Listener<NccAlertInfo>() {
|
||||
@ -51,10 +67,25 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
alertInfo.setId(idGenerator.decrementAndGet());
|
||||
}*/
|
||||
//不论是否mock 都保存数据库
|
||||
AlertRecord record = convertToRecord(alertInfo);
|
||||
alertRecordRepository.save(record);
|
||||
alertInfo.setId(record.getId());
|
||||
nccAlertMessageServer.addMsg(alertInfo);
|
||||
|
||||
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
|
||||
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
|
||||
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.setMock(nccAlertInfo.isMock());
|
||||
record.setAlarmStatus(AlertStatus.NOT_DO);
|
||||
record.setLineType(nccAlertInfo.getLineType());
|
||||
// record.setAlertLocation(nccAlertInfo.getAlertLocationName());
|
||||
return record;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.alert;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
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.AlertType;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
@ -10,8 +11,11 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class NccAlertInfo implements AlertInfo {
|
||||
public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||
|
||||
public NccAlertInfo() {
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
private Integer id;
|
||||
@ -32,6 +36,8 @@ public class NccAlertInfo implements AlertInfo {
|
||||
@Setter
|
||||
private Integer alarmStatus;
|
||||
private AlertDeviceType alertDeviceType;
|
||||
@Setter
|
||||
private LineTypeEnum lineType;
|
||||
// private AlertType confirmAlertType;
|
||||
|
||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
||||
@ -50,6 +56,19 @@ public class NccAlertInfo implements AlertInfo {
|
||||
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,
|
||||
Integer lineId, String alertObject, String locatorDeviceId,
|
||||
Long alertLocationId, AlertDeviceType alertDeviceType) {
|
||||
@ -114,9 +133,12 @@ public class NccAlertInfo implements AlertInfo {
|
||||
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,
|
||||
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";
|
||||
}
|
||||
case PLATFORM_EMERG_STOP -> {
|
||||
return "II";
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
||||
|
||||
public class AlertUtil {
|
||||
|
||||
|
||||
public static Optional<AlertLocation> findLocationByRtuCode(String rtuCode) {
|
||||
switch (rtuCode) {
|
||||
case "1" -> {
|
||||
|
131
src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java
Normal file
131
src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java
Normal file
@ -0,0 +1,131 @@
|
||||
package club.joylink.xiannccda.aop;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.constants.SystemContext;
|
||||
import club.joylink.xiannccda.event.OperateEvent;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.google.common.collect.Maps;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.util.UriTemplate;
|
||||
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SystemEventAspect {
|
||||
|
||||
@Autowired
|
||||
private JwtDecoder jwtDecoder;
|
||||
|
||||
@AfterReturning(value = "execution(public * club.joylink.xiannccda.controller..*.*(..))", returning = "returnObj")
|
||||
public void watchRequest(JoinPoint joinPoint, Object returnObj) {
|
||||
OperateEvent obj = this.parseRequestParameter(joinPoint);
|
||||
if (Objects.nonNull(obj)) {
|
||||
obj.setRequestSuccess(1);
|
||||
if (obj.getType() == CommonLogTypeEnum.LOGIN && obj.getSubType() == SubEventType.LOGIN) {
|
||||
Jwt jwt = jwtDecoder.decode(returnObj.toString());
|
||||
String userId = jwt.getClaimAsString("sub");
|
||||
obj.setUserId(Long.parseLong(userId));
|
||||
}
|
||||
SystemContext.publishEvent(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AfterThrowing(value = "execution(public * club.joylink.xiannccda.controller..*.*(..))", throwing = "e")
|
||||
public void watchRequest(JoinPoint joinPoint, Exception e) {
|
||||
OperateEvent oe = this.parseRequestParameter(joinPoint);
|
||||
if (Objects.nonNull(oe)) {
|
||||
oe.setRequestSuccess(0);
|
||||
SystemContext.publishEvent(oe);
|
||||
}
|
||||
}
|
||||
|
||||
private String getUri(String[] uriMapping, String requestUri) {
|
||||
if (ArrayUtils.isEmpty(uriMapping)) {
|
||||
return requestUri;
|
||||
}
|
||||
if (Arrays.stream(uriMapping).anyMatch(StringUtils::isEmpty)) {
|
||||
return requestUri;
|
||||
}
|
||||
return uriMapping[0];
|
||||
}
|
||||
|
||||
private OperateEvent parseRequestParameter(JoinPoint joinPoint) {
|
||||
MethodSignature ms = (MethodSignature) joinPoint.getSignature();
|
||||
CommonLogAnno commonLogAnno = ms.getMethod().getDeclaredAnnotation(CommonLogAnno.class);
|
||||
if (Objects.nonNull(commonLogAnno)) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
String method = request.getMethod();
|
||||
Long userId = this.userId(commonLogAnno.subLogType());
|
||||
GetMapping getMapping = ms.getMethod().getDeclaredAnnotation(GetMapping.class);
|
||||
PostMapping postMapping = ms.getMethod().getDeclaredAnnotation(PostMapping.class);
|
||||
DeleteMapping deleteMapping = ms.getMethod().getDeclaredAnnotation(DeleteMapping.class);
|
||||
Map<String, Object> params = Map.of();
|
||||
if (Objects.nonNull(getMapping)) {
|
||||
String requestURI = this.getUri(getMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
} else if (Objects.nonNull(postMapping)) {
|
||||
String requestURI = this.getUri(postMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
|
||||
} else if (Objects.nonNull(deleteMapping)) {
|
||||
String requestURI = this.getUri(deleteMapping.value(), uri);
|
||||
params = getRequestParam(requestURI, joinPoint.getArgs());
|
||||
}
|
||||
return new OperateEvent(commonLogAnno.name(), commonLogAnno.logType(), commonLogAnno.subLogType(), uri, method, params, userId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Long userId(SubEventType subEventType) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
Long userId = null;
|
||||
if (subEventType != SubEventType.LOGIN) {
|
||||
userId = Long.valueOf(authentication.getName());
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
private Map<String, Object> getRequestParam(String uriMap, Object[] args) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
int argsIndex = 0;
|
||||
Map<String, Object> uriParamMap = new HashMap<>();
|
||||
UriTemplate ut = new UriTemplate(uriMap);
|
||||
for (String vn : ut.getVariableNames()) {
|
||||
uriParamMap.put(vn, args[argsIndex]);
|
||||
argsIndex++;
|
||||
}
|
||||
params.put("uriParam", uriParamMap);
|
||||
for (; argsIndex < args.length; argsIndex++) {
|
||||
params.put("param", args[argsIndex]);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class LineGraphicDataManage implements ApplicationRunner {
|
||||
list.forEach(d -> {
|
||||
LineGraphicDataRepository.putLineGraph(d);
|
||||
if (!SystemContext.getMasterEnv()) {
|
||||
LineGraphicDataRepository.initDeviceStationCenter();
|
||||
LineGraphicDataRepository.initDeviceStationCenter(d.getLineId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.ats.cache;
|
||||
|
||||
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.DataTypeEnum;
|
||||
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.Turnout;
|
||||
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.KilometerSystem;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
||||
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.RtssGraphicStorage;
|
||||
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 com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
@ -145,43 +149,47 @@ public class LineGraphicDataRepository {
|
||||
|
||||
}
|
||||
|
||||
public static void initDeviceStationCenter() {
|
||||
public static void initDeviceStationCenter(Integer lineId) {
|
||||
log.info("开始初始化地图中设备集中站的归属。。。");
|
||||
|
||||
for (Integer lineId : line_code_table.rowKeySet()) {
|
||||
DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE);
|
||||
InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK);
|
||||
for (MessageOrBuilder mb : line_code_table.values()) {
|
||||
String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class);
|
||||
Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
|
||||
if (Objects.isNull(deviceId) || deviceId == 0) {
|
||||
continue;
|
||||
}
|
||||
Integer rtuId = getStationCenterById(lineId, deviceId.toString());
|
||||
if (Objects.isNull(rtuId)) {
|
||||
continue;
|
||||
}
|
||||
DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE);
|
||||
InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK);
|
||||
;
|
||||
// for (MessageOrBuilder mb : line_code_table.values()) {
|
||||
for (MessageOrBuilder mb : line_code_table.row(lineId).values()) {
|
||||
String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class);
|
||||
Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
|
||||
if (Objects.isNull(deviceId) || deviceId == 0) {
|
||||
continue;
|
||||
}
|
||||
Integer rtuId = getStationCenterById(lineId, deviceId.toString());
|
||||
if (Objects.isNull(rtuId)) {
|
||||
continue;
|
||||
}
|
||||
// List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||
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> tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue());
|
||||
dsd.addDevice(sl);
|
||||
dsd.addDevice(tl);
|
||||
interLock.addDevice(sl);
|
||||
}/* else if (mb instanceof LogicSection logicSection) {
|
||||
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> tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue());
|
||||
dsd.addDevice(sl);
|
||||
dsd.addDevice(tl);
|
||||
interLock.addDevice(sl);
|
||||
}/* 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()));
|
||||
}*/ else if (mb instanceof LayoutGraphicsProto.Section section) {
|
||||
if (section.getSectionType() == SectionType.Physical) {
|
||||
for (Integer childId : section.getChildrenList()) {
|
||||
MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString());
|
||||
String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
||||
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()));
|
||||
}
|
||||
if (section.getSectionType() == SectionType.Physical) {
|
||||
for (Integer childId : section.getChildrenList()) {
|
||||
|
||||
MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString());
|
||||
String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
||||
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.setDeviceStatus(0);
|
||||
statusChange.setRtuId(rtuId);
|
||||
return statusChange.generateProto();
|
||||
return statusChange.generateProto(DeviceNameChangerManage.findNameChanger(lineId));
|
||||
}
|
||||
|
||||
public static Integer getStationCenterById(Integer lineId, String deviceId) {
|
||||
@ -204,8 +212,13 @@ public class LineGraphicDataRepository {
|
||||
if (StringUtils.isEmpty(rtuCode)) {
|
||||
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) {
|
||||
@ -405,7 +418,17 @@ public class LineGraphicDataRepository {
|
||||
Map<String, CoordinateConvertor> convertorMap =
|
||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||
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(
|
||||
t -> {
|
||||
List<KilometerSystem> systemList =
|
||||
@ -419,7 +442,7 @@ public class LineGraphicDataRepository {
|
||||
cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder);
|
||||
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);
|
||||
Map<Integer, Builder> sectionMap = dataMap.getOrDefault(DeviceType.Section.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()))
|
||||
.forEach(
|
||||
ac -> {
|
||||
@ -505,7 +561,7 @@ public class LineGraphicDataRepository {
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -515,19 +571,76 @@ public class LineGraphicDataRepository {
|
||||
* @param dataMap 设备集合
|
||||
* @param storage 地图信息
|
||||
*/
|
||||
private static void initConvertorCoordinate(
|
||||
Integer lineId,
|
||||
Map<String, Map<Integer, Builder>> dataMap,
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
private static void initConvertorCoordinate(Integer lineId, Map<String, Map<Integer, Builder>> dataMap, LayoutGraphicsProto.RtssGraphicStorage storage) {
|
||||
// 强制转换道岔
|
||||
Map<Integer, Builder> turnoutMap = dataMap.get(DeviceType.Turnout.name());
|
||||
if (CollectionUtils.isEmpty(turnoutMap)) {
|
||||
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()
|
||||
.forEach(
|
||||
axle -> {
|
||||
@ -574,13 +687,12 @@ public class LineGraphicDataRepository {
|
||||
long convertKilometer = diffSystem.getKilometer() - diffValue;
|
||||
// 求出坐标系0点位置
|
||||
CoordinateConvertor convertor =
|
||||
CoordinateConvertor.generate(
|
||||
axleSystem, diffSystem.getCoordinateSystem(), convertKilometer);
|
||||
CoordinateConvertor.generate(axleSystem, diffSystem.getCoordinateSystem(), convertKilometer);
|
||||
convertorMap.put(convertorKey, convertor);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -637,11 +749,9 @@ public class LineGraphicDataRepository {
|
||||
return kilometer.getKilometer();
|
||||
}
|
||||
Map<String, CoordinateConvertor> convertorMap = lineCoordinateMain.get(lineId);
|
||||
String convertorKey =
|
||||
CoordinateConvertor.generateConvertorKey(
|
||||
kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE);
|
||||
String convertorKey = CoordinateConvertor.generateConvertorKey(kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE);
|
||||
if (CollectionUtils.isEmpty(convertorMap) || !convertorMap.containsKey(convertorKey)) {
|
||||
log.error("无坐标转换规则" + convertorKey);
|
||||
log.error("无坐标转换规则 lineId:{},规则:{}", lineId, convertorKey);
|
||||
return kilometer.getKilometer();
|
||||
}
|
||||
return convertorMap.get(convertorKey).convertorKilometer(kilometer, CoordinateEnum.MAIN_LINE);
|
||||
|
47
src/main/java/club/joylink/xiannccda/ats/cache/config/LineConfig.java
vendored
Normal file
47
src/main/java/club/joylink/xiannccda/ats/cache/config/LineConfig.java
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
package club.joylink.xiannccda.ats.cache.config;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.dto.PublishedGIDTO.LineType;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
public class LineConfig {
|
||||
|
||||
private List<WarnConfig> warnConfig;
|
||||
|
||||
public List<AlertType> getExcludedAlertType(LineTypeEnum lineType) {
|
||||
for (WarnConfig config : this.warnConfig) {
|
||||
if (config.lineType == lineType) {
|
||||
return config.excludeWarn;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean alertTypeExist(LineTypeEnum lineType, AlertType alertType) {
|
||||
List<AlertType> atList = this.getExcludedAlertType(lineType);
|
||||
if (CollectionUtils.isEmpty(atList)) {
|
||||
return false;
|
||||
}
|
||||
return atList.contains(alertType);
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class WarnConfig {
|
||||
|
||||
|
||||
private LineTypeEnum lineType;
|
||||
private List<AlertType> excludeWarn;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import io.netty.buffer.Unpooled;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@ -19,6 +22,8 @@ public class FrameSchemaParse {
|
||||
* key = 端口号(表明是实时还是非实时)
|
||||
*/
|
||||
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();
|
||||
|
||||
public static List<MessageData> decode2(ByteBuf inByteBuf, Integer port) {
|
||||
@ -38,18 +43,27 @@ public class FrameSchemaParse {
|
||||
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());
|
||||
boolean readComplate = schemaParse(inByteBuf, packageData);
|
||||
ByteBuf sourcePackageData = SOURCE_PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
||||
boolean readComplate = schemaParse(inByteBuf, packageData, sourcePackageData);
|
||||
if (readComplate) {
|
||||
try {
|
||||
DecodeResult dr = new DecodeResult();
|
||||
List<MessageData> messageDataList = Lists.newArrayList();
|
||||
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) {
|
||||
log.error("OCC消息解析异常", e);
|
||||
return null;
|
||||
} finally {
|
||||
sourcePackageData.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();
|
||||
int totalReadables = inByteBuf.readableBytes();
|
||||
if (totalReadables < 4) {
|
||||
@ -100,9 +114,23 @@ public class FrameSchemaParse {
|
||||
log.error("可读内容不足 sysId[{}] totalLen[{}] flag[{}] contentLen[{}] readableBytes[{}]", sysId, totalLength, flag, contentLen, readables);
|
||||
return false;
|
||||
}
|
||||
// byte[] bb = new byte[contentLen];
|
||||
// inByteBuf.readBytes(bb);
|
||||
packageData.writeBytes(inByteBuf, contentLen);
|
||||
byte[] bb = new byte[contentLen];
|
||||
inByteBuf.readBytes(bb);
|
||||
packageData.writeBytes(bb);
|
||||
// packageData.writeBytes(inByteBuf, contentLen);
|
||||
sourcePackageData.writeByte(sysId);
|
||||
sourcePackageData.writeShort(totalLength);
|
||||
sourcePackageData.writeByte(flag);
|
||||
sourcePackageData.writeBytes(bb);
|
||||
return flag != Flag_Multi;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class DecodeResult {
|
||||
|
||||
private List<MessageData> data;
|
||||
private byte[] sourceData;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -65,6 +66,7 @@ public abstract class MessageData {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void decode(ByteBuf buf) throws Exception {
|
||||
final int headerBytes = 10;
|
||||
int readableBytes = buf.readableBytes();
|
||||
@ -92,7 +94,7 @@ public abstract class MessageData {
|
||||
*/
|
||||
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) {
|
||||
@ -115,4 +117,18 @@ public abstract class MessageData {
|
||||
return this.length + 2;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DecodeMessageData {
|
||||
|
||||
private Long id;
|
||||
private List<MessageData> messages;
|
||||
|
||||
private byte[] sourceData;
|
||||
|
||||
public DecodeMessageData(Long id, List<MessageData> messages, byte[] sourceData) {
|
||||
this.id = id;
|
||||
this.messages = messages;
|
||||
this.sourceData = sourceData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,9 +178,9 @@ public enum MessageId {
|
||||
/**
|
||||
* 消息对象创建接口
|
||||
*/
|
||||
OccMessageCreate omc;
|
||||
public OccMessageCreate omc;
|
||||
|
||||
interface OccMessageCreate {
|
||||
public interface OccMessageCreate {
|
||||
|
||||
MessageData create();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
@ -18,7 +19,7 @@ public abstract class MessageRequest extends MessageData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Collections;
|
||||
@ -13,8 +14,9 @@ public abstract class MessageResponse extends MessageData {
|
||||
|
||||
public abstract Short getLineId();
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
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.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
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 {
|
||||
connection.lastReceiveMessageTime = System.currentTimeMillis();
|
||||
connection.receiveMessageLatest = System.currentTimeMillis();
|
||||
|
||||
// List<MessageData> messages = FrameSchema.decode2(in);
|
||||
List<MessageData> messages = FrameSchemaParse.decode(in, this.connection.port);
|
||||
if (!(messages == null || messages.size() == 0)) {
|
||||
// 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);
|
||||
Long id = IdUtil.getSnowflake().nextId();
|
||||
DecodeResult dr = FrameSchemaParse.decode(in, this.connection.port);
|
||||
if (Objects.nonNull(dr) && CollectionUtils.isNotEmpty(dr.getData())) {
|
||||
out.add(List.of(new DecodeMessageData(id, dr.getData(), dr.getSourceData())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.convertor.DeviceChangeStatusConvertor;
|
||||
import club.joylink.xiannccda.ats.message.collect.convertor.DeviceInitConvertor;
|
||||
@ -21,7 +22,7 @@ import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageData>> {
|
||||
public class OccMessageHandler extends SimpleChannelInboundHandler<List<DecodeMessageData>> {
|
||||
|
||||
OccTcpClientConnection connection;
|
||||
boolean collectorData;
|
||||
@ -40,7 +41,7 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageD
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainInitConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRemoveConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
||||
// DeviceStatusConvertorManager.addStatusConvertor(new TrainRecordConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new TrainUpdateConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new PlanScheduleConvertor());
|
||||
DeviceStatusConvertorManager.addStatusConvertor(new InterLockDeviceBitMapConvertor());
|
||||
@ -58,16 +59,17 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageD
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, List<MessageData> msg) throws Exception {
|
||||
if (msg.stream().anyMatch(d -> d.getMsgId() == MessageId.MESSAGE_POLLING)) {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, List<DecodeMessageData> msg) throws Exception {
|
||||
DecodeMessageData messageData = msg.get(0);
|
||||
if (messageData.getMessages().stream().anyMatch(d -> d.getMsgId() == MessageId.MESSAGE_POLLING)) {
|
||||
MessageData md = MessageId.MESSAGE_POLLING.create();
|
||||
this.connection.write(md);
|
||||
}
|
||||
|
||||
if (this.collectorData) {
|
||||
MockAppContext.publish(msg);
|
||||
MockAppContext.publishCollectorAtsData(messageData);
|
||||
}
|
||||
DeviceStatusConvertorManager.doConvertor(msg);
|
||||
DeviceStatusConvertorManager.doConvertor(this.connection.getNameChanger(), messageData.getMessages());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,43 +1,35 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
||||
import com.google.common.collect.Maps;
|
||||
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.software.os.OSProcess;
|
||||
|
||||
/**
|
||||
* OCC客户端管理
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@Component
|
||||
@Setter
|
||||
@Order(1)
|
||||
public class OccMessageManage implements ApplicationRunner {
|
||||
|
||||
|
||||
@Value("${occ.host}")
|
||||
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;
|
||||
@Autowired
|
||||
private OccServerProto occServerProto;
|
||||
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
||||
|
||||
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
||||
@ -48,6 +40,20 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
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) {
|
||||
clientMap.put(client.lineId, client);
|
||||
@ -61,13 +67,21 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("初始化 occ tcp连接.... 是否监控cpu,内存信息:{}", this.monitorHandwareChange);
|
||||
|
||||
DeviceNameChangerManage.init();
|
||||
// 读取数据配置,创建客户端
|
||||
this.registerClient(new XianOccMessagingClient(this.lineId, this.realPort, this.unRealPort, this.serverHost, this.collectorData, receiveMsgTimeout));
|
||||
for (XianOccMessagingClient client : this.clientMap.values()) {
|
||||
client.connect(this.monitorHandwareChange);
|
||||
}
|
||||
this.occServerProto.getClientInfoMap().forEach((k, v) -> {
|
||||
log.info("初始化 occ tcp连接.... 是否监控cpu,lineId:{} 内存信息:{} 是否连接:{}", k, v.isMonitorHandwareChange(), v.isConnectionOcc());
|
||||
DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger());
|
||||
if (v.isConnectionOcc()) {
|
||||
XianOccMessagingClient client = new XianOccMessagingClient(k, v);
|
||||
this.registerClient(client);
|
||||
client.connect(v.isMonitorHandwareChange());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.constants.SystemContext;
|
||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent.SystemWarnConnStateEvent;
|
||||
@ -54,13 +55,16 @@ public class OccTcpClientConnection {
|
||||
@Getter
|
||||
final boolean isRealPort;
|
||||
|
||||
@Getter
|
||||
final NameChangerEnum nameChanger;
|
||||
|
||||
public void write(MessageData messageData) {
|
||||
if (Objects.nonNull(this.channel)) {
|
||||
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.host = host;
|
||||
@ -68,6 +72,7 @@ public class OccTcpClientConnection {
|
||||
this.group = new NioEventLoopGroup(1);
|
||||
this.bootstrap = new Bootstrap();
|
||||
this.isRealPort = isRealPort;
|
||||
this.nameChanger = nameChanger;
|
||||
OccTcpClientConnection self = this;
|
||||
bootstrap.group(group)
|
||||
.channel(NioSocketChannel.class)
|
||||
@ -117,7 +122,6 @@ public class OccTcpClientConnection {
|
||||
this.connected = false;
|
||||
this.channel = null;
|
||||
this.client.resetRequestBaseDataFlag();
|
||||
|
||||
}
|
||||
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
||||
this.reconnectState.resetState();
|
||||
@ -125,7 +129,7 @@ public class OccTcpClientConnection {
|
||||
}
|
||||
|
||||
String hostPortInfo() {
|
||||
return String.format("host=%s, port=%s", this.host, this.port);
|
||||
return String.format("lineId=%s,host=%s, port=%s", this.client.getLineId(), this.host, this.port);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
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 java.time.LocalDateTime;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadDeviceStatusRequest;
|
||||
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import lombok.Getter;
|
||||
@ -21,8 +19,6 @@ import oshi.hardware.GlobalMemory;
|
||||
@Slf4j
|
||||
public class XianOccMessagingClient {
|
||||
|
||||
// final int realTimePortBase = 2600;
|
||||
// final int nonRealTimePortBase = 2700;
|
||||
/**
|
||||
* 线路号 实时信息的侦听端口号为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.lineId = lineId;
|
||||
this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout);
|
||||
@ -67,6 +63,17 @@ public class XianOccMessagingClient {
|
||||
this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false);
|
||||
this.timeOutHandler.addConnection(this.rtConnection);
|
||||
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() {
|
||||
if (this.rtConnection.connected && this.nrtConnection.connected && this.requestBaseDataFlag.compareAndSet(false, true)) {
|
||||
log.info("发送计划运行图请求 lineId[{}] host[{}] 实时接口[{}]", this.lineId, this.host, false);
|
||||
LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
||||
this.send(dataRequest, false);
|
||||
// LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
||||
LoadDeviceStatusRequest dataRequest = new LoadDeviceStatusRequest((short) this.lineId);
|
||||
this.send(dataRequest, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,20 +172,6 @@ public class XianOccMessagingClient {
|
||||
}
|
||||
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() {
|
||||
|
@ -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 com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -24,10 +26,14 @@ import org.springframework.util.CollectionUtils;
|
||||
@Slf4j
|
||||
public class DeviceNameChangerManage {
|
||||
|
||||
final static Table<Integer, DeviceType, List<NameChangerFilter>> CHANGER_TABLE = HashBasedTable.create();
|
||||
private final static Integer TMP_DEFAULT_LINEID = 3;
|
||||
final static Table<NameChangerEnum, DeviceType, List<NameChangerFilter>> CHANGER_TABLE2 = HashBasedTable.create();
|
||||
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)) {
|
||||
log.debug("错误的设备类型 type[{}]", deviceType);
|
||||
return occName;
|
||||
@ -36,7 +42,7 @@ public class DeviceNameChangerManage {
|
||||
log.debug("错误的设备名称 occName[{}]", 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)) {
|
||||
log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
||||
return occName;
|
||||
@ -51,18 +57,93 @@ public class DeviceNameChangerManage {
|
||||
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 {
|
||||
List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.line3.changer", NameChangerFilter.class);
|
||||
List<NameChangerFilter> filters = Lists.newArrayList();
|
||||
List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.changer", NameChangerFilter.class);
|
||||
// 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) {
|
||||
Object obj = clazz.getDeclaredConstructor().newInstance();
|
||||
filters.add((NameChangerFilter) obj);
|
||||
}
|
||||
|
||||
Map<DeviceType, List<NameChangerFilter>> filteMaper = filters.stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType));
|
||||
filteMaper.forEach((k, v) -> {
|
||||
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) {
|
||||
@ -101,18 +182,18 @@ public class DeviceNameChangerManage {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
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);
|
||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
||||
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
||||
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);
|
||||
/*d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "TD_2DG");
|
||||
System.out.println(d);
|
||||
|
||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, "P02309");
|
||||
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);
|
||||
/* d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "XR");
|
||||
System.out.println(d);
|
@ -0,0 +1,17 @@
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface NameChanger {
|
||||
|
||||
NameChangerEnum[] value() default {};
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
|
||||
public enum NameChangerEnum {
|
||||
NONE,
|
||||
//通用
|
||||
UNIVERSAL,
|
||||
LINE_4
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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 java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -10,6 +13,7 @@ public class SignalChanger {
|
||||
/**
|
||||
* X10301 /XR
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Signal1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -37,6 +41,7 @@ public class SignalChanger {
|
||||
/**
|
||||
* X1506_L2
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Signal2Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -1,5 +1,8 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -13,6 +16,7 @@ public class SwitchChanger {
|
||||
/**
|
||||
* 道岔物理区段转换
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class SwitchDGChanger implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -34,6 +38,8 @@ public class SwitchChanger {
|
||||
}
|
||||
}
|
||||
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
|
||||
public static class Switch1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -1,5 +1,8 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -10,6 +13,7 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理 3号线 区段位 T06301A 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -32,6 +36,7 @@ public class TrackChanger {
|
||||
}
|
||||
}
|
||||
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
/**
|
||||
* 处理区段 T11301 这样类似的格式
|
||||
*/
|
||||
@ -63,6 +68,7 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理区段 TP_D33G 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track2Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -84,6 +90,7 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理区段 T150406 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track3Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -2,9 +2,13 @@ package club.joylink.xiannccda.ats.message.collect;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||
import java.util.List;
|
||||
|
||||
/** 消息数据额外转换时间,比如:线路的数据转换为线网数据 */
|
||||
/**
|
||||
* 消息数据额外转换时间,比如:线路的数据转换为线网数据
|
||||
*/
|
||||
public abstract class DeviceStatusConvertor {
|
||||
|
||||
/**
|
||||
@ -14,6 +18,8 @@ public abstract class DeviceStatusConvertor {
|
||||
*/
|
||||
public abstract MessageId getMessageId();
|
||||
|
||||
/** 任务执行逻辑 */
|
||||
public abstract void run(List<MessageData> messageDataList);
|
||||
/**
|
||||
* 任务执行逻辑
|
||||
*/
|
||||
public abstract void run(NameChangerEnum nameChanger, List<MessageData> messageDataList);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -48,14 +49,14 @@ public class DeviceStatusConvertorManager {
|
||||
*
|
||||
* @param dataList 消息数据列表
|
||||
*/
|
||||
public static void doConvertor(List<MessageData> dataList) {
|
||||
public static void doConvertor(NameChangerEnum nameChanger, List<MessageData> dataList) {
|
||||
dataList.stream()
|
||||
.filter(m -> CONVERTOR_MAP.containsKey(m.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) {
|
||||
doConvertor(Collections.singletonList(md));
|
||||
public static void doConvertor(NameChangerEnum nameChanger, MessageData md) {
|
||||
doConvertor(nameChanger, Collections.singletonList(md));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
@ -60,22 +61,20 @@ public abstract class DeviceStatusDataOperate {
|
||||
.forEach(
|
||||
(k, v) -> {
|
||||
// 当前的设备状态
|
||||
Map<String, Builder> deviceStatusMap =
|
||||
allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size()));
|
||||
Map<String, Builder> deviceStatusMap = allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size()));
|
||||
// 新的设备状态
|
||||
Map<String, Builder> newDeviceMap =
|
||||
v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> {
|
||||
Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class);
|
||||
Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class);
|
||||
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
||||
if (collTime >= curTime) {
|
||||
return v2;
|
||||
} else {
|
||||
return v1;
|
||||
}
|
||||
}
|
||||
Map<String, Builder> newDeviceMap = v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> {
|
||||
Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class);
|
||||
Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class);
|
||||
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
||||
if (collTime >= curTime) {
|
||||
return v2;
|
||||
}));
|
||||
} else {
|
||||
return v1;
|
||||
}
|
||||
}
|
||||
return v2;
|
||||
}));
|
||||
// 对比结果
|
||||
Map<String, Message> compareMap = compare(deviceStatusMap, newDeviceMap);
|
||||
if (!CollectionUtils.isEmpty(compareMap) && (!(data instanceof DeviceStatusData))) {
|
||||
@ -177,6 +176,12 @@ public abstract class DeviceStatusDataOperate {
|
||||
Long collTime = DeviceStatusDataOperate.findFieldVal(v, "timestamp", Long.class);
|
||||
if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) {
|
||||
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();
|
||||
curMap.put(k, v.clone());
|
||||
messageMap.put(k, message);
|
||||
|
@ -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.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.DataTypeEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||
@ -46,10 +47,10 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
Map<Short, List<MessageResponse>> lineMapper = this.groupByLineId(messageDataList);
|
||||
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 -> {
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class);
|
||||
Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class);
|
||||
|
@ -1,10 +1,11 @@
|
||||
package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||
|
||||
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.DeviceStatusDataRepository;
|
||||
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.dto.protos.DeviceInfoProto;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer;
|
||||
@ -56,10 +57,10 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param type 所在设备类型
|
||||
* @param deviceName 设备名称
|
||||
*/
|
||||
public static void setUpKilometerCode(
|
||||
public static void setUpKilometerCode(NameChangerEnum nameChanger,
|
||||
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) {
|
||||
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), km));
|
||||
} else {
|
||||
@ -76,14 +77,14 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param type 设备类型
|
||||
* @param name 设备名称
|
||||
*/
|
||||
public static void setTrainDirectionAndKilometerCode(
|
||||
public static void setTrainDirectionAndKilometerCode(NameChangerEnum nameChanger,
|
||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
||||
String globalId,
|
||||
String destinationCode,
|
||||
DeviceType type,
|
||||
String name) {
|
||||
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)) {
|
||||
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
||||
// 目的地最大公里标大于设备最大公里标,上行
|
||||
@ -120,13 +121,13 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param name 设备名称
|
||||
* @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)) {
|
||||
return null;
|
||||
}
|
||||
// 转换成程序中的名称
|
||||
String convertName = DeviceNameChangerManage.findMatch(type, name);
|
||||
String convertName = DeviceNameChangerManage.findMatch(nameChanger, type, name);
|
||||
// 获取到当前区段公里标
|
||||
return LineGraphicDataRepository.getKilometerCodeList(lineId, convertName);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse;
|
||||
@ -13,16 +14,19 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/** 接收列车初始化消息,就收转换线网的列车数据 */
|
||||
/**
|
||||
* 接收列车初始化消息,就收转换线网的列车数据
|
||||
*/
|
||||
@Slf4j
|
||||
public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@Override
|
||||
public MessageId getMessageId() {
|
||||
return MessageId.TRAIN_INDICATION_INIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
try {
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -35,7 +39,7 @@ public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
||||
offset.setLineId(response.getLineId()); // 线路id
|
||||
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
||||
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||
offset,
|
||||
trainCell.getGlobalId(),
|
||||
trainCell.getDestinationId(),
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
@ -23,7 +24,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
// 已存在的设备信息
|
||||
@ -37,7 +38,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
offset.setDir(response.getDirection().getValue()); // 初始设置无运行方向
|
||||
// 设置公里标信息
|
||||
LineNetTrainComMethod.setUpKilometerCode(
|
||||
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||
offset, DeviceType.DEVICE_TYPE_TRACK, response.getTrackName());
|
||||
offset.setShow(offset.getKilometerCode() != 0);
|
||||
buildList.add(offset);
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
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.DeviceStatusDataOperate;
|
||||
@ -17,7 +18,9 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/** 列车信息移除时,线网信息处理 */
|
||||
/**
|
||||
* 列车信息移除时,线网信息处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@ -27,7 +30,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -39,7 +42,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
offset.setGroupId(response.getGroupId());
|
||||
offset.setTrainIndex(response.getTrainIndex());
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
LineNetTrainComMethod.setUpKilometerCode(
|
||||
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||
offset, response.getDevType(), response.getDevName());
|
||||
offset.setShow(false);
|
||||
buildList.add(offset);
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
||||
@ -12,7 +13,9 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/** 列车信息更新时,信息转换 */
|
||||
/**
|
||||
* 列车信息更新时,信息转换
|
||||
*/
|
||||
@Slf4j
|
||||
public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@ -22,7 +25,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -34,7 +37,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
offset.setTrainIndex(response.getTrainIndex()); // 列车标示号,全线唯一
|
||||
offset.setGroupId(response.getGroupId()); // 车组号
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||
offset,
|
||||
response.getGlobalId(),
|
||||
response.getDestinationId(),
|
||||
|
@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.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 com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.List;
|
||||
|
@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.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 com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.List;
|
||||
|
@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.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 com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.List;
|
||||
|
@ -20,6 +20,7 @@ import com.google.common.collect.Tables;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -52,6 +53,9 @@ public class InterLockData extends AbstractData {
|
||||
|
||||
private Map<AlertType, List<AreaConfigVO>> findInterLockAreaConfigData(Integer lineId) {
|
||||
List<AreaConfigVO> areaConfigVOList = this.deviceAreaConfigService.getCache(lineId, AlertDeviceType.DEVICE_TYPE_RTU);
|
||||
if (CollectionUtils.isEmpty(areaConfigVOList)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return areaConfigVOList.stream()
|
||||
.filter(d -> d.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()))
|
||||
.collect(Collectors.groupingBy(d -> AlertType.valueOf(d.getAlertTypes().get(0))));
|
||||
|
@ -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());
|
||||
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.line3;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
@ -18,7 +19,7 @@ public class HeartBeatMsg extends MessageData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
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.DeviceType;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
@ -69,14 +70,14 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
List<GeneratedMessageV3.Builder> msgBuildList = Lists.newArrayList();
|
||||
for (DeviceTypeEntity deviceTypeEntity : this.entityList) {
|
||||
DeviceType dt = deviceTypeEntity.getType();
|
||||
for (DeviceEntity deviceEntity : deviceTypeEntity.deviceList) {
|
||||
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(dt, deviceEntity.status);
|
||||
// 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, "rtuId", this.rtuId);
|
||||
DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime());
|
||||
|
@ -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.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
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.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
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.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 2.7.5 设备状态变化消息
|
||||
@ -91,12 +87,12 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
if (Objects.isNull(this.type)) {
|
||||
log.error("设备变更状态类型为空:{}", JSON.toJSONString(this));
|
||||
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")) {
|
||||
// this.type = DeviceType.DEVICE_TYPE_TRACK;
|
||||
// }
|
||||
@ -112,7 +108,7 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder);
|
||||
DeviceStatusConvertor.convertForPlatform(this.deviceStatus, 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);
|
||||
}
|
||||
|
||||
|
@ -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.device.DeviceType;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityParseUtil {
|
||||
@ -30,7 +33,8 @@ public class EntityParseUtil {
|
||||
public static String convertStr(ByteBuf buf, int len) {
|
||||
byte[] data = new byte[len];
|
||||
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> {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.device.ScheduleSubIdType;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
@ -83,7 +84,7 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GeneratedMessageV3.Builder> generateProto() {
|
||||
public List<GeneratedMessageV3.Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
List<GeneratedMessageV3.Builder> planBuilds = Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(this.entityList)) {
|
||||
Plan.Builder planBuild = Plan.newBuilder();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.device.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
@ -48,7 +49,7 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||
for (TrainCell train : this.trains) {
|
||||
TrainBlock.Builder builder = TrainBlock.newBuilder();
|
||||
|
@ -1,10 +1,11 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.line3.DateTimeUtil;
|
||||
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.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
@ -54,7 +55,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
List<Builder> msgBuildList = Lists.newArrayList();
|
||||
for (TrainCell trainCell : this.trains) {
|
||||
TrainInfo.Builder builder = TrainInfo.newBuilder();
|
||||
@ -75,7 +76,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
|
||||
}
|
||||
// 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);
|
||||
if (trainCell.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//车辆在道岔时,转换对应的设备类型
|
||||
|
@ -1,8 +1,9 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
||||
@ -79,7 +80,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||
trainRemove.setReceiveTime(System.currentTimeMillis());
|
||||
if (Objects.nonNull(this.lineId)) {
|
||||
@ -100,7 +101,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
}
|
||||
// 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);
|
||||
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//车辆在道岔时,转换对应的设备类型
|
||||
|
@ -1,10 +1,11 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.line3.DateTimeUtil;
|
||||
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.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
@ -20,7 +21,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
||||
train.setReceiveTime(System.currentTimeMillis());
|
||||
|
||||
@ -148,7 +148,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//车辆在道岔时,转换对应的设备类型
|
||||
|
@ -1,16 +1,13 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
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.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.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 com.google.common.collect.Lists;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.ZoneOffset;
|
||||
@ -133,7 +130,7 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
||||
builder.setReceiveTime(System.currentTimeMillis());
|
||||
|
||||
@ -164,7 +161,7 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
builder.setSideId(this.getSideId());
|
||||
}
|
||||
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);
|
||||
if (this.getRecordType() != null) {
|
||||
builder.setRecordType(this.getRecordType());
|
||||
|
@ -47,7 +47,7 @@ public class LoadDeviceStatusRequest extends MessageRequest {
|
||||
private Short lineId;
|
||||
|
||||
public LoadDeviceStatusRequest(Short lineId) {
|
||||
super(MessageId.LOAD_DEVICE_STATUS, 2);
|
||||
super(MessageId.LOAD_DEVICE_STATUS, 2 + 1);
|
||||
this.lineId = lineId;
|
||||
}
|
||||
|
||||
@ -55,5 +55,6 @@ public class LoadDeviceStatusRequest extends MessageRequest {
|
||||
@Override
|
||||
public void encode2(ByteBuf buf) {
|
||||
buf.writeShort(this.lineId);
|
||||
buf.writeByte(1);
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,9 @@ public class BuleDisplayMonitoringTask implements AlertMonitoringTask {
|
||||
List<RtuWarnVO> collectRtuList = this.findRtuBuild(lineId, builderMap);
|
||||
Map<Long, List<RtuWarnVO>> rtuVOMapList = collectRtuList.stream().collect(Collectors.groupingBy(d -> d.areaConfigVO.getId()));
|
||||
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();
|
||||
if (allShutdownList.size() == interLockCount && allShutdownList.stream().allMatch(d -> d)) {
|
||||
if (alertDataSource.putAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All")) {
|
||||
|
@ -25,12 +25,12 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SwitchLostTask implements AlertMonitoringTask {
|
||||
public class SwitchLostAndJammedTask implements AlertMonitoringTask {
|
||||
|
||||
private DeviceGuardConfigService configService;
|
||||
private AlertInfoService alertInfoService;
|
||||
|
||||
public SwitchLostTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
public SwitchLostAndJammedTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
this.configService = configService;
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
@ -63,23 +63,44 @@ public class SwitchLostTask implements AlertMonitoringTask {
|
||||
|
||||
private void handle(Builder deviceBuild) {
|
||||
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
this.checkLost(switchBuild, layoutId);
|
||||
this.checkJammed(switchBuild, layoutId);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkLost(Switch.Builder switchBuild, String layoutId) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String JAMMED_NAME = "JAMMED";
|
||||
|
||||
private void checkJammed(Switch.Builder switchBuild, String layoutId) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -57,12 +57,23 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
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) {
|
||||
this.trainRecordMap.remove(trainRecord.getTrainId());
|
||||
boolean isUpWay = trainRecord.getDir() == DirectionEnum.Up.getValue();
|
||||
Platform.Builder platformBuild = this.parsePlatform(trainRecord, isUpWay);
|
||||
if (Objects.nonNull(platformBuild)) {
|
||||
int lineId = trainRecord.getLineId();
|
||||
|
||||
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||
alertDataSource.removeAlterDevice(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||
}
|
||||
@ -171,15 +182,15 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Builder record : this.trainRecordMap.values()) {
|
||||
|
||||
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
|
||||
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
||||
int lineId = record.getLineId();
|
||||
if (Objects.isNull(platformBuild)) {
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (platformBuild.getBizWaitTimerGoing()) {
|
||||
platformBuild.setBizWaitTimerGoing(false);
|
||||
}
|
||||
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());
|
||||
if (planBuildOpt.isEmpty()) {
|
||||
@ -191,6 +202,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
continue;
|
||||
}
|
||||
Plan.Builder planBuild = planBuildOpt.get();
|
||||
int lineId = record.getLineId();
|
||||
boolean isOpen = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||
boolean isClose = alertDataSource.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||
boolean handler = this.preDetection(isOpen, isClose, platformBuild, record);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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.warn.DeviceAlertEvent;
|
||||
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.Builder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -17,8 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
|
||||
|
||||
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||
@Autowired
|
||||
private OccNotHandlePros notHandlePros;
|
||||
|
||||
|
||||
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||
@ -37,6 +36,7 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainR
|
||||
log.info("列车报点驶离,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
||||
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
||||
trainRecord.getRecordType());
|
||||
this.platformAlertMonitoringTask.trainLeavePlatform(trainRecord);
|
||||
this.platformAlertMonitoringTask.removeTrainRecord(trainRecord);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.ats.warn.atp;
|
||||
package club.joylink.xiannccda.ats.warn.train;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.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.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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切除并恢复
|
||||
* <p>
|
||||
@ -116,13 +147,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
||||
layoutDeviceId = section.getCommon().getId();
|
||||
}
|
||||
/* if (mb instanceof Section section) {
|
||||
if (section.getSectionType() == SectionType.Physical) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) {
|
||||
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
@ -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.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.TrainProto.TrainInfo;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||
@ -20,7 +20,6 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
|
||||
|
||||
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) {
|
||||
|
||||
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
|
||||
}
|
||||
|
||||
@ -29,6 +28,8 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
GeneratedMessageV3.Builder trainMsgBuild = event.getSource();
|
||||
if (trainMsgBuild instanceof TrainInfo.Builder trainInfo) {
|
||||
TrainMode trainMode = trainInfo.getMode();
|
||||
//列车不完整直接报警
|
||||
this.atpCutAlertMonitoringTask.trainIntegrityAlarm(trainInfo);
|
||||
if (trainMode.getIpModeTrainEbAlarm()) {
|
||||
//列车紧急制动
|
||||
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
|
@ -0,0 +1,61 @@
|
||||
package club.joylink.xiannccda.configuration;
|
||||
|
||||
|
||||
import club.joylink.xiannccda.constants.common.LoginUserAttr;
|
||||
import club.joylink.xiannccda.dto.auth.ApiPathCacheDTO;
|
||||
import club.joylink.xiannccda.service.AuthService;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
//@Component
|
||||
@Slf4j
|
||||
public class AuthFilter implements Filter {
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
var finder = true;
|
||||
if (Objects.nonNull(authentication) && authentication.isAuthenticated() && (authentication.getPrincipal() instanceof Jwt jwt)) {
|
||||
if (Objects.isNull(jwt.getClaim(LoginUserAttr.DEFAULTS))) {
|
||||
finder = false;
|
||||
Object roleObj = jwt.getClaim(LoginUserAttr.ROLES);
|
||||
var roleList = (List<Long>) roleObj;
|
||||
for (Long roleId : roleList) {
|
||||
var cacheList = this.authService.findByRoleId(roleId);
|
||||
for (ApiPathCacheDTO cache : cacheList) {
|
||||
AntPathRequestMatcher matcher = new AntPathRequestMatcher(cache.getUri());
|
||||
if (matcher.matcher(req).isMatch() && cache.getMethods().contains(req.getMethod().toUpperCase())) {
|
||||
finder = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (finder) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
throw new AccessDeniedException("无权限");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -19,8 +19,6 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
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.JwtEncoder;
|
||||
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.access.BearerTokenAccessDeniedHandler;
|
||||
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.RequestMatcher;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
@ -52,7 +51,8 @@ public class SpringSecurityConfiguration {
|
||||
|
||||
@Autowired
|
||||
CorsConfigurationSource corsConfigurationSource;
|
||||
|
||||
/*@Autowired
|
||||
private AuthFilter authFilter;*/
|
||||
static List<RequestMatcher> AuthWhiteList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
@ -68,6 +68,7 @@ public class SpringSecurityConfiguration {
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
|
||||
http
|
||||
.authorizeHttpRequests((authorize) -> {
|
||||
// authorize.requestMatchers("/favicon.ico", "/js2/**",
|
||||
@ -79,10 +80,14 @@ public class SpringSecurityConfiguration {
|
||||
authorize.anyRequest().authenticated();
|
||||
}
|
||||
)
|
||||
// BearerTokenAuthenticationFilter
|
||||
.cors(corsConfig -> corsConfig.configurationSource(corsConfigurationSource))
|
||||
.csrf((csrf) -> csrf.disable())
|
||||
|
||||
// .httpBasic(Customizer.withDefaults())
|
||||
.oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt -> jwt.decoder(this.jwtDecoder())))
|
||||
|
||||
// .addFilterAfter(authFilter,FilterSecurityInterceptor.class)
|
||||
.sessionManagement(
|
||||
(session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.exceptionHandling((exceptions) -> exceptions
|
||||
|
@ -0,0 +1,26 @@
|
||||
package club.joylink.xiannccda.configuration;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class SystemSynTaskConfig {
|
||||
|
||||
@Bean("nsExecutor")
|
||||
public TaskExecutor nsExecutor(Environment env) {
|
||||
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
|
||||
taskExecutor.setThreadNamePrefix("ns-executor-");
|
||||
taskExecutor.setCorePoolSize(2);
|
||||
taskExecutor.setMaxPoolSize(2);
|
||||
taskExecutor.setQueueCapacity(100);
|
||||
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
taskExecutor.initialize();
|
||||
return taskExecutor;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package club.joylink.xiannccda.configuration.pros;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "occ-not-handle")
|
||||
public class OccNotHandlePros {
|
||||
|
||||
private Integer lineId;
|
||||
private List<Integer> filterRtuIds;
|
||||
private Map<Integer, List<String>> trainRecordStation;
|
||||
|
||||
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
||||
if (Objects.isNull(lineId) || Objects.isNull(rtuId)) {
|
||||
return true;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(this.filterRtuIds)) {
|
||||
return true;
|
||||
}
|
||||
if (this.filterRtuIds.contains(rtuId)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package club.joylink.xiannccda.configuration.protos;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "occ-client")
|
||||
public class OccServerProto {
|
||||
|
||||
private Map<Integer, OccClientMessage> clientInfoMap;
|
||||
|
||||
public OccClientMessage getClientMessage(Integer lineId) {
|
||||
return this.clientInfoMap.get(lineId);
|
||||
}
|
||||
|
||||
public Set<Integer> getAllLineIds() {
|
||||
return this.clientInfoMap.keySet();
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class OccClientMessage {
|
||||
|
||||
private String serverHost;
|
||||
|
||||
private Integer realPort;
|
||||
|
||||
private Integer unRealPort;
|
||||
|
||||
private Boolean collectorData;
|
||||
|
||||
private Integer receiveMsgTimeout;
|
||||
|
||||
private boolean monitorHandwareChange;
|
||||
|
||||
private List<Integer> filterRtuIds;
|
||||
private NameChangerEnum nameChanger;
|
||||
|
||||
private List<LineTypeEnum> lineTypes;
|
||||
|
||||
private boolean connectionOcc;
|
||||
|
||||
public boolean rtuIdExists(Integer rtiud) {
|
||||
return this.filterRtuIds.contains(rtiud);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package club.joylink.xiannccda.constants;
|
||||
|
||||
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
||||
import club.joylink.xiannccda.ats.message.OccMessageManage;
|
||||
import club.joylink.xiannccda.ws.msg.SystemWarnEvent;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.BeansException;
|
||||
@ -26,7 +26,7 @@ public class SystemContext implements ApplicationContextAware {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import org.springframework.stereotype.Indexed;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Indexed
|
||||
public @interface CommonLogAnno {
|
||||
|
||||
String name() default "";
|
||||
|
||||
CommonLogTypeEnum logType();
|
||||
|
||||
CommonLogTypeEnum.SubEventType subLogType();
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum CommonLogTypeEnum {
|
||||
//登录
|
||||
LOGIN,
|
||||
OPERATE,
|
||||
WARN,
|
||||
;
|
||||
|
||||
public enum SubEventType {
|
||||
LOGIN, LOGOUT, QUERY, SAVE_OR_UPDATE, DELETE, WARN, NONE
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum FaultQueryType {
|
||||
// FAULT_EMERGENCY_GUIDE 开头是应急故障,FAULT_EXIT_SERVICE 开头是故障退出服务
|
||||
// T 代表车辆,T后面代表车辆型号
|
||||
|
||||
FAULT_EMERGENCY_NCC,
|
||||
FAULT_EMERGENCY_GUIDE,
|
||||
FAULT_EXIT_SERVICE,
|
||||
FAULT_EMERGENCY_GUIDE_T_DK37,
|
||||
FAULT_EXIT_SERVICE_T_DK37,
|
||||
|
||||
FAULT_EMERGENCY_GUIDE_T_CCD_5037,
|
||||
FAULT_EXIT_SERVICE_T_CCD_5037,
|
||||
;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum LineTypeEnum {
|
||||
NCC, OCC;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public class LoginUserAttr {
|
||||
|
||||
public static final String DEFAULTS = "default";
|
||||
public static final String ROLES = "roles";
|
||||
|
||||
public enum DefaultUserRuleEnum {
|
||||
ADMIN, USER
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,6 +2,10 @@ package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo.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.AlertRecordReportDTO;
|
||||
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.tags.Tag;
|
||||
import java.util.List;
|
||||
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;
|
||||
@ -48,6 +51,7 @@ public class AlertRecordController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "报警信息确认")
|
||||
@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) {
|
||||
return this.alertRecordService.confirm(recordId, tipType, locationId);
|
||||
}
|
||||
@ -56,6 +60,7 @@ public class AlertRecordController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "错误报警")
|
||||
@ApiResponse(description = "错误报警")
|
||||
@CommonLogAnno(name = "报警信息-人工确认", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void batchAlarmWarn(@RequestBody List<Long> recordId) {
|
||||
this.alertRecordService.failAlarm(recordId, AlertStatus.PERSON_WARN_DO);
|
||||
}
|
||||
@ -64,23 +69,28 @@ public class AlertRecordController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "错误报警")
|
||||
@ApiResponse(description = "错误报警")
|
||||
@CommonLogAnno(name = "报警信息-误报", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void failAlarm(@PathVariable("recordId") Long recordId) {
|
||||
this.alertRecordService.failAlarm(List.of(recordId), AlertStatus.FAIL_DO);
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
/* @PostMapping("/page")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页查询报警记录")
|
||||
@ApiResponse(description = "报警记录")
|
||||
@CommonLogAnno(name = "报警信息-列表数据", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
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")
|
||||
@Operation(summary = "分页查询报警记录详情")
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -89,6 +99,7 @@ public class AlertRecordController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "报警统计")
|
||||
@ApiResponse(description = "报警统计")
|
||||
@CommonLogAnno(name = "报警信息-统计", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public List<AlertRecordReportResponseDTO> reportStatistics(@PathVariable("lineId") Integer lineId, @RequestBody AlertRecordReportDTO reportDTO) {
|
||||
return this.alertRecordRepository.report(lineId, reportDTO);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.AlertTipQueryDTO;
|
||||
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.AreaFinder;
|
||||
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.responses.ApiResponse;
|
||||
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.PathVariable;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 报警时的提示信息 前端控制器
|
||||
* 决策信息
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -52,6 +52,7 @@ public class AlertTipController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "插入报警提示信息")
|
||||
@PostMapping()
|
||||
@CommonLogAnno(name = "决策信息-保存修改", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void save(@RequestBody @Validated AlertTipSaveDTO saveDTO) {
|
||||
alertTipService.save(saveDTO);
|
||||
}
|
||||
@ -60,6 +61,7 @@ public class AlertTipController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "根据id查询数据")
|
||||
@GetMapping("/id/{id}")
|
||||
@CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public AlertTip getById(@PathVariable int id) {
|
||||
return alertTipRepository.getById(id);
|
||||
}
|
||||
@ -68,6 +70,7 @@ public class AlertTipController {
|
||||
@Operation(summary = "分页查询报警提示信息")
|
||||
@ApiResponse(description = "报警提示信息分页")
|
||||
@GetMapping("/page")
|
||||
@CommonLogAnno(name = "决策信息-分页列表", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public IPage<AlertTipInfoDto> pageAlertTips(AlertTipQueryDTO alertTipQueryDTO) {
|
||||
return this.alertTipService.page(alertTipQueryDTO);
|
||||
}
|
||||
@ -77,13 +80,15 @@ public class AlertTipController {
|
||||
@Operation(summary = "根据id删除数据")
|
||||
@ApiResponse(description = "是否确实删除掉了一条数据")
|
||||
@DeleteMapping("/id/{id}")
|
||||
@CommonLogAnno(name = "决策信息-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||
public boolean deleteById(@PathVariable int id) {
|
||||
return this.alertTipRepository.removeById(id);
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@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) {
|
||||
return this.areaConfigService.findAlertType(lineId, alertType);
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.entity.AlertTipTimeConfig;
|
||||
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 io.swagger.v3.oas.annotations.Operation;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -15,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 决策信息时间类型配置
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -36,6 +43,7 @@ public class AlertTipTimeConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存修改")
|
||||
@PostMapping("")
|
||||
@CommonLogAnno(name = "决策信息时间-类型保存", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void save(@RequestBody AlertTipTimeConfig dto) {
|
||||
this.timeConfigService.saveOrUpdate(dto);
|
||||
}
|
||||
@ -43,8 +51,8 @@ public class AlertTipTimeConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存修改")
|
||||
@PostMapping("page")
|
||||
@CommonLogAnno(name = "决策信息时间-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public IPage<AlertTipTimeConfig> page(AlertTipTimeQueryDTO dto) {
|
||||
|
||||
return this.configRepository.page(dto, Wrappers.lambdaQuery(AlertTipTimeConfig.class).eq(AlertTipTimeConfig::getListShower, 1));
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
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.DeviceAreaConfigPageDto;
|
||||
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.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 io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@ -25,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 设备区域配置
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -45,6 +42,7 @@ public class DeviceAreaConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存修改")
|
||||
@PostMapping("/save")
|
||||
@CommonLogAnno(name = "决策信息设备区域配置-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public String save(@RequestBody DeviceAreaConfigDto dto) {
|
||||
this.areaConfigService.saveOrUpdate(dto);
|
||||
return "ok";
|
||||
@ -53,23 +51,17 @@ public class DeviceAreaConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "绑定对应的错误类型")
|
||||
@PostMapping("/bind/{id}")
|
||||
@CommonLogAnno(name = "决策信息设备区域配置-信息绑定", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public String bindAlertType(@PathVariable("id") Long id, @RequestBody List<String> alertTypes) {
|
||||
this.areaConfigService.bindAlertType(id, alertTypes);
|
||||
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")
|
||||
@Operation(summary = "获取详情数据")
|
||||
@GetMapping("/page/{lineId}")
|
||||
@CommonLogAnno(name = "决策信息设备区域配置-分页查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public Page<DeviceAreaConfigPageDto> page(@PathVariable("lineId") Integer lineId, DeviceAreaConfigQueryDto queryDto) {
|
||||
return this.areaConfigService.page(queryDto, lineId);
|
||||
}
|
||||
@ -77,6 +69,7 @@ public class DeviceAreaConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "获取详情数据")
|
||||
@GetMapping("/{id}")
|
||||
@CommonLogAnno(name = "决策信息设备区域配置-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public DeviceAreaConfigDto findById(@PathVariable("id") Long id) {
|
||||
return this.areaConfigService.findInfo(id);
|
||||
}
|
||||
@ -84,6 +77,7 @@ public class DeviceAreaConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "获取详情数据")
|
||||
@DeleteMapping("/{id}")
|
||||
@CommonLogAnno(name = "决策信息设备区域配置-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||
public String delete(@PathVariable("id") Long id) {
|
||||
this.areaConfigService.delete(id);
|
||||
return "ok";
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.repository.IDeviceGuardConfigRepository;
|
||||
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.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RestController;
|
||||
|
||||
@Tag(name = "设备保护配置接口")
|
||||
/**
|
||||
* 决策信息阈值管理
|
||||
*/
|
||||
@Tag(name = "决策信息阈值管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/config/device")
|
||||
public class DeviceGuardConfigController {
|
||||
@ -32,6 +37,7 @@ public class DeviceGuardConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "initData")
|
||||
@GetMapping("/initData/{lineId}")
|
||||
@CommonLogAnno(name = "决策信息阈值管理-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public DeviceGuardConfig initData(@PathVariable("lineId") Integer lineId) {
|
||||
LambdaQueryWrapper<DeviceGuardConfig> qw = Wrappers.lambdaQuery(DeviceGuardConfig.class);
|
||||
qw.eq(DeviceGuardConfig::getLineId, lineId);
|
||||
@ -41,6 +47,7 @@ public class DeviceGuardConfigController {
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存修改")
|
||||
@PostMapping("/save")
|
||||
@CommonLogAnno(name = "决策信息阈值管理-数据详情", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public String saveOrUpdate(@RequestBody DeviceGuardConfig dto) {
|
||||
this.configService.saveOrUpdate(dto);
|
||||
return "ok";
|
||||
|
@ -0,0 +1,52 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||
import club.joylink.xiannccda.dto.event.EventLogPageDTO;
|
||||
import club.joylink.xiannccda.dto.event.EventLogQueryDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserEditDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||
import club.joylink.xiannccda.entity.User;
|
||||
import club.joylink.xiannccda.entity.User.Register;
|
||||
import club.joylink.xiannccda.repository.IEventLogRepository;
|
||||
import club.joylink.xiannccda.repository.IUserRepository;
|
||||
import club.joylink.xiannccda.service.UserService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户管理接口
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2023-06-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/log")
|
||||
@Tag(name = "事件查看")
|
||||
public class EventLogController {
|
||||
|
||||
private IEventLogRepository eventLogRepository;
|
||||
|
||||
public EventLogController(IEventLogRepository eventLogRepository) {
|
||||
this.eventLogRepository = eventLogRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/paging")
|
||||
@Operation(summary = "分页数据")
|
||||
@ApiResponse(description = "事件操作")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
public Page<EventLogPageDTO> register(EventLogQueryDTO dto) {
|
||||
return this.eventLogRepository.detailPage(dto);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||
import club.joylink.xiannccda.dto.fq.FaultQueryNcc;
|
||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||
import club.joylink.xiannccda.dto.fq.FaultType;
|
||||
import club.joylink.xiannccda.dto.fq.FaultType.FaultTypeDetail;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
import club.joylink.xiannccda.entity.FaultQuery;
|
||||
import club.joylink.xiannccda.repository.IFaultQueryRepository;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2024-11-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/fault/query")
|
||||
@Tag(name = "故障查询管理")
|
||||
public class FaultQueryController {
|
||||
|
||||
|
||||
private IFaultQueryRepository faultQueryRepository;
|
||||
|
||||
public FaultQueryController(IFaultQueryRepository faultQueryRepository) {
|
||||
this.faultQueryRepository = faultQueryRepository;
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "查询故障类型")
|
||||
@GetMapping("/type")
|
||||
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public List<FaultType> faultType() {
|
||||
return List.of(new FaultType(3,
|
||||
List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE, "车辆故障应急处置指导关键点"), new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE, "车辆故障退出服务地点")
|
||||
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||
, new FaultType(4, List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_DK37, "车辆故障应急处置指导关键点-DK37车型"),
|
||||
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_DK37, "车辆故障退出服务地点-DK37车型")
|
||||
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_CCD_5037, "车辆故障应急处置指导关键点CCD-5037车型"),
|
||||
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_CCD_5037, "车辆故障退出服务地点CCD-5037车型"), new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||
);
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存故障查询")
|
||||
@PostMapping("/ncc")
|
||||
public List<FaultQueryNcc> queryFQForNcc() {
|
||||
return this.faultQueryRepository.fqNcc();
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存故障查询")
|
||||
@PostMapping()
|
||||
// @CommonLogAnno(name = "决策信息-保存修改", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void save(@RequestBody @Validated FaultQuery fq) {
|
||||
this.faultQueryRepository.newSaveOrUpdate(fq);
|
||||
}
|
||||
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "根据id查询数据")
|
||||
@GetMapping("/{id}")
|
||||
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public FaultQuery getById(@PathVariable int id) {
|
||||
return faultQueryRepository.getById(id);
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页查询故障信息")
|
||||
@ApiResponse(description = "分页查询故障信息")
|
||||
@GetMapping("/page")
|
||||
// @CommonLogAnno(name = "决策信息-分页列表", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public IPage<FaultQuery> pageAlertTips(FaultQueryReqDTO req) {
|
||||
return this.faultQueryRepository.page(req);
|
||||
}
|
||||
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "根据id删除数据")
|
||||
@ApiResponse(description = "是否确实删除掉了一条数据")
|
||||
@DeleteMapping("/{id}")
|
||||
// @CommonLogAnno(name = "决策信息-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||
public boolean deleteById(@PathVariable int id) {
|
||||
return this.faultQueryRepository.removeById(id);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||
import club.joylink.xiannccda.dto.auth.AuthApiPathQueryDTO;
|
||||
import club.joylink.xiannccda.dto.auth.AuthRoleDTO;
|
||||
import club.joylink.xiannccda.dto.auth.AuthRoleQueryDTO;
|
||||
import club.joylink.xiannccda.dto.record.AlertRecordQueryDTO;
|
||||
import club.joylink.xiannccda.entity.AlertRecord;
|
||||
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||
import club.joylink.xiannccda.entity.AuthApiPath.AuthApi;
|
||||
import club.joylink.xiannccda.entity.AuthRole;
|
||||
import club.joylink.xiannccda.entity.User;
|
||||
import club.joylink.xiannccda.entity.User.Register;
|
||||
import club.joylink.xiannccda.repository.IAuthApiPathRepository;
|
||||
import club.joylink.xiannccda.repository.IAuthRoleRepository;
|
||||
import club.joylink.xiannccda.service.AuthService;
|
||||
import club.joylink.xiannccda.service.UserService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户管理接口
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2023-06-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/role")
|
||||
@Tag(name = "角色权限资源")
|
||||
public class RoleAuthController {
|
||||
|
||||
private IAuthApiPathRepository authPathRepository;
|
||||
private IAuthRoleRepository authRoleRepository;
|
||||
private AuthService authService;
|
||||
|
||||
public RoleAuthController(IAuthApiPathRepository authPathRepository, IAuthRoleRepository authRoleRepository, AuthService authService) {
|
||||
this.authPathRepository = authPathRepository;
|
||||
this.authRoleRepository = authRoleRepository;
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
@GetMapping("/res/page")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页api资源")
|
||||
@ApiResponse(description = "api资源")
|
||||
public Page<AuthApiPath> pageQuery(AuthApiPathQueryDTO queryDTO) {
|
||||
return authPathRepository.page(queryDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/res/saveOrUpdate")
|
||||
@Operation(summary = "保存编辑资源")
|
||||
@ApiResponse(description = "保存编辑资源")
|
||||
public void saveOrUpdate(@RequestBody @Validated(AuthApi.class) AuthApiPath apiPath) {
|
||||
this.authPathRepository.saveOrUpdate(apiPath);
|
||||
}
|
||||
|
||||
@DeleteMapping("/res/{id}")
|
||||
@Operation(summary = "保存编辑资源")
|
||||
@ApiResponse(description = "保存编辑资源")
|
||||
public void deleteRes(@PathVariable("id") Long id) {
|
||||
this.authPathRepository.removeById(id);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/role/page")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "角色分页")
|
||||
@ApiResponse(description = "角色分页")
|
||||
public Page<AuthRoleDTO> rulePage(AuthRoleQueryDTO queryDTO) {
|
||||
return this.authRoleRepository.roleApiPage(queryDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/role/saveOrUpdate")
|
||||
@Operation(summary = "角色编辑")
|
||||
@ApiResponse(description = "角色编辑")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
public void roleSaveOrUpdate(@RequestBody AuthRoleDTO dto) {
|
||||
this.authService.saveOrUpdate(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/config/{id}")
|
||||
@Operation(summary = "角色配置")
|
||||
@ApiResponse(description = "角色配置")
|
||||
public void roleConfig(@PathVariable("id") Long id, AuthRoleDTO configStr) {
|
||||
this.authRoleRepository.roleConfig(id, configStr);
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,23 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
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.entity.User;
|
||||
import club.joylink.xiannccda.entity.User.Register;
|
||||
import club.joylink.xiannccda.dto.user.UserDetailDTO;
|
||||
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 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 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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -28,31 +36,67 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class UserController {
|
||||
|
||||
private UserService userService;
|
||||
private IUserRepository userRepository;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
public UserController(UserService userService, IUserRepository userRepository) {
|
||||
this.userService = userService;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
/* @PostMapping("/register")
|
||||
@Operation(summary = "用户注册")
|
||||
@ApiResponse(description = "用户注册结果")
|
||||
public String register(@RequestBody @Validated(Register.class) User 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")
|
||||
@Operation(summary = "用户登录")
|
||||
@ApiResponse(description = "授权的jwt")
|
||||
@CommonLogAnno(name = "用户登录", logType = CommonLogTypeEnum.LOGIN, subLogType = SubEventType.LOGIN)
|
||||
public String login(@RequestBody LoginInfoDTO 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")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页查询用户")
|
||||
@ApiResponse(description = "用户列表")
|
||||
public Page<User> pageQuery() {
|
||||
return this.userService.pageQuery();
|
||||
public Page<UserDetailDTO> pageQuery(UserQueryDTO dto) {
|
||||
return this.userRepository.userRolePage(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
30
src/main/java/club/joylink/xiannccda/dto/CommonPage.java
Normal file
@ -0,0 +1,30 @@
|
||||
package club.joylink.xiannccda.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommonPage {
|
||||
|
||||
@Schema(description = "当前页码")
|
||||
private Integer current;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
@Schema(description = "每页条数")
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
@Schema(description = "排序字段,字段驼峰名称,如:userName")
|
||||
private String sortField;
|
||||
|
||||
/**
|
||||
* 排序方式
|
||||
*/
|
||||
@Schema(description = "排序方式,升序:ASCEND;降序:DESCEND")
|
||||
private String sortOrder;
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
*
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
package club.joylink.xiannccda.dto;
|
||||
|
||||
import club.joylink.xiannccda.util.CommonServletUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 通用分页请求
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2021/12/18 14:43
|
||||
*/
|
||||
@Slf4j
|
||||
public class CommonPageRequest {
|
||||
|
||||
private static final String PAGE_SIZE_PARAM_NAME = "size";
|
||||
|
||||
private static final String PAGE_PARAM_NAME = "current";
|
||||
|
||||
private static final Integer PAGE_SIZE_MAX_VALUE = 100;
|
||||
|
||||
public static <T> Page<T> defaultPage() {
|
||||
return defaultPage(null);
|
||||
}
|
||||
|
||||
public static <T> Page<T> defaultPage(List<OrderItem> orderItemList) {
|
||||
|
||||
int size = 20;
|
||||
|
||||
int page = 1;
|
||||
|
||||
//每页条数
|
||||
String pageSizeString = CommonServletUtil.getParamFromRequest(PAGE_SIZE_PARAM_NAME);
|
||||
if (StringUtils.isNotEmpty(pageSizeString)) {
|
||||
try {
|
||||
size = Integer.parseInt(pageSizeString);
|
||||
if (size > PAGE_SIZE_MAX_VALUE) {
|
||||
size = PAGE_SIZE_MAX_VALUE;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 分页条数转换异常:", e);
|
||||
size = 20;
|
||||
}
|
||||
}
|
||||
|
||||
//第几页
|
||||
String pageString = CommonServletUtil.getParamFromRequest(PAGE_PARAM_NAME);
|
||||
if (StringUtils.isNotEmpty(pageString)) {
|
||||
try {
|
||||
page = Integer.parseInt(pageString);
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 分页页数转换异常:", e);
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
Page<T> objectPage = new Page<>(page, size);
|
||||
if (Objects.nonNull(orderItemList)) {
|
||||
objectPage.setOrders(orderItemList);
|
||||
}
|
||||
return objectPage;
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package club.joylink.xiannccda.dto.alertTip;
|
||||
|
||||
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.AlertType;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
import club.joylink.xiannccda.entity.AlertTipTimeConfig;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
@ -19,12 +21,17 @@ import org.apache.commons.lang3.StringUtils;
|
||||
@Data
|
||||
public class AlertTipInfoDto {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "线路id")
|
||||
private Integer lineId;
|
||||
@Schema(description = "线路类型")
|
||||
private LineTypeEnum lineType;
|
||||
@Schema(description = "报警设备类型")
|
||||
private String alertType;
|
||||
|
||||
@Schema(description = "告警关联区域")
|
||||
private Long areaConfigId;
|
||||
|
||||
@Schema(description = "区域名称")
|
||||
private String areaConfigName;
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,13 @@
|
||||
package club.joylink.xiannccda.dto.alertTip;
|
||||
|
||||
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.AlertType;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -12,9 +15,13 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class AlertTipQueryDTO extends PageDTO<AlertTip> {
|
||||
public class AlertTipQueryDTO extends CommonPage {
|
||||
|
||||
private Integer lineId;
|
||||
private LineTypeEnum lineType;
|
||||
@Schema(description = "告警类型")
|
||||
private String alertType;
|
||||
@Schema(description = "时间类型")
|
||||
private String timeType;
|
||||
private String locationType;
|
||||
private Long areaConfigId;
|
||||
|
@ -1,8 +1,11 @@
|
||||
package club.joylink.xiannccda.dto.alertTip;
|
||||
|
||||
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.AlertType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
@ -12,20 +15,33 @@ public class AlertTipSaveDTO {
|
||||
|
||||
private Integer id;
|
||||
@NotNull(message = "报警类型不能为空")
|
||||
@Schema(description = "故障类型")
|
||||
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 AlertLocation locationType;
|
||||
@Schema(description = "地点位置关联")
|
||||
private Long areaConfigId;
|
||||
/**
|
||||
* 行车方面提示信息
|
||||
*/
|
||||
@Schema(description = "行车方面信息")
|
||||
private String drivingInfo;
|
||||
|
||||
/**
|
||||
* 信息报送方面提示信息
|
||||
*/
|
||||
@Schema(description = "信息报送")
|
||||
private String submissionInfo;
|
||||
@Schema(description = "高低峰关联")
|
||||
private List<String> tipTimeIds;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package club.joylink.xiannccda.dto.auth;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class ApiPathCacheDTO {
|
||||
|
||||
private String uri;
|
||||
private List<String> methods;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package club.joylink.xiannccda.dto.auth;
|
||||
|
||||
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthApiPathQueryDTO extends PageDTO<AuthApiPath> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package club.joylink.xiannccda.dto.auth;
|
||||
|
||||
import club.joylink.xiannccda.entity.AuthRole;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthRoleDTO {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private List<Long> resList;
|
||||
@JsonIgnore
|
||||
private String apiIds;
|
||||
private String roleConfigStr;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package club.joylink.xiannccda.dto.auth;
|
||||
|
||||
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||
import club.joylink.xiannccda.entity.AuthRole;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthRoleQueryDTO extends PageDTO<AuthRole> {
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.dto.config;
|
||||
|
||||
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.entity.DeviceAreaConfig;
|
||||
import club.joylink.xiannccda.entity.DeviceGuardConfig;
|
||||
@ -9,7 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceAreaConfigQueryDto extends PageDTO<DeviceAreaConfig> {
|
||||
public class DeviceAreaConfigQueryDto extends CommonPage {
|
||||
|
||||
|
||||
@Schema(description = "设备类型")
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
29
src/main/java/club/joylink/xiannccda/dto/fq/FaultType.java
Normal file
29
src/main/java/club/joylink/xiannccda/dto/fq/FaultType.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,10 @@ public abstract class NewAlertMockDTO {
|
||||
public MessageId parseMessageId() {
|
||||
if (alertType == AlertType.TRAIN_EB_ATP) {
|
||||
return MessageId.TRAIN_INDICATION_UPDATE;
|
||||
} else if (alertType == AlertType.TRAIN_RECORD) {
|
||||
return MessageId.TRAIN_RECORD;
|
||||
}
|
||||
|
||||
return MessageId.DEVICE_STATUS_CHANGE;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user