|
@@ -13,8 +13,7 @@ import com.gyee.generation.model.vo.RealTimeParameterVo;
|
|
|
import com.gyee.generation.util.realtimesource.timeseries.ErrorRequest;
|
|
|
import com.gyee.generation.util.realtimesource.timeseries.JsonObjectHelper;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.HttpClientErrorException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
@@ -704,39 +703,47 @@ public class EdosUtil implements IEdosUtil {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<PointData> getRealData(String... pointids) throws Exception {
|
|
|
+// public List<PointData> getRealData(String... pointids) throws Exception {
|
|
|
+ public List<PointData> getRealDataPost(List<String> pointids) throws Exception {
|
|
|
|
|
|
-
|
|
|
- String pointIdString = StringUtil.join(pointids, ",");
|
|
|
- Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
- String url = baseURL + "/latest?null=0";
|
|
|
- if (pointIdString.startsWith("GF-")) {
|
|
|
- url = baseURL2 + "/latest?null=0";
|
|
|
- }
|
|
|
+// String pointIdString = StringUtil.join(pointids, ",");
|
|
|
+// Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
+ String url = baseURL + "/latest";
|
|
|
+// if (pointIdString.startsWith("GF-")) {
|
|
|
+// url = baseURL2 + "/latest?null=0";
|
|
|
+// }
|
|
|
try {
|
|
|
- if (keys.isPresent())
|
|
|
- url = url + "&keys=" + keys.get();
|
|
|
- else {
|
|
|
- return ErrorRequest.RequestListError(pointids);
|
|
|
- }
|
|
|
- ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+
|
|
|
+ // 将请求体和头部信息整合到HttpEntity中
|
|
|
+ HttpEntity<List<String>> requestEntity = new HttpEntity<>(pointids,headers);
|
|
|
+
|
|
|
+ // 发起POST请求
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.exchange(url,HttpMethod.POST,requestEntity,JSONObject.class);
|
|
|
+// if (keys.isPresent())
|
|
|
+// url = url + "&keys=" + keys.get();
|
|
|
+// else {
|
|
|
+// return ErrorRequest.RequestListError(pointids.toString());
|
|
|
+// }
|
|
|
+// ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
JSONObject jsonObject = resp.getBody();
|
|
|
if (jsonObject != null) {
|
|
|
//对结果进行有序返回
|
|
|
- int len = pointids.length;
|
|
|
+ int len = pointids.size();
|
|
|
List<PointData> result = new ArrayList<>();
|
|
|
HashMap<String, PointData> pointDataHashMap = new HashMap<>();
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
|
|
- if (pointDataHashMap.containsKey(pointids[i]) == false) {
|
|
|
+ if (pointDataHashMap.containsKey(pointids.get(i)) == false) {
|
|
|
PointData pd = new PointData();
|
|
|
- pd.setPointName(pointids[i]);
|
|
|
- pd.setEdnaId(pointids[i]);
|
|
|
+ pd.setPointName(pointids.get(i));
|
|
|
+ pd.setEdnaId(pointids.get(i));
|
|
|
result.add(pd);
|
|
|
|
|
|
pointDataHashMap.put(pd.getPointName(), pd);
|
|
|
} else {
|
|
|
- result.add(pointDataHashMap.get(pointids[i]));
|
|
|
+ result.add(pointDataHashMap.get(pointids.get(i)));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -779,13 +786,13 @@ public class EdosUtil implements IEdosUtil {
|
|
|
return result;
|
|
|
|
|
|
} else {
|
|
|
- return ErrorRequest.RequestListError(pointids);
|
|
|
+ return ErrorRequest.RequestListError(pointids.toString());
|
|
|
}
|
|
|
|
|
|
} catch (HttpClientErrorException exception) {
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
//System.out.println("404请求错误");
|
|
|
- return ErrorRequest.RequestListError(pointids);
|
|
|
+ return ErrorRequest.RequestListError(pointids.toString());
|
|
|
} else {
|
|
|
throw exception;
|
|
|
}
|