#优化设备下线推送

This commit is contained in:
2026-09-22 13:50:19 +08:00
parent 40c6edda36
commit 1d2636f641
4 changed files with 33 additions and 24 deletions

View File

@@ -453,9 +453,9 @@ public class DeviceTaskService {
x.setTaskStausTranslate(taskStaus.getDescription());
});
list.sort(
Comparator.comparing(DevicePlanTask::getFinishTime,
Comparator.comparing(DevicePlanTask::getCreateTime,
Comparator.nullsLast(Comparator.reverseOrder()))
.thenComparing(DevicePlanTask::getCreateTime,
.thenComparing(DevicePlanTask::getFinishTime,
Comparator.nullsLast(Comparator.reverseOrder())));
return list;
}

View File

@@ -223,7 +223,7 @@ public class DeviceThreadService {
}
public List<AlarmMessage> compareErrorStandard(Long siteId, Long orgId, DeviceRunningStatusHistory history,
List<ErrorIdentificationStandard> standards) {
List<ErrorIdentificationStandard> standards) {
if (history == null || CollectionUtils.isEmpty(standards))
return null;
List<AlarmMessage> list = new ArrayList<>();
@@ -343,6 +343,8 @@ public class DeviceThreadService {
}
deviceRunStatisticsMapper.saveOrUpdate(deviceRunStatistics);
}
// todo 删除实时消息推送里面的数据
siteMemory.removeMapPushDTO(deviceId);
}
sessionManager.removeDevice(deviceId);
@@ -393,7 +395,6 @@ public class DeviceThreadService {
}, 0, 500, TimeUnit.MILLISECONDS);
}
/**
* 监控心跳
*/
@@ -404,18 +405,16 @@ public class DeviceThreadService {
if (!CollectionUtils.isEmpty(list)) {
list.forEach(x -> {
Map<String, DeviceMapPushDTO> map = x.getAllDeviceMapPush();
if (!CollectionUtils.isEmpty(map)) {
List<DeviceMapPushDTO> pushList = new ArrayList<>(map.values());
WebMapMessageDTO dto = new WebMapMessageDTO();
dto.setData(pushList);
dto.setType(MesType.mapPush);
try {
websocketMesDispather.mapMessageDispather(x.getSiteId(), JsonUtils.toJsonString(pushList));
} catch (Exception e) {
log.error("实时地图数据websocket推送失败: siteId={}, error={}", x.getSiteId(),
e.getMessage(), e);
}
List<DeviceMapPushDTO> pushList = new ArrayList<>(map.values());
WebMapMessageDTO dto = new WebMapMessageDTO();
dto.setData(pushList);
dto.setType(MesType.mapPush);
try {
websocketMesDispather.mapMessageDispather(x.getSiteId(),
JsonUtils.toJsonString(dto));
} catch (Exception e) {
log.error("实时地图数据websocket推送失败: siteId={}, error={}", x.getSiteId(),
e.getMessage(), e);
}
});
}