|
@@ -0,0 +1,939 @@
|
|
|
+package com.gyee.datatraining.util.realtimesource;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gyee.common.model.DNAStatVal;
|
|
|
+import com.gyee.common.model.DNAVal;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.datatraining.init.InitialConfig;
|
|
|
+import com.gyee.datatraining.model.auto.Windpowerstationtestingpoint;
|
|
|
+import com.gyee.datatraining.model.auto.Windturbinetestingpointai;
|
|
|
+import com.gyee.datatraining.util.StringUtils;
|
|
|
+import com.gyee.datatraining.util.realtimesource.timeseries.ErrorRequest;
|
|
|
+import com.gyee.datatraining.util.realtimesource.timeseries.JsonObjectHelper;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.client.HttpClientErrorException;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class EdosUtil implements IEdosUtil {
|
|
|
+
|
|
|
+ private RestTemplate restTemplate =new RestTemplate();
|
|
|
+ //private static String baseURL = "http://10.155.32.4:8011/ts";
|
|
|
+
|
|
|
+ private static String baseURL = InitialConfig.getBaseurl();
|
|
|
+ @Override
|
|
|
+ public PointData getRealData(Windpowerstationtestingpoint point) throws Exception {
|
|
|
+ try {
|
|
|
+ Optional<String> keys = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingType = Optional.ofNullable("station");
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> uniformCodes = Optional.ofNullable(point.getUniformcode());
|
|
|
+
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCodes.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCodes.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ if (list.size() > 0)
|
|
|
+ return list.get(0);
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ } else {
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasSnap(Windpowerstationtestingpoint point, Long beginDate, Long endDate, Long count, Long pried) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/snap?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasRaw(Windpowerstationtestingpoint point, Long beginDate, Long endDate) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/snap?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PointData getRealData(Windturbinetestingpointai point) throws Exception {
|
|
|
+ Optional<String> keys = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> uniformCodes = Optional.ofNullable(point.getUniformcode());
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCodes.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCodes.get();
|
|
|
+ }
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ if (list.size() > 0)
|
|
|
+ return list.get(0);
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ } else {
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasSnap(Windturbinetestingpointai point, Long beginDate, Long endDate, Long count, Long pried) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/snap?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasRaw(Windturbinetestingpointai point, Long beginDate, Long endDate) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate);
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/snap?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PointData getRealData(String pointid) throws Exception {
|
|
|
+ Optional<String> keys = Optional.ofNullable(pointid);
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ try {
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ if (list.size() > 0)
|
|
|
+ return list.get(0);
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestError(pointid);
|
|
|
+ } else {
|
|
|
+ return ErrorRequest.RequestError(pointid);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestError(pointid);
|
|
|
+ } else {
|
|
|
+ return ErrorRequest.RequestError(pointid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getRealData(String... pointids) throws Exception {
|
|
|
+ String pointIdString = StringUtils.join(pointids, ",");
|
|
|
+ Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
+ String url = baseURL + "/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);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(pointids);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(pointids);
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getRealData(List<String> pointids) throws Exception {
|
|
|
+ String pointIdString = StringUtils.join(pointids.toArray(), ",");
|
|
|
+ Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ try {
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ else {
|
|
|
+ String[] arr = new String[pointids.size()];
|
|
|
+ return ErrorRequest.RequestListError(pointids.toArray(arr));
|
|
|
+ }
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ String[] pointArray = new String[pointids.size()];
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, pointids.toArray(pointArray));
|
|
|
+ } else {
|
|
|
+ String[] arr = new String[pointids.size()];
|
|
|
+ return ErrorRequest.RequestListError(pointids.toArray(arr));
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ String[] arr = new String[pointids.size()];
|
|
|
+ return ErrorRequest.RequestListError(pointids.toArray(arr));
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Double> getRealDataMap(String... pointids) throws Exception {
|
|
|
+ String pointIdString = StringUtils.join(pointids, ",");
|
|
|
+ Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ try {
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null) {
|
|
|
+ Iterator<String> sIterator = jsonArray.keySet().iterator();
|
|
|
+ Map<String, Double> resultMap = new HashMap();
|
|
|
+ while (sIterator.hasNext()) {
|
|
|
+ // 获得key
|
|
|
+ String key = sIterator.next();
|
|
|
+ // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
|
|
|
+ JSONObject jsonData = jsonArray.getJSONObject(key);
|
|
|
+ Long ts = jsonData.getLong("ts");
|
|
|
+ String pointValue = null;
|
|
|
+ if (jsonData.containsKey("doubleValue")) {
|
|
|
+ pointValue = jsonData.getString("doubleValue");
|
|
|
+ } else if (jsonData.containsKey("booleanValue")) {
|
|
|
+ pointValue = jsonData.getString("booleanValue");
|
|
|
+ } else if (jsonData.containsKey("longValue")) {
|
|
|
+ pointValue = jsonData.getString("longValue");
|
|
|
+ } else if (jsonData.containsKey("stringValue")) {
|
|
|
+ pointValue = jsonData.getString("stringValue");
|
|
|
+ }
|
|
|
+ resultMap.put(key, Double.parseDouble(pointValue));
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+
|
|
|
+ } else
|
|
|
+ return ErrorRequest.RequestMapError();
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestMapError();
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasSnap(String pointid, Long beginDate, Long endDate, Long count, Long pried) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(pointid);
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/snap?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistoryDatasRaw(String pointid, Long beginDate, Long endDate) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(pointid);
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/raw?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, pointid);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistStat(Windturbinetestingpointai point, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/stat?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, point.getCode(), type);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistStat(Windpowerstationtestingpoint point, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getCode());
|
|
|
+ Optional<String> thingId = Optional.ofNullable(point.getWindpowerstationid());
|
|
|
+ Optional<String> thingType = Optional.ofNullable(point.getModelid());
|
|
|
+ Optional<String> uniformCode = Optional.ofNullable(point.getUniformcode());
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/stat?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ else {
|
|
|
+ if (thingType.isPresent())
|
|
|
+ url = url + "&thingType=" + thingType.get();
|
|
|
+ if (thingId.isPresent())
|
|
|
+ url = url + "&thingId=" + thingId.get();
|
|
|
+ if (uniformCode.isPresent())
|
|
|
+ url = url + "&uniformCodes=" + uniformCode.get();
|
|
|
+ }
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, point.getCode(), type);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PointData> getHistStat(String pointid, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(pointid);
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Long finalInterval;
|
|
|
+ if (count != null)
|
|
|
+ finalInterval = (endDate - beginDate) / count;
|
|
|
+ else if (pried != null)
|
|
|
+ finalInterval = pried;
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(Integer.parseInt(finalInterval.toString()));
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/stat?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.GeneralTsDataToPointDataByStat(jsonArray, pointid, type);
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(pointid);
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DNAStatVal[] getHistStat(String point, Long beginDate, Long endDate, Integer pried) throws Exception {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point);
|
|
|
+ Optional<Long> startTs = Optional.ofNullable(beginDate * 1000);
|
|
|
+ Optional<Long> endTs = Optional.ofNullable(endDate * 1000);
|
|
|
+ //通过时间区间和时间间隔获取点数
|
|
|
+ Optional<Integer> interval = Optional.ofNullable(pried);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String url = baseURL + "/history/stat?null=0";
|
|
|
+ //tagName 或thingType,thingId,uniformCode可以确定一个标签点
|
|
|
+ if (tagName.isPresent())
|
|
|
+ url = url + "&tagName=" + tagName.get();
|
|
|
+ if (startTs.isPresent())
|
|
|
+ url = url + "&startTs=" + startTs.get();
|
|
|
+ if (endTs.isPresent())
|
|
|
+ url = url + "&endTs=" + endTs.get();
|
|
|
+ if (interval.isPresent())
|
|
|
+ url = url + "&interval=" + interval.get();
|
|
|
+
|
|
|
+ System.out.println(restTemplate.getForEntity(url, JSONArray.class));
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ if (resp != null) {
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray == null || jsonArray.size() <= 0) {
|
|
|
+ DNAStatVal[] dnaVal = new DNAStatVal[1];
|
|
|
+ DNAVal errorData = new DNAVal();
|
|
|
+ errorData.Status = 0;
|
|
|
+
|
|
|
+ DNAStatVal val = new DNAStatVal();
|
|
|
+ val.avg = errorData;
|
|
|
+ val.max = errorData;
|
|
|
+ val.min = errorData;
|
|
|
+ dnaVal[0] = val;
|
|
|
+ return dnaVal;
|
|
|
+ } else {
|
|
|
+ return JsonObjectHelper.phraseDNAVal(jsonArray);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ DNAStatVal val = new DNAStatVal();
|
|
|
+ DNAStatVal[] dnaVal = new DNAStatVal[1];
|
|
|
+ DNAVal errorData = new DNAVal();
|
|
|
+ errorData.Status = 0;
|
|
|
+ val.avg = errorData;
|
|
|
+ val.max = errorData;
|
|
|
+ val.min = errorData;
|
|
|
+ dnaVal[0] = val;
|
|
|
+ return dnaVal;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ DNAStatVal val = new DNAStatVal();
|
|
|
+ DNAStatVal[] dnaVal = new DNAStatVal[1];
|
|
|
+ DNAVal errorData = new DNAVal();
|
|
|
+ errorData.Status = 0;
|
|
|
+ val.avg = errorData;
|
|
|
+ val.max = errorData;
|
|
|
+ val.min = errorData;
|
|
|
+ dnaVal[0] = val;
|
|
|
+ return dnaVal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject convertPointData(PointData pd) {
|
|
|
+ JSONObject jo = new JSONObject();
|
|
|
+ jo.put("tagName", pd.getEdnaId());
|
|
|
+ JSONObject joo = new JSONObject();
|
|
|
+ joo.put("ts", pd.getPointTime()*1000);
|
|
|
+ joo.put("status", 0);
|
|
|
+ joo.put("doubleValue", pd.getPointValueInDouble());
|
|
|
+ jo.put("tsData", joo);
|
|
|
+ return jo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updatePoint(PointData point) throws Exception {
|
|
|
+ String url = baseURL + "/history";
|
|
|
+ try {
|
|
|
+ String result = restTemplate.postForObject(url, convertPointData(point), String.class);
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DNAVal[] getRealtimeTagValues(String... tagNames) throws Exception {
|
|
|
+ String pointIdString = StringUtils.join(tagNames, ",");
|
|
|
+ Optional<String> keys = Optional.ofNullable(pointIdString);
|
|
|
+ String url = baseURL + "/latest?null=0";
|
|
|
+ try {
|
|
|
+ if (keys.isPresent())
|
|
|
+ url = url + "&keys=" + keys.get();
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonObject = resp.getBody();
|
|
|
+ if (jsonObject != null) {
|
|
|
+ return JsonObjectHelper.phraseDNAVal(jsonObject);
|
|
|
+ } else {
|
|
|
+ DNAVal[] errorResult = new DNAVal[1];
|
|
|
+ DNAVal val = new DNAVal();
|
|
|
+ val.Status = 0;
|
|
|
+ errorResult[0] = val;
|
|
|
+ return errorResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ DNAVal[] errorResult = new DNAVal[1];
|
|
|
+ DNAVal val = new DNAVal();
|
|
|
+ val.Status = 0;
|
|
|
+ errorResult[0] = val;
|
|
|
+ return errorResult;
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updatePoint(List<PointData> pointls) throws Exception {
|
|
|
+ String url = baseURL + "/history/batch";
|
|
|
+ List<JSONObject> writeList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (PointData entity : pointls) {
|
|
|
+ writeList.add(convertPointData(entity));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String result = restTemplate.postForObject(url, writeList, String.class);
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendSinglePoint(PointData point) throws Exception {
|
|
|
+ String url = baseURL + "/latest";
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ String result = restTemplate.postForObject(url, convertPointData(point), String.class);
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendMultiPoint(List<PointData> pointls) throws Exception {
|
|
|
+
|
|
|
+ String url = baseURL + "/latest/batch";
|
|
|
+ List<JSONObject> writeList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (PointData entity : pointls) {
|
|
|
+ writeList.add(convertPointData(entity));
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String result = restTemplate.postForObject(url, writeList, String.class);
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendMultiPoint(String[] realvalue, DNAVal[] pointls) throws Exception {
|
|
|
+ String url = baseURL + "/latest/batch";
|
|
|
+
|
|
|
+ List<JSONObject> writeDataList = new ArrayList<>();
|
|
|
+ if (realvalue != null && pointls != null & realvalue.length == pointls.length) {
|
|
|
+ for (int i = 0; i < realvalue.length; i++) {
|
|
|
+ PointData writeData = new PointData();
|
|
|
+ writeData.setEdnaId(realvalue[i]);
|
|
|
+ writeData.setPointValueInDouble(pointls[i].DValue);
|
|
|
+ writeData.setPointTime((long)pointls[i].Time);
|
|
|
+ JSONObject jsonObject=convertPointData(writeData);
|
|
|
+ writeDataList.add(jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String result = restTemplate.postForObject(url, writeDataList, String.class);
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ System.out.println("404请求错误");
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //多点切面数据
|
|
|
+ @Override
|
|
|
+ public DNAVal[] getHistMatrix(String[] nameList, int tTime) throws Exception {
|
|
|
+ String tagNameString = StringUtil.join(nameList, ",");
|
|
|
+ Long time = Long.valueOf(tTime);
|
|
|
+ Optional<String> tagName = Optional.ofNullable(tagNameString);
|
|
|
+ Optional<Long> ts = Optional.ofNullable(time*1000);
|
|
|
+ String url = baseURL + "/history/section?tagNames=" + tagName.get() + "&ts=" + ts.get();
|
|
|
+ try {
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonObject = resp.getBody();
|
|
|
+ if (jsonObject != null)
|
|
|
+ return JsonObjectHelper.phraseDNAVal(jsonObject);
|
|
|
+ else {
|
|
|
+ DNAVal[] errorResult = new DNAVal[1];
|
|
|
+ DNAVal val = new DNAVal();
|
|
|
+ val.Status = 0;
|
|
|
+ errorResult[0] = val;
|
|
|
+ return errorResult;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ DNAVal[] errorResult = new DNAVal[1];
|
|
|
+ DNAVal val = new DNAVal();
|
|
|
+ val.Status = 0;
|
|
|
+ errorResult[0] = val;
|
|
|
+ return errorResult;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|