xuhy
2026-04-25 6edb667321146d954236fc856a92038b478b5013
xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/webSocket/controller/WebSocketController.java
@@ -1,6 +1,9 @@
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.common.core.domain.R;
import com.xiaopeng.common.core.web.controller.BaseController;
import com.xiaopeng.pushMessage.webSocket.service.WebSocketUserService;
@@ -10,6 +13,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -27,6 +31,8 @@
    @Autowired
    private WebSocketUserService webSocketUserService;
    @Autowired ObjectMapper om;
    // ==================== 基于XpAppUser的WebSocket接口 ====================
@@ -355,4 +361,21 @@
            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();
    }
}