|
|
@ -11,14 +11,11 @@ import org.apache.http.client.fluent.Request; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
import org.apache.http.client.methods.HttpDelete; |
|
|
import org.apache.http.client.methods.HttpDelete; |
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
import org.apache.http.client.methods.HttpPost; |
|
|
|
|
|
import org.apache.http.client.utils.URIBuilder; |
|
|
import org.apache.http.client.utils.URIBuilder; |
|
|
import org.apache.http.entity.ContentType; |
|
|
import org.apache.http.entity.ContentType; |
|
|
import org.apache.http.entity.StringEntity; |
|
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.lang.reflect.Type; |
|
|
import java.lang.reflect.Type; |
|
|
@ -31,19 +28,18 @@ import java.util.List; |
|
|
public class EXAUtils { |
|
|
public class EXAUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据分页条件和测点名称测点描述模糊查询 |
|
|
* 根据分页条件和测点名称测点描述模糊查询 |
|
|
* |
|
|
* |
|
|
* @param reqVO 传入对象,页数、页数量、查询条件 |
|
|
* @param reqVO 传入对象,页数、页数量、查询条件 |
|
|
* @return exa列表 |
|
|
* @return exa列表 |
|
|
*/ |
|
|
*/ |
|
|
public List<EXAHttp> getPointInfo(String EXA_IP,EXAPageReqVO reqVO) throws URISyntaxException, IOException { |
|
|
public List<EXAHttp> getPointInfo(String EXA_IP, EXAPageReqVO reqVO) throws URISyntaxException, IOException { |
|
|
// PageResult<EXAHttp> result = new PageResult<>();
|
|
|
// PageResult<EXAHttp> result = new PageResult<>();
|
|
|
List<EXAHttp> exaListAll = new ArrayList<EXAHttp>(); |
|
|
List<EXAHttp> exaListAll = new ArrayList<EXAHttp>(); |
|
|
try { |
|
|
try { |
|
|
// 目标 RPC 服务的 URL
|
|
|
// 目标 RPC 服务的 URL
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exaitem/getitems"; |
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exaitem/getitems"; |
|
|
//创建HttpClient对象
|
|
|
//创建HttpClient对象
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
/* |
|
|
/* |
|
|
@ -104,12 +100,11 @@ public class EXAUtils { |
|
|
* @return exa列表 |
|
|
* @return exa列表 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
public List<String> getNowData(String EXA_IP, String itemNames) throws URISyntaxException, IOException { |
|
|
public List<String> getNowData(String EXA_IP,String itemNames) throws URISyntaxException, IOException { |
|
|
|
|
|
List<String> result = new ArrayList<>(); |
|
|
List<String> result = new ArrayList<>(); |
|
|
try { |
|
|
try { |
|
|
// 目标 RPC 服务的 URL
|
|
|
// 目标 RPC 服务的 URL
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exanow/getfloatvaluebatch"; |
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exanow/getfloatvaluebatch"; |
|
|
//创建HttpClient对象
|
|
|
//创建HttpClient对象
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
/* |
|
|
/* |
|
|
@ -149,41 +144,18 @@ public class EXAUtils { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EXAResult getNowDataList(String EXA_IP,EXANowListReqVO exaNowListReqVO) throws URISyntaxException, IOException { |
|
|
|
|
|
EXAResult result = new EXAResult(); |
|
|
|
|
|
try { |
|
|
|
|
|
// 目标 RPC 服务的 URL
|
|
|
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exanow/GetFloatValueBatch"; |
|
|
|
|
|
String param = JSON.toJSONString(exaNowListReqVO); |
|
|
|
|
|
String resultStr = Request.Post(url) |
|
|
|
|
|
.addHeader("Content-type", "application/json") |
|
|
|
|
|
.bodyString(param, ContentType.APPLICATION_JSON) |
|
|
|
|
|
.execute().returnContent().asString(Charset.forName("utf-8")); |
|
|
|
|
|
Gson gson=new Gson(); |
|
|
|
|
|
|
|
|
|
|
|
result= gson.fromJson(resultStr, EXAResult.class); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据分页条件和测点名称测点描述模糊查询 |
|
|
* 根据分页条件和测点名称测点描述模糊查询 |
|
|
* |
|
|
* |
|
|
* @param exaHistoryReqVo 传入对象,点号、开始时间、结束时间 |
|
|
* @param exaHistoryReqVo 传入对象,点号、开始时间、结束时间 |
|
|
* @return exa列表 |
|
|
* @return exa列表 |
|
|
*/ |
|
|
*/ |
|
|
public List<List<Double>> getHistory(String EXA_IP,EXAHistoryReqVO exaHistoryReqVo) { |
|
|
public List<List<Double>> getHistory(String EXA_IP, EXAHistoryReqVO exaHistoryReqVo) { |
|
|
List<List<Double>> result = new ArrayList<>(); |
|
|
List<List<Double>> result = new ArrayList<>(); |
|
|
try { |
|
|
try { |
|
|
// 目标 RPC 服务的 URL
|
|
|
// 目标 RPC 服务的 URL
|
|
|
// String url = "http://"+EXA_IP+":9000/exawebapi/exatime/GetRawValueArrayFloat";
|
|
|
// String url = "http://"+EXA_IP+":9000/exawebapi/exatime/GetRawValueArrayFloat";
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exatime/GetSamplingValueArrayFloat"; |
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exatime/GetSamplingValueArrayFloat"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建HttpClient对象
|
|
|
//创建HttpClient对象
|
|
|
@ -197,7 +169,7 @@ public class EXAUtils { |
|
|
uriBuilder.addParameter("ItemName", exaHistoryReqVo.getItemName()); |
|
|
uriBuilder.addParameter("ItemName", exaHistoryReqVo.getItemName()); |
|
|
uriBuilder.addParameter("StartingTime", exaHistoryReqVo.getStartTime()); |
|
|
uriBuilder.addParameter("StartingTime", exaHistoryReqVo.getStartTime()); |
|
|
uriBuilder.addParameter("TerminalTime", exaHistoryReqVo.getEndTime()); |
|
|
uriBuilder.addParameter("TerminalTime", exaHistoryReqVo.getEndTime()); |
|
|
uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000*exaHistoryReqVo.getInterval())); |
|
|
uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000 * exaHistoryReqVo.getInterval())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建请求对象
|
|
|
//创建请求对象
|
|
|
@ -232,7 +204,7 @@ public class EXAUtils { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<List<List<Double>>> getHistorys(String EXA_IP,EXAHistoryReqVO exaHistoryReqVo) { |
|
|
public List<List<List<Double>>> getHistorys(String EXA_IP, EXAHistoryReqVO exaHistoryReqVo) { |
|
|
List<List<List<Double>>> results = new ArrayList<>(); |
|
|
List<List<List<Double>>> results = new ArrayList<>(); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
@ -241,7 +213,7 @@ public class EXAUtils { |
|
|
pointName.forEach(entity -> { |
|
|
pointName.forEach(entity -> { |
|
|
List<List<Double>> result = new ArrayList<>(); |
|
|
List<List<Double>> result = new ArrayList<>(); |
|
|
exaHistoryReqVo.setItemName(entity); |
|
|
exaHistoryReqVo.setItemName(entity); |
|
|
result = getHistory(EXA_IP,exaHistoryReqVo); |
|
|
result = getHistory(EXA_IP, exaHistoryReqVo); |
|
|
results.add(result); |
|
|
results.add(result); |
|
|
}); |
|
|
}); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -251,8 +223,8 @@ public class EXAUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//写入点号
|
|
|
//写入点号
|
|
|
public String setPoint(String EXA_IP,Point point) throws IOException { |
|
|
public String setPoint(String EXA_IP, Point point) throws IOException { |
|
|
String requestPathAddItem = "http://"+EXA_IP+":9000/exawebapi/exaitem/AddItem"; |
|
|
String requestPathAddItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/AddItem"; |
|
|
String param = JSON.toJSONString(point); |
|
|
String param = JSON.toJSONString(point); |
|
|
String result = Request.Post(requestPathAddItem) |
|
|
String result = Request.Post(requestPathAddItem) |
|
|
.addHeader("Content-type", "application/json") |
|
|
.addHeader("Content-type", "application/json") |
|
|
@ -269,7 +241,7 @@ public class EXAUtils { |
|
|
List<Object> result = new ArrayList<>(); |
|
|
List<Object> result = new ArrayList<>(); |
|
|
try { |
|
|
try { |
|
|
// 目标 RPC 服务的 URL
|
|
|
// 目标 RPC 服务的 URL
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exagroup/getgroups"; |
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exagroup/getgroups"; |
|
|
//创建HttpClient对象
|
|
|
//创建HttpClient对象
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
/* |
|
|
/* |
|
|
@ -312,8 +284,8 @@ public class EXAUtils { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public String deletePoint(String EXA_IP,String ItemName){ |
|
|
public String deletePoint(String EXA_IP, String ItemName) { |
|
|
String requestPathDeleteItem ="http://"+EXA_IP+":9000/exawebapi/exaitem/DeleteItem?ItemName="+ItemName; |
|
|
String requestPathDeleteItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/DeleteItem?ItemName=" + ItemName; |
|
|
// 创建HttpClient
|
|
|
// 创建HttpClient
|
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
// 创建HttpDelete请求
|
|
|
// 创建HttpDelete请求
|
|
|
|