From 4f7fd9e879d9de211b255eb21535a034893ffbff Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 14 五月 2026 16:20:48 +0800
Subject: [PATCH] 合并代码
---
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java | 67 ++++++++++++++++++++++++++++++++-
1 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java
index ecbe3c1..d347d99 100644
--- a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java
+++ b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java
@@ -1,8 +1,13 @@
package com.xiaopeng.pushMessage.webSocket.controller;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.xiaopeng.api.dto.pushMessage.SendMessageDTO;
+import com.xiaopeng.api.vo.XpTaskVO;
+import com.xiaopeng.api.vo.pushMessage.UpdateEndAddStatusVo;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.controller.BaseController;
+import com.xiaopeng.common.redis.service.RedisService;
import com.xiaopeng.pushMessage.webSocket.service.WebSocketUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -10,9 +15,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
/**
* WebSocket控制器
@@ -28,6 +36,12 @@
@Autowired
private WebSocketUserService webSocketUserService;
+ @Autowired
+ private ObjectMapper om;
+
+ @Resource
+ private RedisService redisService;
+
// ==================== 基于XpAppUser的WebSocket接口 ====================
// 消息格式 "{\"type\":\"mission_push\",\"content\":\"{\"missionId\":\"1983875114637811713\"}\",\"timestamp\":\"2025-10-27T09:22:45.681\"}";
@@ -40,7 +54,7 @@
* @return 操作结果
*/
@ApiOperation(value = "发送订单状态")
- @PostMapping("/inner/websocket/order/sendStatus")
+ @PostMapping("/logan/inner/websocket/order/sendStatus")
public R<String> sendStatus(@RequestBody SendMessageDTO dto) {
try {
String message = dto.getMessage();
@@ -62,6 +76,8 @@
return R.fail("发送消息失败: " + e.getMessage());
}
}
+
+
@PostMapping("/base/websocket/order/sendStatusTest")
public R<String> sendStatusTest(@RequestBody SendMessageDTO dto) {
@@ -98,7 +114,7 @@
* @return 操作结果
*/
@ApiOperation(value = "发送车辆路线、时间")
- @PostMapping("/inner/websocket/order/sendRoute")
+ @PostMapping("/logan/inner/websocket/order/sendRoute")
public R<String> sendRoute(@RequestBody SendMessageDTO dto) {
try {
String message = dto.getMessage();
@@ -355,4 +371,51 @@
return R.fail("获取在线用户列表失败: " + e.getMessage());
}
}
+
+
+ /**
+ * 运维工单app推送
+ */
+ @PostMapping("/inner/websocket/push/task")
+ public R<?> pushTask(@RequestBody XpTaskVO vo) throws JsonProcessingException {
+
+ String handleUserId = vo.getHandleUserId();
+ Map<String, Object> msg = new HashMap<>();
+ msg.put("type", "task");
+ msg.put("data", vo);
+ webSocketUserService.sendMessageToUser(handleUserId, om.writeValueAsString(msg));
+ return R.ok();
+
+ }
+
+
+ /**
+ * 推送订单修改目的地状态消息
+ * @param vo
+ * @return
+ */
+ @PostMapping("/logan/inner/websocket/order/sendUpdateEndAddStatus")
+ public R<?> sendUpdateEndAddStatus(@RequestBody UpdateEndAddStatusVo vo){
+ try {
+ String message = vo.getMessage();
+ if (message.trim().isEmpty()) {
+ return R.fail("消息内容不能为空");
+ }
+ String appUserId = vo.getAppUserId().toString();
+ if (appUserId.trim().isEmpty()) {
+ return R.fail("用户id不能为空");
+ }
+ redisService.setCacheObject("UPDATE_END_ADDRESS_STATUS_MSG:" + vo, System.currentTimeMillis(), 5L, TimeUnit.SECONDS);
+ int deviceCount = webSocketUserService.sendMessageToUser(appUserId, message);
+ if (deviceCount > 0) {
+ return R.ok("消息发送成功,发送到 " + deviceCount + " 个设备");
+ } else {
+ return R.fail("用户不在线或发送失败");
+ }
+ } catch (Exception e) {
+ log.error("推送修改目的地状态消息失败", e);
+ return R.fail("推送修改目的地状态消息失败: " + e.getMessage());
+ }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.7.1