|
|
|
@ -1,9 +1,15 @@
|
|
|
|
|
package com.example.zxweb.utils;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.example.zxweb.common.constant.enums.IotApiEnum;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description ios 设备请求工具
|
|
|
|
|
* @Author ZhouWenTao
|
|
|
|
@ -16,6 +22,31 @@ public class IotUtils {
|
|
|
|
|
|
|
|
|
|
private static final JSONObject headers=JSONObject.parseObject("{\"x-consumer-username\":\"dwVendor\",\"appCode\":\"42142fd0jkbf4515853b7fcec64748f6\"}");
|
|
|
|
|
|
|
|
|
|
public static List<JSONObject> devicesMethodsNews(JSONObject queryData){
|
|
|
|
|
String serial = queryData.getString("serial");
|
|
|
|
|
String[] serials = serial.split(",");
|
|
|
|
|
List<JSONObject> list=new ArrayList<>();
|
|
|
|
|
for (String s : serials) {
|
|
|
|
|
String url = API_PREFIX + IotApiEnum.getPathByText("查询方法历史数据") + "?serial=" + s;
|
|
|
|
|
if (!StringUtils.isEmpty(queryData.getString("methodName"))) {
|
|
|
|
|
url+="&methodName="+queryData.getString("methodName");
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObject = RestUtil.get(url, null, null, headers);
|
|
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
if (code==0) {
|
|
|
|
|
if (jsonObject.getJSONObject("data")==null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("methods");
|
|
|
|
|
if (CollectionUtils.isEmpty(jsonArray)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
list.add(jsonArray.getJSONObject(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static JSONObject getApi(String apiUrl,JSONObject queryData) {
|
|
|
|
|
|
|
|
|
|
StringBuilder sb=new StringBuilder();
|
|
|
|
|