更新路径规划任务推送消息
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
public enum MesType {
|
||||
AUTH, //登录连接权限web->be
|
||||
deviceInfo, //设备状态 be->web
|
||||
path,//路径下发 web->be
|
||||
have_logged_in,//消息
|
||||
device_status_changed,//上下线状态变化
|
||||
device_error_push, //错误推送
|
||||
device_task_change, //任务状态变化推送
|
||||
heartbeat,
|
||||
remoteControl,
|
||||
detectionReport,//障碍物消息
|
||||
switchPermission,//切换控制申请
|
||||
switchResult;//切换结果
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.business.path.LatAndLngEntity;
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WebDeviceTaskStatusMessageDTO {
|
||||
|
||||
private MesType event;
|
||||
private MesType type;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private Long taskId;
|
||||
|
||||
private String status;
|
||||
|
||||
private LatAndLngEntity entity;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -4,6 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
@Data
|
||||
public class WebStatusMessageDTO {
|
||||
private List<DeviceStatusDetail> data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.maibu.netty.handler;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.maibu.common.MiddleCommandConstant;
|
||||
import com.maibu.common.MiddleConstant;
|
||||
import com.maibu.core.business.path.LatAndLngEntity;
|
||||
import com.maibu.core.enums.MesType;
|
||||
import com.maibu.core.enums.RespondCode;
|
||||
import com.maibu.dto.*;
|
||||
import com.maibu.memory.MiddleGlobalMemory;
|
||||
@@ -107,10 +109,20 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
|
||||
String status = obj.get("status").toString();
|
||||
WebDeviceTaskStatusMessageDTO dto = new WebDeviceTaskStatusMessageDTO();
|
||||
dto.setDeviceId(deviceId);
|
||||
dto.setEvent(MesType.device_task_change);
|
||||
dto.setType(MesType.device_task_change);
|
||||
dto.setTaskId(Long.valueOf(taskId));
|
||||
dto.setStatus(status);
|
||||
WebsocketHandler.sendMessageToClient(webSocket, JsonUtils.toJsonString(dto));
|
||||
}else if ("device_task_arrive_point".equals(eventType)) {
|
||||
String taskId = obj.get("taskId").toString();
|
||||
LatAndLngEntity position = JsonUtils.parseObject(obj.get("entity").toString(),
|
||||
LatAndLngEntity.class);
|
||||
WebDeviceTaskStatusMessageDTO dto = new WebDeviceTaskStatusMessageDTO();
|
||||
dto.setDeviceId(deviceId);
|
||||
dto.setType(MesType.device_task_arrive_point);
|
||||
dto.setTaskId(Long.valueOf(taskId));
|
||||
dto.setEntity(position);
|
||||
WebsocketHandler.sendMessageToClient(webSocket, JsonUtils.toJsonString(dto));
|
||||
}
|
||||
} else {
|
||||
/* 判断 respond 字段 */
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.maibu.websocket;
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.common.MiddleConstant;
|
||||
import com.maibu.core.enums.CommandRequestType;
|
||||
import com.maibu.core.enums.MesType;
|
||||
import com.maibu.dto.*;
|
||||
import com.maibu.memory.MiddleGlobalMemory;
|
||||
import com.maibu.netty.NettyClient;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.maibu.websocket;
|
||||
|
||||
import com.maibu.core.business.inter.DeviceWebSocketInterace;
|
||||
import com.maibu.memory.MiddleGlobalMemory;
|
||||
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class WebsocketMesHandler implements DeviceWebSocketInterace {
|
||||
|
||||
@Override
|
||||
public void sendWebsoketMes(String key, String data) {
|
||||
MiddleGlobalMemory.onlineSockets.keySet().forEach(x -> {
|
||||
// key: test:web:token
|
||||
if (x.startsWith(key)) {
|
||||
WebSocket webSocket = MiddleGlobalMemory.onlineSockets.get(x);
|
||||
WebsocketHandler.sendMessageToClient(webSocket, data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user