Commit 40ea5954 by huangjy

fix:设备属性写入

parent 77c23ac1
package com.makeit.module.iot.dto;
import lombok.Data;
@Data
public class UserServerInfo {
private String password;
private String secureKey;
private String secureId;
private String addr;
private String username;
private Integer port;
}
...@@ -3,6 +3,7 @@ package com.makeit.module.iot.service; ...@@ -3,6 +3,7 @@ package com.makeit.module.iot.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.makeit.module.iot.dto.UserServerInfo;
import com.makeit.module.iot.util.HttpRequest; import com.makeit.module.iot.util.HttpRequest;
import com.makeit.module.iot.util.SimpleHttpRequest; import com.makeit.module.iot.util.SimpleHttpRequest;
import com.makeit.module.iot.vo.DeviceInstanceEntity; import com.makeit.module.iot.vo.DeviceInstanceEntity;
...@@ -48,7 +49,7 @@ public class IotDevicePropertiesOperateService extends IotCommonService { ...@@ -48,7 +49,7 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
* 把设备写入属性 * 把设备写入属性
*/ */
@Async @Async
public List<DeviceInstanceEntity> deviceWrite(String deviceId, Integer radarMount, Integer radarMode, Integer radarHight) { public List<DeviceInstanceEntity> deviceWrite(String deviceId, Integer radarMount, Integer radarMode, Integer radarHight, UserServerInfo usrServerInfo) {
String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/property"; String url = iotUrl + DEVICE_PREFIX_URL + deviceId + "/property";
// 条件可以自己改 // 条件可以自己改
...@@ -62,7 +63,9 @@ public class IotDevicePropertiesOperateService extends IotCommonService { ...@@ -62,7 +63,9 @@ public class IotDevicePropertiesOperateService extends IotCommonService {
if (radarHight != null) { if (radarHight != null) {
map.put("radarHight", radarHight); map.put("radarHight", radarHight);
} }
if (usrServerInfo != null) {
map.put("usrServerInfo", JSON.toJSONString(usrServerInfo));
}
for (Map.Entry<String, Object> entry : map.entrySet()) { for (Map.Entry<String, Object> entry : map.entrySet()) {
String body = JsonUtil.toJson(entry); String body = JsonUtil.toJson(entry);
......
package com.makeit.dto.wechat.device; package com.makeit.dto.wechat.device;
import com.makeit.module.iot.dto.UserServerInfo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -32,6 +33,8 @@ public class PlatDeviceAttrWechatDTO { ...@@ -32,6 +33,8 @@ public class PlatDeviceAttrWechatDTO {
@ApiModelProperty(value = "读取硬件的系统参数,主要读取服务信息和雷达信息,多个逗号隔开") @ApiModelProperty(value = "读取硬件的系统参数,主要读取服务信息和雷达信息,多个逗号隔开")
private String readProperties; private String readProperties;
//private String usrServerInfo;
@ApiModelProperty(value = "服务信息 {\n" + @ApiModelProperty(value = "服务信息 {\n" +
" \"password\": \"\",\n" + " \"password\": \"\",\n" +
" \"port\": 0,\n" + " \"port\": 0,\n" +
...@@ -40,6 +43,6 @@ public class PlatDeviceAttrWechatDTO { ...@@ -40,6 +43,6 @@ public class PlatDeviceAttrWechatDTO {
" \"addr\": \"\",\n" + " \"addr\": \"\",\n" +
" \"username\": \"\"\n" + " \"username\": \"\"\n" +
" }") " }")
private String usrServerInfo; private UserServerInfo usrServerInfo;
} }
...@@ -28,7 +28,7 @@ public class MqttController { ...@@ -28,7 +28,7 @@ public class MqttController {
@AuthIgnore @AuthIgnore
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<Void> testMqtt() { public ApiResponseEntity<Void> testMqtt() {
devicePropertiesOperateService.deviceWrite("1701240048151490560", 1,1,1); devicePropertiesOperateService.deviceWrite("1701240048151490560", 1,1,1, null);
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment