From 6edb667321146d954236fc856a92038b478b5013 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期六, 25 四月 2026 01:55:50 +0800
Subject: [PATCH] [fix] reassignment_status = 1
---
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/handler/WebSocketTextFrameHandler.java | 47 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/handler/WebSocketTextFrameHandler.java b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/handler/WebSocketTextFrameHandler.java
index 900cb68..6043071 100644
--- a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/handler/WebSocketTextFrameHandler.java
+++ b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/handler/WebSocketTextFrameHandler.java
@@ -1,7 +1,9 @@
package com.xiaopeng.pushMessage.webSocket.handler;
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.xiaopeng.api.vo.automaticPilot.AppUserPosition;
+import com.xiaopeng.common.redis.service.RedisService;
import com.xiaopeng.pushMessage.webSocket.service.WebSocketUserConnectionManager;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
@@ -9,12 +11,19 @@
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
+import javax.annotation.Resource;
import java.time.LocalDateTime;
-import java.util.Objects;
-import java.util.UUID;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
/**
* TextWebSocketFrame 表示一个文本桢
@@ -32,6 +41,19 @@
@Autowired
private WebSocketAuthHandler authHandler;
+
+ @Resource
+ private MongoTemplate mongoTemplate;
+
+ Map<String, BusinessMsgHandler> businessMsgHandlers;
+
+ public WebSocketTextFrameHandler(List<BusinessMsgHandler> handlers) {
+ this.businessMsgHandlers = handlers.stream()
+ .collect(Collectors.toMap(
+ BusinessMsgHandler::getMessageType,
+ Function.identity()
+ ));
+ }
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
@@ -143,14 +165,16 @@
if (appUserId != null) {
log.info("收到用户 {} 的业务消息: {}", appUserId, messageObj.toJSONString());
- // 回复消息
- JSONObject response = new JSONObject();
- response.put("type", "message_response");
- response.put("appUserId", appUserId);
- response.put("originalMessage", messageObj);
- response.put("serverTime", LocalDateTime.now().toString());
+ businessMsgHandlers.get(messageObj.getString("type")).handle(appUserId, messageObj.toJSONString());
- ctx.channel().writeAndFlush(new TextWebSocketFrame(response.toJSONString()));
+ // 回复消息
+// JSONObject response = new JSONObject();
+// response.put("type", "message_response");
+// response.put("appUserId", appUserId);
+// response.put("originalMessage", messageObj);
+// response.put("serverTime", LocalDateTime.now().toString());
+//
+// ctx.channel().writeAndFlush(new TextWebSocketFrame(response.toJSONString()));
} else {
log.warn("收到未认证连接的业务消息: {}", messageObj.toJSONString());
@@ -192,4 +216,5 @@
log.error("WebSocket连接异常: {}", cause.getMessage(), cause);
ctx.channel().close();
}
+
}
\ No newline at end of file
--
Gitblit v1.7.1