Commit 7e058801 by 姚冰

[add] 设备离线正常处理

1 parent a9f661be
......@@ -29,6 +29,7 @@ import vion.service.monitor.IRAgentEventService;
import vion.utils.JsonUtil;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import static vion.constant.MqttMessageType.WHOLEDAYA_ANALYZE;
......@@ -112,6 +113,14 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
EventRecord eventRecord = JsonUtil.parseObject(payloadStr, EventRecord.class);
String list = (String) eventRecord.getData();
List<OfflineDevice> deviceList = JsonUtil.parseArray(list, OfflineDevice.class);
List<EventRecord> records = new ArrayList<>();
if (deviceList == null || deviceList.isEmpty()) {
EventRecord eventRecord1 = new EventRecord();
BeanUtil.copyProperties(eventRecord, eventRecord1);
eventRecord1.setEventUid(eventRecord.getEventUid());
//入库
records.add(eventRecord1);
} else {
for (int i = 0; i < deviceList.size(); i++) {
OfflineDevice device = deviceList.get(i);
EventRecord eventRecord1 = new EventRecord();
......@@ -125,7 +134,12 @@ public class MqttClientMessageListener implements IMqttClientMessageListener {
eventRecord1.setStatus(EventStatusEnum.FAIL.getCode());
}
//入库
recordService.save(eventRecord1);
records.add(eventRecord1);
}
}
if (!records.isEmpty()) {
recordService.saveBatch(records);
}
// logger.info("设备离线:{}", JSON.toJSONString(eventRecord));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!