main
周文涛 2 years ago
parent d079547978
commit f6c0d4d0de

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

Loading…
Cancel
Save