Commit 73d45681 authored by maoying's avatar maoying

修改实时消息画图数据推送异常

parent 2c25df06
...@@ -300,6 +300,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -300,6 +300,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
public void publishDataToCanvas(List<EquipmentSpecificIndex> indexList) { public void publishDataToCanvas(List<EquipmentSpecificIndex> indexList) {
if (!ObjectUtils.isEmpty(indexList)) { if (!ObjectUtils.isEmpty(indexList)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
EquipmentSpecificIndex index = indexList.stream().filter(x -> x.getUpdateDate() != null) EquipmentSpecificIndex index = indexList.stream().filter(x -> x.getUpdateDate() != null)
.sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) .sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()).get(0); .collect(Collectors.toList()).get(0);
...@@ -323,16 +326,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -323,16 +326,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(equipmentStateVo)); Map<String, Object> map = JSON.parseObject(JSON.toJSONString(equipmentStateVo));
map.put(canvasTopic, topicObject); map.put(canvasTopic, topicObject);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCompletion(int status) {
if (TransactionSynchronization.STATUS_COMMITTED == status) {
// 发送数据至画布 // 发送数据至画布
mqttSendGateway.sendToMqtt(canvasTopic, JSON.toJSONString(map)); mqttSendGateway.sendToMqtt(canvasTopic, JSON.toJSONString(map));
} }
}
}); });
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment