fix: 设备添加,默认告警码为0,告警消息排序修改,sensorErrorCode处理修改。

This commit is contained in:
tianyongbao
2026-05-12 06:56:16 +08:00
parent 28891f03ff
commit fbfacc065b
3 changed files with 20 additions and 14 deletions

View File

@@ -971,8 +971,8 @@ public class IotController extends BaseController {
Map<String, Object> deviceProperties = iotDeviceService.queryDeviceProperties(iotId);
// 初始化警告码:默认探头未校准 (OxyDetectorNoCorrect)
int warnCode = DefineDeviceWarnCode.OxyDetectorNoCorrect;
// int warnCode = DefineDeviceWarnCode.OxyDetectorNoCorrect;
int warnCode = DefineDeviceWarnCode.None;
// 如果设备离线,添加设备离线警告
if (status != null && "OFFLINE".equalsIgnoreCase(status)) {
warnCode |= DefineDeviceWarnCode.DeviceOffline;
@@ -1400,9 +1400,8 @@ public class IotController extends BaseController {
// 获取设备属性
Map<String, Object> deviceProperties = iotDeviceService.queryDeviceProperties(iotId);
// 初始化警告码:默认探头未校准 (0x0001)
int warnCode = 0x0001;
// 初始化警告码
int warnCode = DefineDeviceWarnCode.None;
// 查询该用户已有水质检测仪的名称,找到第一个不冲突的序号
java.util.List<Device> existDevices = deviceMapper.selectList(
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()

View File

@@ -1996,13 +1996,22 @@ public class DeviceDataHandler {
*/
private void handleSensorErrorCode(String deviceName, JSONObject params) {
try {
Integer rawCode = params.getInt("sensorErrorCode");
if (rawCode == null) {
// 部分设备/数据包不携带此字段,属于正常情况
log.debug("[探头错误码] 设备上报数据不包含 sensorErrorCode 字段: {}", deviceName);
// 判断字段是否存在
if (!params.containsKey("sensorErrorCode")) {
return;
}
int sensorErrorCode = rawCode;
// 字段存在但为空字符串时视为无故障0清除探头相关告警位
Object rawValue = params.get("sensorErrorCode");
int sensorErrorCode;
if (rawValue == null || "".equals(rawValue.toString().trim())) {
sensorErrorCode = 0;
} else {
Integer parsed = params.getInt("sensorErrorCode");
if (parsed == null) {
return;
}
sensorErrorCode = parsed;
}
// 查询设备,需要 id / warnCode / isOxygenUsed / pondId / deadTime
Device device = deviceMapper.selectOne(