| | |
| | | package com.xiaopeng.pushMessage.webSocket.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Autowired |
| | | private WebSocketUserService webSocketUserService; |
| | | |
| | | @Autowired ObjectMapper om; |
| | | |
| | | // ==================== 基于XpAppUser的WebSocket接口 ==================== |
| | | |
| | | // 消息格式 "{\"type\":\"mission_push\",\"content\":\"{\"missionId\":\"1983875114637811713\"}\",\"timestamp\":\"2025-10-27T09:22:45.681\"}"; |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "发送订单状态") |
| | | @PostMapping("/logan/inner/websocket/order/sendStatus") |
| | | @PostMapping("/inner/websocket/order/sendStatus") |
| | | public R<String> sendStatus(@RequestBody SendMessageDTO dto) { |
| | | try { |
| | | String message = dto.getMessage(); |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "发送车辆路线、时间") |
| | | @PostMapping("/logan/inner/websocket/order/sendRoute") |
| | | @PostMapping("/inner/websocket/order/sendRoute") |
| | | public R<String> sendRoute(@RequestBody SendMessageDTO dto) { |
| | | try { |
| | | String message = dto.getMessage(); |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "发送车辆实时定位") |
| | | @PostMapping("/logan/inner/websocket/order/sendVehicleLocation") |
| | | @PostMapping("/inner/websocket/order/sendVehicleLocation") |
| | | public R<String> sendVehicleLocation(@RequestBody SendMessageDTO dto) { |
| | | try { |
| | | String message = dto.getMessage(); |
| | |
| | | * @return 操作结果 |
| | | */ |
| | | @ApiOperation(value = "发送是否开启倒计时") |
| | | @PostMapping("/logan/inner/websocket/order/sendOpenTrunk") |
| | | @PostMapping("/inner/websocket/order/sendOpenTrunk") |
| | | public R<String> sendOpenTrunk(@RequestBody SendMessageDTO dto) { |
| | | try { |
| | | String message = dto.getMessage(); |
| | |
| | | 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(); |
| | | |
| | | } |
| | | |
| | | } |