|
|
@@ -177,11 +177,18 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
|
|
|
final JSONArray data = (JSONArray) req.getData();
|
|
|
final List<AlarmDataReq> dataReqList = data.toJavaList(AlarmDataReq.class);
|
|
|
for (AlarmDataReq dataReq : dataReqList) {
|
|
|
- IotDeviceInfo deviceInfo = iotDeviceInfoService.selectByTokenProductAndDeviceCode(iotCode, req.getProductName(), dataReq.getDeviceCode());
|
|
|
+ IotDeviceInfo deviceInfo = iotDeviceInfoService.selectByTokenProductAndDeviceCode(iotCode, req.getProductName(), req.getDeviceName());
|
|
|
if (ObjectUtil.isNull(deviceInfo)) {
|
|
|
LogUtils.SOCKET_DEVICE_ALARM_DATA.error("收到设备报警消息,根据token:{},productName:{},deviceName:{}未查询到设备信息", iotCode, req.getProductName(), req.getDeviceName());
|
|
|
continue;
|
|
|
}
|
|
|
+ //此处特殊逻辑:处理新设备状态为未知的时候,上报状态切主机上经过告警规则未产生告警数据,导致设备状态一直是未知;
|
|
|
+ //此处主机会上报空对象(所有字段为null),用于通知设备状态为正常
|
|
|
+ if (dataReq.getId() == null && dataReq.getStartTime() == null) {
|
|
|
+ LogUtils.SOCKET_DEVICE_ALARM_DATA.info("收到设备报警消息,设备未产生告警,修改设备状态为正常,iotCode:{},productName:{},deviceName:{}", iotCode, req.getProductName(), req.getDeviceName());
|
|
|
+ updateStatusByDevicePrimaryId(deviceInfo.getId(), DeviceStatusEnum.NORMAL.getValue());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
final IotAlarmData iotAlarmData = BeanHelper.copyProperties(dataReq, IotAlarmData.class);
|
|
|
iotAlarmData.setOrgId(sysOrg.getId());
|
|
|
iotAlarmData.setDeviceId(String.valueOf(deviceInfo.getId()));
|