删除了部分打印数据,新增删除事件
This commit is contained in:
parent
0717201c58
commit
5c0bb3f3ba
@ -395,4 +395,26 @@ public class AllXml {
|
||||
" </TisFlight>\n" +
|
||||
" </Body>\n" +
|
||||
"</Msg>";
|
||||
|
||||
|
||||
public static final String XML_DFDE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<Msg>\n" +
|
||||
"<Head>\n" +
|
||||
" <Svc_ServiceCode>ADXP_NAOMS_O_DYN_DFDE</Svc_ServiceCode>\n" +
|
||||
" <Svc_Version>1.0</Svc_Version>\n" +
|
||||
" <Svc_Sender_Org>ADXP</Svc_Sender_Org>\n" +
|
||||
" <Svc_Sender>NAOMS</Svc_Sender>\n" +
|
||||
" <Svc_Receiver_Org></Svc_Receiver_Org>\n" +
|
||||
" <Svc_Receiver></Svc_Receiver>\n" +
|
||||
" <Svc_SerialNumber></Svc_SerialNumber>\n" +
|
||||
" <Svc_SessionId>20171208140658867</Svc_SessionId>\n" +
|
||||
" <Svc_SendTimeStamp>20171208140658867</Svc_SendTimeStamp>\n" +
|
||||
"</Head>\n" +
|
||||
"<Body>\n" +
|
||||
" <DynFlight>\n" +
|
||||
" <FlightId>4155920</FlightId>\n" +
|
||||
" <BizKey>CZ3158-A-20170906230500</BizKey>\n" +
|
||||
" </DynFlight>\n" +
|
||||
"</Body>\n" +
|
||||
"</Msg>";
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ public class AdxpSdkService {
|
||||
Object body = msg.getBody();
|
||||
|
||||
if (head != null && body != null) {
|
||||
log.info("本条消息的接收到消息头{},消息体{}", head.getSvcServiceCode(), messageString);
|
||||
//log.info("本条消息的接收到消息头{},消息体{}", head.getSvcServiceCode(), messageString);
|
||||
FlightMessage flightMessage = new FlightMessage(
|
||||
head.getSvcServiceCode(),
|
||||
null, // actionCode 在 body 中
|
||||
@ -300,7 +300,7 @@ public class AdxpSdkService {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
for (FlightMessage message : messages){
|
||||
String txt = message.getContent();
|
||||
log.info("接收到的XML字符串:{}", txt);
|
||||
//log.info("接收到的XML字符串:{}", txt);
|
||||
// 解析 XML 字符串
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
InputStream is = new ByteArrayInputStream(txt.getBytes("UTF-8"));
|
||||
@ -331,6 +331,7 @@ public class AdxpSdkService {
|
||||
break;
|
||||
default:
|
||||
System.out.println("未定义的消息");
|
||||
handleNEW(txt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -484,9 +485,11 @@ public class AdxpSdkService {
|
||||
String runwayNum = getElementValue(dynFlight, "RunwayNum");
|
||||
|
||||
// 输出提取的值
|
||||
System.out.println("FlightId: " + flightId);
|
||||
System.out.println("InOut: " + inOut);
|
||||
System.out.println("RunwayNum: " + runwayNum);
|
||||
|
||||
log.info("动态航班信息: {}", flightId);
|
||||
log.info("动态航班信息: {}", inOut);
|
||||
log.info("动态航班信息: {}", runwayNum);
|
||||
log.info("RunwayNum: " + runwayNum);
|
||||
|
||||
// 获取 CraftseatList 并提取 Code
|
||||
NodeList craftseatListNodes = dynFlight.getElementsByTagName("CraftseatList");
|
||||
@ -501,7 +504,7 @@ public class AdxpSdkService {
|
||||
String code = getElementValue(craftseat, "Code");
|
||||
|
||||
// 输出提取的值
|
||||
System.out.println("Craftseat Code: " + code);
|
||||
log.info("Craftseat Code: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -519,15 +522,15 @@ public class AdxpSdkService {
|
||||
|
||||
// 提取 BizKey
|
||||
String bizKey = getElementValue(flightElement, "BizKey");
|
||||
System.out.println("BizKey: " + bizKey);
|
||||
log.info("BizKey: " + bizKey);
|
||||
|
||||
// 提取 RUNWAYDEP
|
||||
String runwayDep = getElementValue(flightElement, "RUNWAYDEP");
|
||||
System.out.println("RUNWAYDEP: " + runwayDep);
|
||||
log.info("RUNWAYDEP: " + runwayDep);
|
||||
|
||||
// 提取 RUNWAYARR
|
||||
String runwayArr = getElementValue(flightElement, "RUNWAYARR");
|
||||
System.out.println("RUNWAYARR: " + runwayArr);
|
||||
log.info("RunwayArr: " + runwayArr);
|
||||
}
|
||||
}
|
||||
private static void handleCRAFTSEAT(Document document) {
|
||||
@ -538,7 +541,7 @@ public class AdxpSdkService {
|
||||
|
||||
// 提取 FlightId
|
||||
String flightId = getElementValue(dynFlightElement, "FlightId");
|
||||
System.out.println("FlightId: " + flightId);
|
||||
log.info("FlightId: " + flightId);
|
||||
|
||||
// 获取 CraftseatList 元素
|
||||
NodeList craftseatList = dynFlightElement.getElementsByTagName("Craftseat");
|
||||
@ -547,7 +550,7 @@ public class AdxpSdkService {
|
||||
|
||||
// 提取 Code
|
||||
String code = getElementValue(craftseatElement, "Code");
|
||||
System.out.println("Code: " + code);
|
||||
log.info("Code: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -560,8 +563,8 @@ public class AdxpSdkService {
|
||||
// 提取所需的值
|
||||
String flightId = getElementValue(dynFlight, "FlightId");
|
||||
String bizKey = getElementValue(dynFlight, "BizKey");
|
||||
System.out.println("FlightId: " + flightId);
|
||||
System.out.println("BizKey: " + bizKey);
|
||||
log.info("FlightId: " + flightId);
|
||||
log.info("BizKey: " + bizKey);
|
||||
}
|
||||
}
|
||||
private static void handleAXOT(Document document) {
|
||||
@ -577,7 +580,7 @@ public class AdxpSdkService {
|
||||
|
||||
// 提取 BizKey 元素的值
|
||||
String bizKey = getElementValue(flight, "BizKey");
|
||||
System.out.println("BizKey: " + bizKey);
|
||||
log.info("BizKey: " + bizKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -592,10 +595,10 @@ public class AdxpSdkService {
|
||||
String runwayNum = getElementValue(dynFlight, "RunwayNum");
|
||||
String bizKey = getElementValue(dynFlight, "BizKey");
|
||||
|
||||
System.out.println("FlightId: " + flightId);
|
||||
System.out.println("InOut: " + inOut);
|
||||
System.out.println("RunwayNum: " + runwayNum);
|
||||
System.out.println("BizKey: " + bizKey);
|
||||
log.info("FlightId: " + flightId);
|
||||
log.info("InOut: " + inOut);
|
||||
log.info("RunwayNum: " + runwayNum);
|
||||
log.info("BizKey: " + bizKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -611,12 +614,21 @@ public class AdxpSdkService {
|
||||
String contactCross = getElementValue(tisFlight, "ContactCross");
|
||||
|
||||
// 打印提取的内容
|
||||
System.out.println("FuId: " + fuId);
|
||||
System.out.println("State: " + state);
|
||||
System.out.println("ContactCross: " + contactCross);
|
||||
|
||||
log.info("FuId: " + fuId);
|
||||
log.info("State: " + state);
|
||||
log.info("ContactCross: " + contactCross);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 未定义的消息
|
||||
* @param message
|
||||
*/
|
||||
private static void handleNEW(String message) {
|
||||
System.out.println("新的报文是: " + message);
|
||||
}
|
||||
|
||||
|
||||
// 获取元素的值
|
||||
private static String getElementValue(Element parentElement, String tagName) {
|
||||
|
||||
@ -43,8 +43,6 @@ public class AdxpWebSocketHandler extends TextWebSocketHandler {
|
||||
if ("ping".equals(message.getPayload())) {
|
||||
session.sendMessage(new TextMessage("pong"));
|
||||
List<FlightMessage> messages = new CopyOnWriteArrayList<>();
|
||||
FlightMessage mgARR = new FlightMessage("ADXP_NAOMS_O_DYN_ARR", "pong", AllXml.XML_ARR);
|
||||
messages.add(mgARR);
|
||||
FlightMessage mgDFIE = new FlightMessage("ADXP_NAOMS_O_DYN_DFIE", "pong", AllXml.XML_DFIE);
|
||||
messages.add(mgDFIE);
|
||||
FlightMessage mgRUNWAY = new FlightMessage("ADXP_NAOMS_O_CDM_RUNWAY", "pong", AllXml.XML_RUNWAY);
|
||||
@ -53,8 +51,18 @@ public class AdxpWebSocketHandler extends TextWebSocketHandler {
|
||||
messages.add(mgCRAFTSEAT);
|
||||
FlightMessage mgTISFLIGHT = new FlightMessage("ADXP_NAOMS_O_DYN_TISFLIGHT", "pong", AllXml.XML_TISFLIGHT);
|
||||
messages.add(mgTISFLIGHT);
|
||||
FlightMessage mgAXOT = new FlightMessage("ADXP_NAOMS_O_CDM_AXOT", "pong", AllXml.XML_AXOT);
|
||||
messages.add(mgAXOT);
|
||||
FlightMessage mgARR = new FlightMessage("ADXP_NAOMS_O_DYN_ARR", "pong", AllXml.XML_ARR);
|
||||
messages.add(mgARR);
|
||||
broadcastMessages(messages);
|
||||
log.debug("发送心跳响应到客户端: sessionId={}", session.getId());
|
||||
}else if ("delete".equals(message.getPayload())) {
|
||||
List<FlightMessage> messages = new CopyOnWriteArrayList<>();
|
||||
FlightMessage mgDFIE = new FlightMessage("ADXP_NAOMS_O_DYN_DFDE", "pong", AllXml.XML_DFIE);
|
||||
messages.add(mgDFIE);
|
||||
broadcastMessages(messages);
|
||||
log.debug("收到客户端心跳响应: sessionId={}", session.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ public class RoutePersistenceService {
|
||||
* @param routeType 路由类型(IN/OUT)
|
||||
*/
|
||||
@Transactional
|
||||
private void saveRouteAssignment(String objectName, Long routeId, String routeType) {
|
||||
public void saveRouteAssignment(String objectName, Long routeId, String routeType) {
|
||||
try {
|
||||
// 查找当前路由信息
|
||||
Optional<TransportRoute> currentRoute = transportRouteRepository.findById(routeId);
|
||||
|
||||
@ -209,7 +209,7 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
// // 解析接收到的消息
|
||||
// String payload = message.getPayload();
|
||||
|
||||
log.debug("📥 收到WebSocket消息 ({} bytes)", payload.length());
|
||||
//log.debug("📥 收到WebSocket消息 ({} bytes)", payload.length());
|
||||
|
||||
// 增加消息计数
|
||||
messageCount.incrementAndGet();
|
||||
@ -278,16 +278,14 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
List<FlightMessage> flightMessages =
|
||||
objectMapper.readValue(jsonContent, new TypeReference<List<FlightMessage>>() {});
|
||||
|
||||
log.error("📥 收到WebSocket消息 ({})", flightMessages);
|
||||
|
||||
|
||||
//log.error("📥 收到WebSocket消息 ({})", flightMessages);
|
||||
|
||||
List<FlightNotificationDTO> notifications = new java.util.ArrayList<>();
|
||||
|
||||
for (FlightMessage message : flightMessages) {
|
||||
try {
|
||||
log.error("hhhhh获取消息内容: serviceCode={}", message.getServiceCode());
|
||||
log.error("hhhhh获取消息内容: content={}", message.getContent());
|
||||
log.error("获取消息类型: serviceCode={}", message.getServiceCode());
|
||||
//log.error("获取消息内容: content={}", message.getContent());
|
||||
FlightNotificationDTO dto = parseXmlMessage(message.getServiceCode(), message.getContent());
|
||||
if (dto != null) {
|
||||
notifications.add(dto);
|
||||
@ -320,7 +318,8 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
//return parseArrival(root);
|
||||
return handleARR(root);
|
||||
case "ADXP_NAOMS_O_CDM_AXOT":
|
||||
return parsePushback(root);
|
||||
//return parsePushback(root);
|
||||
return handleAXOT(root);
|
||||
case "ADXP_NAOMS_O_CDM_RUNWAY":
|
||||
//return parseRunway(root);
|
||||
return handleRUNWAY(root);
|
||||
@ -331,6 +330,8 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
return handleDFIE(root);
|
||||
case "ADXP_NAOMS_O_DYN_TISFLIGHT":
|
||||
return handleTISFLIGHT(root);
|
||||
case "ADXP_NAOMS_O_DYN_DFDE":
|
||||
return handleDFDE(root);
|
||||
default:
|
||||
log.debug("未知的服务代码: {}", serviceCode);
|
||||
return null;
|
||||
@ -514,7 +515,7 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
}
|
||||
}
|
||||
//假装模拟请求接口
|
||||
dataProcessingService.hello(arr[0]);
|
||||
dataProcessingService.ARR(arr[0]);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -560,10 +561,6 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
String flightNo = getTextContent(root, "BizKey");
|
||||
String outRunway = getTextContent(root, "RUNWAYDEP");
|
||||
String inRunway = getTextContent(root, "RUNWAYARR");
|
||||
if (inRunway.equals("")){
|
||||
log.error("inRunway为空字符串");
|
||||
}
|
||||
|
||||
log.error("inRunway-{}",inRunway);
|
||||
log.error("outRunway-{}",outRunway);
|
||||
//分解BizKey
|
||||
@ -593,8 +590,6 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
log.error("存储航班数据到Redis失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
//假装模拟请求接口
|
||||
dataProcessingService.hello(arr[0]);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -620,8 +615,6 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
log.error("存储航班数据到Redis失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
//假装模拟请求接口
|
||||
dataProcessingService.hello(arr[0]);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -645,6 +638,45 @@ public class AdxpFlightServiceWebSocketClient implements WebSocketHandler {
|
||||
return dto;
|
||||
}
|
||||
|
||||
private FlightNotificationDTO handleAXOT(org.w3c.dom.Element root) {
|
||||
String flightNo = getTextContent(root, "BizKey");
|
||||
//分解BizKey
|
||||
String[] arr = flightNo.split("-", 3); // 最多切 3 段
|
||||
FlightNotificationDTO dto = new FlightNotificationDTO();
|
||||
dto.setFlightNo(flightNo);
|
||||
dto.setType("OUT");
|
||||
// 存储到Redis
|
||||
if (arr.length >= 3) {
|
||||
try {
|
||||
String key = "flight:" + arr[0]; // 使用航班号作为键
|
||||
redisCache.setCacheMapValue(key, "flightNumber", arr[0]);
|
||||
redisCache.setCacheMapValue(key, "type", arr[1]);
|
||||
redisCache.setCacheMapValue(key, "time", arr[2]);
|
||||
log.info("成功将航班数据存储到Redis: flightNumber={}, type={}, time={}", arr[0], arr[1], arr[2]);
|
||||
} catch (Exception e) {
|
||||
log.error("存储航班数据到Redis失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
//假装模拟请求接口
|
||||
dataProcessingService.AXOT(arr[0]);
|
||||
return dto;
|
||||
}
|
||||
|
||||
private FlightNotificationDTO handleDFDE(org.w3c.dom.Element root) {
|
||||
String flightNo = getTextContent(root, "BizKey");
|
||||
//分解BizKey
|
||||
String[] arr = flightNo.split("-", 3); // 最多切 3 段
|
||||
FlightNotificationDTO dto = new FlightNotificationDTO();
|
||||
if (arr[1].equals("A")){
|
||||
dto.setType("IN");
|
||||
}else {
|
||||
dto.setType("OUT");
|
||||
}
|
||||
String key = "flight:" + arr[0]; // 使用航班号作为键
|
||||
redisCache.deleteObject(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -140,8 +140,8 @@ public class DataProcessingService {
|
||||
// 第三步:处理通用车辆状态数据并发送WebSocket更新
|
||||
processUniversalVehicleStatusUpdates();
|
||||
|
||||
// 第四步:处理航班通知数据并发送WebSocket更新
|
||||
processFlightNotificationUpdates();
|
||||
// 第四步:处理航班通知数据并发送WebSocket更新, 暂时关闭改为用websocket接收
|
||||
//processFlightNotificationUpdates();
|
||||
|
||||
// 第五步:执行路径冲突检测
|
||||
pathConflictDetectionService.detectPathConflicts(currentActiveObjects);
|
||||
@ -1252,6 +1252,7 @@ public class DataProcessingService {
|
||||
*/
|
||||
private void publishAircraftRouteUpdateEvent(String flightNo, AircraftRoute route,
|
||||
com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO routeParams) {
|
||||
log.error( "发布航空器路由更新事件: flightNo={}", flightNo);
|
||||
try {
|
||||
// 创建路由更新事件
|
||||
com.qaup.collision.websocket.event.AircraftRouteUpdateEvent routeUpdateEvent =
|
||||
@ -1280,8 +1281,7 @@ public class DataProcessingService {
|
||||
/**
|
||||
* 触发查询航班号对应的路由
|
||||
*/
|
||||
public void hello(String flightNo){
|
||||
log.error("hello666666666666666666666666666666666666");
|
||||
public void ARR(String flightNo){
|
||||
String key = "flight:"+flightNo;
|
||||
|
||||
String time =(String) redisCache.getCacheMapValue(key, "time");
|
||||
@ -1300,6 +1300,73 @@ public class DataProcessingService {
|
||||
outRunway,
|
||||
contactCross,
|
||||
seat);
|
||||
log.error("routeData是{}",routeData);
|
||||
log.error("进港路由数据routeData是{}",routeData);
|
||||
|
||||
// 创建路由参数:目前有用的只有type
|
||||
com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO routeParams = new com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO();
|
||||
routeParams.setFlightNo(flightNo);
|
||||
routeParams.setRouteType("IN");
|
||||
routeParams.setInRunway(inRunway);
|
||||
routeParams.setOutRunway(outRunway);
|
||||
routeParams.setContactCross(contactCross);
|
||||
routeParams.setSeat(seat);
|
||||
|
||||
//处理路由数据并发布
|
||||
handleRouteData(flightNo, routeData, routeParams);
|
||||
}
|
||||
|
||||
public void AXOT(String flightNo){
|
||||
String key = "flight:"+flightNo;
|
||||
|
||||
String time =(String) redisCache.getCacheMapValue(key, "time");
|
||||
log.error("time是{}",time);
|
||||
String inRunway = "17";
|
||||
String outRunway = "35";
|
||||
String startSeat = "201";
|
||||
|
||||
// 获取DataCollectorDao进行路由数据查询
|
||||
DataCollectorDao dataCollectorDao = applicationContext.getBean(DataCollectorDao.class);
|
||||
AircraftRouteDTO routeData = null;
|
||||
// 进港路由查询
|
||||
routeData = dataCollectorDao.getDepartureRoute(
|
||||
inRunway,
|
||||
outRunway,
|
||||
startSeat);
|
||||
log.error("出港路由数据是routeData是{}",routeData);
|
||||
|
||||
// 创建路由参数:目前有用的只有type
|
||||
com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO routeParams = new com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO();
|
||||
routeParams.setFlightNo(flightNo);
|
||||
routeParams.setRouteType("OUT");
|
||||
routeParams.setInRunway(inRunway);
|
||||
routeParams.setOutRunway(outRunway);
|
||||
routeParams.setStartSeat(startSeat);
|
||||
|
||||
//处理路由数据并发布
|
||||
handleRouteData(flightNo, routeData, routeParams);
|
||||
}
|
||||
|
||||
private void handleRouteData(String flightNo, AircraftRouteDTO routeData,
|
||||
com.qaup.collision.datacollector.dto.AircraftRouteParamsDTO routeParams){
|
||||
// 步骤3: 处理路由查询结果
|
||||
if (routeData != null) {
|
||||
log.info("🎯 成功获取{}路由数据: 编码={}, 状态={}",
|
||||
routeData.getType(), routeData.getCodes(), routeData.getStatus());
|
||||
|
||||
// 转换DTO为航空器路由对象
|
||||
AircraftRoute aircraftRoute = convertToAircraftRoute(routeData);
|
||||
|
||||
if (aircraftRoute != null) {
|
||||
// 保存路由到数据库
|
||||
saveAircraftRouteToDatabase(flightNo, aircraftRoute);
|
||||
|
||||
// 发布WebSocket路由更新事件
|
||||
publishAircraftRouteUpdateEvent(flightNo, aircraftRoute, routeParams);
|
||||
} else {
|
||||
log.warn("⚠️ 路由数据转换失败: flightNo={}", flightNo);
|
||||
}
|
||||
} else {
|
||||
log.warn("⚠️ 未获取到路由数据: flightNo={}", flightNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,6 +36,7 @@ public class AircraftRouteUpdateEventListener {
|
||||
*/
|
||||
@EventListener
|
||||
public void handleAircraftRouteUpdateEvent(AircraftRouteUpdateEvent event) {
|
||||
log.error("处理航空器路由更新事件: flightNo={}", event.getFlightNo());
|
||||
try {
|
||||
// 构建WebSocket消息
|
||||
String message = objectMapper.writeValueAsString(new WebSocketMessage(
|
||||
|
||||
@ -236,8 +236,12 @@ public class RedisCache
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
|
||||
{
|
||||
redisTemplate.opsForHash().put(key, hKey, value);
|
||||
// 统一设置 Hash 的过期时间(对整个 key 生效)
|
||||
//redisTemplate.expire(key, DEFAULT_EXPIRE_TIME, DEFAULT_TIME_UNIT);
|
||||
redisTemplate.expire(key, 24 * DEFAULT_EXPIRE_TIME , DEFAULT_TIME_UNIT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user