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,20 +113,33 @@ 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);
for (int i = 0; i < deviceList.size(); i++) {
OfflineDevice device = deviceList.get(i);
List<EventRecord> records = new ArrayList<>();
if (deviceList == null || deviceList.isEmpty()) {
EventRecord eventRecord1 = new EventRecord();
BeanUtil.copyProperties(eventRecord, eventRecord1);
eventRecord1.setEventUid(eventRecord.getEventUid());
eventRecord1.setData(JsonUtil.toJsonString(device));
eventRecord1.setMallUid(deviceList.get(i).getMallUid());
if (StringUtils.isEmpty(device.getDevices())) {
eventRecord1.setStatus(EventStatusEnum.SUCCESS.getCode());
} else {
eventRecord1.setStatus(EventStatusEnum.FAIL.getCode());
}
//入库
recordService.save(eventRecord1);
records.add(eventRecord1);
} else {
for (int i = 0; i < deviceList.size(); i++) {
OfflineDevice device = deviceList.get(i);
EventRecord eventRecord1 = new EventRecord();
BeanUtil.copyProperties(eventRecord, eventRecord1);
eventRecord1.setEventUid(eventRecord.getEventUid());
eventRecord1.setData(JsonUtil.toJsonString(device));
eventRecord1.setMallUid(deviceList.get(i).getMallUid());
if (StringUtils.isEmpty(device.getDevices())) {
eventRecord1.setStatus(EventStatusEnum.SUCCESS.getCode());
} else {
eventRecord1.setStatus(EventStatusEnum.FAIL.getCode());
}
//入库
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!