chejianzheng 4 месяцев назад
Родитель
Сommit
f05b508a8d

+ 8 - 7
device-service-application/src/main/java/com/hfln/device/application/service/impl/DeviceEventServiceImpl.java

@@ -211,10 +211,10 @@ public class DeviceEventServiceImpl implements DeviceEventService {
             
             // 保存设备
             Device savedDevice = deviceGateway.saveDevice(newDevice);
-            if (savedDevice != null) {
+            if (newDevice != null) {
                 // 添加到缓存
-                deviceManagerService.updateDeviceInCache(savedDevice);
-                device = savedDevice;
+                deviceManagerService.updateDeviceInCache(newDevice);
+                device = newDevice;
                 
                 // 更新设备在线状态
                 deviceGateway.updateDeviceOnlineStatus(deviceId, 1);
@@ -1477,8 +1477,8 @@ public class DeviceEventServiceImpl implements DeviceEventService {
             
             // 解析其他字段
             Map<String, Object> fallingStateMachineDurations = (Map<String, Object>) messageData.get("fallingStateMachineDurations");  // fallingStateMachineDurations = payload["fallingStateMachineDurations"]
-            Boolean is45Degree = (Boolean) messageData.get("is45Degree");                 // is45Degree = payload["is45Degree"]
-            Boolean isCeiling = (Boolean) messageData.get("isCeiling");                   // isCeiling = payload["isCeiling"]
+            int is45Degree = (int) messageData.get("is45Degree");                 // is45Degree = payload["is45Degree"]
+            int isCeiling = (int) messageData.get("isCeiling");                   // isCeiling = payload["isCeiling"]
             
             // === 构造安装参数对象 (对应Python: install_param = InstallParam(mount_plain="", height=sensor_height, tracking_region=TrackingRegion(x1,y1,z1,x2,y2,z2))) ===
             Device.TrackingRegion trackingRegion = new Device.TrackingRegion();
@@ -1492,7 +1492,8 @@ public class DeviceEventServiceImpl implements DeviceEventService {
             Device.InstallParam installParam = new Device.InstallParam();
             installParam.setMountPlain("");                    // mount_plain=""
             installParam.setHeight(sensorHeight);              // height=sensor_height
-            installParam.setIsCeiling(isCeiling != null ? (isCeiling ? 1 : 0) : 0);  // is_ceiling处理
+//            installParam.setIsCeiling(isCeiling != null ? (isCeiling ? 1 : 0) : 0);  // is_ceiling处理
+            installParam.setIsCeiling(isCeiling);  // is_ceiling处理
             installParam.setTrackingRegion(trackingRegion);    // tracking_region=TrackingRegion(...)
             
             // === 更新设备信息 (对应Python的三行核心操作) ===
@@ -1618,7 +1619,7 @@ public class DeviceEventServiceImpl implements DeviceEventService {
                 Device.NetworkInfo network = new Device.NetworkInfo();
                 network.setIp(deviceIp);
                 
-                Device device = new Device();
+                Device device = new Device(deviceId);
                 device.setDevId(deviceId);
                 device.updateOnlineStatus(1);
                 device.setDevType(deviceType);

+ 4 - 0
device-service-domain/src/main/java/com/hfln/device/domain/entity/Device.java

@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -730,6 +731,9 @@ public class Device {
             long currentTime = System.currentTimeMillis();
             
             // 更新所有告警计划的目标
+            if (CollectionUtils.isEmpty(alarmPlanMap)) {
+                return;
+            }
             for (AlarmPlan plan : alarmPlanMap.values()) {
                 plan.updateTarget(targets, currentTime);
             }

+ 4 - 4
device-service-infrastructure/src/main/java/com/hfln/device/infrastructure/config/MybatisPlusConfig.java

@@ -31,8 +31,8 @@ public class MybatisPlusConfig {
      * 审计字段自动填充
      * @return {@link MetaObjectHandler}
      */
-//    @Bean
-//    public MybatisPlusMetaObjectHandler mybatisPlusMetaObjectHandler() {
-//        return new MybatisPlusMetaObjectHandler();
-//    }
+    @Bean
+    public MybatisPlusMetaObjectHandler mybatisPlusMetaObjectHandler() {
+        return new MybatisPlusMetaObjectHandler();
+    }
 }

+ 72 - 71
device-service-infrastructure/src/main/java/com/hfln/device/infrastructure/config/MybatisPlusMetaObjectHandler.java

@@ -1,78 +1,79 @@
-//package com.hfln.device.infrastructure.config;
-//
-//import cn.hutool.core.util.StrUtil;
-//import cn.hfln.framework.common.security.LoginUser;
-//import cn.hfln.framework.common.security.utils.SecurityUtils;
-//import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-//import lombok.extern.slf4j.Slf4j;
-//import org.apache.ibatis.reflection.MetaObject;
-//import org.springframework.util.ClassUtils;
-//
-//import java.nio.charset.Charset;
-//import java.util.Date;
-//
-///**
-// * MybatisPlus 鑷姩濉厖閰嶇疆
-// *
-// */
-//@Slf4j
-//public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
-//
-//	@Override
-//	public void insertFill(MetaObject metaObject) {
-//		log.debug("mybatis plus start insert fill ....");
-//		Date now = new Date();
-//
-//		fillValIfNullByName("createTime", now, metaObject, false);
-//		fillValIfNullByName("updateTime", now, metaObject, false);
-//		fillValIfNullByName("createBy", getUserName(), metaObject, false);
-//		fillValIfNullByName("updateBy", getUserName(), metaObject, false);
-//	}
-//
-//	@Override
-//	public void updateFill(MetaObject metaObject) {
-//		log.debug("mybatis plus start update fill ....");
-//		fillValIfNullByName("updateTime", new Date(), metaObject, true);
-//		fillValIfNullByName("updateBy", getUserName(), metaObject, true);
-//	}
-//
-//	/**
-//	 * 濉厖鍊硷紝鍏堝垽鏂槸鍚︽湁鎵嬪姩璁剧疆锛屼紭鍏堟墜鍔ㄨ缃殑鍊硷紝渚嬪锛歫ob蹇呴』鎵嬪姩璁剧疆
-//	 * @param fieldName 灞炴€у悕
-//	 * @param fieldVal 灞炴€у€?
-//	 * @param metaObject MetaObject
-//	 * @param isCover 鏄惁瑕嗙洊鍘熸湁鍊?閬垮厤鏇存柊鎿嶄綔鎵嬪姩鍏ュ弬
-//	 */
-//	private static void fillValIfNullByName(String fieldName, Object fieldVal, MetaObject metaObject, boolean isCover) {
-//		// 1. 娌℃湁 set 鏂规硶
-//		if (!metaObject.hasSetter(fieldName)) {
-//			return;
-//		}
-//		// 2. 濡傛灉鐢ㄦ埛鏈夋墜鍔ㄨ缃殑鍊?
-//		Object userSetValue = metaObject.getValue(fieldName);
-//		String setValueStr = StrUtil.str(userSetValue, Charset.defaultCharset());
-//		if (StrUtil.isNotBlank(setValueStr) && !isCover) {
-//			return;
-//		}
-//		// 3. field 绫诲瀷鐩稿悓鏃惰缃?
-//		Class<?> getterType = metaObject.getGetterType(fieldName);
-//		if (ClassUtils.isAssignableValue(getterType, fieldVal)) {
-//			metaObject.setValue(fieldName, fieldVal);
-//		}
-//	}
-//
-//	/**
-//	 * 鑾峰彇 spring security 褰撳墠鐨勭敤鎴峰悕
-//	 * @return 褰撳墠鐢ㄦ埛鍚?
-//	 */
-//	private String getUserName() {
+package com.hfln.device.infrastructure.config;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.util.ClassUtils;
+
+import java.nio.charset.Charset;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * MybatisPlus 鑷姩濉厖閰嶇疆
+ *
+ */
+@Slf4j
+public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
+
+	@Override
+	public void insertFill(MetaObject metaObject) {
+		log.debug("mybatis plus start insert fill ....");
+		LocalDateTime now = LocalDateTime.now();
+
+		fillValIfNullByName("createTime", now, metaObject, false);
+		fillValIfNullByName("updateTime", now, metaObject, false);
+		fillValIfNullByName("createId", getUserId(), metaObject, false);
+		fillValIfNullByName("updateId", getUserId(), metaObject, false);
+	}
+
+	@Override
+	public void updateFill(MetaObject metaObject) {
+		log.debug("mybatis plus start update fill ....");
+		fillValIfNullByName("updateTime", LocalDateTime.now(), metaObject, true);
+		fillValIfNullByName("updateId", getUserId(), metaObject, true);
+	}
+
+	/**
+	 * 濉厖鍊硷紝鍏堝垽鏂槸鍚︽湁鎵嬪姩璁剧疆锛屼紭鍏堟墜鍔ㄨ缃殑鍊硷紝渚嬪锛歫ob蹇呴』鎵嬪姩璁剧疆
+	 * @param fieldName 灞炴€у悕
+	 * @param fieldVal 灞炴€у€?
+	 * @param metaObject MetaObject
+	 * @param isCover 鏄惁瑕嗙洊鍘熸湁鍊?閬垮厤鏇存柊鎿嶄綔鎵嬪姩鍏ュ弬
+	 */
+	private static void fillValIfNullByName(String fieldName, Object fieldVal, MetaObject metaObject, boolean isCover) {
+		// 1. 娌℃湁 set 鏂规硶
+		if (!metaObject.hasSetter(fieldName)) {
+			return;
+		}
+		// 2. 濡傛灉鐢ㄦ埛鏈夋墜鍔ㄨ缃殑鍊?
+		Object userSetValue = metaObject.getValue(fieldName);
+		String setValueStr = StrUtil.str(userSetValue, Charset.defaultCharset());
+		if (StrUtil.isNotBlank(setValueStr) && !isCover) {
+			return;
+		}
+		// 3. field 绫诲瀷鐩稿悓鏃惰缃?
+		Class<?> getterType = metaObject.getGetterType(fieldName);
+		if (ClassUtils.isAssignableValue(getterType, fieldVal)) {
+			metaObject.setValue(fieldName, fieldVal);
+		}
+	}
+
+	/**
+	 * 鑾峰彇 spring security 褰撳墠鐨勭敤鎴峰悕
+	 * @return 褰撳墠鐢ㄦ埛鍚?
+	 */
+	private Long getUserId() {
+
+	    return 0L;
 //		LoginUser loginUser = SecurityUtils.getLoginUser();
 //		if (loginUser == null){
 //			return "";
 //		}
 //		return loginUser.getUsername();
-//	}
-//
-//}
+	}
+
+}
 
 

+ 21 - 22
device-service-infrastructure/src/main/java/com/hfln/device/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -31,7 +31,6 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -162,7 +161,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             boolean flag = devInfoService.update(null,
                     Wrappers.<DevInfo>lambdaUpdate()
                             .set(DevInfo::getUserId, null)
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getClientId, deviceId));
             //更新设备分享表
             boolean flagV2 = devShareService.update(null,
                     Wrappers.<DevShare>lambdaUpdate()
@@ -189,7 +188,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         // 1. 检查设备是否存在
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, request.getDevId())
+                        .eq(DevInfo::getClientId, request.getDevId())
         );
         if (Objects.isNull(devInfo)) {
             throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
@@ -199,7 +198,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
 
         // 3. 更新设备信息
-        return devInfoService.updateDevice(devInfo.getDevInfoId(), request);
+        return devInfoService.updateDevice(devInfo.getDevId(), request);
     }
 
 
@@ -207,7 +206,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
     public DeviceDTO queryDeviceById(String deviceId) {
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, deviceId));
+                        .eq(DevInfo::getClientId, deviceId));
         if (Objects.isNull(devInfo)) {
             throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
         }
@@ -284,7 +283,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         Boolean flag = devInfoService.updateDevice(request.getDevId(), request);
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, request.getDevId()));
+                        .eq(DevInfo::getClientId, request.getDevId()));
 
         //检查parts.length >= 2确保数组有足够元素,提供默认值"2.0"
         String result = Optional.ofNullable(devInfo.getSoftware())
@@ -314,7 +313,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
 
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
-                        .eq(DevInfo::getDevId, params.getDeviceId()));
+                        .eq(DevInfo::getClientId, params.getDeviceId()));
         if (Objects.isNull(devInfo)) {
             throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
         }
@@ -369,7 +368,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 查询设备信息
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, devId));
+                            .eq(DevInfo::getClientId, devId));
             
             if (devInfo == null) {
                 log.warn("设备不存在: {}", devId);
@@ -399,7 +398,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 检查设备是否已存在
             DevInfo existingDevice = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, device.getDevId()));
+                            .eq(DevInfo::getClientId, device.getDevId()));
             
             DevInfo devInfo;
             if (existingDevice != null) {
@@ -430,7 +429,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
      */
     private DevInfo createDeviceInfo(Device device) {
         DevInfo devInfo = new DevInfo();
-        devInfo.setDevId(device.getDevId());
+        devInfo.setClientId(device.getDevId());
         devInfo.setOnline(device.getOnline());
         devInfo.setDevType(device.getDevType());
         devInfo.setSoftware(device.getSoftware());
@@ -516,7 +515,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             boolean updateResult = devInfoService.update(
                     Wrappers.<DevInfo>lambdaUpdate()
                             .set(DevInfo::getOnline, online)
-                            .eq(DevInfo::getDevId, devId));
+                            .eq(DevInfo::getClientId, devId));
             
             if (!updateResult) {
                 log.warn("更新设备在线状态失败: 设备不存在或更新失败, ID={}", devId);
@@ -526,7 +525,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 获取更新后的设备信息
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, devId));
+                            .eq(DevInfo::getClientId, devId));
             
             if (devInfo != null) {
                 // 转换为领域对象
@@ -643,7 +642,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 查询设备是否存在
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getClientId, deviceId));
             return devInfo != null;
         } catch (Exception e) {
             // 记录错误日志
@@ -658,7 +657,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 查询设备是否已被绑定
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getClientId, deviceId));
             return devInfo != null && devInfo.getUserId() != null;
         } catch (Exception e) {
             // 记录错误日志
@@ -686,7 +685,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 检查设备是否存在
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getClientId, deviceId));
             if (devInfo == null) {
                 return false;
             }
@@ -700,7 +699,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             boolean updateResult = devInfoService.update(
                     Wrappers.<DevInfo>lambdaUpdate()
                             .set(DevInfo::getUserId, userId)
-                            .eq(DevInfo::getDevId, deviceId));
+                            .eq(DevInfo::getClientId, deviceId));
             
             return updateResult;
         } catch (Exception e) {
@@ -884,7 +883,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 查询设备记录
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId)
+                            .eq(DevInfo::getClientId, deviceId)
             );
             
             if (devInfo == null) {
@@ -934,7 +933,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             
             // 创建设备信息
             DevInfo devInfo = new DevInfo();
-            devInfo.setDevId(deviceId);
+            devInfo.setClientId(deviceId);
             
             // 设置设备类型
             if (deviceInfo.containsKey("devType")) {
@@ -995,7 +994,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 更新设备信息
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, device.getDevId())
+                            .eq(DevInfo::getClientId, device.getDevId())
             );
             
             if (devInfo != null) {
@@ -1045,7 +1044,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
         
         Device device = Device.builder()
-                .devId(devInfo.getDevId())
+                .devId(devInfo.getClientId())
                 .online(devInfo.getOnline())
                 .devType(devInfo.getDevType())
                 .software(devInfo.getSoftware())
@@ -1071,7 +1070,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 查询设备记录
             DevInfo devInfo = devInfoService.getOne(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId)
+                            .eq(DevInfo::getClientId, deviceId)
             );
             
             if (devInfo == null) {
@@ -1460,7 +1459,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
             // 删除设备信息
             boolean result = devInfoService.remove(
                     Wrappers.<DevInfo>lambdaQuery()
-                            .eq(DevInfo::getDevId, deviceId)
+                            .eq(DevInfo::getClientId, deviceId)
             );
             
             // 删除设备相关的区域信息

+ 10 - 10
device-service-infrastructure/src/main/java/com/hfln/device/infrastructure/po/DevInfo.java

@@ -17,14 +17,14 @@ public class DevInfo extends BasePO {
     /**
      * 主键ID
      */
-    @TableId(value = "dev_info_id", type = IdType.ASSIGN_ID)
-    private Long devInfoId;
+    @TableId(value = "dev_id", type = IdType.ASSIGN_ID)
+    private Long devId;
 
     /**
      * 设备ID
      */
-    @TableField("dev_id")
-    private String devId;
+    @TableField("client_id")
+    private String clientId;
 
     /**
      * 用户openid
@@ -184,8 +184,8 @@ public class DevInfo extends BasePO {
     /**
      * 设备保活时间戳(毫秒)
      */
-    @TableField("keepalive_time")
-    private Long keepaliveTime;
+//    @TableField("keepalive_time")
+//    private Long keepaliveTime;
 
     /**
      * 设备信息常量类
@@ -226,16 +226,16 @@ public class DevInfo extends BasePO {
     }
 
     // 补全所有字段的 getter/setter 方法
-    public String getDevId() { return this.devId; }
-    public void setDevId(String devId) { this.devId = devId; }
+    public String getClientId() { return this.clientId; }
+    public void setClientId(String clientId) { this.clientId = clientId; }
     public Integer getOnline() { return this.online; }
     public void setOnline(Integer online) { this.online = online; }
     public String getDevType() { return this.devType; }
     public void setDevType(String devType) { this.devType = devType; }
     public String getHardware() { return this.hardware; }
     public void setHardware(String hardware) { this.hardware = hardware; }
-    public Long getKeepaliveTime() { return this.keepaliveTime; }
-    public void setKeepaliveTime(Long keepaliveTime) { this.keepaliveTime = keepaliveTime; }
+    public Long getKeepaliveTime() { return 0L; }
+    public void setKeepaliveTime(Long keepaliveTime) {/* this.keepaliveTime = keepaliveTime;*/ }
     public String getWifiName() { return this.wifiName; }
     public void setWifiName(String wifiName) { this.wifiName = wifiName; }
     public String getWifiPassword() { return this.wifiPassword; }

+ 15 - 15
device-service-infrastructure/src/main/java/com/hfln/device/infrastructure/service/impl/DevInfoServiceImpl.java

@@ -33,14 +33,14 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
 
         // 用户设备+共享设备条件
         if (CollectionUtils.isNotEmpty(sharedDevIds)) {
-            wrapper.nested(qw -> qw.eq(DevInfo::getUserId, userId).or().in(DevInfo::getDevId, sharedDevIds));
+            wrapper.nested(qw -> qw.eq(DevInfo::getUserId, userId).or().in(DevInfo::getClientId, sharedDevIds));
         } else {
             wrapper.eq(DevInfo::getUserId, userId);
         }
 
         // 关键字查询条件
         if (Objects.nonNull(keyWord)) {
-            wrapper.and(qw -> qw.like(DevInfo::getDevName, keyWord).or().like(DevInfo::getDevId, keyWord));
+            wrapper.and(qw -> qw.like(DevInfo::getDevName, keyWord).or().like(DevInfo::getClientId, keyWord));
         }
 
         // 状态查询条件
@@ -69,7 +69,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
     public List<DevInfo> queryDevices(Long userId, String deviceId) {
         LambdaQueryWrapper<DevInfo> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(DevInfo::getUserId, userId);
-        wrapper.eq(DevInfo::getDevId, deviceId);
+        wrapper.eq(DevInfo::getClientId, deviceId);
         return this.baseMapper.selectList(wrapper);
     }
 
@@ -82,7 +82,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
 
         // 构建更新条件
         UpdateWrapperBuilder<DevInfo> builder = UpdateWrapperBuilder.<DevInfo>create()
-                .setIfNotNull(DevInfo::getDevId, request.getDevId())
+                .setIfNotNull(DevInfo::getClientId, request.getDevId())
                 .setIfNotNull(DevInfo::getUserId, request.getUserId())
                 .setIfNotBlank(DevInfo::getDevName, request.getDevName())
                 .setIfNotNull(DevInfo::getLength, request.getLength())
@@ -101,9 +101,9 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
 
         // 根据identifier类型决定使用哪个条件
         if (identifier instanceof Long) {
-            builder.eq(DevInfo::getDevInfoId, identifier);
-        } else if (identifier instanceof String) {
             builder.eq(DevInfo::getDevId, identifier);
+        } else if (identifier instanceof String) {
+            builder.eq(DevInfo::getClientId, identifier);
         } else {
             throw new IllegalArgumentException("不支持的设备标识类型");
         }
@@ -119,7 +119,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
     
     @Override
     public Boolean registerDevice(DevInfo devInfo) {
-        if (Objects.isNull(devInfo) || Objects.isNull(devInfo.getDevId())) {
+        if (Objects.isNull(devInfo) || Objects.isNull(devInfo.getClientId())) {
             log.error("设备注册失败:设备信息或设备ID为空");
             return false;
         }
@@ -127,12 +127,12 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
         try {
             // 检查设备是否已存在
             LambdaQueryWrapper<DevInfo> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(DevInfo::getDevId, devInfo.getDevId());
+            queryWrapper.eq(DevInfo::getClientId, devInfo.getClientId());
             DevInfo existDevice = this.getOne(queryWrapper);
             
             if (existDevice != null) {
                 // 设备已存在,更新设备信息
-                devInfo.setDevInfoId(existDevice.getDevInfoId());
+                devInfo.setDevId(existDevice.getDevId());
                 devInfo.setOnline(1);
                 devInfo.setUpdateTime(LocalDateTime.now());
                 return this.updateById(devInfo);
@@ -159,7 +159,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
         
         try {
             LambdaUpdateWrapper<DevInfo> updateWrapper = new LambdaUpdateWrapper<>();
-            updateWrapper.eq(DevInfo::getDevId, devId)
+            updateWrapper.eq(DevInfo::getClientId, devId)
                     .set(DevInfo::getOnline, online)
                     .set(DevInfo::getUpdateTime, LocalDateTime.now());
             
@@ -179,7 +179,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
         
         try {
             LambdaUpdateWrapper<DevInfo> updateWrapper = new LambdaUpdateWrapper<>();
-            updateWrapper.eq(DevInfo::getDevId, devId)
+            updateWrapper.eq(DevInfo::getClientId, devId)
                     .set(DevInfo::getKeepaliveTime, keepaliveTime)
                     .set(DevInfo::getOnline, 1)
                     .set(DevInfo::getUpdateTime, LocalDateTime.now());
@@ -200,7 +200,7 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
         
         try {
             LambdaQueryWrapper<DevInfo> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(DevInfo::getDevId, devId);
+            queryWrapper.eq(DevInfo::getClientId, devId);
             return this.getOne(queryWrapper);
         } catch (Exception e) {
             log.error("查询设备详情异常: {}", e.getMessage(), e);
@@ -224,10 +224,10 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
             if (CollectionUtils.isNotEmpty(timeoutDevices)) {
                 List<String> timeoutDevIds = new ArrayList<>();
                 for (DevInfo device : timeoutDevices) {
-                    timeoutDevIds.add(device.getDevId());
-                    boolean success = this.updateDeviceOnlineStatus(device.getDevId(), 0);
+                    timeoutDevIds.add(device.getClientId());
+                    boolean success = this.updateDeviceOnlineStatus(device.getClientId(), 0);
                     if (!success) {
-                        failed.add(device.getDevId());
+                        failed.add(device.getClientId());
                     }
                 }
                 log.info("批量离线设备: {}, 失败: {}", timeoutDevIds, failed);