Compare commits
No commits in common. "local-test" and "master" have entirely different histories.
local-test
...
master
@ -1,61 +0,0 @@
|
||||
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://gitea.joylink.club/joylink/xian-ncc-da-message.git
|
||||
url = https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-message.git
|
||||
|
11
Dockerfile
11
Dockerfile
@ -1,11 +0,0 @@
|
||||
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,10 +44,7 @@
|
||||
<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>
|
||||
@ -152,40 +149,8 @@
|
||||
<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,24 +2,12 @@ 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;
|
||||
@ -31,14 +19,11 @@ 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, LineInfoService lineInfoService) {
|
||||
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
|
||||
IAlertRecordRepository alertRecordRepository) {
|
||||
this.wsMessageServerManager = wsMessageServerManager;
|
||||
this.alertRecordRepository = alertRecordRepository;
|
||||
this.lineInfoService = lineInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,14 +31,13 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
//添加报警事件监听器
|
||||
addAlertListeners();
|
||||
//注册西安NCC的报警ws消息发送服务
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.NCC));
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getInstance(LineTypeEnum.OCC));
|
||||
wsMessageServerManager.registerMessageServer(NccAlertMessageServer.getDefault());
|
||||
//启动报警源事件监测任务
|
||||
AlertManager.getDefault().taskStart();
|
||||
}
|
||||
|
||||
private void addAlertListeners() {
|
||||
|
||||
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
//添加消息
|
||||
alertManager.on(new Listener<NccAlertInfo>() {
|
||||
@ -67,25 +51,10 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
alertInfo.setId(idGenerator.decrementAndGet());
|
||||
}*/
|
||||
//不论是否mock 都保存数据库
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
AlertRecord record = convertToRecord(alertInfo);
|
||||
alertRecordRepository.save(record);
|
||||
alertInfo.setId(record.getId());
|
||||
nccAlertMessageServer.addMsg(alertInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -101,7 +70,6 @@ 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,7 +2,6 @@ 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;
|
||||
@ -11,11 +10,8 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||
public class NccAlertInfo implements AlertInfo {
|
||||
|
||||
public NccAlertInfo() {
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
private Integer id;
|
||||
@ -36,8 +32,6 @@ public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||
@Setter
|
||||
private Integer alarmStatus;
|
||||
private AlertDeviceType alertDeviceType;
|
||||
@Setter
|
||||
private LineTypeEnum lineType;
|
||||
// private AlertType confirmAlertType;
|
||||
|
||||
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
|
||||
@ -56,19 +50,6 @@ public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||
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) {
|
||||
@ -133,12 +114,9 @@ public class NccAlertInfo implements AlertInfo, Cloneable {
|
||||
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, SWITCH_JAMMED, PLATFORM_WAIT_TRAIN_MAX_RECORD, HOLD_PLATFORM_STAY_TRAIN_MORE -> {
|
||||
ALL_LINE_BLUE_DISPLAY, AXLE_LED_RED_INTERLOCK_AREA, AXLE_LED_ORANGE_INTERLOCK_AREA -> {
|
||||
return "I";
|
||||
}
|
||||
case PLATFORM_EMERG_STOP -> {
|
||||
return "II";
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,7 @@ public enum AlertDeviceType {
|
||||
/**
|
||||
* 列车设备
|
||||
*/
|
||||
DEVICE_TYPE_TRAIN,
|
||||
DEVICE_TYPE_TRAIN
|
||||
|
||||
|
||||
/**
|
||||
* 站台扣车对应的区段
|
||||
*/
|
||||
LOGIC_DEVICE_TRACK_AREA_FOR_PLATFORM_HOLDER;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import java.util.Optional;
|
||||
|
||||
public class AlertUtil {
|
||||
|
||||
|
||||
public static Optional<AlertLocation> findLocationByRtuCode(String rtuCode) {
|
||||
switch (rtuCode) {
|
||||
case "1" -> {
|
||||
|
@ -1,131 +0,0 @@
|
||||
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(d.getLineId());
|
||||
LineGraphicDataRepository.initDeviceStationCenter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -12,36 +11,29 @@ 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;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.entity.PublishedGi;
|
||||
import club.joylink.xiannccda.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;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.Getter;
|
||||
@ -87,9 +79,7 @@ public class LineGraphicDataRepository {
|
||||
|
||||
private static final Table<Integer, String, String> TURNOUT_TO_TURNOUT_TRACK = HashBasedTable.create();
|
||||
private static final Table<Integer, String, String> LOGIC_SECTION_TO_AXLE_TABLE = HashBasedTable.create();
|
||||
private static final Table<Integer, String, String> turnout_to_switch = HashBasedTable.create();
|
||||
|
||||
public static final Map<Integer, List<Integer>> STATION_SORTS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 缓存线路数据信息
|
||||
@ -98,7 +88,6 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
public static void putLineGraph(PublishedGi publishGi) {
|
||||
try {
|
||||
|
||||
if (publishGi.getLineId() != null) {
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
||||
@ -120,15 +109,18 @@ public class LineGraphicDataRepository {
|
||||
|
||||
// 填充line_code_table
|
||||
fillLineCodeTable(publishGi.getLineId(), storage);
|
||||
|
||||
Map<String, Map<Integer, Builder>> tmpMaper = lineGraphMap.get(publishGi.getLineId());
|
||||
if (CollectionUtils.isEmpty(tmpMaper)) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, Builder> turnoutMap = tmpMaper.get(DeviceType.Turnout.name());
|
||||
|
||||
Map<Integer, Builder> builderMap = tmpMaper.get(DeviceType.Section.name());
|
||||
|
||||
for (Section section : storage.getSectionList()) {
|
||||
if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
||||
|
||||
for (Integer childId : section.getChildrenList()) {
|
||||
Builder b = turnoutMap.get(childId);
|
||||
if (b instanceof DeviceInfoProto.Turnout.Builder logicSection) {
|
||||
@ -146,70 +138,54 @@ public class LineGraphicDataRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STATION_SORTS.computeIfAbsent(publishGi.getLineId(), lineId -> {
|
||||
List<Station> allStation = LineGraphicDataRepository.getDevices(publishGi.getLineId(), LayoutGraphicsProto.Station.class)
|
||||
.filter(d -> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(d.getCode())).toList();
|
||||
List<Integer> stationCodeList = allStation.stream().map(d -> Integer.valueOf(d.getCode())).distinct().sorted().toList();
|
||||
return stationCodeList;
|
||||
});
|
||||
}
|
||||
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
log.error("反序列化信息失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void initDeviceStationCenter(Integer lineId) {
|
||||
public static void initDeviceStationCenter() {
|
||||
log.info("开始初始化地图中设备集中站的归属。。。");
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// 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()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Integer> allStation(Integer lineId) {
|
||||
return STATION_SORTS.get(lineId);
|
||||
}
|
||||
|
||||
private static List<GeneratedMessageV3.Builder> createMsg(Integer lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType dt, String devName, short rtuId) {
|
||||
DeviceStatusChangeResponse statusChange = new DeviceStatusChangeResponse();
|
||||
@ -219,7 +195,7 @@ public class LineGraphicDataRepository {
|
||||
statusChange.setType(dt);
|
||||
statusChange.setDeviceStatus(0);
|
||||
statusChange.setRtuId(rtuId);
|
||||
return statusChange.generateProto(DeviceNameChangerManage.findNameChanger(lineId));
|
||||
return statusChange.generateProto();
|
||||
}
|
||||
|
||||
public static Integer getStationCenterById(Integer lineId, String deviceId) {
|
||||
@ -228,13 +204,8 @@ public class LineGraphicDataRepository {
|
||||
if (StringUtils.isEmpty(rtuCode)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(rtuCode);
|
||||
return Integer.parseInt(rtuCode);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static Optional<Platform> findLayoutPlatformFromSection(Integer lineId, String sectionName) {
|
||||
@ -254,12 +225,6 @@ public class LineGraphicDataRepository {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Collection<Integer> getAllLines() {
|
||||
return lineGraphMap.keySet();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取线路上区段名为【sectionName】的公里标
|
||||
*
|
||||
@ -298,42 +263,21 @@ public class LineGraphicDataRepository {
|
||||
|
||||
public static MessageOrBuilder getDeviceByCodeNotException(int lineId, String code) {
|
||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||
return mob;
|
||||
}
|
||||
|
||||
public static MessageOrBuilder getDeviceByCode2(int lineId, String code, String t) {
|
||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
||||
String.format("线路[%s]code[%s] deviceid[%s]", lineId, code, t));
|
||||
return mob;
|
||||
}
|
||||
|
||||
public static MessageOrBuilder getDeviceByCode(int lineId, String code) {
|
||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
||||
String.format("线路[%s]code[%s]", lineId, code));
|
||||
return mob;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据道岔code 查找对应的道岔区段
|
||||
*
|
||||
* @param lineId
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String findTurnoutSectionFromTurnoutCode(int lineId, String code) {
|
||||
return TURNOUT_TO_TURNOUT_TRACK.get(lineId, code);
|
||||
}
|
||||
|
||||
public static <T> T getDeviceByCodeNotException(int lineId, String code, Class<T> cls) {
|
||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||
return (T) mob;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static <T> Optional<T> getDeviceOptByCode(int lineId, String code, Class<T> cls) {
|
||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||
if (Objects.isNull(mob)) {
|
||||
@ -461,17 +405,7 @@ public class LineGraphicDataRepository {
|
||||
Map<String, CoordinateConvertor> convertorMap =
|
||||
lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>());
|
||||
Map<Integer, Builder> cacheSwitchMap = new HashMap<>(storage.getTurnoutsList().size());
|
||||
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()
|
||||
storage.getTurnoutsList().stream()
|
||||
.forEach(
|
||||
t -> {
|
||||
List<KilometerSystem> systemList =
|
||||
@ -485,7 +419,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -542,40 +476,7 @@ 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());
|
||||
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()
|
||||
storage.getAxleCountingsList().stream()
|
||||
.filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem()))
|
||||
.forEach(
|
||||
ac -> {
|
||||
@ -604,7 +505,7 @@ public class LineGraphicDataRepository {
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -614,76 +515,19 @@ 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<>());
|
||||
// 从计轴中转换信息
|
||||
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
|
||||
storage
|
||||
.getAxleCountingsList()
|
||||
.forEach(
|
||||
axle -> {
|
||||
@ -730,12 +574,13 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -792,9 +637,11 @@ 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("无坐标转换规则 lineId:{},规则:{}", lineId, convertorKey);
|
||||
log.error("无坐标转换规则" + convertorKey);
|
||||
return kilometer.getKilometer();
|
||||
}
|
||||
return convertorMap.get(convertorKey).convertorKilometer(kilometer, CoordinateEnum.MAIN_LINE);
|
||||
|
@ -1,47 +0,0 @@
|
||||
package club.joylink.xiannccda.ats.cache.config;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.dto.PublishedGIDTO.LineType;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
public class LineConfig {
|
||||
|
||||
private List<WarnConfig> warnConfig;
|
||||
|
||||
public List<AlertType> getExcludedAlertType(LineTypeEnum lineType) {
|
||||
for (WarnConfig config : this.warnConfig) {
|
||||
if (config.lineType == lineType) {
|
||||
return config.excludeWarn;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean alertTypeExist(LineTypeEnum lineType, AlertType alertType) {
|
||||
List<AlertType> atList = this.getExcludedAlertType(lineType);
|
||||
if (CollectionUtils.isEmpty(atList)) {
|
||||
return false;
|
||||
}
|
||||
return atList.contains(alertType);
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class WarnConfig {
|
||||
|
||||
|
||||
private LineTypeEnum lineType;
|
||||
private List<AlertType> excludeWarn;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class FrameSchema {
|
||||
* (Multi-flag)为帧标识位,占1字节,值为0或者1,分别表示下面的意思: 1:表示在这帧数据中,一个完整的消息没有发送结束,有后续帧; 0:表示在这帧数据中,消息完整发送,没有后续帧。同样,几个消息可合并成一帧数据发送
|
||||
*/
|
||||
short multiFlag;
|
||||
public static final short Flag_Multi = 1;
|
||||
static final short Flag_Multi = 1;
|
||||
/**
|
||||
* 消息内容,最长为1024字节。它可由一个或多个消息组成,也可以是一个消息的一部分。每个消息由消息标识和消息数据组成
|
||||
*/
|
||||
|
@ -8,9 +8,6 @@ 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
|
||||
@ -22,8 +19,6 @@ 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) {
|
||||
@ -43,27 +38,18 @@ public class FrameSchemaParse {
|
||||
return null;
|
||||
}*/
|
||||
|
||||
|
||||
public static DecodeResult decode(ByteBuf inByteBuf, Integer port) {
|
||||
public static List<MessageData> decode(ByteBuf inByteBuf, Integer port) {
|
||||
ByteBuf packageData = PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
||||
ByteBuf sourcePackageData = SOURCE_PACKAGE_DATA_MAP.computeIfAbsent(port, (d) -> Unpooled.buffer());
|
||||
boolean readComplate = schemaParse(inByteBuf, packageData, sourcePackageData);
|
||||
boolean readComplate = schemaParse(inByteBuf, packageData);
|
||||
if (readComplate) {
|
||||
try {
|
||||
DecodeResult dr = new DecodeResult();
|
||||
List<MessageData> messageDataList = Lists.newArrayList();
|
||||
messageDecode(packageData, messageDataList);
|
||||
dr.data = messageDataList;
|
||||
byte[] data = new byte[sourcePackageData.readableBytes()];
|
||||
sourcePackageData.readBytes(data);
|
||||
dr.sourceData = data;
|
||||
|
||||
return dr;
|
||||
return messageDataList;
|
||||
} catch (Exception e) {
|
||||
log.error("OCC消息解析异常", e);
|
||||
return null;
|
||||
} finally {
|
||||
sourcePackageData.clear();
|
||||
packageData.clear();
|
||||
}
|
||||
}
|
||||
@ -96,7 +82,7 @@ public class FrameSchemaParse {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean schemaParse(ByteBuf inByteBuf, ByteBuf packageData, ByteBuf sourcePackageData) {
|
||||
private static boolean schemaParse(ByteBuf inByteBuf, ByteBuf packageData) {
|
||||
inByteBuf.markReaderIndex();
|
||||
int totalReadables = inByteBuf.readableBytes();
|
||||
if (totalReadables < 4) {
|
||||
@ -114,23 +100,9 @@ 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(bb);
|
||||
// packageData.writeBytes(inByteBuf, contentLen);
|
||||
sourcePackageData.writeByte(sysId);
|
||||
sourcePackageData.writeShort(totalLength);
|
||||
sourcePackageData.writeByte(flag);
|
||||
sourcePackageData.writeBytes(bb);
|
||||
// byte[] bb = new byte[contentLen];
|
||||
// inByteBuf.readBytes(bb);
|
||||
packageData.writeBytes(inByteBuf, contentLen);
|
||||
return flag != Flag_Multi;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class DecodeResult {
|
||||
|
||||
private List<MessageData> data;
|
||||
private byte[] sourceData;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -66,7 +65,6 @@ public abstract class MessageData {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void decode(ByteBuf buf) throws Exception {
|
||||
final int headerBytes = 10;
|
||||
int readableBytes = buf.readableBytes();
|
||||
@ -94,7 +92,7 @@ public abstract class MessageData {
|
||||
*/
|
||||
public abstract void decode2(ByteBuf buf) throws Exception;
|
||||
|
||||
public abstract List<GeneratedMessageV3.Builder> generateProto(NameChangerEnum nameChanger);
|
||||
public abstract List<GeneratedMessageV3.Builder> generateProto();
|
||||
|
||||
|
||||
public void encode(ByteBuf buf) {
|
||||
@ -117,18 +115,4 @@ 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 {
|
||||
/**
|
||||
* 消息对象创建接口
|
||||
*/
|
||||
public OccMessageCreate omc;
|
||||
OccMessageCreate omc;
|
||||
|
||||
public interface OccMessageCreate {
|
||||
interface OccMessageCreate {
|
||||
|
||||
MessageData create();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -19,7 +18,7 @@ public abstract class MessageRequest extends MessageData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -14,9 +13,8 @@ public abstract class MessageResponse extends MessageData {
|
||||
|
||||
public abstract Short getLineId();
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,9 @@
|
||||
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 {
|
||||
|
||||
@ -27,13 +21,18 @@ public class OccMessageDecoder extends ByteToMessageDecoder {
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
connection.lastReceiveMessageTime = System.currentTimeMillis();
|
||||
// connection.receiveMessageLatest = System.currentTimeMillis();
|
||||
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())));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -22,7 +21,7 @@ import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class OccMessageHandler extends SimpleChannelInboundHandler<List<DecodeMessageData>> {
|
||||
public class OccMessageHandler extends SimpleChannelInboundHandler<List<MessageData>> {
|
||||
|
||||
OccTcpClientConnection connection;
|
||||
boolean collectorData;
|
||||
@ -41,7 +40,7 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<DecodeMe
|
||||
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());
|
||||
@ -59,17 +58,16 @@ public class OccMessageHandler extends SimpleChannelInboundHandler<List<DecodeMe
|
||||
|
||||
|
||||
@Override
|
||||
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)) {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, List<MessageData> msg) throws Exception {
|
||||
if (msg.stream().anyMatch(d -> d.getMsgId() == MessageId.MESSAGE_POLLING)) {
|
||||
MessageData md = MessageId.MESSAGE_POLLING.create();
|
||||
this.connection.write(md);
|
||||
}*/
|
||||
}
|
||||
|
||||
if (this.collectorData) {
|
||||
MockAppContext.publishCollectorAtsData(messageData);
|
||||
MockAppContext.publish(msg);
|
||||
}
|
||||
DeviceStatusConvertorManager.doConvertor(this.connection.getNameChanger(), messageData.getMessages());
|
||||
DeviceStatusConvertorManager.doConvertor(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,35 +1,43 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
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 club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
||||
import com.google.common.collect.Maps;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
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客户端管理
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Setter
|
||||
@Order(1)
|
||||
@Slf4j
|
||||
public class OccMessageManage implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private OccServerProto occServerProto;
|
||||
|
||||
@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;
|
||||
Map<Integer, XianOccMessagingClient> clientMap = new HashMap<>();
|
||||
|
||||
public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) {
|
||||
@ -40,20 +48,6 @@ 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);
|
||||
@ -67,21 +61,13 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("初始化 occ tcp连接.... 是否监控cpu,内存信息:{}", this.monitorHandwareChange);
|
||||
|
||||
DeviceNameChangerManage.init();
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 读取数据配置,创建客户端
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -48,28 +47,20 @@ public class OccTcpClientConnection {
|
||||
/**
|
||||
* 最后一次接受到消息的时间
|
||||
*/
|
||||
// long receiveMessageLatest;
|
||||
/**
|
||||
* 最近一次连接occ 服务时间
|
||||
*/
|
||||
long connectionOccTimeLatest;
|
||||
|
||||
long receiveMessageLatest;
|
||||
|
||||
final ReconnectState reconnectState;
|
||||
|
||||
@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, NameChangerEnum nameChanger) {
|
||||
public OccTcpClientConnection(XianOccMessagingClient client, String host, int port, boolean collectorData, boolean isRealPort) {
|
||||
|
||||
this.client = client;
|
||||
this.host = host;
|
||||
@ -77,7 +68,6 @@ 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,8 +107,7 @@ public class OccTcpClientConnection {
|
||||
this.lastReceiveMessageTime = System.currentTimeMillis();
|
||||
this.channel = channelFuture.channel();
|
||||
this.connected = true;
|
||||
this.client.requestBaseData();
|
||||
this.connectionOccTimeLatest = System.currentTimeMillis();
|
||||
// this.client.requestBaseData();
|
||||
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
||||
}
|
||||
});
|
||||
@ -128,6 +117,7 @@ public class OccTcpClientConnection {
|
||||
this.connected = false;
|
||||
this.channel = null;
|
||||
this.client.resetRequestBaseDataFlag();
|
||||
|
||||
}
|
||||
SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this));
|
||||
this.reconnectState.resetState();
|
||||
@ -135,7 +125,7 @@ public class OccTcpClientConnection {
|
||||
}
|
||||
|
||||
String hostPortInfo() {
|
||||
return String.format("lineId=%s,host=%s, port=%s", this.client.getLineId(), this.host, this.port);
|
||||
return String.format("host=%s, port=%s", this.host, this.port);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package club.joylink.xiannccda.ats.message;
|
||||
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadDeviceStatusRequest;
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
||||
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
|
||||
import java.time.LocalDateTime;
|
||||
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;
|
||||
@ -22,6 +21,8 @@ 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)
|
||||
*/
|
||||
@ -44,8 +45,7 @@ public class XianOccMessagingClient {
|
||||
|
||||
private final Long requestBaseTime;
|
||||
|
||||
private final ConnectionTimeOutHandler timeOutHandler;
|
||||
|
||||
private final ConnectionTimeOutHandler timeOutHandler = new ConnectionTimeOutHandler();
|
||||
|
||||
public void send(MessageData md, boolean isRealTime) {
|
||||
OccTcpClientConnection conn = isRealTime ? rtConnection : nrtConnection;
|
||||
@ -58,15 +58,13 @@ public class XianOccMessagingClient {
|
||||
}
|
||||
|
||||
|
||||
public XianOccMessagingClient(Integer lineId, OccClientMessage clientMessage) {
|
||||
this.host = clientMessage.getServerHost();
|
||||
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(clientMessage.getReceiveMsgTimeout());
|
||||
this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout);
|
||||
// 创建实时和非实时消息连接
|
||||
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 = new ConnectionTimeOutHandler(this.requestBaseTime);
|
||||
|
||||
this.rtConnection = new OccTcpClientConnection(this, host, realPort, collectorData, true);
|
||||
this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false);
|
||||
this.timeOutHandler.addConnection(this.rtConnection);
|
||||
this.timeOutHandler.addConnection(this.nrtConnection);
|
||||
|
||||
@ -78,7 +76,7 @@ public class XianOccMessagingClient {
|
||||
*/
|
||||
public void resetRequestBaseDataFlag() {
|
||||
//实时数据客户端断开,并且最新的获取时间 + 2小时小于当前时间
|
||||
if (Objects.equals(false, this.rtConnection.connected) /*&& (this.rtConnection.receiveMessageLatest + this.requestBaseTime) < System.currentTimeMillis()*/) {
|
||||
if (Objects.equals(false, this.rtConnection.connected) && (this.rtConnection.receiveMessageLatest + this.requestBaseTime) < System.currentTimeMillis()) {
|
||||
this.requestBaseDataFlag.set(false);
|
||||
}
|
||||
}
|
||||
@ -87,10 +85,8 @@ 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 planData = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
||||
// this.send(planData, false);
|
||||
LoadDeviceStatusRequest dataRequest = new LoadDeviceStatusRequest((short) this.lineId);
|
||||
this.send(dataRequest, true);
|
||||
LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
|
||||
this.send(dataRequest, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,11 +137,7 @@ public class XianOccMessagingClient {
|
||||
Executor.shutdownNow();
|
||||
}
|
||||
|
||||
//重新请求基础数据间隔
|
||||
private Long requestBaseTime;
|
||||
|
||||
public ConnectionTimeOutHandler(Long requestBaseTime) {
|
||||
this.requestBaseTime = requestBaseTime;
|
||||
public ConnectionTimeOutHandler() {
|
||||
this.systemInfo = new SystemInfo();
|
||||
if (Executor.isShutdown()) {
|
||||
Executor = Executors.newSingleThreadScheduledExecutor();
|
||||
@ -172,6 +164,20 @@ 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() {
|
||||
@ -185,13 +191,9 @@ public class XianOccMessagingClient {
|
||||
for (OccTcpClientConnection cc : this.clientConnections) {
|
||||
if (cc.connected) {
|
||||
long ctm = System.currentTimeMillis();
|
||||
|
||||
/*if (cc.lastReceiveMessageTime + HeartBeatTimeout < ctm) {
|
||||
if (cc.lastReceiveMessageTime + HeartBeatTimeout < ctm) {
|
||||
log.info("超时未收到OCC消息,尝试断开重连 port :{} 最后一次获取数据时间:{}", cc.port, cc.lastReceiveMessageTime);
|
||||
cc.reconnect();
|
||||
}*/
|
||||
if (cc.isRealPort && (cc.connectionOccTimeLatest + requestBaseTime) < ctm) {
|
||||
|
||||
}
|
||||
} else {
|
||||
cc.reconnect();
|
||||
|
@ -1,17 +0,0 @@
|
||||
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 {};
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
|
||||
public enum NameChangerEnum {
|
||||
NONE,
|
||||
//通用
|
||||
UNIVERSAL,
|
||||
LINE_4
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package club.joylink.xiannccda.ats.message.changer.line4;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChanger;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerEnum;
|
||||
import club.joylink.xiannccda.ats.message.changer.NameChangerFilter;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class TrackChanger {
|
||||
|
||||
|
||||
/**
|
||||
* 处理 3号线 区段位 T06301A 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.LINE_4})
|
||||
public static class Track1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
public DeviceType deviceType() {
|
||||
return DeviceType.DEVICE_TYPE_TRACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeDeviceName(String sourceName) {
|
||||
if (StringUtils.startsWith(sourceName, "DG")) {
|
||||
int flag = StringUtils.indexOf(sourceName, "-");
|
||||
if (flag > 0) {
|
||||
return sourceName.substring(0, flag);
|
||||
}
|
||||
return sourceName;
|
||||
}
|
||||
return sourceName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,13 +2,9 @@ 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 {
|
||||
|
||||
/**
|
||||
@ -18,8 +14,6 @@ public abstract class DeviceStatusConvertor {
|
||||
*/
|
||||
public abstract MessageId getMessageId();
|
||||
|
||||
/**
|
||||
* 任务执行逻辑
|
||||
*/
|
||||
public abstract void run(NameChangerEnum nameChanger, List<MessageData> messageDataList);
|
||||
/** 任务执行逻辑 */
|
||||
public abstract void run(List<MessageData> messageDataList);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -14,7 +13,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class DeviceStatusConvertorManager {
|
||||
|
||||
|
||||
/**
|
||||
* 消息类型,与转换列表
|
||||
*/
|
||||
@ -50,14 +48,14 @@ public class DeviceStatusConvertorManager {
|
||||
*
|
||||
* @param dataList 消息数据列表
|
||||
*/
|
||||
public static void doConvertor(NameChangerEnum nameChanger, List<MessageData> dataList) {
|
||||
public static void doConvertor(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(nameChanger, v)));
|
||||
.forEach((k, v) -> CONVERTOR_MAP.get(k).values().forEach(c -> c.run(v)));
|
||||
}
|
||||
|
||||
public static void doConvertor(NameChangerEnum nameChanger, MessageData md) {
|
||||
doConvertor(nameChanger, Collections.singletonList(md));
|
||||
public static void doConvertor(MessageData md) {
|
||||
doConvertor(Collections.singletonList(md));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -61,23 +60,25 @@ 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) {
|
||||
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;
|
||||
} else {
|
||||
return v1;
|
||||
}
|
||||
}
|
||||
return v2;
|
||||
}));
|
||||
}));
|
||||
// 对比结果
|
||||
Map<String, Message> compareMap = compare(deviceStatusMap, newDeviceMap);
|
||||
if (!CollectionUtils.isEmpty(compareMap)/* && ((data instanceof DeviceStatusData))*/) {
|
||||
if (!CollectionUtils.isEmpty(compareMap) && (!(data instanceof DeviceStatusData))) {
|
||||
statusVOMap.put(k, compareMap);
|
||||
}
|
||||
});
|
||||
@ -176,12 +177,6 @@ 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);
|
||||
|
@ -1,9 +1,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.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;
|
||||
@ -23,7 +21,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Collection;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@ -48,37 +45,15 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
||||
return responseList.stream().collect(Collectors.groupingBy(MessageResponse::getLineId));
|
||||
}
|
||||
|
||||
private void tmpChangeLine4Name(Integer lineId, GeneratedMessageV3.Builder msg) {
|
||||
|
||||
if (lineId == 4 && msg instanceof TrainInfo.Builder ti) {
|
||||
String deviceName = ti.getDevName();
|
||||
if (StringUtils.startsWith(deviceName, "P")) {
|
||||
String occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineId, deviceName);
|
||||
if (StringUtils.isNotEmpty(occName)) {
|
||||
ti.setDevName(occName);
|
||||
}
|
||||
} else if (StringUtils.startsWith(deviceName, "DG")) {
|
||||
int flag = StringUtils.indexOf(deviceName, "-");
|
||||
if (flag > 0) {
|
||||
String newName = deviceName.substring(0, flag);
|
||||
ti.setDevName(newName);
|
||||
}
|
||||
}
|
||||
} else if (lineId == 4 && msg instanceof TrainRemove.Builder re) {
|
||||
System.out.println(re.getDevName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
Map<Short, List<MessageResponse>> lineMapper = this.groupByLineId(messageDataList);
|
||||
lineMapper.forEach((k, v) -> {
|
||||
List<GeneratedMessageV3.Builder> builders = v.stream().map(d -> d.generateProto(nameChanger))
|
||||
List<GeneratedMessageV3.Builder> builders = v.stream().map(MessageResponse::generateProto)
|
||||
.flatMap(Collection::stream).filter(d -> {
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class);
|
||||
Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class);
|
||||
if (d instanceof TrainInfo.Builder ti || d instanceof TrainRemove.Builder) {
|
||||
tmpChangeLine4Name(lineId, d);
|
||||
if (d instanceof TrainInfo.Builder || d instanceof TrainRemove.Builder) {
|
||||
return true;
|
||||
}
|
||||
return SystemContext.notMatchRtu(lineId, rtuId);
|
||||
|
@ -1,11 +1,10 @@
|
||||
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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -57,10 +56,10 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param type 所在设备类型
|
||||
* @param deviceName 设备名称
|
||||
*/
|
||||
public static void setUpKilometerCode(NameChangerEnum nameChanger,
|
||||
public static void setUpKilometerCode(
|
||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj, DeviceType type, String deviceName) {
|
||||
// 获取到当前区段公里标
|
||||
DeviceKilometer.Builder km = getDeviceKM(nameChanger, obj.getLineId(), type, deviceName);
|
||||
DeviceKilometer.Builder km = getDeviceKM(obj.getLineId(), type, deviceName);
|
||||
if (km != null) {
|
||||
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), km));
|
||||
} else {
|
||||
@ -77,14 +76,14 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param type 设备类型
|
||||
* @param name 设备名称
|
||||
*/
|
||||
public static void setTrainDirectionAndKilometerCode(NameChangerEnum nameChanger,
|
||||
public static void setTrainDirectionAndKilometerCode(
|
||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
||||
String globalId,
|
||||
String destinationCode,
|
||||
DeviceType type,
|
||||
String name) {
|
||||
TrainRunDirection direction = null;
|
||||
DeviceKilometer.Builder deviceKm = getDeviceKM(nameChanger, obj.getLineId(), type, name);
|
||||
DeviceKilometer.Builder deviceKm = getDeviceKM(obj.getLineId(), type, name);
|
||||
if (deviceKm != null && StringUtils.isNoneEmpty(destinationCode)) {
|
||||
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
||||
// 目的地最大公里标大于设备最大公里标,上行
|
||||
@ -121,13 +120,13 @@ public abstract class LineNetTrainComMethod {
|
||||
* @param name 设备名称
|
||||
* @return 公里标列表
|
||||
*/
|
||||
private static DeviceKilometer.Builder getDeviceKM(NameChangerEnum nameChanger, int lineId, DeviceType type, String name) {
|
||||
private static DeviceKilometer.Builder getDeviceKM(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(nameChanger, type, name);
|
||||
String convertName = DeviceNameChangerManage.findMatch(type, name);
|
||||
// 获取到当前区段公里标
|
||||
return LineGraphicDataRepository.getKilometerCodeList(lineId, convertName);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -14,19 +13,16 @@ 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(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
try {
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -39,7 +35,7 @@ public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
||||
offset.setLineId(response.getLineId()); // 线路id
|
||||
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
||||
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||
offset,
|
||||
trainCell.getGlobalId(),
|
||||
trainCell.getDestinationId(),
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -24,7 +23,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
// 已存在的设备信息
|
||||
@ -38,7 +37,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor {
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
offset.setDir(response.getDirection().getValue()); // 初始设置无运行方向
|
||||
// 设置公里标信息
|
||||
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||
LineNetTrainComMethod.setUpKilometerCode(
|
||||
offset, DeviceType.DEVICE_TYPE_TRACK, response.getTrackName());
|
||||
offset.setShow(offset.getKilometerCode() != 0);
|
||||
buildList.add(offset);
|
||||
|
@ -3,7 +3,6 @@ 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;
|
||||
@ -18,9 +17,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 列车信息移除时,线网信息处理
|
||||
*/
|
||||
/** 列车信息移除时,线网信息处理 */
|
||||
@Slf4j
|
||||
public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@ -30,7 +27,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -42,7 +39,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor {
|
||||
offset.setGroupId(response.getGroupId());
|
||||
offset.setTrainIndex(response.getTrainIndex());
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
LineNetTrainComMethod.setUpKilometerCode(nameChanger,
|
||||
LineNetTrainComMethod.setUpKilometerCode(
|
||||
offset, response.getDevType(), response.getDevName());
|
||||
offset.setShow(false);
|
||||
buildList.add(offset);
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -13,9 +12,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 列车信息更新时,信息转换
|
||||
*/
|
||||
/** 列车信息更新时,信息转换 */
|
||||
@Slf4j
|
||||
public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@ -25,7 +22,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(NameChangerEnum nameChanger, List<MessageData> messageDataList) {
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
try {
|
||||
List<Builder> buildList = Lists.newArrayList();
|
||||
for (MessageData data : messageDataList) {
|
||||
@ -37,7 +34,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
||||
offset.setTrainIndex(response.getTrainIndex()); // 列车标示号,全线唯一
|
||||
offset.setGroupId(response.getGroupId()); // 车组号
|
||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger,
|
||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||
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.train.TrainModeAlertListener.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.atp.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.train.TrainModeAlertListener.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.atp.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.train.TrainModeAlertListener.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.List;
|
||||
|
@ -7,10 +7,7 @@ import club.joylink.xiannccda.constants.SystemContext;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||
@ -23,7 +20,6 @@ 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;
|
||||
@ -34,10 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
public class InterLockData extends AbstractData {
|
||||
|
||||
/**
|
||||
@ -58,9 +52,6 @@ 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))));
|
||||
@ -97,19 +88,11 @@ public class InterLockData extends AbstractData {
|
||||
Integer max = Integer.parseInt(sortStationList.get(sortStationList.size() - 1).getCode());
|
||||
if (rtuId >= min && rtuId <= max) {
|
||||
if (builder instanceof Track.Builder track) {
|
||||
MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, track.getId());
|
||||
if (section instanceof LayoutGraphicsProto.Section ss) {
|
||||
if (ss.getSectionType() == SectionType.TurnoutPhysical) {
|
||||
this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
||||
}
|
||||
} else {
|
||||
if (section instanceof LayoutGraphicsProto.LogicSection) {
|
||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, track.getId());
|
||||
MessageOrBuilder sec = LineGraphicDataRepository.getDeviceByCode2(lineId, axleCode, track.getId());
|
||||
this.put(sec, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
||||
}
|
||||
}
|
||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, track.getId());
|
||||
|
||||
// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, track.getId());
|
||||
MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, axleCode);
|
||||
this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId);
|
||||
} else if (builder instanceof Switch.Builder switchs) {
|
||||
// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, switchs.getId());
|
||||
// this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_SWITCH, interlockArea, min, max, rtuId);
|
||||
@ -164,11 +147,7 @@ public class InterLockData extends AbstractData {
|
||||
@Override
|
||||
public void addDevice(List<Builder> dataList) {
|
||||
for (Builder builder : dataList) {
|
||||
try {
|
||||
this.insert(builder);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
this.insert(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,6 @@ public class TrainDataSource extends AbstractData {
|
||||
|
||||
/**
|
||||
* 增量的设备更新信息
|
||||
* <p>
|
||||
* k1 数据类型
|
||||
* <p>
|
||||
* k2 车组号
|
||||
* <p>
|
||||
* v 列车数据
|
||||
*/
|
||||
private Table<String, String, Message> trainUpdate = Tables.synchronizedTable(HashBasedTable.create());
|
||||
|
||||
@ -76,7 +70,6 @@ public class TrainDataSource extends AbstractData {
|
||||
if (Objects.nonNull(dbTime) && Objects.nonNull(collTime)) {
|
||||
if (collTime >= dbTime) {
|
||||
DeviceStatusDataOperate.merge(trainBuild, message);
|
||||
|
||||
// this.putTrainDeviceMapper(trainBuild);
|
||||
}
|
||||
}
|
||||
@ -85,10 +78,6 @@ public class TrainDataSource extends AbstractData {
|
||||
trainInfo.clearBlock();
|
||||
trainInfo.clearRemove();
|
||||
trainInfo.clearRecord();
|
||||
if (builder instanceof TrainInfo.Builder oldTrain) {
|
||||
trainInfo.setHasNextStation(oldTrain.getHasNextStation());
|
||||
trainInfo.setTrainDelay(oldTrain.getTrainDelay());
|
||||
}
|
||||
allTrainInfoMaper.put(idVal.toString(), trainInfo);
|
||||
if (SystemContext.notMatchRtu(trainInfo.getLineId(), trainInfo.getRtuId())) {
|
||||
this.putTrainDeviceMapper(trainInfo);
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -19,7 +18,7 @@ public class HeartBeatMsg extends MessageData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,14 @@
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
package club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -26,14 +24,10 @@ import org.springframework.util.CollectionUtils;
|
||||
@Slf4j
|
||||
public class DeviceNameChangerManage {
|
||||
|
||||
final static Table<NameChangerEnum, DeviceType, List<NameChangerFilter>> CHANGER_TABLE2 = HashBasedTable.create();
|
||||
final static Map<Integer, NameChangerEnum> LINEID_NAMECHANGER_MAP = Maps.newHashMap();
|
||||
final static Table<Integer, DeviceType, List<NameChangerFilter>> CHANGER_TABLE = HashBasedTable.create();
|
||||
private final static Integer TMP_DEFAULT_LINEID = 3;
|
||||
|
||||
|
||||
public static String findMatch(NameChangerEnum nameChanger, DeviceType deviceType, String occName) {
|
||||
if (nameChanger == NameChangerEnum.NONE) {
|
||||
return occName;
|
||||
}
|
||||
public static String findMatch(DeviceType deviceType, String occName) {
|
||||
if (Objects.isNull(deviceType)) {
|
||||
log.debug("错误的设备类型 type[{}]", deviceType);
|
||||
return occName;
|
||||
@ -42,7 +36,7 @@ public class DeviceNameChangerManage {
|
||||
log.debug("错误的设备名称 occName[{}]", occName);
|
||||
return occName;
|
||||
}
|
||||
List<NameChangerFilter> filters = CHANGER_TABLE2.get(nameChanger, deviceType);
|
||||
List<NameChangerFilter> filters = CHANGER_TABLE.get(TMP_DEFAULT_LINEID, deviceType);
|
||||
if (CollectionUtils.isEmpty(filters)) {
|
||||
log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType);
|
||||
return occName;
|
||||
@ -57,93 +51,18 @@ 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.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();
|
||||
List<Class> classes = getClassFQName("club.joylink.xiannccda.ats.message.line3.changer", NameChangerFilter.class);
|
||||
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));
|
||||
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);
|
||||
CHANGER_TABLE.put(TMP_DEFAULT_LINEID, k, v);
|
||||
});
|
||||
}
|
||||
|
||||
private static List<Class> getClassFQName(String packgeName, Class clz) {
|
||||
@ -182,18 +101,18 @@ public class DeviceNameChangerManage {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
DeviceNameChangerManage.init();
|
||||
String d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T13301C");
|
||||
String d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T13301C");
|
||||
System.out.println(d);
|
||||
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T06301C");
|
||||
System.out.println(d);
|
||||
d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T04325G");
|
||||
d = DeviceNameChangerManage.findMatch(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(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_SIGNAL, "S03305");
|
||||
d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "S03305");
|
||||
System.out.println(d);
|
||||
/* d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "XR");
|
||||
System.out.println(d);
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.ats.message.changer;
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
|
@ -1,8 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
|
||||
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,7 +10,6 @@ public class SignalChanger {
|
||||
/**
|
||||
* X10301 /XR
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Signal1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -41,7 +37,6 @@ public class SignalChanger {
|
||||
/**
|
||||
* X1506_L2
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Signal2Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -1,8 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
|
||||
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;
|
||||
@ -16,7 +13,6 @@ public class SwitchChanger {
|
||||
/**
|
||||
* 道岔物理区段转换
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class SwitchDGChanger implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -38,8 +34,6 @@ public class SwitchChanger {
|
||||
}
|
||||
}
|
||||
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
|
||||
public static class Switch1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -1,8 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.message.changer.universal;
|
||||
package club.joylink.xiannccda.ats.message.line3.changer;
|
||||
|
||||
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,7 +10,6 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理 3号线 区段位 T06301A 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track1Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -36,7 +32,6 @@ public class TrackChanger {
|
||||
}
|
||||
}
|
||||
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
/**
|
||||
* 处理区段 T11301 这样类似的格式
|
||||
*/
|
||||
@ -68,7 +63,6 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理区段 TP_D33G 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track2Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
||||
@ -90,7 +84,6 @@ public class TrackChanger {
|
||||
/**
|
||||
* 处理区段 T150406 这样类似的格式
|
||||
*/
|
||||
@NameChanger(value = {NameChangerEnum.UNIVERSAL})
|
||||
public static class Track3Changer implements NameChangerFilter {
|
||||
|
||||
@Override
|
@ -57,7 +57,7 @@ public class ActionReportResponse extends MessageResponse {
|
||||
this.totalMessage = buf.readShort();
|
||||
this.messageSequence = buf.readShort();
|
||||
this.count = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.count, buf, ActionReportEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.count, buf, ActionReportEntity.class);
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ public class ActionReportResponse extends MessageResponse {
|
||||
private String actionContent;
|
||||
|
||||
@Override
|
||||
public ActionReportEntity read(Integer lineId, ByteBuf buf) {
|
||||
public ActionReportEntity read(ByteBuf buf) {
|
||||
ActionReportEntity entity = new ActionReportEntity();
|
||||
|
||||
entity.actionSite = ActionReportSiteEnum.of(buf.readByte());
|
||||
|
@ -55,7 +55,7 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
this.totalMessage = buf.readShort();
|
||||
this.messageSequence = buf.readShort();
|
||||
this.count = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.count, buf, AlarmReportEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.count, buf, AlarmReportEntity.class);
|
||||
}
|
||||
|
||||
|
||||
@ -128,18 +128,18 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public AlarmReportEntity read(Integer lineId, ByteBuf buf) {
|
||||
public AlarmReportEntity read(ByteBuf buf) {
|
||||
AlarmReportEntity entity = new AlarmReportEntity();
|
||||
entity.alamrSite = AlarmReportSiteEnum.of(buf.readByte());
|
||||
entity.alarmSiteid = buf.readShort();
|
||||
entity.alarmNname = EntityParseUtil.convertStr(lineId, buf, 20);
|
||||
entity.alarmNname = EntityParseUtil.convertStr(buf, 20);
|
||||
|
||||
entity.alarmTime = DateTimeUtil.convert(buf);
|
||||
entity.alarmType = AlarmTypeControlEnum.of(buf.readShort());
|
||||
entity.alarmSubType = buf.readShort();
|
||||
entity.alarmLen = buf.readShort();
|
||||
|
||||
entity.alarmContent = EntityParseUtil.convertStr(lineId, buf, entity.alarmLen);
|
||||
entity.alarmContent = EntityParseUtil.convertStr(buf, entity.alarmLen);
|
||||
|
||||
entity.alarmAckSiteid = buf.readShort();
|
||||
entity.alarmAckSite = EntityParseUtil.convertStr(buf, 32);
|
||||
|
@ -58,7 +58,7 @@ public class DepotPlanResponse extends MessageResponse {
|
||||
this.lineId = buf.readShort();
|
||||
this.date = DateTimeUtil.convert(buf);
|
||||
this.depotCount = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.depotCount, buf, DepotPlanEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.depotCount, buf, DepotPlanEntity.class);
|
||||
|
||||
}
|
||||
|
||||
@ -230,11 +230,11 @@ public class DepotPlanResponse extends MessageResponse {
|
||||
private Integer inLocalSubid;
|
||||
|
||||
@Override
|
||||
public DepotPlanEntity read(Integer lineId, ByteBuf buf) {
|
||||
public DepotPlanEntity read(ByteBuf buf) {
|
||||
DepotPlanEntity entity = new DepotPlanEntity();
|
||||
entity.depotStation = buf.readShort();
|
||||
entity.groupId = EntityParseUtil.convertStr(lineId, buf, 9);
|
||||
entity.driverId = EntityParseUtil.convertStr(lineId, buf, 13);
|
||||
entity.groupId = EntityParseUtil.convertStr(buf, 9);
|
||||
entity.driverId = EntityParseUtil.convertStr(buf, 13);
|
||||
entity.outFlag = buf.readShort() == 1;
|
||||
entity.outSchedule = buf.readByte() == 1;
|
||||
entity.outTime = DateTimeUtil.convert(buf);
|
||||
|
@ -2,9 +2,8 @@ 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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -66,18 +65,18 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
this.lineId = buf.readShort();
|
||||
this.rtuId = buf.readShort();
|
||||
this.typeCnt = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.typeCnt, buf, DeviceTypeEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.typeCnt, buf, DeviceTypeEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
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(nameChanger, dt, deviceEntity.devName);
|
||||
String newOccName = DeviceNameChangerManage.findMatch(dt, deviceEntity.devName);
|
||||
DeviceStatusConvertor.fillField(builder, "id", newOccName);
|
||||
DeviceStatusConvertor.fillField(builder, "rtuId", this.rtuId);
|
||||
DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime());
|
||||
@ -88,7 +87,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
DeviceStatusConvertor.convertForTrack(deviceEntity.getStatus(), builder);
|
||||
DeviceStatusConvertor.convertForPlatform(deviceEntity.getStatus(), (Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare()), builder);
|
||||
DeviceStatusConvertor.convertForSwitch(Objects.isNull(deviceEntity.getSpare()) ? 0 : deviceEntity.getSpare(), builder);
|
||||
// log.info("接受全量状态设备类型:[{}] 对应状态[{}]", dt.name(), builder);
|
||||
log.info("接受全量状态设备类型:[{}] 对应状态[{}]", dt.name(), builder);
|
||||
msgBuildList.add(builder);
|
||||
}
|
||||
}
|
||||
@ -122,12 +121,12 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
private List<DeviceEntity> deviceList;
|
||||
|
||||
@Override
|
||||
public DeviceTypeEntity read(Integer lineId, ByteBuf buf) {
|
||||
public DeviceTypeEntity read(ByteBuf buf) {
|
||||
DeviceTypeEntity entity = new DeviceTypeEntity();
|
||||
|
||||
entity.type = DeviceType.of(buf.readShort());
|
||||
entity.objCount = buf.readShort();
|
||||
entity.deviceList = EntityParseUtil.collect(lineId, entity.objCount, buf, DeviceEntity.class);
|
||||
entity.deviceList = EntityParseUtil.collect(entity.objCount, buf, DeviceEntity.class);
|
||||
/* for (DeviceEntity de : entity.deviceList) {
|
||||
de.devName = DeviceNameChangerManage.findMatch(entity.type, de.devName);
|
||||
}*/
|
||||
@ -163,9 +162,9 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceEntity read(Integer lineId, ByteBuf buf) {
|
||||
public DeviceEntity read(ByteBuf buf) {
|
||||
DeviceEntity entity = new DeviceEntity();
|
||||
entity.devName = EntityParseUtil.convertStr(lineId, buf, 24);
|
||||
entity.devName = EntityParseUtil.convertStr(buf, 24);
|
||||
entity.status = buf.readInt();
|
||||
entity.spare = buf.readInt();
|
||||
return entity;
|
||||
|
@ -2,18 +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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -80,23 +83,20 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
this.lineId = buf.readShort();
|
||||
this.rtuId = buf.readShort();
|
||||
this.type = DeviceType.of(buf.readShort());
|
||||
|
||||
this.devName = EntityParseUtil.convertStr(Integer.valueOf(this.lineId), buf, 24);
|
||||
this.devName = EntityParseUtil.convertStr(buf, 24);
|
||||
this.deviceStatus = buf.readInt();
|
||||
this.spare = buf.readInt();
|
||||
|
||||
// this.devName = DeviceNameChangerManage.findMatch(this.type, this.devName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
if (Objects.isNull(this.type)) {
|
||||
log.error("设备变更状态类型为空:{}", JSON.toJSONString(this));
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.type, this.devName);
|
||||
String occName = DeviceNameChangerManage.findMatch(this.type, this.devName);
|
||||
// if (this.type == DeviceType.DEVICE_TYPE_SWITCH && StringUtils.startsWith(occName, "DG")) {
|
||||
// this.type = DeviceType.DEVICE_TYPE_TRACK;
|
||||
// }
|
||||
@ -112,7 +112,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,27 +2,22 @@ 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.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityParseUtil {
|
||||
|
||||
public static <T> List<T> collect(int lineId, int count, ByteBuf buf, Class<T> tClass) {
|
||||
public static <T> List<T> collect(int count, ByteBuf buf, Class<T> tClass) {
|
||||
|
||||
List<T> list = Lists.newArrayListWithCapacity(count);
|
||||
for (var i = 0; i < count; i++) {
|
||||
try {
|
||||
Object obj = tClass.getDeclaredConstructor().newInstance();
|
||||
if (obj instanceof ReadData rd) {
|
||||
list.add((T) rd.read(lineId, buf));
|
||||
list.add((T) rd.read(buf));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -35,36 +30,12 @@ public class EntityParseUtil {
|
||||
public static String convertStr(ByteBuf buf, int len) {
|
||||
byte[] data = new byte[len];
|
||||
buf.readBytes(data);
|
||||
String name = new String(data, MessageCons.STRING_CHARSET).trim();
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String convertStr(Integer lineId, ByteBuf buf, int len) {
|
||||
byte[] data = new byte[len];
|
||||
buf.readBytes(data);
|
||||
if (lineId == 3) {
|
||||
return new String(data, MessageCons.STRING_CHARSET).trim();
|
||||
} else {
|
||||
int findIndex = 0;
|
||||
for (; findIndex < data.length; findIndex++) {
|
||||
byte dn = data[findIndex];
|
||||
if (dn == 0) {
|
||||
// findIndex = findIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
byte[] nameByte = new byte[findIndex];
|
||||
System.arraycopy(data, 0, nameByte, 0, findIndex);
|
||||
|
||||
return new String(nameByte, Charset.forName("GBK"));
|
||||
|
||||
}
|
||||
|
||||
return new String(data, MessageCons.STRING_CHARSET).trim();
|
||||
}
|
||||
|
||||
public interface ReadData<T> {
|
||||
|
||||
T read(Integer lineId, ByteBuf buf);
|
||||
T read(ByteBuf buf);
|
||||
}
|
||||
|
||||
/* public static void fill(GeneratedMessageV3.Builder builder, String name, Object val) {
|
||||
|
@ -66,7 +66,7 @@ public class HistoryScheduleResponse extends MessageResponse {
|
||||
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
||||
this.groupId = EntityParseUtil.convertStr(buf, 9);
|
||||
this.recCnt = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.recCnt, buf, HistoryScheduleEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.recCnt, buf, HistoryScheduleEntity.class);
|
||||
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class HistoryScheduleResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public HistoryScheduleEntity read(Integer lineId, ByteBuf buf) {
|
||||
public HistoryScheduleEntity read(ByteBuf buf) {
|
||||
HistoryScheduleEntity entity = new HistoryScheduleEntity();
|
||||
|
||||
entity.stationId = buf.readShort();
|
||||
@ -134,8 +134,8 @@ public class HistoryScheduleResponse extends MessageResponse {
|
||||
entity.aTime = DateTimeUtil.convert(buf);
|
||||
entity.dTime = DateTimeUtil.convert(buf);
|
||||
entity.flag = buf.readShort();
|
||||
entity.serviceId = EntityParseUtil.convertStr(lineId, buf, 9);
|
||||
entity.globalId = EntityParseUtil.convertStr(lineId, buf, 12);
|
||||
entity.serviceId = EntityParseUtil.convertStr(buf, 9);
|
||||
entity.globalId = EntityParseUtil.convertStr(buf, 12);
|
||||
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
||||
|
||||
entity.planType = buf.readShort() == 1;
|
||||
|
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -75,22 +74,16 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
this.lineId = buf.readShort();
|
||||
this.date = DateTimeUtil.convert(buf);
|
||||
this.subId = ScheduleSubIdType.of(buf.readShort());
|
||||
/* if (this.subId == ScheduleSubIdType.HISTORY_BEGIN) {
|
||||
System.out.println("aaaaaaaaaa");
|
||||
}
|
||||
if (this.subId == ScheduleSubIdType.HISTORY_STOP) {
|
||||
System.out.println("bbbbbbbbbbbb");
|
||||
}*/
|
||||
if (this.subId == ScheduleSubIdType.HISTORY_RUN) {
|
||||
|
||||
this.trainId = EntityParseUtil.convertStr(buf, 9);
|
||||
this.tripCnt = buf.readShort();
|
||||
this.entityList = EntityParseUtil.collect(this.lineId, this.tripCnt, buf, InusedScheduleEntity.class);
|
||||
this.entityList = EntityParseUtil.collect(this.tripCnt, buf, InusedScheduleEntity.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GeneratedMessageV3.Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<GeneratedMessageV3.Builder> generateProto() {
|
||||
List<GeneratedMessageV3.Builder> planBuilds = Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(this.entityList)) {
|
||||
Plan.Builder planBuild = Plan.newBuilder();
|
||||
@ -157,14 +150,14 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public InusedScheduleEntity read(Integer lineId, ByteBuf buf) {
|
||||
public InusedScheduleEntity read(ByteBuf buf) {
|
||||
InusedScheduleEntity entity = new InusedScheduleEntity();
|
||||
|
||||
entity.globalId = EntityParseUtil.convertStr(buf, 12);
|
||||
entity.groupId = EntityParseUtil.convertStr(buf, 9);
|
||||
entity.destinationId = EntityParseUtil.convertStr(buf, 4);
|
||||
entity.recCnt = buf.readShort();
|
||||
entity.recordList = EntityParseUtil.collect(lineId, entity.recCnt, buf, EntityRecord.class);
|
||||
entity.recordList = EntityParseUtil.collect(entity.recCnt, buf, EntityRecord.class);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@ -210,7 +203,7 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public EntityRecord read(Integer lineId, ByteBuf buf) {
|
||||
public EntityRecord read(ByteBuf buf) {
|
||||
EntityRecord record = new EntityRecord();
|
||||
|
||||
record.stationId = buf.readShort();
|
||||
|
@ -52,7 +52,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
||||
this.lineId = buf.readShort();
|
||||
this.rtuId = buf.readShort();
|
||||
this.singalCount = buf.readShort();
|
||||
this.signals = EntityParseUtil.collect(this.lineId, this.singalCount, buf, SignalStatusEntity.class);
|
||||
this.signals = EntityParseUtil.collect(this.singalCount, buf, SignalStatusEntity.class);
|
||||
|
||||
}
|
||||
|
||||
@ -90,12 +90,12 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
||||
private List<RouteStatusEntity> routes;
|
||||
|
||||
@Override
|
||||
public SignalStatusEntity read(Integer lineId, ByteBuf buf) {
|
||||
public SignalStatusEntity read(ByteBuf buf) {
|
||||
SignalStatusEntity entity = new SignalStatusEntity();
|
||||
|
||||
entity.signalName = EntityParseUtil.convertStr(buf, 20);
|
||||
entity.routeCount = buf.readByte();
|
||||
entity.routes = EntityParseUtil.collect(lineId, entity.routeCount, buf, RouteStatusEntity.class);
|
||||
entity.routes = EntityParseUtil.collect(entity.routeCount, buf, RouteStatusEntity.class);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@ -121,9 +121,9 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public RouteStatusEntity read(Integer lineId, ByteBuf buf) {
|
||||
public RouteStatusEntity read(ByteBuf buf) {
|
||||
RouteStatusEntity entity = new RouteStatusEntity();
|
||||
entity.routeName = EntityParseUtil.convertStr(lineId, buf, 64);
|
||||
entity.routeName = EntityParseUtil.convertStr(buf, 64);
|
||||
|
||||
entity.routeStatus = RouteStatusEnum.of(buf.readByte());
|
||||
return entity;
|
||||
|
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -16,8 +15,6 @@ import lombok.Getter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
@ -25,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Slf4j
|
||||
public class TrainBlockInfoResponse extends MessageResponse {
|
||||
|
||||
/**
|
||||
@ -44,19 +40,15 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
||||
@Override
|
||||
public void decode2(ByteBuf buf) throws Exception {
|
||||
this.lineId = buf.readShort();
|
||||
|
||||
this.trainCnt = buf.readShort();
|
||||
this.trains = new ArrayList<>(this.trainCnt);
|
||||
/*if (this.lineId == 4) {
|
||||
log.warn("lineId:{} 阻塞数据量:{}", this.lineId, this.trainCnt);
|
||||
}*/
|
||||
for (int cnt = 0; cnt < this.trainCnt; cnt++) {
|
||||
this.trains.add(new TrainCell().decode(buf));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||
for (TrainCell train : this.trains) {
|
||||
TrainBlock.Builder builder = TrainBlock.newBuilder();
|
||||
|
@ -1,12 +1,10 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -56,7 +54,7 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
List<Builder> msgBuildList = Lists.newArrayList();
|
||||
for (TrainCell trainCell : this.trains) {
|
||||
TrainInfo.Builder builder = TrainInfo.newBuilder();
|
||||
@ -77,17 +75,11 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
|
||||
}
|
||||
// builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), ""));
|
||||
String occName = DeviceNameChangerManage.findMatch(nameChanger, trainCell.getDevType(), trainCell.getDevName());
|
||||
String occName = DeviceNameChangerManage.findMatch(trainCell.getDevType(), trainCell.getDevName());
|
||||
builder.setDevName(occName);
|
||||
if (trainCell.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//车辆在道岔时,转换对应的设备类型
|
||||
builder.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
||||
/* if (lineId == 4) {
|
||||
if (StringUtils.startsWith(trainCell.getDevName(), "P")) {
|
||||
occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(this.lineId, trainCell.getDevName());
|
||||
builder.setDevName(occName);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
builder.setTrainIndex(StringUtils.defaultString(trainCell.getTrainIndex(), ""));
|
||||
builder.setGroupId(StringUtils.defaultString(trainCell.getGroupId(), ""));
|
||||
|
@ -1,9 +1,8 @@
|
||||
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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -80,7 +79,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||
trainRemove.setReceiveTime(System.currentTimeMillis());
|
||||
if (Objects.nonNull(this.lineId)) {
|
||||
@ -101,7 +100,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
}
|
||||
// trainRemove.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName);
|
||||
String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName);
|
||||
trainRemove.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.cache.LineGraphicDataRepository;
|
||||
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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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 club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
@ -23,6 +20,7 @@ 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;
|
||||
|
||||
/**
|
||||
@ -129,7 +127,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
||||
train.setReceiveTime(System.currentTimeMillis());
|
||||
|
||||
@ -148,18 +146,13 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
if (Objects.nonNull(this.devType)) {
|
||||
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
}
|
||||
|
||||
// train.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||
String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName);
|
||||
String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName);
|
||||
train.setDevName(occName);
|
||||
if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//车辆在道岔时,转换对应的设备类型
|
||||
train.setDevType(DeviceStatusProto.DeviceType.SWITCH_TRACK);
|
||||
/* if (lineId == 4) {
|
||||
if (StringUtils.startsWith(this.devName, "P")) {
|
||||
occName = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(this.lineId, this.devName);
|
||||
train.setDevName(occName);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
train.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
||||
train.setRollingStock(this.getRollingStock());
|
||||
|
@ -1,13 +1,16 @@
|
||||
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.changer.DeviceNameChangerManage;
|
||||
import club.joylink.xiannccda.ats.message.line3.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;
|
||||
@ -130,7 +133,7 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto(NameChangerEnum nameChanger) {
|
||||
public List<Builder> generateProto() {
|
||||
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
||||
builder.setReceiveTime(System.currentTimeMillis());
|
||||
|
||||
@ -161,7 +164,7 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
builder.setSideId(this.getSideId());
|
||||
}
|
||||
builder.setTrackName(StringUtils.defaultString(this.trackName, ""));
|
||||
String deviceName = DeviceNameChangerManage.findMatch(nameChanger, DeviceType.DEVICE_TYPE_TRACK, builder.getTrackName());
|
||||
String deviceName = DeviceNameChangerManage.findMatch(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 + 1);
|
||||
super(MessageId.LOAD_DEVICE_STATUS, 2);
|
||||
this.lineId = lineId;
|
||||
}
|
||||
|
||||
@ -55,6 +55,5 @@ public class LoadDeviceStatusRequest extends MessageRequest {
|
||||
@Override
|
||||
public void encode2(ByteBuf buf) {
|
||||
buf.writeShort(this.lineId);
|
||||
buf.writeByte(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.xiannccda.ats.warn.train;
|
||||
package club.joylink.xiannccda.ats.warn.atp;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||
@ -19,11 +19,9 @@ 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;
|
||||
@ -64,41 +62,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
}
|
||||
}
|
||||
|
||||
private final static String TRAIN_INTEGRITY_NAME = "TRAIN_INTEGRITY";
|
||||
|
||||
/**
|
||||
* 列车不完整直接报警
|
||||
*
|
||||
* @param trainInfo
|
||||
*/
|
||||
public void trainIntegrityAlarm(TrainInfo.Builder trainInfo) {
|
||||
if (trainInfo.getMode().getIpModeTrainIntegrityAlarm()) {
|
||||
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId())) {
|
||||
|
||||
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
// CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class);
|
||||
String layoutDeviceId = null;
|
||||
if (mb instanceof LogicSection) {
|
||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class);
|
||||
layoutDeviceId = String.valueOf(section.getCommon().getId());
|
||||
} else if (mb instanceof Turnout) {
|
||||
String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
||||
layoutDeviceId = String.valueOf(section.getCommon().getId());
|
||||
}
|
||||
|
||||
String alertMsg = String.format("列车[%s] 丢失完整性所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.TRAIN_INTEGRITY_ALARM, trainInfo, alertMsg, layoutDeviceId,
|
||||
AlertDeviceType.DEVICE_TYPE_TRACK, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断紧致后发生atp切除并恢复
|
||||
* <p>
|
||||
@ -133,12 +96,13 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
return "TRAIN_EB_WITH_ATP_CUT_ALTER";
|
||||
}
|
||||
|
||||
private Integer findTrainLocation(TrainInfo.Builder trainInfo) {
|
||||
|
||||
protected void trainAlert(TrainInfo.Builder trainInfo) {
|
||||
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
if (!(mb instanceof LogicSection) && !(mb instanceof Turnout) && !(mb instanceof Section)) {
|
||||
log.error("线路[{}]列车[{}]所在未知设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
||||
this.trainInfoMap.remove(trainInfo.getGroupId());
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class);
|
||||
Integer layoutDeviceId = commonInfo.getId();
|
||||
@ -146,19 +110,20 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class);
|
||||
layoutDeviceId = section.getCommon().getId();
|
||||
} else if (mb instanceof Turnout) {
|
||||
}
|
||||
if (mb instanceof Turnout) {
|
||||
String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class);
|
||||
layoutDeviceId = section.getCommon().getId();
|
||||
}
|
||||
return layoutDeviceId;
|
||||
}
|
||||
/* if (mb instanceof Section section) {
|
||||
if (section.getSectionType() == SectionType.Physical) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
protected void trainAlert(TrainInfo.Builder trainInfo) {
|
||||
Integer layoutDeviceId = this.findTrainLocation(trainInfo);
|
||||
if (Objects.isNull(layoutDeviceId)) {
|
||||
return;
|
||||
}
|
||||
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) {
|
||||
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
|
||||
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||
@ -169,21 +134,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
this.trainInfoMap.remove(trainInfo.getGroupId());
|
||||
}
|
||||
|
||||
private final static String TRAIN_LOST_LOCATION_ALERT_NAME = "train_lost_location_alert";
|
||||
|
||||
private void trainLostLocation(TrainInfo.Builder trainInfo) {
|
||||
Integer layoutDeviceId = this.findTrainLocation(trainInfo);
|
||||
if (Objects.isNull(layoutDeviceId)) {
|
||||
return;
|
||||
}
|
||||
if (alertDataSource.putAlterDevice(trainInfo.getLineId(), TRAIN_LOST_LOCATION_ALERT_NAME, trainInfo.getGroupId())) {
|
||||
String alertMsg = String.format("列车[%s] 定位丢失所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_LOST_LOCATION, AlertDeviceType.DEVICE_TYPE_TRACK, layoutDeviceId, trainInfo, alertMsg,
|
||||
AlertDeviceType.DEVICE_TYPE_TRAIN, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Builder trainInfo : this.trainInfoMap.values()) {
|
||||
@ -198,12 +148,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
} else if (timeOver) {
|
||||
this.trainInfoMap.remove(groupId);
|
||||
}
|
||||
if (trainInfo.getMode().getIpModeTrainDriveModeRmf()) {
|
||||
//列车紧致导致rm模式
|
||||
this.trainLostLocation(trainInfo);
|
||||
} else if (trainInfo.getMode().getIpModeTrainDriveModeRmf() == false) {
|
||||
alertDataSource.removeAlterDevice(trainInfo.getLineId(), TRAIN_LOST_LOCATION_ALERT_NAME, trainInfo.getGroupId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package club.joylink.xiannccda.ats.warn.train;
|
||||
package club.joylink.xiannccda.ats.warn.atp;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.platform.PlatformAlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.atp.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;
|
||||
@ -19,11 +18,10 @@ import org.springframework.stereotype.Component;
|
||||
public class TrainModeAlertListener implements AlertSourceEventListener<TrainAlertEvent> {
|
||||
|
||||
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
|
||||
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||
|
||||
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask, PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) {
|
||||
|
||||
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
|
||||
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,10 +29,6 @@ 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);
|
||||
//列车晚点超时
|
||||
this.platformAlertMonitoringTask.trainDelayCheck(trainInfo);
|
||||
if (trainMode.getIpModeTrainEbAlarm()) {
|
||||
//列车紧急制动
|
||||
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
|
||||
@ -43,15 +37,14 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
|
||||
} else if (Objects.equals(false, trainMode.getIpModeTrainAtpCut())) {
|
||||
this.atpCutAlertMonitoringTask.recoverAtpCut(trainInfo);
|
||||
//TODo
|
||||
} else {
|
||||
this.atpCutAlertMonitoringTask.updateTrainInfo(trainInfo);
|
||||
}
|
||||
} else if (trainMsgBuild instanceof TrainRemove.Builder trainRemove) {
|
||||
this.atpCutAlertMonitoringTask.trainRemoveAllInfo(trainRemove);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TrainAlertEvent extends DeviceAlertEvent<Builder> {
|
||||
|
@ -28,7 +28,6 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -71,7 +70,6 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
||||
for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) {
|
||||
String rtuIdJoinStr = interLockDetail.getKey();
|
||||
InterLockDetail detail = interLockDetail.getValue();
|
||||
|
||||
Optional<AxleInterLockSource> redOpt = this.handle(lineId, detail, AlertType.AXLE_LED_RED, AlertType.AXLE_LED_RED_INTERLOCK_AREA, rtuIdJoinStr);
|
||||
Optional<AxleInterLockSource> orangeOpt = this.handle(lineId, detail, AlertType.AXLE_LED_ORANGE, AlertType.AXLE_LED_ORANGE_INTERLOCK_AREA, rtuIdJoinStr);
|
||||
redOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource)));
|
||||
@ -84,7 +82,6 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
||||
private Optional<AxleInterLockSource> handle(String lineId, InterLockDetail detail, AlertType findWarnAlertType, AlertType warnAlertType, String rtuIdJoinStr) {
|
||||
int deviceCount = detail.getDevices().size();
|
||||
Integer lineIdInt = Integer.parseInt(lineId);
|
||||
|
||||
//收集联锁下的所有所有区段设备
|
||||
List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices());
|
||||
List<String> occupidedDeviceList = resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).toList();
|
||||
@ -113,10 +110,6 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
||||
}
|
||||
|
||||
private List<TrackOccupiedStatus> collectorLedWarDevices(AlertType alertType, String lineId, List<Integer> deviceLayoutIds) {
|
||||
if (CollectionUtils.isEmpty(deviceLayoutIds)) {
|
||||
log.error("{}", lineId);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Integer lineIdInt = Integer.parseInt(lineId);
|
||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
|
||||
@ -155,19 +148,15 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
||||
if (deviceStatus instanceof Track.Builder track) {
|
||||
if (alertType == AlertType.AXLE_LED_RED) {
|
||||
boolean red = track.getCiOccupied() && !track.getCbtcOccupied();
|
||||
sectionStatusList.add(this.isLight(red, track.getReceiveTime()));
|
||||
|
||||
sectionStatusList.add(red);
|
||||
} else {
|
||||
boolean orange = track.getAtcInvalid();
|
||||
sectionStatusList.add(this.isLight(orange, track.getReceiveTime()));
|
||||
sectionStatusList.add(orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sectionStatusList.stream().allMatch(d -> d);
|
||||
}
|
||||
|
||||
private boolean isLight(boolean ledLight, long deviceReceiveTime) {
|
||||
return ledLight && (System.currentTimeMillis() - deviceReceiveTime) / 1000 > 3;
|
||||
return sectionStatusList.stream().allMatch(d -> d);
|
||||
}
|
||||
|
||||
private boolean checkTurnoutStatus(Integer lineId, Section section, AlertType alertType, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
|
||||
@ -184,9 +173,9 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
|
||||
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied();
|
||||
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
|
||||
if (alertType == AlertType.AXLE_LED_RED) {
|
||||
turnoutOccLList.add(this.isLight(ledRed, switchBuild.getReceiveTime()));
|
||||
turnoutOccLList.add(ledRed);
|
||||
} else {
|
||||
turnoutOccLList.add(this.isLight(orange, switchBuild.getReceiveTime()));
|
||||
turnoutOccLList.add(orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,6 @@ 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")) {
|
||||
|
@ -1,107 +0,0 @@
|
||||
package club.joylink.xiannccda.ats.warn.lost;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SwitchLostAndJammedTask implements AlertMonitoringTask {
|
||||
|
||||
private DeviceGuardConfigService configService;
|
||||
private AlertInfoService alertInfoService;
|
||||
|
||||
public SwitchLostAndJammedTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
this.configService = configService;
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
|
||||
private final AlertManager alertManager = AlertManager.getDefault();
|
||||
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SWITCH_LOST_ALTER";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Set<String> lineCollSet = DeviceDataRepository.getAllLines();
|
||||
if (CollectionUtils.isEmpty(lineCollSet)) {
|
||||
return;
|
||||
}
|
||||
for (String lineId : lineCollSet) {
|
||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||
Map<String, Builder> deviceBuildMap = deviceStatusData.getAllDeviceMap().get(Switch.getDescriptor().getName());
|
||||
if (CollectionUtils.isNotEmpty(deviceBuildMap)) {
|
||||
for (Builder deviceBuild : deviceBuildMap.values()) {
|
||||
this.handle(deviceBuild);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(Builder deviceBuild) {
|
||||
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
this.checkLost(switchBuild, layoutId);
|
||||
this.checkJammed(switchBuild, layoutId);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkLost(Switch.Builder switchBuild, String layoutId) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String JAMMED_NAME = "JAMMED";
|
||||
|
||||
private void checkJammed(Switch.Builder switchBuild, String layoutId) {
|
||||
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied();//&& !switchBuild.getIpSingleSwitchStusCbtcOccupied();
|
||||
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
|
||||
if (switchBuild.getIpSingleSwitchStusJammed() && (ledRed || orange)) {
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), JAMMED_NAME, switchBuild.getId())) {
|
||||
String alertMsg = String.format("设备[%s]挤岔", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_JAMMED, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), JAMMED_NAME, switchBuild.getId());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package club.joylink.xiannccda.ats.warn.lost;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SwitchLostTask implements AlertMonitoringTask {
|
||||
|
||||
private DeviceGuardConfigService configService;
|
||||
private AlertInfoService alertInfoService;
|
||||
|
||||
public SwitchLostTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
this.configService = configService;
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
|
||||
private final AlertManager alertManager = AlertManager.getDefault();
|
||||
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SWITCH_LOST_ALTER";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Set<String> lineCollSet = DeviceDataRepository.getAllLines();
|
||||
if (CollectionUtils.isEmpty(lineCollSet)) {
|
||||
return;
|
||||
}
|
||||
for (String lineId : lineCollSet) {
|
||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||
Map<String, Builder> deviceBuildMap = deviceStatusData.getAllDeviceMap().get(Switch.getDescriptor().getName());
|
||||
if (CollectionUtils.isNotEmpty(deviceBuildMap)) {
|
||||
for (Builder deviceBuild : deviceBuildMap.values()) {
|
||||
this.handle(deviceBuild);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(Builder deviceBuild) {
|
||||
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,31 +10,24 @@ 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.ats.message.collect.datasource.InUsedScheduleData;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto;
|
||||
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.GuardConfigProto.GuardConfig;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainDelayInfo;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
||||
import club.joylink.xiannccda.dto.protos.TrainShedule.Plan;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -64,77 +57,12 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
this.trainRecordMap.put(trainRecord.getTrainId(), trainRecord);
|
||||
}
|
||||
|
||||
void findNexPlatform(TrainRecord.Builder tr) {
|
||||
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_5.name(), tr.getGroupId());
|
||||
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_15.name(), tr.getGroupId());
|
||||
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_25.name(), tr.getGroupId());
|
||||
alertDataSource.removeAlterDevice(tr.getLineId(), AlertType.TRAIN_DELAY_MIN_55.name(), tr.getGroupId());
|
||||
boolean upWay = PlatformAlertMonitoringTask.isUpWay(tr);
|
||||
TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(String.valueOf(tr.getLineId()), DataTypeEnum.TRAIN);
|
||||
TrainInfo.Builder ti = trainInfoData.getTrainInfo(tr.getGroupId());
|
||||
if (Objects.isNull(ti)) {
|
||||
return;
|
||||
}
|
||||
Platform.Builder pf = PlatformAlertMonitoringTask.parsePlatform(tr, upWay);
|
||||
|
||||
if (Objects.isNull(pf)) {
|
||||
ti.setHasNextStation(false);
|
||||
return;
|
||||
}
|
||||
LayoutGraphicsProto.Platform giPF = LineGraphicDataRepository.getDeviceByCode(pf.getLineId(), pf.getId(), LayoutGraphicsProto.Platform.class);
|
||||
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCodeNotException(pf.getLineId(), String.valueOf(giPF.getRefStation()), LayoutGraphicsProto.Station.class);
|
||||
if (Objects.isNull(station)) {
|
||||
ti.setHasNextStation(false);
|
||||
return;
|
||||
}
|
||||
List<Integer> sortStations = LineGraphicDataRepository.allStation(pf.getLineId());
|
||||
if (tr.getStationId() + 1 <= sortStations.get(sortStations.size() - 1) || tr.getStationId() - 1 >= sortStations.get(0)) {
|
||||
Integer nextStationInt = tr.getStationId() + 1;
|
||||
if (upWay == false) {
|
||||
nextStationInt = tr.getStationId() - 1;
|
||||
}
|
||||
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(tr.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(ti.getTrainId(), ti.getGlobalId(), nextStationInt, upWay, tr.getSideId());
|
||||
if (planBuildOpt.isEmpty()) {
|
||||
ti.setHasNextStation(false);
|
||||
return;
|
||||
}
|
||||
String nextStationCode = Strings.padStart(String.valueOf(nextStationInt), 2, '0');
|
||||
LayoutGraphicsProto.Station nextStation = LineGraphicDataRepository.getDevices(tr.getLineId(), LayoutGraphicsProto.Station.class).filter(d -> StringUtils.equals(d.getCode(), nextStationCode))
|
||||
.findFirst().orElse(null);
|
||||
if (nextStation == null) {
|
||||
ti.setHasNextStation(false);
|
||||
return;
|
||||
}
|
||||
ti.setHasNextStation(true);
|
||||
TrainDelayInfo.Builder tdbuild = TrainDelayInfo.newBuilder();
|
||||
tdbuild.setNextStationName(nextStation.getName());
|
||||
tdbuild.setNextStationName(nextStationCode);
|
||||
tdbuild.setCurrentPlatfomrLayoutId(giPF.getCommon().getId());
|
||||
tdbuild.setNextStationArriveTime(System.currentTimeMillis());
|
||||
ti.setTrainDelay(tdbuild);
|
||||
} else {
|
||||
ti.setHasNextStation(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void trainLeavePlatform(TrainRecord.Builder trainRecord) {
|
||||
boolean isUpWay = trainRecord.getDir() == DirectionEnum.Up.getValue();
|
||||
Platform.Builder platformBuild = this.parsePlatform(trainRecord, isUpWay);
|
||||
if (Objects.nonNull(platformBuild)) {
|
||||
platformBuild.setBizWaitTimerGoing(true);
|
||||
platformBuild.setBizWaitStartTimeSec(System.currentTimeMillis() / 1000);
|
||||
platformBuild.setBizWaitTimeSec(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTrainRecord(TrainRecord.Builder trainRecord) {
|
||||
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());
|
||||
}
|
||||
@ -153,7 +81,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
}
|
||||
|
||||
|
||||
static Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
||||
private Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
||||
// String newTrackName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, record.getTrackName());
|
||||
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(record.getLineId(), record.getTrackName());
|
||||
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
||||
@ -167,7 +95,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
if (Objects.nonNull(builder)) {
|
||||
Platform.Builder platformBuild = (Platform.Builder) builder;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("未找到对应的站台信息,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 屏蔽门是否开启[{}] 是否车辆停靠[{}]"
|
||||
log.debug("车站报对应的屏蔽门信息,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 屏蔽门是否开启[{}] 是否车辆停靠[{}]"
|
||||
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getPsdOpen(), platformBuild.getTrainberth());
|
||||
}
|
||||
return platformBuild;
|
||||
@ -237,47 +165,21 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void trainDelayCheck(TrainInfo.Builder ti) {
|
||||
if (ti.getHasNextStation() == false) {
|
||||
return;
|
||||
}
|
||||
TrainDelayInfo.Builder td = ti.getTrainDelayBuilder();
|
||||
this.trainDelayAlert(ti, 5, AlertType.TRAIN_DELAY_MIN_5);
|
||||
this.trainDelayAlert(ti, 15, AlertType.TRAIN_DELAY_MIN_15);
|
||||
this.trainDelayAlert(ti, 25, AlertType.TRAIN_DELAY_MIN_25);
|
||||
this.trainDelayAlert(ti, 55, AlertType.TRAIN_DELAY_MIN_55);
|
||||
}
|
||||
|
||||
private void trainDelayAlert(TrainInfo.Builder ti, Integer min, AlertType at) {
|
||||
TrainDelayInfo.Builder td = ti.getTrainDelayBuilder();
|
||||
long delayTime = (System.currentTimeMillis() - td.getNextStationArriveTime()) / 1000;
|
||||
if (delayTime >= TimeUnit.MINUTES.toSeconds(min) && alertDataSource.putAlterDevice(ti.getLineId(), at.name(), ti.getGroupId())) {
|
||||
String msg = String.format("列车[%s] 已晚点超时%d", ti.getGroupId(), min);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), at, ti, msg, String.valueOf(td.getCurrentPlatfomrLayoutId()),
|
||||
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isUpWay(TrainRecord.Builder tr) {
|
||||
return tr.getDir() == DirectionEnum.Up.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Builder record : this.trainRecordMap.values()) {
|
||||
boolean isUpWay = isUpWay(record);
|
||||
|
||||
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()) {
|
||||
@ -289,7 +191,6 @@ 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);
|
||||
|
@ -1,241 +0,0 @@
|
||||
package club.joylink.xiannccda.ats.warn.platform;
|
||||
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||
import club.joylink.xiannccda.configuration.protos.OccServerProto;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.entity.DeviceAreaConfig;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceAreaConfigService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import club.joylink.xiannccda.vo.AreaConfigVO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.AbstractMessage;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order(30)
|
||||
public class PlatformEmergStopTask implements AlertMonitoringTask {
|
||||
|
||||
@Autowired
|
||||
private AlertInfoService alertInfoService;
|
||||
@Autowired
|
||||
private DeviceAreaConfigService deviceAreaConfigService;
|
||||
@Autowired
|
||||
private DeviceGuardConfigService guardConfigService;
|
||||
|
||||
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
|
||||
private final AlertManager alertManager = AlertManager.getDefault();
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PLATFORM_EMERG_STOP_ALTER";
|
||||
}
|
||||
|
||||
private void emergStop(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform) {
|
||||
Integer lineId = platformBuild.getLineId();
|
||||
if (platformBuild.getEmergstop()) {
|
||||
if (alertDataSource.putAlterDevice(lineId, this.getName(), platformBuild.getId())) {
|
||||
Integer layOutId = giPlatform.getCommon().getId();
|
||||
Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefStation() + "", Station.class);
|
||||
String upWay = giPlatform.getUp() ? "上行" : "下行";
|
||||
String msg = String.format("%s-%s站台 应急触发", station.getName(), upWay);
|
||||
// Optional<AreaConfigVO> optional = alertInfoService.findAreaDevice(AlertType.PLATFORM_EMERG_STOP, AlertDeviceType.DEVICE_TYPE_PLATFORM, layOutId, lineIdInt);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.PLATFORM_EMERG_STOP, platformBuild, msg, layOutId.toString(),
|
||||
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(lineId, this.getName(), platformBuild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String PLATFORM_HOLD_ALERT_NAME = "platform_hold_alert";
|
||||
|
||||
private void stationPlatformHoldCheck(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform, List<Integer> stationCodeList) {
|
||||
boolean upHold = platformBuild.getUpHold() || platformBuild.getUpOccHold();
|
||||
boolean downHold = platformBuild.getDownHold() || platformBuild.getDownOccHold();
|
||||
if (!upHold && !downHold) {
|
||||
alertDataSource.removeAlterDevice(platformBuild.getLineId(), PLATFORM_HOLD_ALERT_NAME, platformBuild.getId());
|
||||
return;
|
||||
}
|
||||
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), String.valueOf(giPlatform.getRefStation()), LayoutGraphicsProto.Station.class);
|
||||
Integer currentStationCodeInt = Integer.valueOf(station.getCode());
|
||||
Integer startStationCodeInt = stationCodeList.get(0);
|
||||
if (giPlatform.getUp() == false) {
|
||||
startStationCodeInt = stationCodeList.get(stationCodeList.size() - 1);
|
||||
}
|
||||
if (!currentStationCodeInt.equals(startStationCodeInt)) {
|
||||
LayoutGraphicsProto.Section startSection = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefSectionId() + "", LayoutGraphicsProto.Section.class);
|
||||
LayoutGraphicsProto.RelatedRef sectionRef = startSection.getPaRef();
|
||||
if (giPlatform.getUp() == false) {
|
||||
sectionRef = startSection.getPbRef();
|
||||
}
|
||||
Map<Integer, GeneratedMessageV3> deviceMap = new HashMap<>();
|
||||
deviceMap.put(startSection.getCommon().getId(), startSection);
|
||||
findPlatformTrack(platformBuild, giPlatform.getUp(), sectionRef, deviceMap);
|
||||
deviceMap.remove(startSection.getCommon().getId());//移除站台轨
|
||||
List<LayoutGraphicsProto.Section> trackAreas = deviceMap.values().stream().filter(d -> d instanceof LayoutGraphicsProto.Section).map(d -> (LayoutGraphicsProto.Section) d).toList();
|
||||
List<String> areaTrainGroups = this.findAreaTrain(trackAreas, platformBuild.getLineId());
|
||||
if (areaTrainGroups.size() >= 2 && alertDataSource.putAlterDevice(platformBuild.getLineId(), PLATFORM_HOLD_ALERT_NAME, platformBuild.getId())) {
|
||||
String pf = giPlatform.getUp() ? "上行站台" : "下行站台";
|
||||
String msg = String.format("%s%s扣车此区间已驶入%d辆列车", station.getName(), pf, areaTrainGroups.size());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.HOLD_PLATFORM_STAY_TRAIN_MORE, platformBuild, msg, String.valueOf(giPlatform.getCommon().getId()),
|
||||
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> findAreaTrain(List<LayoutGraphicsProto.Section> findTrackArea, Integer lineId) {
|
||||
List<String> findAreaTrains = Lists.newArrayList();
|
||||
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.TRAIN);
|
||||
for (Section section : findTrackArea) {
|
||||
if (section.getSectionType() == SectionType.Physical) {
|
||||
for (Integer childSecionId : section.getChildrenList()) {
|
||||
MessageOrBuilder childMB = LineGraphicDataRepository.getDeviceByCode(lineId, childSecionId.toString());
|
||||
String deviceCode = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
|
||||
String trainGroupId = trainDataSource.findTrainForDeviceName(deviceCode);
|
||||
if (StringUtils.isNotEmpty(trainGroupId)) {
|
||||
findAreaTrains.add(trainGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
||||
String trainGroupId = trainDataSource.findTrainForDeviceName(section.getCode());
|
||||
if (StringUtils.isNotEmpty(trainGroupId)) {
|
||||
findAreaTrains.add(trainGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return findAreaTrains;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站台所属的道轨
|
||||
*
|
||||
* @param platformBuild
|
||||
* @param upway
|
||||
* @param startRef
|
||||
* @param deviceMap
|
||||
*/
|
||||
public void findPlatformTrack(Platform.Builder platformBuild, boolean upway, LayoutGraphicsProto.RelatedRef startRef, Map<Integer, GeneratedMessageV3> deviceMap) {
|
||||
if (startRef.getDeviceType() == DeviceType.Turnout) {
|
||||
LayoutGraphicsProto.Turnout turnout = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), startRef.getId() + "", LayoutGraphicsProto.Turnout.class);
|
||||
String sectionCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(platformBuild.getLineId(), turnout.getCode());
|
||||
LayoutGraphicsProto.Section turnoutSec = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), sectionCode + "", LayoutGraphicsProto.Section.class);
|
||||
|
||||
deviceMap.put(turnoutSec.getCommon().getId(), turnoutSec);
|
||||
deviceMap.put(turnout.getCommon().getId(), turnout);
|
||||
if (deviceMap.containsKey(turnout.getPaRef().getId())) {
|
||||
this.findPlatformTrack(platformBuild, upway, turnout.getPbRef(), deviceMap);
|
||||
} else {
|
||||
this.findPlatformTrack(platformBuild, upway, turnout.getPaRef(), deviceMap);
|
||||
}
|
||||
} else if (startRef.getDeviceType() == DeviceType.Section) {
|
||||
LayoutGraphicsProto.Section nextSection = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), startRef.getId() + "", LayoutGraphicsProto.Section.class);
|
||||
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(platformBuild.getLineId(), nextSection.getCode());
|
||||
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
||||
if (StringUtils.isNotEmpty(platformCode)) {
|
||||
return;
|
||||
}
|
||||
deviceMap.put(nextSection.getCommon().getId(), nextSection);
|
||||
|
||||
LayoutGraphicsProto.RelatedRef sectionRef = nextSection.getPaRef();
|
||||
if (upway == false) {
|
||||
sectionRef = nextSection.getPbRef();
|
||||
}
|
||||
this.findPlatformTrack(platformBuild, upway, sectionRef, deviceMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String PLATFORM_WAIT_MAX_TIME_ALERT_NAME = "platform_wait_max_time_alert";
|
||||
|
||||
/**
|
||||
* 检查站台列车候车时间阈值
|
||||
*
|
||||
* @param platformBuild
|
||||
*/
|
||||
private void checkPlatformWithTimeOut(Platform.Builder platformBuild, LayoutGraphicsProto.Platform giPlatform) {
|
||||
if (platformBuild.getBizWaitTimerGoing() == false && platformBuild.getBizWaitStartTimeSec() > 0) {
|
||||
long waitTimes = (System.currentTimeMillis() / 1000 - (platformBuild.getBizWaitStartTimeSec()));
|
||||
GuardConfig config = this.guardConfigService.getGuardConfig(platformBuild.getLineId());
|
||||
if (waitTimes > config.getPlatformWaitTimes()) {
|
||||
|
||||
if (alertDataSource.putAlterDevice(platformBuild.getLineId(), PLATFORM_WAIT_MAX_TIME_ALERT_NAME, platformBuild.getId())) {
|
||||
LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(platformBuild.getLineId(), giPlatform.getRefStation() + "", LayoutGraphicsProto.Station.class);
|
||||
String pf = giPlatform.getUp() ? "上行站台" : "下行站台";
|
||||
String msg = String.format("%s%s乘客等待列车时间超过%d秒", station.getName(), pf, config.getPlatformWaitTimes());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.PLATFORM_WAIT_TRAIN_MAX_RECORD, platformBuild, msg, String.valueOf(giPlatform.getCommon().getId()),
|
||||
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(platformBuild.getLineId(), PLATFORM_WAIT_MAX_TIME_ALERT_NAME, platformBuild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Set<String> allLineSet = DeviceDataRepository.getAllLines();
|
||||
for (String lineIdStr : allLineSet) {
|
||||
Integer lineIdInt = Integer.parseInt(lineIdStr);
|
||||
List<Integer> stationCodeList = LineGraphicDataRepository.allStation(lineIdInt);
|
||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineIdStr, DataTypeEnum.DEVICE);
|
||||
List<LayoutGraphicsProto.Platform> giPlatformList = LineGraphicDataRepository.getDevices(lineIdInt, LayoutGraphicsProto.Platform.class).distinct().toList();
|
||||
for (LayoutGraphicsProto.Platform giPlatform : giPlatformList) {
|
||||
Map<String, Builder> builderMap = deviceStatusData.getAllDeviceMap().get(DeviceStatusProto.Platform.getDescriptor().getName());
|
||||
if (CollectionUtils.isNotEmpty(builderMap) && Objects.nonNull(builderMap.get(giPlatform.getCode()))) {
|
||||
Platform.Builder platformBuild = (Platform.Builder) builderMap.get(giPlatform.getCode());
|
||||
this.emergStop(platformBuild, giPlatform);
|
||||
this.stationPlatformHoldCheck(platformBuild, giPlatform, stationCodeList);
|
||||
this.checkPlatformWithTimeOut(platformBuild, giPlatform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,29 +1,13 @@
|
||||
package club.joylink.xiannccda.ats.warn.platform;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
|
||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
||||
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.platform.TrainReacrdAlertListener.TrainRecordAlertEvent;
|
||||
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainDelayInfo;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
||||
import club.joylink.xiannccda.dto.protos.TrainShedule.Plan;
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -33,27 +17,26 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(TrainRecordAlertEvent event) {
|
||||
TrainRecord.Builder trainRecord = event.getSource();
|
||||
|
||||
if (trainRecord.getRecordType()) {
|
||||
log.info("列车报点,线路[{}] 列车表号[{}] 列车车次号[{}] 车站[{}] 上行[{}] 列车类型[{}] 是否进站[{}]",
|
||||
trainRecord.getLineId(), trainRecord.getTrainId(), trainRecord.getGlobalId(), trainRecord.getStationId(), (trainRecord.getDir() == DirectionEnum.Up.getValue()), trainRecord.getTrainType(),
|
||||
trainRecord.getRecordType());
|
||||
this.platformAlertMonitoringTask.findNexPlatform(trainRecord);
|
||||
this.platformAlertMonitoringTask.putTrainRecord(trainRecord);
|
||||
} else {
|
||||
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,61 +0,0 @@
|
||||
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,6 +19,8 @@ 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;
|
||||
@ -29,7 +31,6 @@ 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;
|
||||
@ -51,8 +52,7 @@ public class SpringSecurityConfiguration {
|
||||
|
||||
@Autowired
|
||||
CorsConfigurationSource corsConfigurationSource;
|
||||
/*@Autowired
|
||||
private AuthFilter authFilter;*/
|
||||
|
||||
static List<RequestMatcher> AuthWhiteList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
@ -68,7 +68,6 @@ public class SpringSecurityConfiguration {
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
|
||||
http
|
||||
.authorizeHttpRequests((authorize) -> {
|
||||
// authorize.requestMatchers("/favicon.ico", "/js2/**",
|
||||
@ -80,14 +79,10 @@ 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
|
||||
|
@ -1,26 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
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.ats.message.OccMessageManage;
|
||||
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
||||
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) {
|
||||
OccMessageManage cu = SystemContext.getAppContext().getBean(OccMessageManage.class);
|
||||
OccNotHandlePros cu = SystemContext.getAppContext().getBean(OccNotHandlePros.class);
|
||||
return cu.notMatchHandle(lineId, rtuId);
|
||||
}
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
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();
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum CommonLogTypeEnum {
|
||||
//登录
|
||||
LOGIN,
|
||||
OPERATE,
|
||||
WARN,
|
||||
;
|
||||
|
||||
public enum SubEventType {
|
||||
LOGIN, LOGOUT, QUERY, SAVE_OR_UPDATE, DELETE, WARN, NONE
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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,
|
||||
;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum LineTypeEnum {
|
||||
NCC, OCC;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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,10 +2,6 @@ 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;
|
||||
@ -19,6 +15,7 @@ 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;
|
||||
@ -51,7 +48,6 @@ 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);
|
||||
}
|
||||
@ -60,7 +56,6 @@ 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);
|
||||
}
|
||||
@ -69,28 +64,23 @@ 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);
|
||||
}
|
||||
|
||||
return alertRecordRepository.newPage(CommonPageRequest.defaultPage(), queryDTO);
|
||||
}*/
|
||||
|
||||
|
||||
@GetMapping("/page/detail")
|
||||
@PostMapping("/page/detail")
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页查询报警记录详情")
|
||||
@ApiResponse(description = "报警记录详情")
|
||||
@CommonLogAnno(name = "报警信息-列表数据", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public Page<NccAlertInfo> pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) {
|
||||
public Page<NccAlertInfo> pageQueryAlertDetail(@RequestBody AlertRecordQueryDTO queryDTO) {
|
||||
return alertRecordService.pageQueryAlertDetail(queryDTO);
|
||||
}
|
||||
|
||||
@ -99,7 +89,6 @@ 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,8 +1,5 @@
|
||||
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;
|
||||
@ -12,6 +9,8 @@ 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;
|
||||
@ -22,13 +21,14 @@ 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,7 +52,6 @@ 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);
|
||||
}
|
||||
@ -61,7 +60,6 @@ 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);
|
||||
}
|
||||
@ -70,7 +68,6 @@ 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);
|
||||
}
|
||||
@ -80,15 +77,13 @@ 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(value = "/find/type/{lineId}/{alertType}")
|
||||
@CommonLogAnno(name = "决策信息-类型绑定查询", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
@PostMapping("/find/type/{lineId}/{alertType}")
|
||||
public List<AreaFinder> findAlertType(@PathVariable("lineId") Integer lineId, @PathVariable("alertType") String alertType) {
|
||||
return this.areaConfigService.findAlertType(lineId, alertType);
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
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;
|
||||
@ -11,10 +8,6 @@ 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;
|
||||
@ -22,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 决策信息时间类型配置
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -43,7 +36,6 @@ 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);
|
||||
}
|
||||
@ -51,8 +43,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,12 +1,15 @@
|
||||
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;
|
||||
@ -22,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备区域配置
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
@ -42,7 +45,6 @@ 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";
|
||||
@ -51,17 +53,23 @@ 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);
|
||||
}
|
||||
@ -69,7 +77,6 @@ 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);
|
||||
}
|
||||
@ -77,7 +84,6 @@ 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,8 +1,5 @@
|
||||
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;
|
||||
@ -11,6 +8,7 @@ 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;
|
||||
@ -19,10 +17,7 @@ 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 {
|
||||
@ -37,7 +32,6 @@ 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);
|
||||
@ -47,7 +41,6 @@ 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";
|
||||
|
@ -1,52 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/mock/ats")
|
||||
@Tag(name = "线路信息管理接口")
|
||||
@RequiredArgsConstructor
|
||||
public class MockLoadAtsDataController {
|
||||
|
||||
@PostMapping("")
|
||||
public void startLoad() {
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping()
|
||||
public void delete() {
|
||||
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
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,23 +1,15 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.dto.LoginInfoDTO;
|
||||
import club.joylink.xiannccda.dto.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.entity.User;
|
||||
import club.joylink.xiannccda.entity.User.Register;
|
||||
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 java.security.Principal;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
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;
|
||||
@ -36,67 +28,31 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class UserController {
|
||||
|
||||
private UserService userService;
|
||||
private IUserRepository userRepository;
|
||||
|
||||
public UserController(UserService userService, IUserRepository userRepository) {
|
||||
public UserController(UserService userService) {
|
||||
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<UserDetailDTO> pageQuery(UserQueryDTO dto) {
|
||||
return this.userRepository.userRolePage(dto);
|
||||
public Page<User> pageQuery() {
|
||||
return this.userService.pageQuery();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* 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,14 +1,12 @@
|
||||
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;
|
||||
@ -21,17 +19,12 @@ 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,13 +1,10 @@
|
||||
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;
|
||||
@ -15,13 +12,9 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class AlertTipQueryDTO extends CommonPage {
|
||||
public class AlertTipQueryDTO extends PageDTO<AlertTip> {
|
||||
|
||||
private Integer lineId;
|
||||
private LineTypeEnum lineType;
|
||||
@Schema(description = "告警类型")
|
||||
private String alertType;
|
||||
@Schema(description = "时间类型")
|
||||
private String timeType;
|
||||
private String locationType;
|
||||
private Long areaConfigId;
|
||||
|
@ -1,11 +1,8 @@
|
||||
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;
|
||||
@ -15,33 +12,20 @@ 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;
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
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;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
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> {
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
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;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package club.joylink.xiannccda.dto.auth;
|
||||
|
||||
import club.joylink.xiannccda.entity.AuthApiPath;
|
||||
import club.joylink.xiannccda.entity.AuthRole;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AuthRoleQueryDTO extends PageDTO<AuthRole> {
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user