Ver Fonte

接口调整

hxd há 2 meses atrás
pai
commit
c4c3adc019

+ 1 - 1
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java

@@ -63,7 +63,7 @@ public class DeviceController {
 
     @PostMapping("/updateDevice")
     @Operation(summary = "设备信息修改")
-    public ApiResult<Boolean> updateDevice(@RequestBody @Valid UpdateDeviceParams params) {
+    public ApiResult<DeviceDTO> updateDevice(@RequestBody @Valid UpdateDeviceParams params) {
         return ApiResult.success(deviceGateway.updateDevice(params));
     }
 

+ 3 - 3
portal-service-application/src/main/java/com/hfln/portal/application/controller/web/WebDeviceController.java

@@ -4,7 +4,7 @@ import cn.hfln.framework.catchlog.CatchAndLog;
 import cn.hfln.framework.dto.ApiResult;
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
 import com.hfln.portal.common.request.device.DeviceListQueryReq;
-import com.hfln.portal.common.request.device.UpdateDeviceParams;
+import com.hfln.portal.common.request.device.WebUpdateDeviceParams;
 import com.hfln.portal.common.request.web.DeviceAddParam;
 import com.hfln.portal.common.vo.PageRecord;
 import com.hfln.portal.common.vo.UploadRes;
@@ -60,8 +60,8 @@ public class WebDeviceController {
 
     @PostMapping("/updateDevice")
     @Operation(summary = "更新设备信息")
-    public ApiResult<Boolean> updateDevice(@Valid @RequestBody UpdateDeviceParams Params) {
-        return ApiResult.success(DeviceGateway.updateDevice(Params));
+    public ApiResult<Boolean> webUpdateDevice(@Valid @RequestBody WebUpdateDeviceParams Params) {
+        return ApiResult.success(DeviceGateway.webUpdateDevice(Params));
     }
 
 

+ 0 - 11
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/device/DeviceDTO.java

@@ -168,17 +168,6 @@ public class DeviceDTO extends BaseVO {
     @Schema(description = "雷达监测宽度(Y) yyEnd-yyStart")
     private BigDecimal width;
 
-    /**
-     * target数组
-     */
-    @Schema(description = "target数组")
-    private Object targetPoints;
-
-    /**
-     * 接收target时间
-     */
-    @Schema(description = "接收target时间")
-    private LocalDateTime signalTime;
 
     /**
      * 北向夹角

+ 0 - 5
portal-service-common/src/main/java/com/hfln/portal/common/request/device/UpdateDeviceParams.java

@@ -22,8 +22,6 @@ public class UpdateDeviceParams extends BaseVO {
     @Schema(description = "用户Id", required = true)
     private Long userId;
 
-    @Schema(description = "租户ID")
-    private Long tenantId;
 
     @Schema(description = "设备名称:最多10个字符")
     @Size(max = 10, message = "设备名称不能超过10个字符")
@@ -82,7 +80,4 @@ public class UpdateDeviceParams extends BaseVO {
     @DecimalMax(value = "300", message = "zzEnd不能大于300")
     private BigDecimal zzEnd;
 
-    @Schema(description = "设备跌倒确认时间,大于0")
-    @DecimalMin(value = "1", message = "跌倒确认时间必须大于等于1")
-    private BigDecimal fallingConfirm;
 }

+ 88 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/device/WebUpdateDeviceParams.java

@@ -0,0 +1,88 @@
+package com.hfln.portal.common.request.device;
+
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.*;
+import java.math.BigDecimal;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Schema(description = "修改设备信息")
+public class WebUpdateDeviceParams extends BaseVO {
+
+    @NotEmpty(message = "设备Id不能为空")
+    @Schema(description = "设备ID", required = true)
+    private String clientId;
+
+    @NotNull(message = "用户Id不能为空")
+    @Schema(description = "用户Id", required = true)
+    private Long userId;
+
+    @Schema(description = "租户ID")
+    private Long tenantId;
+
+    @Schema(description = "设备名称:最多10个字符")
+    @Size(max = 10, message = "设备名称不能超过10个字符")
+    private String devName;
+
+    @Schema(description = "安装高度: 250 - 370 cm 之内")
+    @DecimalMax(value = "370", message = "height不能大于370")
+    @DecimalMin(value = "250", message = "height不能小于250")
+    private BigDecimal height;
+
+    @Schema(description = "WIFI名称")
+    private String wifiName;
+
+    @Schema(description = "WIFI密码")
+    private String wifiPassword;
+
+    @Schema(description = "北向夹角 允许传值: 0,90,180,270")
+    private BigDecimal northAngle;
+
+    @Schema(description = "安装方式:Wall-墙装,Ceiling-顶装")
+    private String mountPlain;
+
+    @Schema(description = "安装位置:Toilet-卫生间,Bedroom-卧室,LivingRoom-客厅,Restaurant-餐厅")
+    private String installPosition;
+
+    @Schema(description = "雷达监测范围x开始,范围:-200-200 cm之内")
+    @DecimalMin(value = "-200", message = "xxStart不能小于-200")
+    @DecimalMax(value = "200", message = "xxStart不能大于200")
+    private BigDecimal xxStart;
+
+    @Schema(description = "雷达监测范围x结束,范围:-200-200 cm之内,且xxEnd > xxStart")
+    @DecimalMin(value = "-200", message = "xxEnd不能小于-200")
+    @DecimalMax(value = "200", message = "xxEnd不能大于200")
+    private BigDecimal xxEnd;
+
+
+    @Schema(description = "雷达监测范围y开始,范围:-250-250 cm之内")
+    @DecimalMin(value = "-250", message = "yyStart不能小于-250")
+    @DecimalMax(value = "250", message = "yyStart不能大于250")
+    private BigDecimal yyStart;
+
+    @Schema(description = "雷达监测范围y结束,范围:-250-250 cm之内,且yyEnd > yyStart")
+    @DecimalMin(value = "-250", message = "yyEnd不能小于-250")
+    @DecimalMax(value = "250", message = "yyEnd不能大于250")
+    private BigDecimal yyEnd;
+
+
+    @Schema(description = "雷达监测范围z开始,范围:0-5 cm之内")
+    @DecimalMin(value = "0", message = "zzStart不能小于0")
+    @DecimalMax(value = "5", message = "zzStart不能大于5")
+    private BigDecimal zzStart;
+
+
+    @Schema(description = "雷达监测范围z结束,范围:200-300 cm之内")
+    @DecimalMin(value = "200", message = "zzEnd不能小于200")
+    @DecimalMax(value = "300", message = "zzEnd不能大于300")
+    private BigDecimal zzEnd;
+
+    @Schema(description = "设备跌倒确认时间,大于0")
+    @DecimalMin(value = "1", message = "跌倒确认时间必须大于等于1")
+    private BigDecimal fallingConfirm;
+}

+ 0 - 12
portal-service-common/src/main/java/com/hfln/portal/common/request/web/DeviceAddParam.java

@@ -150,18 +150,6 @@ public class DeviceAddParam extends BaseVO {
     private BigDecimal width;
 
     /**
-     * target数组
-     */
-    @Schema(description = "target数组")
-    private Object targetPoints;
-
-    /**
-     * 接收target时间
-     */
-    @Schema(description = "接收target时间")
-    private LocalDateTime signalTime;
-
-    /**
      * 北向夹角
      */
     @Schema(description = "北向夹角")

+ 2 - 1
portal-service-domain/src/main/java/com/hfln/portal/domain/customer/util/WxOfficeAccountClient.java

@@ -209,10 +209,11 @@ public class WxOfficeAccountClient {
                     log.error("微信接口返回错误码:{}", result);
                     return null;
                 }
+                //4.获取access_token
                 if (map.containsKey("access_token")) {
                     String accessToken = (String) map.get("access_token");
 
-                    //4.写入redis,有效期7080秒
+                    //5.写入redis,有效期7080秒
                     stringRedisTemplate.opsForValue().set(XCX_ACCESS_TOKEN_KEY, accessToken, 7080, TimeUnit.SECONDS);
                     log.info("从微信中获取 access_token 并写入Redis:{}", accessToken);
                     return accessToken;

+ 1 - 0
portal-service-domain/src/main/java/com/hfln/portal/domain/exception/ErrorEnum.java

@@ -62,6 +62,7 @@ public enum ErrorEnum implements ErrorEnumInterface{
     DEVICE_PARAM_ERROR("50005", "设备参数范围错误!"),
     STATUS_LIGHT_IS_NOT_EXIST("50006","指示灯状态不合法!"),
     USER_NO_PERMISSION("50007", "当前用户没有权限!"),
+    DEVICE_UPDATE_FAIL("50008", "设备更新失败!"),
 
     /**
      * 设备房间相关

+ 3 - 1
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java

@@ -33,7 +33,9 @@ public interface DeviceGateway {
 
     Boolean handleEvent(Long eventListId);
 
-    Boolean updateDevice(UpdateDeviceParams params);
+    Boolean webUpdateDevice(WebUpdateDeviceParams params);
+
+    DeviceDTO updateDevice(UpdateDeviceParams params);
 
     Boolean updateDeviceLocation(DeviceLocationParams params);
 

+ 64 - 77
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -47,7 +47,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -256,7 +255,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
 
         //4.通过MQTT把信息参数发送到设备
-        sendDeviceParamsToMqtt(devInfo.getClientId(), request);
+        mqttSubHandle.sendDeviceParamsToMqtt(devInfo.getClientId(), request);
 
         //5.返回绑定结果和设备主键id
         DeviceDTO result = new DeviceDTO();
@@ -320,7 +319,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean updateDevice(UpdateDeviceParams params) {
+    public Boolean webUpdateDevice(WebUpdateDeviceParams params) {
         //1.校验设备是否存在
         DevInfo devInfo = devInfoService.getOne(
                 Wrappers.<DevInfo>lambdaQuery()
@@ -360,98 +359,86 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
 
         boolean updated = devInfoService.updateById(devInfo);
-        
+        if (!updated){
+            log.warn("更新设备信息失败,clientId:{}", devInfo.getClientId());
+            throw new BizException(ErrorEnum.DEVICE_UPDATE_FAIL.getErrorCode(),ErrorEnum.DEVICE_UPDATE_FAIL.getErrorMessage());
+        }
         //4.通过MQTT把信息参数发送到设备
-        sendDeviceParamsToMqtt(devInfo.getClientId(), params);
+        mqttSubHandle.sendWebDeviceParamsToMqtt(devInfo.getClientId(), params);
         
         return updated;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DeviceDTO updateDevice(UpdateDeviceParams params) {
+        //1.校验设备是否存在
+        DevInfo devInfo = devInfoService.getOne(
+                Wrappers.<DevInfo>lambdaQuery()
+                        .eq(DevInfo::getClientId, params.getClientId()));
+        if (Objects.isNull(devInfo)){
+            throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
+        }
 
-    // 辅助方法:如果值为null则设置默认值
-    private <T> void setIfNull(java.util.function.Supplier<T> getter,
-                               java.util.function.Supplier<T> defaultValueSupplier,
-                               java.util.function.Consumer<T> setter) {
-        if (getter.get() == null) {
-            setter.accept(defaultValueSupplier.get());
+        //2.校验是否为主绑人
+        if (!devInfo.getUserId().equals(params.getUserId())){
+            throw new BizException(ErrorEnum.USER_NO_PERMISSION.getErrorCode(), ErrorEnum.USER_NO_PERMISSION.getErrorMessage());
         }
-    }
 
-    /**
-     * 发送设备参数到MQTT的通用方法
-     * @param clientId 设备客户端ID
-     * @param params 设备参数(DeviceBandingParams或UpdateDeviceParams)
-     */
-    private void sendDeviceParamsToMqtt(String clientId, Object params) {
-        String topic = String.format(TopicConstants.TOPIC_SET_DEVICE_PARAM, clientId);
-
-        //构建检测区域
-        Map<String, BigDecimal> base = new HashMap<>();
-        base.put("x_cm_start", getFieldValue(params, "xxStart"));
-        base.put("x_cm_stop", getFieldValue(params, "xxEnd"));
-        base.put("y_cm_start", getFieldValue(params, "yyStart"));
-        base.put("y_cm_stop", getFieldValue(params, "yyEnd"));
-        base.put("z_cm_start", getFieldValue(params, "zzStart"));
-        base.put("z_cm_stop", getFieldValue(params, "zzEnd"));
-        Map<String, Map<String, BigDecimal>> baseParent = new HashMap<>();
-        baseParent.put("base", base);
-
-        //构建安装高度
-        Map<String, BigDecimal> z_cm = new HashMap<>();
-        z_cm.put("z_cm", getFieldValue(params, "height"));
-
-        //构建跌倒确认时间
-        Map<String, Integer> fallingStateMachineDurations = new HashMap<>();
-        // 从参数中获取跌倒确认时间
-        BigDecimal fallingConfirm = getFieldValue(params, "fallingConfirm");
-        if (fallingConfirm != null && fallingConfirm.compareTo(BigDecimal.ZERO) > 0) {
-            int confirmTime = fallingConfirm.intValue();
-            fallingStateMachineDurations.put("durationUntilConfirm_sec", confirmTime);
-            // minTimeOfTarInFallLoc_sec 是 durationUntilConfirm_sec的90%
-            fallingStateMachineDurations.put("minTimeOfTarInFallLoc_sec", (int)(confirmTime * 0.9));
-            // 固定默认值
-            fallingStateMachineDurations.put("durationUntilCalling_sec", 13);
-            fallingStateMachineDurations.put("durationUntilReset_sec", 3);
-        } else {
-            // 使用默认值
-            fallingStateMachineDurations.put("durationUntilConfirm_sec", 53);
-            fallingStateMachineDurations.put("minTimeOfTarInFallLoc_sec", 33);
-            fallingStateMachineDurations.put("durationUntilCalling_sec", 13);
-            fallingStateMachineDurations.put("durationUntilReset_sec", 3);
+
+        //3.更新数据
+        devInfo.setDevName(params.getDevName());
+        devInfo.setHeight(params.getHeight());
+        devInfo.setWifiName(params.getWifiName());
+        devInfo.setWifiPassword(params.getWifiPassword());
+        devInfo.setNorthAngle(params.getNorthAngle());
+        devInfo.setMountPlain(params.getMountPlain());
+        devInfo.setInstallPosition(params.getInstallPosition());
+        devInfo.setXxStart(params.getXxStart());
+        devInfo.setXxEnd(params.getXxEnd());
+        devInfo.setYyStart(params.getYyStart());
+        devInfo.setYyEnd(params.getYyEnd());
+        devInfo.setZzStart(params.getZzStart());
+        devInfo.setZzEnd(params.getZzEnd());
+        devInfo.setLength(params.getXxEnd().subtract(params.getXxStart()));
+        devInfo.setWidth(params.getYyEnd().subtract(params.getYyStart()));
+
+        boolean updated = devInfoService.updateById(devInfo);
+        if (!updated){
+            log.warn("更新设备信息失败,clientId:{}", devInfo.getClientId());
+            throw new BizException(ErrorEnum.DEVICE_UPDATE_FAIL.getErrorCode(),ErrorEnum.DEVICE_UPDATE_FAIL.getErrorMessage());
         }
 
-        //发送最终消息
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("ext_region", baseParent);
-        jsonObject.put("sensor_location", z_cm);
-        jsonObject.put("fallingStateMachineDurations", fallingStateMachineDurations);
+        //4.通过MQTT把信息参数发送到设备
+        mqttSubHandle.sendDeviceParamsToMqtt(devInfo.getClientId(), params);
 
-        try {
-            mqttClient.sendMessage(topic, jsonObject.toJSONString());
-        } catch (Exception e) {
-            log.error("发送设备参数到MQTT失败", e);
-            throw new BizException(ErrorEnum.MQTT_SEND_ERROR.getErrorCode(), ErrorEnum.MQTT_SEND_ERROR.getErrorMessage());
+        //5.重新从数据库获取最新的设备信息,确保返回的数据完整
+        DevInfo updatedDevInfo = devInfoService.getOne(
+                Wrappers.<DevInfo> lambdaQuery()
+                        .eq(DevInfo::getClientId, params.getClientId()));
+        if (Objects.isNull(updatedDevInfo)){
+            throw new BizException(ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorCode(), ErrorEnum.DEVICE_IS_NOT_EXIST.getErrorMessage());
         }
+
+        //6.将查询到的完整设备数据复制到 DeviceDTO 返还前端
+        DeviceDTO dto = new DeviceDTO();
+        BeanUtils.copyProperties(updatedDevInfo, dto);
+        return dto;
+
     }
 
-    /**
-     * 通过反射获取对象字段值
-     * @param obj 对象
-     * @param fieldName 字段名
-     * @return 字段值
-     */
-    private BigDecimal getFieldValue(Object obj, String fieldName) {
-        try {
-            Field field = obj.getClass().getDeclaredField(fieldName);
-            field.setAccessible(true);
-            return (BigDecimal) field.get(obj);
-        } catch (Exception e) {
-            log.error("获取字段值失败: {}", fieldName, e);
-            return BigDecimal.ZERO;
+
+    // 辅助方法:如果值为null则设置默认值
+    private <T> void setIfNull(java.util.function.Supplier<T> getter,
+                               java.util.function.Supplier<T> defaultValueSupplier,
+                               java.util.function.Consumer<T> setter) {
+        if (getter.get() == null) {
+            setter.accept(defaultValueSupplier.get());
         }
     }
 
 
+
     @Override
     public Boolean updateDeviceLocation(DeviceLocationParams params) {
 

+ 114 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/mqtt/MqttSubHandle.java

@@ -1,5 +1,6 @@
 package com.hfln.portal.infrastructure.mqtt;
 
+import cn.hfln.framework.extension.BizException;
 import cn.hfln.framework.redis.util.RedisUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
@@ -11,6 +12,7 @@ import com.hfln.portal.common.dto.data.user.SendMsgUserDto;
 import com.hfln.portal.common.request.room.SubRegionInfo;
 import com.hfln.portal.domain.customer.util.MsgClient;
 import com.hfln.portal.domain.customer.util.WxOfficeAccountClient;
+import com.hfln.portal.domain.exception.ErrorEnum;
 import com.hfln.portal.infrastructure.po.*;
 import com.hfln.portal.infrastructure.service.*;
 import lombok.extern.slf4j.Slf4j;
@@ -20,6 +22,7 @@ import org.springframework.messaging.Message;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -579,4 +582,115 @@ public class MqttSubHandle {
             log.error("Failed to send subRegions message to topic: {}", topicDev, e);
         }
     }
+
+    /**
+     * web端修改设备参数之后通过MQTT发送到设备参数
+     * @param clientId 设备客户端ID
+     * @param params 设备参数(DeviceBandingParams或UpdateDeviceParams)
+     */
+    public void sendWebDeviceParamsToMqtt(String clientId, Object params) {
+        String topic = String.format(TopicConstants.TOPIC_SET_DEVICE_PARAM, clientId);
+
+        //构建检测区域
+        Map<String, BigDecimal> base = new HashMap<>();
+        base.put("x_cm_start", getFieldValue(params, "xxStart"));
+        base.put("x_cm_stop", getFieldValue(params, "xxEnd"));
+        base.put("y_cm_start", getFieldValue(params, "yyStart"));
+        base.put("y_cm_stop", getFieldValue(params, "yyEnd"));
+        base.put("z_cm_start", getFieldValue(params, "zzStart"));
+        base.put("z_cm_stop", getFieldValue(params, "zzEnd"));
+        Map<String, Map<String, BigDecimal>> baseParent = new HashMap<>();
+        baseParent.put("base", base);
+
+        //构建安装高度
+        Map<String, BigDecimal> z_cm = new HashMap<>();
+        z_cm.put("z_cm", getFieldValue(params, "height"));
+
+        //构建跌倒确认时间
+        Map<String, Integer> fallingStateMachineDurations = new HashMap<>();
+        // 从参数中获取跌倒确认时间
+        BigDecimal fallingConfirm = getFieldValue(params, "fallingConfirm");
+        if (fallingConfirm != null && fallingConfirm.compareTo(BigDecimal.ZERO) > 0) {
+            int confirmTime = fallingConfirm.intValue();
+            fallingStateMachineDurations.put("durationUntilConfirm_sec", confirmTime);
+            // minTimeOfTarInFallLoc_sec 是 durationUntilConfirm_sec的90%
+            fallingStateMachineDurations.put("minTimeOfTarInFallLoc_sec", (int)(confirmTime * 0.9));
+            // 固定默认值
+            fallingStateMachineDurations.put("durationUntilCalling_sec", 13);
+            fallingStateMachineDurations.put("durationUntilReset_sec", 3);
+        } else {
+            // 使用默认值
+            fallingStateMachineDurations.put("durationUntilConfirm_sec", 53);
+            fallingStateMachineDurations.put("minTimeOfTarInFallLoc_sec", 33);
+            fallingStateMachineDurations.put("durationUntilCalling_sec", 13);
+            fallingStateMachineDurations.put("durationUntilReset_sec", 3);
+        }
+
+        //发送最终消息
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("ext_region", baseParent);
+        jsonObject.put("sensor_location", z_cm);
+        jsonObject.put("fallingStateMachineDurations", fallingStateMachineDurations);
+
+        try {
+            mqttClient.sendMessage(topic, jsonObject.toJSONString());
+        } catch (Exception e) {
+            log.error("发送设备参数到MQTT失败", e);
+            throw new BizException(ErrorEnum.MQTT_SEND_ERROR.getErrorCode(), ErrorEnum.MQTT_SEND_ERROR.getErrorMessage());
+        }
+    }
+
+    /**
+     * 小程序端修改设备参数之后通过MQTT发送到设备参数
+     * @param clientId 设备客户端ID
+     * @param params 设备参数(DeviceBandingParams或UpdateDeviceParams)
+     */
+    public void sendDeviceParamsToMqtt(String clientId, Object params) {
+        String topic = String.format(TopicConstants.TOPIC_SET_DEVICE_PARAM, clientId);
+
+        //构建检测区域
+        Map<String, BigDecimal> base = new HashMap<>();
+        base.put("x_cm_start", getFieldValue(params, "xxStart"));
+        base.put("x_cm_stop", getFieldValue(params, "xxEnd"));
+        base.put("y_cm_start", getFieldValue(params, "yyStart"));
+        base.put("y_cm_stop", getFieldValue(params, "yyEnd"));
+        base.put("z_cm_start", getFieldValue(params, "zzStart"));
+        base.put("z_cm_stop", getFieldValue(params, "zzEnd"));
+        Map<String, Map<String, BigDecimal>> baseParent = new HashMap<>();
+        baseParent.put("base", base);
+
+        //构建安装高度
+        Map<String, BigDecimal> z_cm = new HashMap<>();
+        z_cm.put("z_cm", getFieldValue(params, "height"));
+
+
+        //发送最终消息
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("ext_region", baseParent);
+        jsonObject.put("sensor_location", z_cm);
+
+        try {
+            mqttClient.sendMessage(topic, jsonObject.toJSONString());
+        } catch (Exception e) {
+            log.error("发送设备参数到MQTT失败", e);
+            throw new BizException(ErrorEnum.MQTT_SEND_ERROR.getErrorCode(), ErrorEnum.MQTT_SEND_ERROR.getErrorMessage());
+        }
+    }
+
+    /**
+     * 通过反射获取对象字段值
+     * @param obj 对象
+     * @param fieldName 字段名
+     * @return 字段值
+     */
+    private BigDecimal getFieldValue(Object obj, String fieldName) {
+        try {
+            Field field = obj.getClass().getDeclaredField(fieldName);
+            field.setAccessible(true);
+            return (BigDecimal) field.get(obj);
+        } catch (Exception e) {
+            log.error("获取字段值失败: {}", fieldName, e);
+            return BigDecimal.ZERO;
+        }
+    }
 }

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

@@ -164,17 +164,7 @@ public class DevInfo extends BasePO {
     @TableField("width")
     private BigDecimal width;
 
-    /**
-     * target数组
-     */
-    @TableField("target_points")
-    private String targetPoints;
 
-    /**
-     * 接收target时间
-     */
-    @TableField("signal_time")
-    private LocalDateTime signalTime;
 
     /**
      * 北向夹角 //判断数值 0 90 180 270