From 916d0f9012590ff4b4eb7ce838f5d69d305fe539 Mon Sep 17 00:00:00 2001
From: 曾富康 <1067864236@qq.com>
Date: 星期三, 17 六月 2026 18:48:40 +0800
Subject: [PATCH] 显示乘客地址定位信息
---
MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java
index cf893ba..ad0a197 100644
--- a/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java
+++ b/MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java
@@ -171,6 +171,10 @@
sendMsgToClient(ctx, jsonMsg.toJSONString());
}
}
+ //乘客上传位置,转发到用户端服务做订单校验和司机推送
+ if(method.equals(Method.passengerLocation)){
+ forwardPassengerLocation(ctx, jsonCon);
+ }
//司机上传位置
if(method.equals(Method.location)){
Integer driverId = jsonCon.getInteger("driverId");
@@ -265,6 +269,42 @@
}
/**
+ * 转发乘客实时定位到用户服务,由用户服务校验订单后推送给司机端
+ */
+ private void forwardPassengerLocation(ChannelHandlerContext ctx, JSONObject jsonCon) {
+ Integer userId = jsonCon.getInteger("userId");
+ Integer orderId = jsonCon.getInteger("orderId");
+ Integer orderType = jsonCon.getInteger("orderType");
+ Double lon = jsonCon.getDouble("lon");
+ Double lat = jsonCon.getDouble("lat");
+ String timestamp = jsonCon.getString("timestamp");
+ // 基础参数不合法时直接返回错误,不再调用后端业务接口
+ if (userId == null || orderId == null || orderType == null || lon == null || lat == null || lon == 0 || lat == 0) {
+ this.sendMsgToClient(ctx, "__error__" + jsonCon.toJSONString());
+ return;
+ }
+ Map<String, Object> params = new HashMap<>();
+ params.put("userId", String.valueOf(userId));
+ params.put("orderId", String.valueOf(orderId));
+ params.put("orderType", String.valueOf(orderType));
+ params.put("lon", String.valueOf(lon));
+ params.put("lat", String.valueOf(lat));
+ params.put("timestamp", timestamp);
+ HttpRequest post = HttpUtil.createPost(qytConfig.getChuxingUrl() + "/user-server/base/passenger/location/push");
+ post.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
+ post.form(params);
+ HttpResponse execute = post.execute();
+ if (200 != execute.getStatus()) {
+ System.err.println("调用user-server推送乘客定位出错");
+ return;
+ }
+ JSONObject jsonObject = JSON.parseObject(execute.body(), JSONObject.class);
+ if (jsonObject.getIntValue("code") != 200) {
+ System.err.println("调用user-server推送乘客定位出错:" + jsonObject.getString("msg"));
+ }
+ }
+
+ /**
* 向客户端发送消息
*
* @param ctx
--
Gitblit v1.7.1