#update 地图统一推送功能
This commit is contained in:
@@ -102,6 +102,11 @@ public class DeviceTask {
|
||||
return builder(FastBeeConstant.TASK.DEVICE_HEARTBEAT_MONITOR);
|
||||
}
|
||||
|
||||
@Bean(FastBeeConstant.TASK.MAP_MESSAGE_PUSH)
|
||||
public Executor mapMessagePush() {
|
||||
return builder(FastBeeConstant.TASK.MAP_MESSAGE_PUSH);
|
||||
}
|
||||
|
||||
@Bean(FastBeeConstant.TASK.DEVICE_TASK_HANDLER)
|
||||
public Executor deviceTaskHandler() {
|
||||
return builder(FastBeeConstant.TASK.DEVICE_TASK_HANDLER);
|
||||
|
||||
@@ -105,6 +105,13 @@ public interface FastBeeConstant {
|
||||
* 设备错误
|
||||
*/
|
||||
String DEVICE_HEARTBEAT_MONITOR = "deviceHeartBeatMonitor";
|
||||
|
||||
/**
|
||||
* 设备错误
|
||||
*/
|
||||
String MAP_MESSAGE_PUSH = "mapMessagePush";
|
||||
|
||||
|
||||
/**
|
||||
* 设备任务处理线程
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.maibu.core.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceMapPushDTO {
|
||||
private String id;
|
||||
private double lat;
|
||||
private double lng;
|
||||
private double y; //yaw
|
||||
private double f; //fix_status
|
||||
private double a; //altitude
|
||||
private String s;//status 运行状态
|
||||
private Long t; //taskId 任务id
|
||||
private double b; //电量
|
||||
private boolean ha = false;//hasAlarm 有无告警
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.maibu.core.business.dto;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WebMapMessageDTO {
|
||||
private List<DeviceMapPushDTO> data;
|
||||
private MesType type;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.maibu.core.business.inter;
|
||||
|
||||
public interface DeviceWebSocketInterace {
|
||||
|
||||
void sendWebsoketMes(String key, String data);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.maibu.core.business.inter;
|
||||
|
||||
public interface DeviceWebSocketInterface {
|
||||
|
||||
void sendWebsocketMes(String key, String data);
|
||||
|
||||
|
||||
void sendMapWebsocketMes(Long siteId,String data);
|
||||
|
||||
}
|
||||
@@ -14,10 +14,19 @@ public class WebsocketMesDispather {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
public void dispather(String key, String data) {
|
||||
Map<String, DeviceWebSocketInterace> beanMap = applicationContext.getBeansOfType(DeviceWebSocketInterace.class);
|
||||
Map<String, DeviceWebSocketInterface> beanMap = applicationContext.getBeansOfType(DeviceWebSocketInterface.class);
|
||||
// 遍历
|
||||
beanMap.values().forEach(x -> {
|
||||
x.sendWebsoketMes(key, data);
|
||||
x.sendWebsocketMes(key, data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void mapMessageDispather(Long siteId, String data) {
|
||||
Map<String, DeviceWebSocketInterface> beanMap = applicationContext.getBeansOfType(DeviceWebSocketInterface.class);
|
||||
// 遍历
|
||||
beanMap.values().forEach(x -> {
|
||||
x.sendMapWebsocketMes(siteId, data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,5 +15,6 @@ public enum MesType {
|
||||
detectionReport, // 障碍物消息
|
||||
switchPermission, // 切换控制申请
|
||||
switchResult,// 切换结果
|
||||
route_post;// 路径规划 点位推送
|
||||
route_post,// 路径规划 点位推送
|
||||
mapPush;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.maibu.core.business.*;
|
||||
import com.maibu.core.business.dto.DeviceMapPushDTO;
|
||||
import com.maibu.mqtt.CustomMqttDeviceMonitor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
@@ -56,6 +57,17 @@ public class SiteMemory {
|
||||
// 记录 设备上线后的运行数据 下线后清除并保存到数据库
|
||||
public static ConcurrentHashMap<String, DeviceRunStatistics> deviceRunStatisticsMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceMapPushDTO> deviceMapPushMap = new ConcurrentHashMap<>();
|
||||
|
||||
public Map<String, DeviceMapPushDTO> getAllDeviceMapPush() {
|
||||
return deviceMapPushMap;
|
||||
}
|
||||
|
||||
public void saveMaPushDTO(String deviceId, DeviceMapPushDTO dto) {
|
||||
deviceMapPushMap.put(deviceId, dto);
|
||||
}
|
||||
|
||||
|
||||
public void saveRunStatistics(DeviceRunStatistics deviceRunStatistics) {
|
||||
if (deviceRunStatistics != null && !StringUtils.isEmpty(deviceRunStatistics.getDeviceId())) {
|
||||
deviceRunStatisticsMap.put(deviceRunStatistics.getDeviceId(), deviceRunStatistics);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.maibu.mqtt;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.maibu.core.business.dto.DeviceMapPushDTO;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -160,7 +161,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
}
|
||||
|
||||
public WebStatusMessageDTO createWebDeviceLocationMessage(HostLocationRelTimeDTO locationRelTimeDTO,
|
||||
String deviceId) {
|
||||
String deviceId) {
|
||||
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
||||
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
||||
DeviceStatusDetail lat = new DeviceStatusDetail();
|
||||
@@ -217,6 +218,27 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
|
||||
webStatusMessageDTO.setData(transferData);
|
||||
webStatusMessageDTO.setType(MesType.locationInfo);
|
||||
|
||||
if (nettyDevice != null && nettyDevice.getDevice() != null) {
|
||||
Long siteId = nettyDevice.getDevice().getSiteId();
|
||||
Long orgId = nettyDevice.getDevice().getOrgId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
||||
dto.setA(Double.parseDouble(altitude.getValue()));
|
||||
dto.setId(deviceId);
|
||||
// dto.setB();
|
||||
// dto.setHa();
|
||||
dto.setF(Double.parseDouble(fix_status.getValue()));
|
||||
dto.setS(status.getValue());
|
||||
dto.setLat(Double.parseDouble(lat.getValue()));
|
||||
dto.setLng(Double.parseDouble(lng.getValue()));
|
||||
dto.setT(nettyDevice.getCurrentTaskId());
|
||||
dto.setY(Double.parseDouble(yaw.getValue()));
|
||||
siteMemory.saveMaPushDTO(deviceId, dto);
|
||||
}
|
||||
}
|
||||
|
||||
return webStatusMessageDTO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user