From e40831c76d40fcf2302ef3cb8922ff1fb9cb3a15 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Tue, 12 May 2026 06:56:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=91=8A=E8=AD=A6=E7=A0=81=E4=B8=BA?= =?UTF-8?q?0=EF=BC=8C=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=BF=AE=E6=94=B9=EF=BC=8CsensorErrorCode=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MessageWarnServiceImpl.java | 6 ++---- .../intc/iot/controller/IotController.java | 9 ++++----- .../intc/iot/handler/DeviceDataHandler.java | 19 ++++++++++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/service/impl/MessageWarnServiceImpl.java b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/service/impl/MessageWarnServiceImpl.java index 5824bd4..47877b2 100644 --- a/intc-modules/intc-fishery/src/main/java/com/intc/fishery/service/impl/MessageWarnServiceImpl.java +++ b/intc-modules/intc-fishery/src/main/java/com/intc/fishery/service/impl/MessageWarnServiceImpl.java @@ -8,15 +8,12 @@ import com.intc.common.mybatis.core.page.PageQuery; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.intc.fishery.domain.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import com.intc.fishery.domain.bo.MessageWarnBo; import com.intc.fishery.domain.vo.MessageWarnVo; -import com.intc.fishery.domain.MessageWarn; -import com.intc.fishery.domain.AquUser; -import com.intc.fishery.domain.Device; -import com.intc.fishery.domain.Pond; import com.intc.fishery.mapper.MessageWarnMapper; import com.intc.fishery.service.IMessageWarnService; @@ -113,6 +110,7 @@ public class MessageWarnServiceImpl implements IMessageWarnService { .eq(bo.getIsRead() != null, MessageWarn::getIsRead, bo.getIsRead()) .eq(bo.getWarnType() != null, MessageWarn::getWarnType, bo.getWarnType()) .like(StringUtils.isNotBlank(bo.getPondName()), MessageWarn::getPondName, bo.getPondName()) + .orderByAsc(bo.getUserId() != null, MessageWarn::getIsRead) .orderByDesc(MessageWarn::getCreateTime); // 处理额外的查询参数 diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java index cc6c855..a28f970 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/controller/IotController.java @@ -971,8 +971,8 @@ public class IotController extends BaseController { Map 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 deviceProperties = iotDeviceService.queryDeviceProperties(iotId); - // 初始化警告码:默认探头未校准 (0x0001) - int warnCode = 0x0001; - + // 初始化警告码 + int warnCode = DefineDeviceWarnCode.None; // 查询该用户已有水质检测仪的名称,找到第一个不冲突的序号 java.util.List existDevices = deviceMapper.selectList( new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java index 2331514..5495449 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java @@ -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(