Commit 76688392 by guoxuejian Committed by gdj

fix: handle case when sub device is not found in DeviceServiceImpl

parent a46bbeeb
......@@ -280,7 +280,13 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
return;
}
DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build()).get(0);
List<DeviceDTO> subDevices = getDevicesByParams(DeviceQueryParam.builder().deviceSn(gateway.getChildDeviceSn()).build());
if (CollectionUtils.isEmpty(subDevices)) {
log.warn("sub device not found, gatewaySn={}, childDeviceSn={}", gateway.getDeviceSn(), gateway.getChildDeviceSn());
return;
}
DeviceDTO subDevice = subDevices.get(0);
subDevice.setStatus(deviceRedisService.checkDeviceOnline(subDevice.getDeviceSn()));
gateway.setChildren(subDevice);
......
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