#优化设备下线推送
This commit is contained in:
@@ -63,10 +63,13 @@ public class SiteMemory {
|
|||||||
return deviceMapPushMap;
|
return deviceMapPushMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveMaPushDTO(String deviceId, DeviceMapPushDTO dto) {
|
public void saveMapPushDTO(String deviceId, DeviceMapPushDTO dto) {
|
||||||
deviceMapPushMap.put(deviceId, dto);
|
deviceMapPushMap.put(deviceId, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeMapPushDTO(String deviceId) {
|
||||||
|
deviceMapPushMap.remove(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
public void saveRunStatistics(DeviceRunStatistics deviceRunStatistics) {
|
public void saveRunStatistics(DeviceRunStatistics deviceRunStatistics) {
|
||||||
if (deviceRunStatistics != null && !StringUtils.isEmpty(deviceRunStatistics.getDeviceId())) {
|
if (deviceRunStatistics != null && !StringUtils.isEmpty(deviceRunStatistics.getDeviceId())) {
|
||||||
|
|||||||
@@ -162,14 +162,20 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WebStatusMessageDTO createWebDeviceLocationMessage(HostLocationRelTimeDTO locationRelTimeDTO,
|
public WebStatusMessageDTO createWebDeviceLocationMessage(HostLocationRelTimeDTO locationRelTimeDTO,
|
||||||
String deviceId) {
|
String deviceId) {
|
||||||
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
||||||
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
||||||
|
|
||||||
|
DeviceStatusDetail d = new DeviceStatusDetail();
|
||||||
|
d.setName("deviceId");
|
||||||
|
d.setValue(deviceId);
|
||||||
|
d.setUnit("");
|
||||||
|
transferData.add(d);
|
||||||
|
|
||||||
DeviceStatusDetail lat = new DeviceStatusDetail();
|
DeviceStatusDetail lat = new DeviceStatusDetail();
|
||||||
lat.setName("latitude");
|
lat.setName("latitude");
|
||||||
lat.setValue(String.valueOf(locationRelTimeDTO.getData().getLatitude()));
|
lat.setValue(String.valueOf(locationRelTimeDTO.getData().getLatitude()));
|
||||||
lat.setUnit("");
|
lat.setUnit("");
|
||||||
|
|
||||||
transferData.add(lat);
|
transferData.add(lat);
|
||||||
|
|
||||||
DeviceStatusDetail lng = new DeviceStatusDetail();
|
DeviceStatusDetail lng = new DeviceStatusDetail();
|
||||||
@@ -228,15 +234,15 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
||||||
dto.setA(Double.parseDouble(altitude.getValue()));
|
dto.setA(Double.parseDouble(altitude.getValue()));
|
||||||
dto.setId(deviceId);
|
dto.setId(deviceId);
|
||||||
// dto.setB();
|
// dto.setB();
|
||||||
// dto.setHa();
|
// dto.setHa();
|
||||||
dto.setF(fix_status.getValue());
|
dto.setF(fix_status.getValue());
|
||||||
dto.setS(status.getValue());
|
dto.setS(status.getValue());
|
||||||
dto.setLat(Double.parseDouble(lat.getValue()));
|
dto.setLat(Double.parseDouble(lat.getValue()));
|
||||||
dto.setLng(Double.parseDouble(lng.getValue()));
|
dto.setLng(Double.parseDouble(lng.getValue()));
|
||||||
dto.setT(nettyDevice.getCurrentTaskId());
|
dto.setT(nettyDevice.getCurrentTaskId());
|
||||||
dto.setY(Double.parseDouble(yaw.getValue()));
|
dto.setY(Double.parseDouble(yaw.getValue()));
|
||||||
siteMemory.saveMaPushDTO(deviceId, dto);
|
siteMemory.saveMapPushDTO(deviceId, dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,9 +383,10 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//todo 推送实时位置和状态消息到外部
|
// todo 推送实时位置和状态消息到外部
|
||||||
try {
|
try {
|
||||||
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId, String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, taskId),
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
||||||
|
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, taskId),
|
||||||
JsonUtils.toJsonString(sendDto));
|
JsonUtils.toJsonString(sendDto));
|
||||||
} catch (MqttException e) {
|
} catch (MqttException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
|||||||
@@ -453,9 +453,9 @@ public class DeviceTaskService {
|
|||||||
x.setTaskStausTranslate(taskStaus.getDescription());
|
x.setTaskStausTranslate(taskStaus.getDescription());
|
||||||
});
|
});
|
||||||
list.sort(
|
list.sort(
|
||||||
Comparator.comparing(DevicePlanTask::getFinishTime,
|
Comparator.comparing(DevicePlanTask::getCreateTime,
|
||||||
Comparator.nullsLast(Comparator.reverseOrder()))
|
Comparator.nullsLast(Comparator.reverseOrder()))
|
||||||
.thenComparing(DevicePlanTask::getCreateTime,
|
.thenComparing(DevicePlanTask::getFinishTime,
|
||||||
Comparator.nullsLast(Comparator.reverseOrder())));
|
Comparator.nullsLast(Comparator.reverseOrder())));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public class DeviceThreadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AlarmMessage> compareErrorStandard(Long siteId, Long orgId, DeviceRunningStatusHistory history,
|
public List<AlarmMessage> compareErrorStandard(Long siteId, Long orgId, DeviceRunningStatusHistory history,
|
||||||
List<ErrorIdentificationStandard> standards) {
|
List<ErrorIdentificationStandard> standards) {
|
||||||
if (history == null || CollectionUtils.isEmpty(standards))
|
if (history == null || CollectionUtils.isEmpty(standards))
|
||||||
return null;
|
return null;
|
||||||
List<AlarmMessage> list = new ArrayList<>();
|
List<AlarmMessage> list = new ArrayList<>();
|
||||||
@@ -343,6 +343,8 @@ public class DeviceThreadService {
|
|||||||
}
|
}
|
||||||
deviceRunStatisticsMapper.saveOrUpdate(deviceRunStatistics);
|
deviceRunStatisticsMapper.saveOrUpdate(deviceRunStatistics);
|
||||||
}
|
}
|
||||||
|
// todo 删除实时消息推送里面的数据
|
||||||
|
siteMemory.removeMapPushDTO(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionManager.removeDevice(deviceId);
|
sessionManager.removeDevice(deviceId);
|
||||||
@@ -393,7 +395,6 @@ public class DeviceThreadService {
|
|||||||
}, 0, 500, TimeUnit.MILLISECONDS);
|
}, 0, 500, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监控心跳
|
* 监控心跳
|
||||||
*/
|
*/
|
||||||
@@ -404,18 +405,16 @@ public class DeviceThreadService {
|
|||||||
if (!CollectionUtils.isEmpty(list)) {
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
list.forEach(x -> {
|
list.forEach(x -> {
|
||||||
Map<String, DeviceMapPushDTO> map = x.getAllDeviceMapPush();
|
Map<String, DeviceMapPushDTO> map = x.getAllDeviceMapPush();
|
||||||
if (!CollectionUtils.isEmpty(map)) {
|
List<DeviceMapPushDTO> pushList = new ArrayList<>(map.values());
|
||||||
List<DeviceMapPushDTO> pushList = new ArrayList<>(map.values());
|
WebMapMessageDTO dto = new WebMapMessageDTO();
|
||||||
WebMapMessageDTO dto = new WebMapMessageDTO();
|
dto.setData(pushList);
|
||||||
dto.setData(pushList);
|
dto.setType(MesType.mapPush);
|
||||||
dto.setType(MesType.mapPush);
|
try {
|
||||||
try {
|
websocketMesDispather.mapMessageDispather(x.getSiteId(),
|
||||||
websocketMesDispather.mapMessageDispather(x.getSiteId(), JsonUtils.toJsonString(pushList));
|
JsonUtils.toJsonString(dto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("实时地图数据websocket推送失败: siteId={}, error={}", x.getSiteId(),
|
log.error("实时地图数据websocket推送失败: siteId={}, error={}", x.getSiteId(),
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user