调整,添加站台急停告警
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 3m46s

This commit is contained in:
tiger_zhou 2024-11-01 14:00:56 +08:00
parent 37d5260ee8
commit 58609211ee
33 changed files with 1907 additions and 153 deletions

View File

@ -152,6 +152,12 @@
<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>
</dependencies>
<repositories>
<repository>

View File

@ -5,6 +5,7 @@ import club.joylink.xiannccda.alert.core.AlertManager;
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;
@ -64,16 +65,26 @@ public class AlertListenerJob implements ApplicationRunner {
//不论是否mock 都保存数据库
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
if (alertInfo.getAlertType() == AlertType.PLATFORM_EMERG_STOP) {
NccAlertInfo cloned = alertInfo.clone2();
// NccAlertInfo cloneNcc = ObjectUtils.clone(alertInfo);
cloned.setLineType(lineType);
cloned.setLineType(LineTypeEnum.OCC);
AlertRecord record = convertToRecord(cloned);
alertRecordRepository.save(record);
cloned.setId(record.getId());
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(LineTypeEnum.OCC);
nccAlertMessageServer.addMsg(cloned);
} else {
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
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);
}
}
}
});
}

View File

@ -136,6 +136,9 @@ public class NccAlertInfo implements AlertInfo, Cloneable {
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);
}
}

View File

@ -152,7 +152,9 @@ public class LineGraphicDataRepository {
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()) {
;
// 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) {
@ -205,8 +207,13 @@ public class LineGraphicDataRepository {
if (StringUtils.isEmpty(rtuCode)) {
return null;
}
return Integer.parseInt(rtuCode);
try {
return Integer.parseInt(rtuCode);
} catch (Exception e) {
e.printStackTrace();
}
return 1;
}
public static Optional<Platform> findLayoutPlatformFromSection(Integer lineId, String sectionName) {

View File

@ -129,7 +129,7 @@ public class OccTcpClientConnection {
}
String hostPortInfo() {
return String.format("host=%s, port=%s", this.host, this.port);
return String.format("lineId=%s,host=%s, port=%s", this.client.getLineId(), this.host, this.port);
}

View File

@ -1,10 +1,8 @@
package club.joylink.xiannccda.ats.message;
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
import club.joylink.xiannccda.ats.message.line3.req.LoadDeviceStatusRequest;
import club.joylink.xiannccda.configuration.protos.OccServerProto.OccClientMessage;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.Executors;
@ -94,8 +92,9 @@ public class XianOccMessagingClient {
public void requestBaseData() {
if (this.rtConnection.connected && this.nrtConnection.connected && this.requestBaseDataFlag.compareAndSet(false, true)) {
log.info("发送计划运行图请求 lineId[{}] host[{}] 实时接口[{}]", this.lineId, this.host, false);
LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
this.send(dataRequest, false);
// LoadHistoryTGDataRequest dataRequest = new LoadHistoryTGDataRequest((short) this.lineId, LocalDateTime.now(), ApplyTypeEnum.PLAN_GRAPH);
LoadDeviceStatusRequest dataRequest = new LoadDeviceStatusRequest((short) this.lineId);
this.send(dataRequest, true);
}
}

View File

@ -30,6 +30,9 @@ public class DeviceNameChangerManage {
public static String findMatch(NameChangerEnum nameChanger, DeviceType deviceType, String occName) {
if (nameChanger == NameChangerEnum.NONE) {
return occName;
}
if (Objects.isNull(deviceType)) {
log.debug("错误的设备类型 type[{}]", deviceType);
return occName;

View File

@ -1,6 +1,7 @@
package club.joylink.xiannccda.ats.message.changer;
public enum NameChangerEnum {
NONE,
//通用
UNIVERSAL,
;

View File

@ -20,6 +20,7 @@ import com.google.common.collect.Tables;
import com.google.protobuf.GeneratedMessageV3.Builder;
import com.google.protobuf.MessageOrBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -52,6 +53,9 @@ public class InterLockData extends AbstractData {
private Map<AlertType, List<AreaConfigVO>> findInterLockAreaConfigData(Integer lineId) {
List<AreaConfigVO> areaConfigVOList = this.deviceAreaConfigService.getCache(lineId, AlertDeviceType.DEVICE_TYPE_RTU);
if (CollectionUtils.isEmpty(areaConfigVOList)) {
return Collections.emptyMap();
}
return areaConfigVOList.stream()
.filter(d -> d.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()))
.collect(Collectors.groupingBy(d -> AlertType.valueOf(d.getAlertTypes().get(0))));

View File

@ -2,10 +2,13 @@ package club.joylink.xiannccda.ats.message.line3.rep;
import club.joylink.xiannccda.ats.message.line3.MessageCons;
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.GeneratedMessageV3;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class EntityParseUtil {
@ -30,7 +33,16 @@ public class EntityParseUtil {
public static String convertStr(ByteBuf buf, int len) {
byte[] data = new byte[len];
buf.readBytes(data);
return new String(data, MessageCons.STRING_CHARSET).trim();
StringBuilder sb = new StringBuilder();
for (byte datum : data) {
sb.append(datum).append(",");
}
System.out.println(sb.toString());
String datas = Joiner.on(",").join(Collections.singleton(data));
String name = new String(data, MessageCons.STRING_CHARSET).trim();
System.out.println(name.trim().split(" ")[0]);
return name;
}
public interface ReadData<T> {

View File

@ -47,7 +47,7 @@ public class LoadDeviceStatusRequest extends MessageRequest {
private Short lineId;
public LoadDeviceStatusRequest(Short lineId) {
super(MessageId.LOAD_DEVICE_STATUS, 2);
super(MessageId.LOAD_DEVICE_STATUS, 2 + 1);
this.lineId = lineId;
}
@ -55,5 +55,6 @@ public class LoadDeviceStatusRequest extends MessageRequest {
@Override
public void encode2(ByteBuf buf) {
buf.writeShort(this.lineId);
buf.writeByte(1);
}
}

View File

@ -0,0 +1,73 @@
package club.joylink.xiannccda.ats.warn.platform;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
import club.joylink.xiannccda.configuration.protos.OccServerProto;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.vo.AreaConfigVO;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class PlatformEmergStopTask implements AlertMonitoringTask {
@Autowired
private AlertInfoService alertInfoService;
private final AlertDeviceStatusRepository alertDataSource = AlertDeviceStatusRepository.getInstance();
private final AlertManager alertManager = AlertManager.getDefault();
@Override
public String getName() {
return "PLATFORM_EMERG_STOP_ALTER";
}
@Override
public void run() {
Set<String> allLineSet = DeviceDataRepository.getAllLines();
for (String lineIdStr : allLineSet) {
Integer lineIdInt = Integer.parseInt(lineIdStr);
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(lineIdStr, DataTypeEnum.DEVICE);
List<LayoutGraphicsProto.Platform> giPlatformList = LineGraphicDataRepository.getDevices(lineIdInt, LayoutGraphicsProto.Platform.class).toList();
for (LayoutGraphicsProto.Platform giPlatform : giPlatformList) {
Map<String, Builder> builderMap = deviceStatusData.getAllDeviceMap().get(DeviceStatusProto.Platform.getDescriptor().getName());
if (CollectionUtils.isNotEmpty(builderMap) && Objects.nonNull(builderMap.get(giPlatform.getCode()))) {
Platform.Builder platformBuild = (Platform.Builder) builderMap.get(giPlatform.getCode());
if (platformBuild.getEmergstop()) {
if (alertDataSource.putAlterDevice(lineIdInt, this.getName(), platformBuild.getId())) {
Integer layOutId = giPlatform.getCommon().getId();
Station station = LineGraphicDataRepository.getDeviceByCode(lineIdInt, giPlatform.getRefStation() + "", Station.class);
Optional<AreaConfigVO> optional = alertInfoService.findAreaDevice(AlertType.PLATFORM_EMERG_STOP, AlertDeviceType.DEVICE_TYPE_PLATFORM, layOutId, lineIdInt);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(optional, AlertType.PLATFORM_EMERG_STOP, platformBuild, "aaaaa", layOutId.toString(),
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
alertManager.emit(alertInfo);
}
} else {
alertDataSource.removeAlterDevice(lineIdInt, this.getName(), platformBuild.getId());
}
}
}
}
}
}

View File

@ -4,6 +4,7 @@ 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;
@ -19,6 +20,10 @@ public class OccServerProto {
return this.clientInfoMap.get(lineId);
}
public Set<Integer> getAllLineIds() {
return this.clientInfoMap.keySet();
}
@Data
public static class OccClientMessage {

View File

@ -20,6 +20,7 @@ public abstract class NewAlertMockDTO {
if (alertType == AlertType.TRAIN_EB_ATP) {
return MessageId.TRAIN_INDICATION_UPDATE;
}
return MessageId.DEVICE_STATUS_CHANGE;
}

View File

@ -0,0 +1,20 @@
package club.joylink.xiannccda.dto.mock.show;
import lombok.Data;
@Data
public class PlatformEBDTO extends NewAlertMockDTO {
@Override
public Integer deviceStatus(AlertMockStatus status) {
switch (status) {
case NORMAL -> {
return 0;
}
case ALERT -> {
return 21;
}
}
return 0;
}
}

View File

@ -375,6 +375,14 @@ public final class AlertConstProto {
* <code>INTERLOCK_LEVEL_ONE = 23;</code>
*/
INTERLOCK_LEVEL_ONE(23),
/**
* <pre>
*应急触发
* </pre>
*
* <code>PLATFORM_EMERG_STOP = 24;</code>
*/
PLATFORM_EMERG_STOP(24),
UNRECOGNIZED(-1),
;
@ -550,6 +558,14 @@ public final class AlertConstProto {
* <code>INTERLOCK_LEVEL_ONE = 23;</code>
*/
public static final int INTERLOCK_LEVEL_ONE_VALUE = 23;
/**
* <pre>
*应急触发
* </pre>
*
* <code>PLATFORM_EMERG_STOP = 24;</code>
*/
public static final int PLATFORM_EMERG_STOP_VALUE = 24;
public final int getNumber() {
@ -598,6 +614,7 @@ public final class AlertConstProto {
case 21: return AXLE_LED_ORANGE_INTERLOCK_AREA;
case 22: return SWITCH_LOST_INTERLOCK_AREA;
case 23: return INTERLOCK_LEVEL_ONE;
case 24: return PLATFORM_EMERG_STOP;
default: return null;
}
}
@ -841,7 +858,7 @@ public final class AlertConstProto {
"\n\020alertConst.proto\022\005alert*g\n\rAlertLocati" +
"on\022\032\n\026ALERT_LOCATION_UNKNOWN\020\000\022\006\n\002QX\020\001\022\013" +
"\n\007YHZ_LSQ\020\002\022\013\n\007HJM_LSQ\020\003\022\013\n\007BCT_LSQ\020\004\022\013\n" +
"\007BSQ_LSQ\020\005*\253\004\n\tAlertType\022\026\n\022ALERT_TYPE_U" +
"\007BSQ_LSQ\020\005*\304\004\n\tAlertType\022\026\n\022ALERT_TYPE_U" +
"NKNOWN\020\000\022\020\n\014BLUE_DISPLAY\020\001\022\021\n\rTRAIN_DELA" +
"Y_2\020\002\022\022\n\016TRAIN_DELAY_10\020\003\022\'\n#PLATFORM_DO" +
"OR_WITHOUT_LOCKED_SIGNAL\020\004\022\035\n\031PLATFORM_D" +
@ -855,11 +872,12 @@ public final class AlertConstProto {
"\020\023\022\037\n\033AXLE_LED_RED_INTERLOCK_AREA\020\024\022\"\n\036A" +
"XLE_LED_ORANGE_INTERLOCK_AREA\020\025\022\036\n\032SWITC" +
"H_LOST_INTERLOCK_AREA\020\026\022\027\n\023INTERLOCK_LEV" +
"EL_ONE\020\027*x\n\rTipTimeConfig\022\026\n\022HOLIDAYS_MO" +
"RN_PEAK\020\000\022\031\n\025HOLIDAYS_EVENING_PEAK\020\001\022\r\n\t" +
"MORN_PEAK\020\002\022\021\n\rEVENING_PEARK\020\003\022\022\n\016NORMAL" +
"_UNPEARK\020\004B4\n!club.joylink.xiannccda.dto" +
".protosB\017AlertConstProtob\006proto3"
"EL_ONE\020\027\022\027\n\023PLATFORM_EMERG_STOP\020\030*x\n\rTip" +
"TimeConfig\022\026\n\022HOLIDAYS_MORN_PEAK\020\000\022\031\n\025HO" +
"LIDAYS_EVENING_PEAK\020\001\022\r\n\tMORN_PEAK\020\002\022\021\n\r" +
"EVENING_PEARK\020\003\022\022\n\016NORMAL_UNPEARK\020\004B4\n!c" +
"lub.joylink.xiannccda.dto.protosB\017AlertC" +
"onstProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,

View File

@ -184,6 +184,11 @@ public class MockOccServer {
Integer stationId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
System.out.println(mb);
return this.findRtuStation(lineId, stationId);
} else if (alertType == AlertType.PLATFORM_EMERG_STOP) {
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCode(lineId, deviceName);
System.out.println(mb);
Integer stationId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class);
return this.findRtuStation(lineId, stationId);
}
return null;
}

View File

@ -12,9 +12,11 @@ import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
import club.joylink.xiannccda.ats.message.collect.datasource.AbstractData;
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import club.joylink.xiannccda.constants.SystemContext;
import club.joylink.xiannccda.dto.mock.show.BlueAlertMockDTO;
import club.joylink.xiannccda.dto.mock.show.NewAlertMockDTO.DeviceNameInfo;
import club.joylink.xiannccda.dto.mock.show.PlatformEBDTO;
import club.joylink.xiannccda.dto.mock.test.AlertMockDTO;
import club.joylink.xiannccda.dto.mock.show.NewAlertMockDTO;
import club.joylink.xiannccda.dto.mock.show.OrangeAlertMockDTO;
@ -113,6 +115,10 @@ public class AlertMockService {
}
}
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(!sb.isEmpty(), sb.toString());
} else if (alertType == AlertType.PLATFORM_EMERG_STOP) {
for (DeviceNameInfo deviceInfo : mockDTO.getDeviceInfos()) {
deviceInfo.setDeviceType(DeviceType.DEVICE_TYPE_PLATFORM);
}
}
mockDTO.setAlertType(alertType);
@ -139,6 +145,9 @@ public class AlertMockService {
case TRAIN_EB_ATP -> {
return TrainSignlaAlertMockDTO.class;
}
case PLATFORM_EMERG_STOP -> {
return PlatformEBDTO.class;
}
default -> throw new IllegalStateException("Unexpected value: " + alertType);
}
}
@ -233,6 +242,11 @@ public class AlertMockService {
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRACK, commonInfo.getId(), track, "测试车组号", AlertDeviceType.DEVICE_TYPE_TRAIN, true);
}
/* case PLATFORM_EMERG_STOP -> {
MessageOrBuilder msg = LineGraphicDataRepository.getDeviceByCode(lineId, dto.getFrist());
DeviceStatusProto.Platform.Builder pb = DeviceStatusProto.Platform.newBuilder();
pb.setId(dto.getFrist());
}*/
default -> throw new IllegalStateException("Unexpected value: " + dto.getAlertType());
}
}

View File

@ -7,6 +7,7 @@ import club.joylink.xiannccda.repository.IAuthRoleRepository;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -45,12 +46,14 @@ public class InitTask implements ApplicationRunner {
public void run(ApplicationArguments args) throws Exception {
Map<String, AuthRole> initRoleMap = this.staticInitialData();
QueryWrapper<AuthRole> qw = new QueryWrapper<>();
qw.lambda().in(AuthRole::getName, List.of(initRoleMap.keySet()));
// List<AuthRole> authRoles = this.authRoleRepository.list(qw);
qw.lambda().in(AuthRole::getName, List.of(initRoleMap.keySet().toArray()));
List<AuthRole> authRoles = this.authRoleRepository.list(qw);
initRoleMap.forEach((k, v) -> {
v.setRoleConfigStr(JSON.toJSONString(v.tmpRoleConfig()));
this.authRoleRepository.saveOrUpdate(v);
if (authRoles.stream().filter(d -> StringUtils.equals(d.getName(), k)).findFirst().isEmpty()) {
v.setRoleConfigStr(JSON.toJSONString(v.tmpRoleConfig()));
this.authRoleRepository.saveOrUpdate(v);
}
});
}
}

View File

@ -21,7 +21,6 @@ occ-client:
server-host: 127.0.0.1
real-port: 2603
un-real-port: 5703
line-id: 3
collector-data: false
monitor-handware-change: false
receiveMsgTimeout: 6
@ -32,6 +31,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
#故障测试
mock-alert-test: false

View File

@ -19,7 +19,7 @@ occ-client:
server-host: 127.0.0.1
real-port: 2603
un-real-port: 5703
line-id: 3
collector-data: false
monitor-handware-change: false
receiveMsgTimeout: 6
@ -29,6 +29,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
#故障测试
mock-alert-test: true
#加载历史模拟数据

View File

@ -21,7 +21,6 @@ occ-client:
server-host: 127.0.0.1
real-port: 2603
un-real-port: 5703
line-id: 3
collector-data: false
monitor-handware-change: false
receiveMsgTimeout: 6
@ -32,7 +31,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
mock-alert-test: true
load-mock-history-data: false

View File

@ -4,6 +4,9 @@ spring:
url: jdbc:mysql://192.168.53.11:3306/xian-ncc-da?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&autoReconnect=true&maxReconnets=10&initialTimeout=10
username: root
password: joylink0503
#url: jdbc:mysql://127.0.0.1:3306/xian-ncc-da?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&autoReconnect=true&maxReconnets=10&initialTimeout=10
# username: root
# password: root
spring-doc:
packages-to-scan: club.joylink.xiannccda.controller
swagger-ui:
@ -35,6 +38,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
mock-alert-test: false
load-mock-history-data: false

View File

@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.3.233:3306/xian-ncc-da?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://192.168.33.233:3306/xian-ncc-da?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: joylink0503
spring-doc:
@ -32,6 +32,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
mock-alert-test: false
load-mock-history-data: false

View File

@ -28,7 +28,7 @@ occ-client:
server-host: 127.0.0.1
real-port: 2603
un-real-port: 5703
line-id: 3
collector-data: false
monitor-handware-change: false
receiveMsgTimeout: 6
@ -38,6 +38,20 @@ occ-client:
lineTypes:
- OCC
- NCC
4:
nameChanger: NONE
server-host: 10.254.12.45
real-port: 3604
un-real-port: 3704
collector-data: true
monitor-handware-change: false
receiveMsgTimeout: 6
filterRtuIds:
- 10
- 11
lineTypes:
- OCC
- NCC
mock-alert-test: true
load-mock-history-data: false
#延时加载告警处理

View File

@ -90,10 +90,21 @@ public class DeviceStatusCheckTest {
System.out.println(s6);
}
@Test
public void platformEbTest() {
for (int i = 0; i < 999999999; i++) {
Platform.Builder p1 = DeviceStatusConvertor.convert(DeviceStatus.PLATFORM.class, i);
if (p1.getEmergstop() && !p1.getTrainberth() && !p1.getDownHold()) {
System.out.println(i);
}
}
}
@Test
public void platformTest() {
Platform.Builder p1 = DeviceStatusConvertor.convert(DeviceStatus.PLATFORM.class, 2555906);
Platform.Builder p1 = DeviceStatusConvertor.convert(DeviceStatus.PLATFORM.class, 21);
System.out.println(p1);
System.out.println("-----------------");
Platform.Builder p2 = DeviceStatusConvertor.convert(DeviceStatus.PLATFORM.class, 2686976);

View File

@ -82,6 +82,7 @@ public class MockMsgTest {
@Autowired
private INccMockDataRepository iNccMockDataRepository;
@Test
public void insert() throws Exception {
/* List<NccMockData> messageDataList2 = Lists.newArrayList();

View File

@ -26,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -44,6 +45,34 @@ public class CollectorData {
NccMockDataService nccMockDataService;
@Test
public void collectorTrack() {
Table<DeviceType, String, List<String>> dataTable = this.loadData();
for (DeviceType dt : dataTable.rowKeySet()) {
Map<String, List<String>> mapList = dataTable.row(dt);
if (dt == DeviceType.DEVICE_TYPE_PLATFORM) {
System.out.println("aaaaaaaaaaaaaaaaa");
}
mapList.forEach((k, v) -> {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("d:\\usr\\" + dt.name(), true)))) {
writer.write(String.format("集中站:%s \n", k));
List<String> newList = new ArrayList<>();
StringBuilder sb = new StringBuilder();
for (String s : v) {
String[] ssss = s.split("\u0000");
newList.add(ssss[0]);
}
writer.write("\t\t" + newList.stream().sorted().collect(Collectors.joining(",")) + "\n");
writer.write("-----------------------------------\n");
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
@Test
public void collector() {

View File

@ -0,0 +1,190 @@
package club.joylink.xiannccda.util.impo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.constants.common.LineTypeEnum;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.entity.PublishedGi;
import club.joylink.xiannccda.repository.IPublishedGiRepository;
import club.joylink.xiannccda.repository.impl.AlertTipRepository;
import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class PlatformStopImportTest {
@Autowired
private DeviceAreaConfigRepository configRepository;
@Autowired
private AlertTipRepository tipRepository;
@Autowired
private IPublishedGiRepository iPublishedGiRepository;
private PublishedGi findGi() {
return this.iPublishedGiRepository.lambdaQuery().eq(PublishedGi::getLineId, lineId).one();
}
private static final Integer lineId = 3;
@SneakyThrows
public List<AreaConfigPF> giTest() {
List<AreaConfigPF> list = new ArrayList<>();
PublishedGi gi = this.findGi();
LayoutGraphicsProto.RtssGraphicStorage storage =
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(gi.getProto());
for (Platform platform : storage.getPlatformsList()) {
int platFromId = platform.getCommon().getId();
Optional<Station> opt = storage.getStationsList().stream().filter(d -> d.getCommon().getId() == platform.getRefStation()).findFirst();
if (opt.isEmpty()) {
throw new RuntimeException(platform.getCode());
}
list.add(new AreaConfigPF(platform.getCode(), platform.getUp(), opt.get().getName(), platFromId));
}
return list;
}
@SneakyThrows
@Test
public void ImportAreaConfig() {
List<AreaConfigPF> list = this.giTest();
if (CollectionUtils.isEmpty(list)) {
throw new RuntimeException("No AreaConfig");
}
String filePath = "g:\\1.xlsx";
List<DeviceAreaConfig> saveList = new ArrayList<>();
try (FileInputStream file = new FileInputStream(new File(filePath));
Workbook workbook = new XSSFWorkbook(file)) {
Sheet sheet = workbook.getSheetAt(4);
String station = null;
for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) {
Row row = sheet.getRow(i);
Cell sc = row.getCell(2);
Cell sx = row.getCell(3);
if (StringUtils.isNotEmpty(sc.getStringCellValue())) {
station = sc.getStringCellValue();
}
String sxStr = sx.getStringCellValue();
boolean isup = StringUtils.contains(sxStr, "下行") ? false : true;
String finalStation = station;
List<AreaConfigPF> findPf = list.stream().filter(d -> (StringUtils.contains(d.stationName, finalStation) || StringUtils.contains(finalStation, d.stationName)) && d.up == isup).toList();
if (CollectionUtils.isEmpty(findPf) || findPf.size() > 1) {
throw new RuntimeException("No AreaConfig");
}
AreaConfigPF ppff = findPf.get(0);
System.out.println(String.format("紧停触发-%s-%s-%s", station, sx.getStringCellValue(), ppff.platformId));
DeviceAreaConfig ac = new DeviceAreaConfig();
ac.setAreaName(String.format("紧停触发-%s-%s", station, sx.getStringCellValue()));
ac.setLineId(lineId);
ac.setData(String.valueOf(ppff.platformId));
ac.setDeviceType(AlertDeviceType.DEVICE_TYPE_PLATFORM);
ac.setAlertTypes(AlertType.PLATFORM_EMERG_STOP.name());
saveList.add(ac);
}
}
this.configRepository.saveBatch(saveList);
}
private List<DeviceAreaConfig> findAreaConfig() {
QueryWrapper<DeviceAreaConfig> qw = new QueryWrapper<>();
qw.lambda().eq(DeviceAreaConfig::getLineId, lineId).eq(DeviceAreaConfig::getAlertTypes, AlertType.PLATFORM_EMERG_STOP.name());
List<DeviceAreaConfig> list = this.configRepository.list(qw);
return list;
}
private Long findAreaConfigId(List<DeviceAreaConfig> areaConfigList, String station, boolean isup) {
for (DeviceAreaConfig ac : areaConfigList) {
String[] names = ac.getAreaName().split(StringPool.DASH);
String sn = names[1];
String upStr = names[2];
String upStrShort = isup ? "上行" : "下行";
if (StringUtils.contains(sn, station.substring(0, 2)) && StringUtils.contains(upStr, upStrShort)) {
return ac.getId();
}
}
return null;
}
@SneakyThrows
@Test
public void ImportAlertTip() {
String filePath = "g:\\1.xlsx";
List<AlertTip> saveList = new ArrayList<>();
List<DeviceAreaConfig> areaConfigList = this.findAreaConfig();
try (FileInputStream file = new FileInputStream(new File(filePath));
Workbook workbook = new XSSFWorkbook(file)) {
Sheet sheet = workbook.getSheetAt(4);
String station = null;
for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) {
Row row = sheet.getRow(i);
Cell sc = row.getCell(2);
Cell sx = row.getCell(3);
Cell m1 = row.getCell(4);
Cell m2 = row.getCell(5);
if (StringUtils.isNotEmpty(sc.getStringCellValue())) {
station = sc.getStringCellValue();
}
String sxStr = sx.getStringCellValue();
boolean isup = StringUtils.contains(sxStr, "下行") ? false : true;
Long areaId = findAreaConfigId(areaConfigList, station, isup);
if (Objects.isNull(areaId)) {
throw new RuntimeException("No AreaConfig");
}
String msg1 = m1.getStringCellValue();
String msg2 = m2.getStringCellValue();
msg1 = TestObj.formatStr(msg1);
msg2 = TestObj.formatStr(msg2);
saveList.add(TestObj.create(lineId, LineTypeEnum.OCC, AlertType.PLATFORM_EMERG_STOP.name(), msg1, msg2, areaId));
}
}
this.tipRepository.saveBatch(saveList);
}
private static class AreaConfigPF {
public AreaConfigPF(String platformCode, boolean up, String stationName, int platformId) {
this.platformCode = platformCode;
this.up = up;
this.stationName = stationName;
this.platformId = platformId;
}
private String platformCode;
private boolean up;
private String stationName;
private int platformId;
}
}

View File

@ -0,0 +1,102 @@
package club.joylink.xiannccda.util.impo;
import club.joylink.xiannccda.constants.common.LineTypeEnum;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.repository.impl.AlertTipRepository;
import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class SwitchImportTest {
@Autowired
private DeviceAreaConfigRepository configRepository;
@Autowired
private AlertTipRepository tipRepository;
private List<DeviceAreaConfig> findAreaConfig() {
QueryWrapper<DeviceAreaConfig> qw = new QueryWrapper<>();
qw.lambda().eq(DeviceAreaConfig::getLineId, lineId).eq(DeviceAreaConfig::getDeviceType, "DEVICE_TYPE_SWITCH");
List<DeviceAreaConfig> list = this.configRepository.list(qw);
return list;
}
private static final Integer lineId = 3;
private static final LineTypeEnum lineType = LineTypeEnum.OCC;
@SneakyThrows
@Test
public void testRead() {
String filePath = "g:\\1.xlsx";
List<DeviceAreaConfig> areaConfigList = this.findAreaConfig();
List<AlertTip> saveList = new ArrayList<>();
try (FileInputStream file = new FileInputStream(new File(filePath));
Workbook workbook = new XSSFWorkbook(file)) {
/* for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
System.out.println(sheet.getSheetName());
}*/
Sheet sheet = workbook.getSheetAt(2);
String newDeviceName = "";
for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) {
Row row = sheet.getRow(i);
Cell cell3 = row.getCell(3);
Cell cell4 = row.getCell(4);
Cell cell5 = row.getCell(5);
Cell cell6 = row.getCell(6);
String dn = cell3.getStringCellValue();
if (StringUtils.isNotEmpty(dn)) {
newDeviceName = dn;
}
String fun = cell4.getStringCellValue();
String msg = cell5.getStringCellValue();
String msg2 = cell6.getStringCellValue();
String funType = AlertType.SWITCH_All_LOST.name();
if (StringUtils.contains(fun, "定位失表")) {
funType = AlertType.SWITCH_DW_LOST.name();
} else if (StringUtils.contains(fun, "反位失表")) {
funType = AlertType.SWITCH_FW_LOST.name();
}
String finalNewDeviceName = newDeviceName;
Optional<DeviceAreaConfig> optional = areaConfigList.stream().filter(d -> StringUtils.contains(d.getAreaName(), finalNewDeviceName)).findFirst();
if (optional.isPresent()) {
DeviceAreaConfig config = optional.get();
msg = msg.replaceAll("\n", "\\\\n");
msg2 = msg2.replaceAll("\n", "\\\\n");
msg = "\"" + msg + "\"";
msg2 = "\"" + msg2 + "\"";
saveList.add(TestObj.create(lineId, lineType, funType, msg, msg2, config.getId()));
} else {
throw new RuntimeException("");
}
}
}
this.tipRepository.saveBatch(saveList);
}
}

View File

@ -0,0 +1,25 @@
package club.joylink.xiannccda.util.impo;
import club.joylink.xiannccda.constants.common.LineTypeEnum;
import club.joylink.xiannccda.entity.AlertTip;
public class TestObj {
public static AlertTip create(Integer lineId, LineTypeEnum lineType, String type, String msg1, String msg2, Long areaId) {
AlertTip tip = new AlertTip();
tip.setAlertType(type);
tip.setLineId(lineId);
tip.setLineType(lineType);
tip.setDrivingInfo(msg1);
tip.setSubmissionInfo(msg2);
tip.setAreaConfigId(areaId);
return tip;
}
public static String formatStr(String source) {
String msg = source.replaceAll("\n", "\\\\n");
msg = "\"" + msg + "\"";
return msg;
}
}

@ -1 +1 @@
Subproject commit 4f9012b0795f62bf352b078ebbc1b1fffa86849d
Subproject commit c8ca17875615e4fd3483a7b15c11a1bc2f2f9cd5