日志调整
This commit is contained in:
parent
c9b8724195
commit
19dc3b31bc
@ -9,16 +9,33 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@OpenAPIDefinition(info = @Info(title = "西安NCC调度辅助决策系统API", version = "0.1"))
|
||||
@SecurityScheme(name = "jwt", scheme = "bearer", type = SecuritySchemeType.HTTP, in = SecuritySchemeIn.HEADER)
|
||||
//@RestController
|
||||
public class XianNccDaApplication {
|
||||
|
||||
public static ConfigurableApplicationContext applicationContext;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(XianNccDaApplication.class, args);
|
||||
ConfigurableApplicationContext ac = SpringApplication.run(XianNccDaApplication.class, args);
|
||||
applicationContext = ac;
|
||||
}
|
||||
|
||||
/*@PostMapping("/tmpRestart")
|
||||
public String shutdown() {
|
||||
Thread t = new Thread(() -> {
|
||||
applicationContext.close();
|
||||
|
||||
});
|
||||
t.setDaemon(false);
|
||||
t.start();
|
||||
return "1";
|
||||
}*/
|
||||
}
|
||||
|
@ -53,6 +53,12 @@ public class OccMessageManage implements ApplicationRunner {
|
||||
clientMap.put(client.lineId, client);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
for (XianOccMessagingClient client : this.clientMap.values()) {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("初始化 occ tcp连接.... 是否监控cpu,内存信息:{}", this.monitorHandwareChange);
|
||||
|
@ -4,9 +4,11 @@ import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest;
|
||||
import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum;
|
||||
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;
|
||||
@ -113,39 +115,32 @@ public class XianOccMessagingClient {
|
||||
private Long lastReceiveMessageTime;
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.timeOutHandler.shutdown();
|
||||
}
|
||||
|
||||
public static class ConnectionTimeOutHandler {
|
||||
|
||||
final int HeartBeatTimeout = 20 * 1000;
|
||||
static final int Period = 2;
|
||||
|
||||
static final ScheduledExecutorService Executor = Executors.newSingleThreadScheduledExecutor();
|
||||
static ScheduledExecutorService Executor = Executors.newSingleThreadScheduledExecutor();
|
||||
private final LinkedList<OccTcpClientConnection> clientConnections = new LinkedList<>();
|
||||
private final SystemInfo systemInfo;
|
||||
// private long[] ticks = null;
|
||||
|
||||
private boolean monitorHandwareChange;
|
||||
// private OSProcess osProcess;
|
||||
// private Integer processId;
|
||||
|
||||
private long[] ticks;
|
||||
|
||||
public void shutdown() {
|
||||
Executor.shutdownNow();
|
||||
}
|
||||
|
||||
public ConnectionTimeOutHandler() {
|
||||
this.systemInfo = new SystemInfo();
|
||||
/* List<OSProcess> osProcesses = systemInfo.getOperatingSystem().getProcesses();
|
||||
for (OSProcess osProcess : osProcesses) {
|
||||
String processName = osProcess.getName();
|
||||
if (StringUtils.contains(processName, "java")) {
|
||||
log.info(osProcess.getArguments().toString());
|
||||
for (String arg : osProcess.getArguments()) {
|
||||
if (StringUtils.containsAny(arg, "XianNccDaApplication", "xian-ncc-da")) {
|
||||
*//*System.out.println(osProcess.getProcessID());
|
||||
System.out.println(osProcess.getName());
|
||||
System.out.println(osProcess.getProcessCpuLoadBetweenTicks(osProcess) * 100);*//*
|
||||
this.osProcess = osProcess;
|
||||
this.processId = osProcess.getProcessID();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (Executor.isShutdown()) {
|
||||
Executor = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
}
|
||||
|
||||
public void addConnection(OccTcpClientConnection conn) {
|
||||
@ -192,6 +187,7 @@ public class XianOccMessagingClient {
|
||||
log.info(moitorContent);
|
||||
}
|
||||
}
|
||||
|
||||
for (OccTcpClientConnection cc : this.clientConnections) {
|
||||
if (cc.connected) {
|
||||
long ctm = System.currentTimeMillis();
|
||||
@ -204,7 +200,9 @@ public class XianOccMessagingClient {
|
||||
}
|
||||
}
|
||||
}, Period, Period, TimeUnit.SECONDS);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,9 +77,6 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(dt, deviceEntity.status);
|
||||
// DeviceStatusConvertor.fillField(builder, "id", deviceEntity.devName);
|
||||
String newOccName = DeviceNameChangerManage.findMatch(dt, deviceEntity.devName);
|
||||
if (dt == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
log.info("接受屏蔽门全量状态 屏蔽门[{}] 状态[{}] 接受时间[{}]", newOccName, deviceEntity.status, this.getTime());
|
||||
}
|
||||
DeviceStatusConvertor.fillField(builder, "id", newOccName);
|
||||
DeviceStatusConvertor.fillField(builder, "rtuId", this.rtuId);
|
||||
DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime());
|
||||
@ -90,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);
|
||||
msgBuildList.add(builder);
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +101,7 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
// this.type = DeviceType.DEVICE_TYPE_TRACK;
|
||||
// }
|
||||
GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(this.type, this.deviceStatus);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("设备状态变更 设备类型[{}] 设备名称[{}] 状态[{}] 接受时间[{}]", this.type.name(), occName, this.deviceStatus, this.getTime());
|
||||
}
|
||||
|
||||
// DeviceStatusConvertor.fillField(builder, "id", this.devName);
|
||||
DeviceStatusConvertor.fillField(builder, "id", occName);
|
||||
DeviceStatusConvertor.fillField(builder, "dataFrom", MessageId.DEVICE_STATUS_CHANGE.name());
|
||||
@ -115,6 +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);
|
||||
return List.of(builder);
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,12 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
public List<GeneratedMessageV3.Builder> generateProto() {
|
||||
List<GeneratedMessageV3.Builder> planBuilds = Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(this.entityList)) {
|
||||
Plan.Builder planBuild = Plan.newBuilder();
|
||||
planBuild.setLineId(this.lineId);
|
||||
planBuild.setDate(DateTimeUtil.epochSecond(this.date));
|
||||
planBuild.setActionId(this.subId.val());
|
||||
planBuild.setTrainId(this.trainId);
|
||||
planBuilds.add(planBuild);
|
||||
return planBuilds;
|
||||
}
|
||||
for (InusedScheduleEntity entity : this.entityList) {
|
||||
|
@ -28,6 +28,7 @@ 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;
|
||||
@ -115,7 +116,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
} else if (isOpen && Objects.equals(false, platformBuild.getPsdOpen())) {
|
||||
//开门后,在阈值内关门
|
||||
alertManager.putAlterDevice(platformBuild.getLineId(), PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||
} else if (isOpen && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) {
|
||||
} else if (isOpen /*&& !isClose*/ && this.timeOver(platformBuild.getReceiveTime(), (int) stayTimeSecond + guardConfig.getCanNotCloseTimes())) {
|
||||
//车辆停靠,只开门 超过等待时间+阈值时间
|
||||
this.alert(platformBuild, AlertType.PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_IS_CLOSE, isUpWay, record);
|
||||
} else if (!isOpen && !isClose && platformBuild.getTrainberth() && this.timeOver(platformBuild.getReceiveTime(), guardConfig.getCanNotOpenTimes())) {
|
||||
@ -128,11 +129,9 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
int lineId = platformBuild.getLineId();
|
||||
boolean alertAdd = alertManager.putAlterDevice(lineId, customName, platformBuild.getId());
|
||||
if (alertAdd) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("列车开关门是否已经报警检测,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}], 告警类型[{}] 告警名称[{}]",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), alertType,
|
||||
customName);
|
||||
}
|
||||
log.info("列车开关门是否已经报警检测,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}], 告警类型[{}] 告警名称[{}]",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), alertType,
|
||||
customName);
|
||||
|
||||
LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(lineId, platformBuild.getId(), LayoutGraphicsProto.Platform.class);
|
||||
String openClose = alertType == AlertType.PLATFORM_DOOR_CANNOT_CLOSE ? "关闭" : "打开";
|
||||
@ -146,7 +145,6 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
alertManager.emit(alertInfo);
|
||||
this.removeTrainRecord(record);
|
||||
}
|
||||
// this.removeTrainRecordOnly(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,45 +152,44 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
for (Builder record : this.trainRecordMap.values()) {
|
||||
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
|
||||
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
||||
|
||||
if (Objects.nonNull(platformBuild)) {
|
||||
int lineId = record.getLineId();
|
||||
boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||
boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||
if (isOpen && isClose && Objects.equals(false, platformBuild.getTrainberth())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info(
|
||||
"列车开关过屏蔽门车辆离站,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] 是否靠站[{}]",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId()
|
||||
, isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), platformBuild.getTrainberth());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
if (isOpen && isClose) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info(
|
||||
"列车开关过屏蔽门只是等待,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] ",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay);
|
||||
if (planBuildOpt.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
|
||||
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
Plan.Builder planBuild = planBuildOpt.get();
|
||||
this.handle(record, isUpWay, platformBuild, isOpen, isClose, planBuild);
|
||||
} else {
|
||||
int lineId = record.getLineId();
|
||||
if (Objects.isNull(platformBuild)) {
|
||||
this.removeTrainRecord(record);
|
||||
break;
|
||||
}
|
||||
boolean isOpen = alertManager.deviceIsExist(lineId, PLATFORM_IS_OPEN, platformBuild.getId());
|
||||
boolean isClose = alertManager.deviceIsExist(lineId, PLATFORM_IS_CLOSE, platformBuild.getId());
|
||||
if (isOpen && isClose && Objects.equals(false, platformBuild.getTrainberth())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info(
|
||||
"列车开关过屏蔽门车辆离站,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] 是否靠站[{}]",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId()
|
||||
, isUpWay, platformBuild.getId(), platformBuild.getReceiveTime(), platformBuild.getTrainberth());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
if (isOpen && isClose) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info(
|
||||
"列车开关过屏蔽门只是等待,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}],接收时间[{}] ",
|
||||
record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId(), platformBuild.getReceiveTime());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay);
|
||||
if (planBuildOpt.isEmpty()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
|
||||
, record.getLineId(), record.getTrainId(), record.getGlobalId(), record.getStationId(), record.getSideId(), isUpWay, platformBuild.getId());
|
||||
}
|
||||
this.removeTrainRecord(record);
|
||||
continue;
|
||||
}
|
||||
Plan.Builder planBuild = planBuildOpt.get();
|
||||
this.handle(record, isUpWay, platformBuild, isOpen, isClose, planBuild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
public void putSwitchIfNotExist(Switch.Builder switchBuilder) {
|
||||
if (!deviceMap.containsKey(switchBuilder.getId())) {
|
||||
deviceMap.put(switchBuilder.getId(), switchBuilder);
|
||||
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
||||
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder.getIpSingleSwitchStusLostIndication());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,10 @@ public class SystemContext implements ApplicationContextAware {
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
|
||||
if (Objects.isNull(appContext)) {
|
||||
System.out.println("获取 spring appContext");
|
||||
appContext = applicationContext;
|
||||
masterEnv = applicationContext.getEnvironment().matchesProfiles("master");
|
||||
}
|
||||
// if (Objects.isNull(appContext)) {
|
||||
System.out.println("获取 spring appContext");
|
||||
appContext = applicationContext;
|
||||
masterEnv = applicationContext.getEnvironment().matchesProfiles("master");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ public class MockLoadData implements ApplicationRunner {
|
||||
static final ScheduledExecutorService CIRCLE_QUERY_THREAD = Executors.newSingleThreadScheduledExecutor();
|
||||
private final NccMockDataService nccMockDataService;
|
||||
|
||||
public void close() {
|
||||
CIRCLE_QUERY_THREAD.shutdownNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
this.nccMockDataService.reset(10);
|
||||
|
@ -56,11 +56,11 @@ public class AlertInfoService {
|
||||
|
||||
|
||||
public NccAlertInfo createAlert2(Optional<AreaConfigVO> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String alertMsg, String layoutId, AlertDeviceType deviceType, boolean mockData) {
|
||||
Long timestamp = DeviceStatusDataOperate.findFieldVal(mb, "timestamp", Long.class);
|
||||
// Long timestamp = DeviceStatusDataOperate.findFieldVal(mb, "timestamp", Long.class);
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class);
|
||||
LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.of("+8"));
|
||||
// LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.of("+8"));
|
||||
Long areaConfigId = areaConfigOpt.map(AreaConfigVO::getId).orElse(null);
|
||||
return this.createAlert2(areaConfigId, alertType, lineId, createTime, alertMsg, layoutId, deviceType, mockData);
|
||||
return this.createAlert2(areaConfigId, alertType, lineId, LocalDateTime.now(), alertMsg, layoutId, deviceType, mockData);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user