|
|
@ -1,6 +1,9 @@ |
|
|
|
package cn.iocoder.yudao.module.alert.utils; |
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.*; |
|
|
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAHistoryReqVO; |
|
|
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAHttp; |
|
|
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.EXAPageReqVO; |
|
|
|
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.Point; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.google.gson.Gson; |
|
|
@ -11,14 +14,11 @@ import org.apache.http.client.fluent.Request; |
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
import org.apache.http.client.methods.HttpDelete; |
|
|
|
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.entity.ContentType; |
|
|
|
import org.apache.http.entity.StringEntity; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.lang.reflect.Type; |
|
|
@ -31,19 +31,18 @@ import java.util.List; |
|
|
|
public class EXAUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据分页条件和测点名称测点描述模糊查询 |
|
|
|
* |
|
|
|
* @param reqVO 传入对象,页数、页数量、查询条件 |
|
|
|
* @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<>();
|
|
|
|
List<EXAHttp> exaListAll = new ArrayList<EXAHttp>(); |
|
|
|
try { |
|
|
|
// 目标 RPC 服务的 URL
|
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exaitem/getitems"; |
|
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exaitem/getitems"; |
|
|
|
//创建HttpClient对象
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
|
/* |
|
|
@ -104,11 +103,11 @@ public class EXAUtils { |
|
|
|
* @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<>(); |
|
|
|
try { |
|
|
|
// 目标 RPC 服务的 URL
|
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exanow/getfloatvaluebatch"; |
|
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exanow/getfloatvaluebatch"; |
|
|
|
//创建HttpClient对象
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
|
/* |
|
|
@ -154,12 +153,12 @@ public class EXAUtils { |
|
|
|
* @param exaHistoryReqVo 传入对象,点号、开始时间、结束时间 |
|
|
|
* @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<>(); |
|
|
|
try { |
|
|
|
// 目标 RPC 服务的 URL
|
|
|
|
// 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对象
|
|
|
@ -173,7 +172,7 @@ public class EXAUtils { |
|
|
|
uriBuilder.addParameter("ItemName", exaHistoryReqVo.getItemName()); |
|
|
|
uriBuilder.addParameter("StartingTime", exaHistoryReqVo.getStartTime()); |
|
|
|
uriBuilder.addParameter("TerminalTime", exaHistoryReqVo.getEndTime()); |
|
|
|
uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000*exaHistoryReqVo.getInterval())); |
|
|
|
uriBuilder.addParameter("SamplingPeriod", String.valueOf(1000 * exaHistoryReqVo.getInterval())); |
|
|
|
|
|
|
|
|
|
|
|
//创建请求对象
|
|
|
@ -208,7 +207,7 @@ public class EXAUtils { |
|
|
|
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<>(); |
|
|
|
|
|
|
|
try { |
|
|
@ -217,7 +216,7 @@ public class EXAUtils { |
|
|
|
pointName.forEach(entity -> { |
|
|
|
List<List<Double>> result = new ArrayList<>(); |
|
|
|
exaHistoryReqVo.setItemName(entity); |
|
|
|
result = getHistory(EXA_IP,exaHistoryReqVo); |
|
|
|
result = getHistory(EXA_IP, exaHistoryReqVo); |
|
|
|
results.add(result); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
@ -227,8 +226,8 @@ public class EXAUtils { |
|
|
|
} |
|
|
|
|
|
|
|
//写入点号
|
|
|
|
public String setPoint(String EXA_IP,Point point) throws IOException { |
|
|
|
String requestPathAddItem = "http://"+EXA_IP+":9000/exawebapi/exaitem/AddItem"; |
|
|
|
public String setPoint(String EXA_IP, Point point) throws IOException { |
|
|
|
String requestPathAddItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/AddItem"; |
|
|
|
String param = JSON.toJSONString(point); |
|
|
|
String result = Request.Post(requestPathAddItem) |
|
|
|
.addHeader("Content-type", "application/json") |
|
|
@ -245,7 +244,7 @@ public class EXAUtils { |
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
try { |
|
|
|
// 目标 RPC 服务的 URL
|
|
|
|
String url = "http://"+EXA_IP+":9000/exawebapi/exagroup/getgroups"; |
|
|
|
String url = "http://" + EXA_IP + ":9000/exawebapi/exagroup/getgroups"; |
|
|
|
//创建HttpClient对象
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|
|
|
/* |
|
|
@ -288,8 +287,8 @@ public class EXAUtils { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public String deletePoint(String EXA_IP,String ItemName){ |
|
|
|
String requestPathDeleteItem ="http://"+EXA_IP+":9000/exawebapi/exaitem/DeleteItem?ItemName="+ItemName; |
|
|
|
public String deletePoint(String EXA_IP, String ItemName) { |
|
|
|
String requestPathDeleteItem = "http://" + EXA_IP + ":9000/exawebapi/exaitem/DeleteItem?ItemName=" + ItemName; |
|
|
|
// 创建HttpClient
|
|
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
|
// 创建HttpDelete请求
|
|
|
|