fix: 盐度补偿设定,太阳能网控缓存逻辑修改完善。

This commit is contained in:
tianyongbao
2026-06-28 22:52:03 +08:00
parent 3b37f59aff
commit 4847f6a9e9
4 changed files with 142 additions and 27 deletions

View File

@@ -50,6 +50,9 @@ public class AmqpMessageHandlerImpl implements AmqpMessageHandler {
String topic = json.getStr("topic");
String method = json.getStr("method");
String status = json.getStr("status");
if (status != null) {
status = status.trim().toLowerCase();
}
// 检查是否是设备上线/下线消息
if (status != null && ("online".equals(status) || "offline".equals(status))) {
@@ -215,6 +218,9 @@ public class AmqpMessageHandlerImpl implements AmqpMessageHandler {
private void handleStatusMessage(JSONObject json) {
String deviceName = json.getStr("deviceName");
String status = json.getStr("status");
if (status != null) {
status = status.trim().toLowerCase();
}
log.debug("设备状态: {} - {}", deviceName, status);
@@ -235,6 +241,9 @@ public class AmqpMessageHandlerImpl implements AmqpMessageHandler {
if (action == null) {
action = json.getStr("status");
}
if (action != null) {
action = action.trim().toLowerCase();
}
log.debug("设备{}: {}", "online".equals(action) ? "上线" : "下线", deviceName);

View File

@@ -2,11 +2,13 @@ package com.intc.iot.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.intc.iot.handler.DeviceDataHandler;
import com.intc.iot.domain.IotDeviceStatus;
import com.intc.iot.mapper.IotDeviceStatusMapper;
import com.intc.iot.service.DeviceStatusService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -28,6 +30,9 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
private final IotDeviceStatusMapper deviceStatusMapper;
@Autowired(required = false)
private DeviceDataHandler deviceDataHandler;
@Override
@Transactional(rollbackFor = Exception.class)
public void handleStatusChange(Map<String, Object> statusData) {
@@ -83,6 +88,10 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
log.info("[设备状态] 新增设备状态记录 - ProductKey: {}, DeviceName: {}, Status: {}",
productKey, deviceName, status);
}
if ("online".equalsIgnoreCase(status) && deviceDataHandler != null) {
deviceDataHandler.handleDeviceOnline(deviceName);
}
} catch (Exception e) {
log.error("[设备状态] 处理设备状态变更异常: {}", e.getMessage(), e);
throw e;