|
@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.Parameter; |
|
|
import okhttp3.Response; |
|
|
import okhttp3.Response; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
@ -166,6 +167,10 @@ public class DcDeviceController extends BaseController { |
|
|
@GetMapping("/properties/latest/{deviceId}") |
|
|
@GetMapping("/properties/latest/{deviceId}") |
|
|
public AjaxResult getDeviceLatestProperties(@PathVariable @Parameter(description = "设备ID") String deviceId) throws HttpException, IOException { |
|
|
public AjaxResult getDeviceLatestProperties(@PathVariable @Parameter(description = "设备ID") String deviceId) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
Response response // 请求响应
|
|
|
Response response // 请求响应
|
|
|
= okHttp |
|
|
= okHttp |
|
@ -187,6 +192,11 @@ public class DcDeviceController extends BaseController { |
|
|
public AjaxResult queryDeviceProperties(@PathVariable @Parameter(description = "设备ID") String deviceId, |
|
|
public AjaxResult queryDeviceProperties(@PathVariable @Parameter(description = "设备ID") String deviceId, |
|
|
@PathVariable @Parameter(description = "属性ID") String propertyId, |
|
|
@PathVariable @Parameter(description = "属性ID") String propertyId, |
|
|
@Parameter(hidden = true) HashMap<String, Object> props) throws HttpException, IOException { |
|
|
@Parameter(hidden = true) HashMap<String, Object> props) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(props); |
|
|
RequestParams requestParams = new RequestParams(props); |
|
@ -210,6 +220,11 @@ public class DcDeviceController extends BaseController { |
|
|
@GetMapping("/properties/latest/{deviceId}/{propertyId}") |
|
|
@GetMapping("/properties/latest/{deviceId}/{propertyId}") |
|
|
public AjaxResult getDeviceLatestProperty(@PathVariable @Parameter(description = "设备ID") String deviceId, |
|
|
public AjaxResult getDeviceLatestProperty(@PathVariable @Parameter(description = "设备ID") String deviceId, |
|
|
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException { |
|
|
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
Response response // 请求响应
|
|
|
Response response // 请求响应
|
|
|
= okHttp |
|
|
= okHttp |
|
@ -232,6 +247,10 @@ public class DcDeviceController extends BaseController { |
|
|
@PathVariable String propertyId, |
|
|
@PathVariable String propertyId, |
|
|
@RequestParam HashMap<String, Object> props) throws HttpException, IOException { |
|
|
@RequestParam HashMap<String, Object> props) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(props); |
|
|
RequestParams requestParams = new RequestParams(props); |
|
@ -257,6 +276,10 @@ public class DcDeviceController extends BaseController { |
|
|
@PathVariable String deviceId, |
|
|
@PathVariable String deviceId, |
|
|
@RequestBody DeviceGetPropertiesOperateRequest props) throws HttpException, IOException { |
|
|
@RequestBody DeviceGetPropertiesOperateRequest props) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -286,6 +309,11 @@ public class DcDeviceController extends BaseController { |
|
|
@PathVariable String deviceId, |
|
|
@PathVariable String deviceId, |
|
|
@RequestBody HashMap<String, Object> props |
|
|
@RequestBody HashMap<String, Object> props |
|
|
) throws HttpException, IOException { |
|
|
) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(props); |
|
|
RequestParams requestParams = new RequestParams(props); |
|
@ -313,6 +341,10 @@ public class DcDeviceController extends BaseController { |
|
|
@PathVariable String functionId, |
|
|
@PathVariable String functionId, |
|
|
@RequestBody HashMap<String, Object> props) throws HttpException, IOException { |
|
|
@RequestBody HashMap<String, Object> props) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(functionId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(props); |
|
|
RequestParams requestParams = new RequestParams(props); |
|
@ -343,6 +375,10 @@ public class DcDeviceController extends BaseController { |
|
|
@Parameter(hidden = true) HashMap<String, Object> queryParam |
|
|
@Parameter(hidden = true) HashMap<String, Object> queryParam |
|
|
) throws HttpException, IOException { |
|
|
) throws HttpException, IOException { |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(eventId)) { |
|
|
|
|
|
return AjaxResult.error("设备未接入"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(queryParam); |
|
|
RequestParams requestParams = new RequestParams(queryParam); |
|
|