fix: 设备添加,默认告警码为0,告警消息排序修改,sensorErrorCode处理修改。
This commit is contained in:
@@ -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);
|
||||
|
||||
// 处理额外的查询参数
|
||||
|
||||
@@ -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>()
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user