|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.example.zxweb.common.constant.DevConstant;
|
|
|
|
|
import com.example.zxweb.common.constant.enums.IotApiEnum;
|
|
|
|
|
import com.example.zxweb.exception.BusinessException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
@ -18,6 +19,7 @@ import java.util.List;
|
|
|
|
|
* @Date 2023/9/8 11:59
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class IotUtils {
|
|
|
|
|
//请求服务地址 https://10.0.10.153:2443/api/iot/v1
|
|
|
|
|
private static final String API_PREFIX = "https://10.0.10.153:2443/api/iot/v1";
|
|
|
|
@ -87,16 +89,14 @@ public class IotUtils {
|
|
|
|
|
System.out.println(requestBody.toJSONString());
|
|
|
|
|
try {
|
|
|
|
|
JSONObject jsonObject = postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody);
|
|
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
if (code==0) {
|
|
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
|
if (data!=null) {
|
|
|
|
|
JSONObject outputData = data.getJSONObject("outputData");
|
|
|
|
|
if (outputData!=null) {
|
|
|
|
|
String code1 = outputData.getString("code");
|
|
|
|
|
if (StringUtils.isNotBlank(code1) && "1".equals(code1)) {
|
|
|
|
|
return true;//更改成功
|
|
|
|
|
}
|
|
|
|
|
log.info(jsonObject.toJSONString());
|
|
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
|
if (data!=null) {
|
|
|
|
|
JSONObject outputData = data.getJSONObject("outputData");
|
|
|
|
|
if (outputData!=null) {
|
|
|
|
|
Integer code1 = outputData.getInteger("code");
|
|
|
|
|
if (code1!=null && 1==code1) {
|
|
|
|
|
return true;//更改成功
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|