From 241fcb033394a5d49efb754a5f30e76c28b3ac46 Mon Sep 17 00:00:00 2001 From: George Date: Sat, 10 Jan 2026 16:00:41 +0800 Subject: [PATCH] =?UTF-8?q?20260110:=201=E3=80=81=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E5=BC=80=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/data/aspect/DeviceDebugLogAspect.java | 99 ------------------- vue/src/api/iot/mqttTest.js | 30 +++--- .../views/iot/device/instruction-parsing.vue | 23 +---- 3 files changed, 16 insertions(+), 136 deletions(-) diff --git a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java index 0586faeb..3c1eb7b0 100644 --- a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java +++ b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/aspect/DeviceDebugLogAspect.java @@ -2,7 +2,6 @@ package com.fastbee.iot.data.aspect; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.fastbee.common.constant.CacheConstants; import com.fastbee.common.core.device.DeviceAndProtocol; import com.fastbee.common.core.mq.DeviceReportBo; import com.fastbee.common.core.mq.message.DeviceData; @@ -11,8 +10,6 @@ import com.fastbee.common.core.redis.RedisCache; import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem; import com.fastbee.common.enums.DeviceLogTypeEnum; import com.fastbee.common.enums.TopicType; -import com.fastbee.common.utils.DateUtils; -import com.fastbee.common.utils.SecurityUtils; import com.fastbee.common.utils.StringUtils; import com.fastbee.common.utils.gateway.mq.TopicsUtils; import com.fastbee.iot.domain.*; @@ -60,23 +57,6 @@ import java.util.function.Function; @Slf4j public class DeviceDebugLogAspect { - /** - * 日志值最大长度 - */ - private static final int MAX_LOG_VALUE_LENGTH = 64; - /** - * 备注最大长度 - */ - private static final int MAX_REMARK_LENGTH = 200; - /** - * 错误信息显示最大长度 - */ - private static final int MAX_ERROR_MSG_DISPLAY_LENGTH = 50; - /** - * 其他模式 - */ - private static final int MODE_OTHER = 3; - @Resource private ILogService logService; @@ -220,11 +200,6 @@ public class DeviceDebugLogAspect { return; } - // 检查用户是否在数据调试页面 - if (!isUserInDebugPage(context.getSerialNumber())) { - return; - } - saveErrorLog(context); } catch (Exception ex) { log.error("{}: {}", errorLogPrefix, ex.getMessage(), ex); @@ -300,48 +275,7 @@ public class DeviceDebugLogAspect { } @Resource private IDeviceUserService deviceUserService; - /** - * 检查当前用户是否在数据调试页面 - * @return true-在调试页面,false-不在调试页面 - */ - private boolean isUserInDebugPage(String serialNumber) { - // 1、从Redis中获取用户ID - - // 2、从SecurityContext中获取用户ID -// try { -// Long userId = SecurityUtils.getUserId(); -// if (userId == null) { -// return false; -// } -// String cacheKey = CacheConstants.DEVICE_DEBUG_USER_KEY + userId; -// String flag = redisCache.getCacheObject(cacheKey); -// return "1".equals(flag); -// } catch (Exception e) { -// // 如果获取用户信息失败,默认不记录日志,避免影响正常功能 -// log.debug("无法从SecurityContext获取用户ID(可能在异步线程中)"); -// } - - - // 3、从数据库中获取用户ID - try { - // 获取设备信息 - Device device = getDeviceBySerialNumber(serialNumber); - if (device == null || device.getTenantId() == null) { - return false; - } - String cacheKey = CacheConstants.DEVICE_DEBUG_USER_KEY + device.getTenantId(); - String flag = redisCache.getCacheObject(cacheKey); - if ("1".equals(flag)) { - log.debug("检测到设备[{}]的关联用户[{}]开启了调试标志", serialNumber, device.getTenantId()); - return true; - } - return false; - } catch (Exception e) { - log.warn("检查设备用户调试状态失败: {}, 设备编号: {}", e.getMessage(), serialNumber); - return false; - } - } /** * 检查设备是否已授权 @@ -400,15 +334,6 @@ public class DeviceDebugLogAspect { return; } - // 构建并保存设备日志 -// DeviceLog deviceLog = buildDeviceLog(device, context); -// logService.saveDeviceLog(deviceLog); -// if (log.isDebugEnabled()) { -// log.debug("已保存错误日志到数据库 - 设备: {}, 错误类型: {}, 错误信息: {}", -// serialNumber, context.getIdentity(), -// StringUtils.substring(context.getErrorMsg(), 0, MAX_ERROR_MSG_DISPLAY_LENGTH)); -// } - // 推送错误信息到前端页面 pushErrorToFrontend(serialNumber, productId, context); } catch (Exception ex) { @@ -428,30 +353,6 @@ public class DeviceDebugLogAspect { } } - /** - * 构建设备日志对象 - */ - private DeviceLog buildDeviceLog(Device device, ErrorLogContext context) { - DeviceLog deviceLog = new DeviceLog(); - deviceLog.setSerialNumber(context.getSerialNumber()); - deviceLog.setDeviceId(device.getDeviceId()); - deviceLog.setDeviceName(device.getDeviceName()); - deviceLog.setLogType(context.getLogType()); - deviceLog.setLogValue(StringUtils.substring(context.getSourceData(), 0, MAX_LOG_VALUE_LENGTH)); - deviceLog.setRemark(StringUtils.substring(context.getErrorMsg(), 0, MAX_REMARK_LENGTH)); - deviceLog.setIdentity(context.getIdentity()); - deviceLog.setModelName(Objects.equals(context.getLogType(), DeviceLogTypeEnum.DATA_PARSE_ERROR.getType()) ? - "数据解析错误" : "指令发送错误"); - deviceLog.setCreateTime(DateUtils.getNowDate()); - deviceLog.setUserId(device.getTenantId()); - deviceLog.setUserName(device.getTenantName()); - deviceLog.setTenantId(device.getTenantId()); - deviceLog.setTenantName(device.getTenantName()); - deviceLog.setIsMonitor(0); - deviceLog.setMode(MODE_OTHER); - return deviceLog; - } - /** * 推送错误信息到前端页面 */ diff --git a/vue/src/api/iot/mqttTest.js b/vue/src/api/iot/mqttTest.js index e429b8eb..9f191d3a 100644 --- a/vue/src/api/iot/mqttTest.js +++ b/vue/src/api/iot/mqttTest.js @@ -62,18 +62,18 @@ export function delPreferences(data) { }); } -// 开启设备调试日志记录 -export function enableDebugLog() { - return request({ - url: '/iot/device/debug/enable', - method: 'post', - }); -} - -// 关闭设备调试日志记录 -export function disableDebugLog() { - return request({ - url: '/iot/device/debug/disable', - method: 'post', - }); -} +// 开启设备调试日志记录(先关闭) +//export function enableDebugLog() { +// return request({ +// url: '/iot/device/debug/enable', +// method: 'post', +// }); +//} +// +//// 关闭设备调试日志记录 +//export function disableDebugLog() { +// return request({ +// url: '/iot/device/debug/disable', +// method: 'post', +// }); +//} diff --git a/vue/src/views/iot/device/instruction-parsing.vue b/vue/src/views/iot/device/instruction-parsing.vue index b9a86fbd..b42bdaa2 100644 --- a/vue/src/views/iot/device/instruction-parsing.vue +++ b/vue/src/views/iot/device/instruction-parsing.vue @@ -375,7 +375,7 @@