Commit 9c792fbc by 罗志长

fix: 平台设备故障状态

parent f7df7f06
package com.makeit.module.iot.vo;
import lombok.Data;
@Data
public class DeviceFaultState {
private String text;
private String value;
}
......@@ -48,6 +48,13 @@ public class DeviceInstanceEntity {
private String state;
@Schema(
description = "故障状态(只读) normal(正常), abnormal(故障)"
, accessMode = Schema.AccessMode.READ_ONLY
, defaultValue = "normal"
)
private String faultState;
@Schema(
description = "创建者ID(只读)"
, accessMode = Schema.AccessMode.READ_ONLY
)
......
......@@ -951,6 +951,12 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
DeviceState deviceState = JSON.parseObject(state, DeviceState.class);
platDevice.setStatus(deviceState.getValue());
String faultState = iotDevice.getFaultState();
DeviceFaultState deviceFaultState = JSON.parseObject(faultState, DeviceFaultState.class);
if (com.makeit.module.iot.enums.DeviceState.abnormal.getValue().equals(deviceFaultState.getValue())) {
platDevice.setStatus(deviceFaultState.getValue());
}
String categoryName = DeviceNameEnum.getNameByPrefix(productName);
platDevice.setCategory(dicNameIdMap.get(categoryName));
......@@ -968,7 +974,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus, messageType.toLowerCase())
.eq(PlatDevice::getOriDeviceId, deviceId));
.eq(PlatDevice::getOriDeviceId, deviceId)
.ne(PlatDevice::getStatus, com.makeit.module.iot.enums.DeviceState.abnormal.getValue()));
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId, deviceId);
......@@ -1210,6 +1217,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
return;
}
RedisUtil.set(key, faultState);
this.update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus, "abnormal").eq(PlatDevice::getOriDeviceId, deviceId));
log.info("设备:{} 故障处理, 设置故障", deviceId);
}
} else {
......
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 sign in to comment