|
@@ -33,111 +33,130 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
|
|
|
|
|
|
@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();
|
|
|
+ if(StringUtils.notEmp(point) && StringUtils.notEmp(point.getCode()))
|
|
|
+ {
|
|
|
+ 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 (StringUtils.isNotEmpty(jsonArray)){
|
|
|
- List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
- if (list.size() > 0)
|
|
|
- return list.get(0);
|
|
|
- else
|
|
|
+ ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
+ JSONObject jsonArray = resp.getBody();
|
|
|
+ if (StringUtils.isNotEmpty(jsonArray)){
|
|
|
+ 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());
|
|
|
- } 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;
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new PointData();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@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) {
|
|
|
- List<PointData> snapList = JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
- List<PointData> resultList = new ArrayList<>();
|
|
|
-
|
|
|
- if(snapList.isEmpty())
|
|
|
- {
|
|
|
-
|
|
|
- getHistsnapSameTiem(point.getCode(), beginDate, pried, resultList);
|
|
|
- }else
|
|
|
- {
|
|
|
- for (PointData snapItem : snapList) {
|
|
|
+ if(StringUtils.notEmp(point) && StringUtils.notEmp(point.getCode()))
|
|
|
+ {
|
|
|
+ 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) {
|
|
|
+ List<PointData> snapList = JsonObjectHelper.phrasePointData(jsonArray, point.getCode());
|
|
|
+ List<PointData> resultList = new ArrayList<>();
|
|
|
|
|
|
- long subTime = snapItem.getPointTime() - pried;
|
|
|
- //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
|
|
|
- // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
|
|
|
- // 则代表该时间节点快照有效,否则为0
|
|
|
- String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getCode() + "&ts=" + snapItem.getPointTime() + "000";
|
|
|
- ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
|
|
|
- JSONObject jsonObjectSection = sectionResp.getBody();
|
|
|
+ if(snapList.isEmpty())
|
|
|
+ {
|
|
|
|
|
|
- if (jsonObjectSection != null) {
|
|
|
- List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
|
|
|
- if (sectionlist.size() > 0) {
|
|
|
- if(sectionlist.get(0).getPointTime()>=subTime&§ionlist.get(0).getPointTime()<=snapItem.getPointTime()){
|
|
|
- resultList.add(snapItem);
|
|
|
- }
|
|
|
- else{
|
|
|
+ getHistsnapSameTiem(point.getCode(), beginDate, pried, resultList);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ for (PointData snapItem : snapList) {
|
|
|
+
|
|
|
+ long subTime = snapItem.getPointTime() - pried;
|
|
|
+ //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
|
|
|
+ // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
|
|
|
+ // 则代表该时间节点快照有效,否则为0
|
|
|
+ String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getCode() + "&ts=" + snapItem.getPointTime() + "000";
|
|
|
+ ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
|
|
|
+ JSONObject jsonObjectSection = sectionResp.getBody();
|
|
|
+
|
|
|
+ if (jsonObjectSection != null) {
|
|
|
+ List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
|
|
|
+ if (sectionlist.size() > 0) {
|
|
|
+ if(sectionlist.get(0).getPointTime()>=subTime&§ionlist.get(0).getPointTime()<=snapItem.getPointTime()){
|
|
|
+ resultList.add(snapItem);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ PointData data = new PointData();
|
|
|
+ data.setEdnaId(point.getCode());
|
|
|
+ data.setPointTime(snapItem.getPointTime());
|
|
|
+ data.setPointValue("0");
|
|
|
+ data.setPointName("1");
|
|
|
+ data.setPointValueInDouble(0.0);
|
|
|
+ resultList.add(data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
PointData data = new PointData();
|
|
|
data.setEdnaId(point.getCode());
|
|
|
data.setPointTime(snapItem.getPointTime());
|
|
@@ -155,35 +174,31 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
|
|
|
data.setPointValueInDouble(0.0);
|
|
|
resultList.add(data);
|
|
|
}
|
|
|
- } else {
|
|
|
- PointData data = new PointData();
|
|
|
- data.setEdnaId(point.getCode());
|
|
|
- data.setPointTime(snapItem.getPointTime());
|
|
|
- data.setPointValue("0");
|
|
|
- data.setPointName("1");
|
|
|
- data.setPointValueInDouble(0.0);
|
|
|
- resultList.add(data);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- return resultList;
|
|
|
+ return resultList;
|
|
|
|
|
|
|
|
|
- } else {
|
|
|
- return ErrorRequest.RequestListError(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;
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -231,158 +246,185 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
|
|
|
|
|
|
@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(StringUtils.notEmp(point) && StringUtils.notEmp(point.getCode()))
|
|
|
+ {
|
|
|
+ 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();
|
|
|
+ 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());
|
|
|
- }
|
|
|
+ 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;
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getCode());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PointData getRealData(WindTurbineTestingPointAi point) throws Exception {
|
|
|
- Optional<String> keys = Optional.ofNullable(point.getId());
|
|
|
- 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 (StringUtils.isNotEmpty(jsonArray)){
|
|
|
- List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
- if (list.size() > 0)
|
|
|
- return list.get(0);
|
|
|
- else
|
|
|
+ if(StringUtils.notEmp(point) && StringUtils.notEmp(point.getId()))
|
|
|
+ {
|
|
|
+ Optional<String> keys = Optional.ofNullable(point.getId());
|
|
|
+ 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 (StringUtils.isNotEmpty(jsonArray)){
|
|
|
+ List<PointData> list = JsonObjectHelper.phrasePointData(jsonArray);
|
|
|
+ if (list.size() > 0)
|
|
|
+ return list.get(0);
|
|
|
+ else
|
|
|
+ return ErrorRequest.RequestError(point.getId());
|
|
|
+ } else {
|
|
|
return ErrorRequest.RequestError(point.getId());
|
|
|
- } else {
|
|
|
- return ErrorRequest.RequestError(point.getId());
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- } catch (HttpClientErrorException exception) {
|
|
|
- if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
- //System.out.println("404请求错误");
|
|
|
- return ErrorRequest.RequestError(point.getId());
|
|
|
- } else {
|
|
|
- throw exception;
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestError(point.getId());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new PointData();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<PointData> getHistoryDatasSnap(WindTurbineTestingPointAi point, Long beginDate, Long endDate, Long count, Long pried) throws Exception {
|
|
|
- Optional<String> tagName = Optional.ofNullable(point.getId());
|
|
|
- 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.getId());
|
|
|
- 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) {
|
|
|
- List<PointData> snapList = JsonObjectHelper.phrasePointData(jsonArray, point.getId());
|
|
|
- List<PointData> resultList = new ArrayList<>();
|
|
|
-
|
|
|
- if(snapList.isEmpty())
|
|
|
- {
|
|
|
+ if(StringUtils.notEmp(point) && StringUtils.notEmp(point.getId()))
|
|
|
+ {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getId());
|
|
|
+ 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.getId());
|
|
|
+ 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) {
|
|
|
+ List<PointData> snapList = JsonObjectHelper.phrasePointData(jsonArray, point.getId());
|
|
|
+ List<PointData> resultList = new ArrayList<>();
|
|
|
|
|
|
- getHistsnapSameTiem(point.getId(), beginDate, pried, resultList);
|
|
|
- }else
|
|
|
- {
|
|
|
- for (PointData snapItem : snapList) {
|
|
|
- long subTime = snapItem.getPointTime() - pried;
|
|
|
- //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
|
|
|
- // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
|
|
|
- // 则代表该时间节点快照有效,否则为0
|
|
|
- String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getId() + "&ts=" + snapItem.getPointTime() + "000";
|
|
|
- ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
|
|
|
- JSONObject jsonObjectSection = sectionResp.getBody();
|
|
|
+ if(snapList.isEmpty())
|
|
|
+ {
|
|
|
|
|
|
- if (jsonObjectSection != null) {
|
|
|
- List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
|
|
|
- if (sectionlist.size() > 0) {
|
|
|
- if(sectionlist.get(0).getPointTime()>=subTime&§ionlist.get(0).getPointTime()<=snapItem.getPointTime()){
|
|
|
- resultList.add(snapItem);
|
|
|
- }
|
|
|
- else{
|
|
|
+ getHistsnapSameTiem(point.getId(), beginDate, pried, resultList);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ for (PointData snapItem : snapList) {
|
|
|
+ long subTime = snapItem.getPointTime() - pried;
|
|
|
+ //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
|
|
|
+ // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
|
|
|
+ // 则代表该时间节点快照有效,否则为0
|
|
|
+ String rawUrl = baseURL + "/history/section?null=0&tagNames=" + point.getId() + "&ts=" + snapItem.getPointTime() + "000";
|
|
|
+ ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
|
|
|
+ JSONObject jsonObjectSection = sectionResp.getBody();
|
|
|
+
|
|
|
+ if (jsonObjectSection != null) {
|
|
|
+ List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
|
|
|
+ if (sectionlist.size() > 0) {
|
|
|
+ if(sectionlist.get(0).getPointTime()>=subTime&§ionlist.get(0).getPointTime()<=snapItem.getPointTime()){
|
|
|
+ resultList.add(snapItem);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ PointData data = new PointData();
|
|
|
+ data.setEdnaId(point.getId());
|
|
|
+ data.setPointTime(snapItem.getPointTime());
|
|
|
+ data.setPointValue("0");
|
|
|
+ data.setPointName("1");
|
|
|
+ data.setPointValueInDouble(0.0);
|
|
|
+ resultList.add(data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
PointData data = new PointData();
|
|
|
data.setEdnaId(point.getId());
|
|
|
data.setPointTime(snapItem.getPointTime());
|
|
@@ -400,76 +442,79 @@ public class EdosUtil implements IRealTimeDataBaseUtil {
|
|
|
data.setPointValueInDouble(0.0);
|
|
|
resultList.add(data);
|
|
|
}
|
|
|
- } else {
|
|
|
- PointData data = new PointData();
|
|
|
- data.setEdnaId(point.getId());
|
|
|
- data.setPointTime(snapItem.getPointTime());
|
|
|
- data.setPointValue("0");
|
|
|
- data.setPointName("1");
|
|
|
- data.setPointValueInDouble(0.0);
|
|
|
- resultList.add(data);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- return resultList;
|
|
|
- } else {
|
|
|
- return ErrorRequest.RequestListError(point.getId());
|
|
|
- }
|
|
|
- } catch (HttpClientErrorException exception) {
|
|
|
- if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
- //System.out.println("404请求错误");
|
|
|
- return ErrorRequest.RequestListError(point.getId());
|
|
|
- } else {
|
|
|
- throw exception;
|
|
|
+ return resultList;
|
|
|
+ } else {
|
|
|
+ return ErrorRequest.RequestListError(point.getId());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getId());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public List<PointData> getHistoryDatasRaw(WindTurbineTestingPointAi point, Long beginDate, Long endDate) throws Exception {
|
|
|
- Optional<String> tagName = Optional.ofNullable(point.getId());
|
|
|
- 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(StringUtils.notEmp(point) && StringUtils.notEmp(point.getId()))
|
|
|
+ {
|
|
|
+ Optional<String> tagName = Optional.ofNullable(point.getId());
|
|
|
+ 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();
|
|
|
+ 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.getId());
|
|
|
- else {
|
|
|
- return ErrorRequest.RequestListError(point.getId());
|
|
|
- }
|
|
|
- } catch (HttpClientErrorException exception) {
|
|
|
- if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
- //System.out.println("404请求错误");
|
|
|
- return ErrorRequest.RequestListError(point.getId());
|
|
|
- } else {
|
|
|
- throw exception;
|
|
|
+ ResponseEntity<JSONArray> resp = restTemplate.getForEntity(url, JSONArray.class);
|
|
|
+ JSONArray jsonArray = resp.getBody();
|
|
|
+ if (jsonArray != null)
|
|
|
+ return JsonObjectHelper.phrasePointData(jsonArray, point.getId());
|
|
|
+ else {
|
|
|
+ return ErrorRequest.RequestListError(point.getId());
|
|
|
+ }
|
|
|
+ } catch (HttpClientErrorException exception) {
|
|
|
+ if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
|
|
+ //System.out.println("404请求错误");
|
|
|
+ return ErrorRequest.RequestListError(point.getId());
|
|
|
+ } else {
|
|
|
+ throw exception;
|
|
|
+ }
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|