This commit is contained in:
2026-06-17 09:14:42 +08:00
parent 3879cd0067
commit a68a670ecb
27 changed files with 1053 additions and 392 deletions

View File

@@ -1,10 +0,0 @@
package com.maibu.dto;
import lombok.Data;
@Data
public class DeviceStatusDetail {
private String name;
private String value;
private String unit;
}

View File

@@ -1,13 +0,0 @@
package com.maibu.dto;
import lombok.Data;
import java.util.List;
import com.maibu.core.enums.MesType;
@Data
public class WebStatusMessageDTO {
private List<DeviceStatusDetail> data;
private MesType type;
}

View File

@@ -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.device.DeviceStatusDetail;
import com.maibu.core.business.inter.WebsocketMesDispather;
import com.maibu.core.business.path.LatAndLngEntity;
import com.maibu.core.enums.MesType;
import com.maibu.core.enums.RespondCode;
@@ -37,6 +39,8 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
private static final HttpService httpService = SpringUtils.getBean(HttpService.class);
private final WebsocketMesDispather websocketMesDispather = SpringUtils.getBean(WebsocketMesDispather.class);
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
try {
@@ -113,7 +117,7 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
dto.setTaskId(Long.valueOf(taskId));
dto.setStatus(status);
WebsocketHandler.sendMessageToClient(webSocket, JsonUtils.toJsonString(dto));
}else if ("device_task_arrive_point".equals(eventType)) {
} else if ("device_task_arrive_point".equals(eventType)) {
String taskId = obj.get("taskId").toString();
LatAndLngEntity position = JsonUtils.parseObject(obj.get("entity").toString(),
LatAndLngEntity.class);
@@ -179,13 +183,14 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
}
} else if (isStatusDate(data)) {
// 状态消息推送给前端
WebStatusMessageDTO dto = createWebDeviceStatusMessage(data);
WebsocketHandler.sendMessageToClient(webSocket, JsonUtils.toJsonString(dto));
// WebStatusMessageDTO dto = createWebDeviceStatusMessage(data);
// WebsocketHandler.sendMessageToClient(webSocket, JsonUtils.toJsonString(dto));
// String[] k = key.split(":");
// String deviceId = k[0] + ":" + k[1];
// websocketMesDispather.dispather(deviceId,JsonUtils.toJsonString(dto));
} else if (isPath(data)) {
// 已到达
if (data[5] == (byte) 0x01) {
}
}
} catch (Exception e) {
logger.error("channelRead error:{}", e.getMessage());