#80 -- fix forecasting
This commit is contained in:
parent
4d7f0f38b8
commit
9aa05b83e2
@ -21,15 +21,20 @@ public class HttpService {
|
|||||||
|
|
||||||
public JSONObject post(String url, JSONObject postData) {
|
public JSONObject post(String url, JSONObject postData) {
|
||||||
log.debug("Service call: {}", url);
|
log.debug("Service call: {}", url);
|
||||||
JSONObject response = new JSONObject(Optional.ofNullable(client
|
JSONObject response = null;
|
||||||
.post()
|
try {
|
||||||
.uri(url)
|
response = new JSONObject(Optional.ofNullable(client
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.post()
|
||||||
.body(BodyInserters.fromValue(postData.toString()))
|
.uri(url)
|
||||||
.accept(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.retrieve()
|
.body(BodyInserters.fromValue(postData.toString()))
|
||||||
.bodyToMono(String.class)
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
.block()).orElse("{response:\"empty\"}"));
|
.retrieve()
|
||||||
|
.bodyToMono(String.class)
|
||||||
|
.toFuture().get()).orElse("{response:\"empty\"}"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new JSONObject("{response:\"empty\"}");
|
||||||
|
}
|
||||||
log.debug("Service response: {}", response);
|
log.debug("Service response: {}", response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,9 @@ public class TimeSeriesService {
|
|||||||
if (ts != null && ts.getValues().size() > 5) {
|
if (ts != null && ts.getValues().size() > 5) {
|
||||||
JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
|
JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
|
||||||
LOG.debug("Успешно отправлен на сервис сглаживания");
|
LOG.debug("Успешно отправлен на сервис сглаживания");
|
||||||
response.get("timeSeries");
|
if (response.has("response") && response.getString("response").equals("empty")) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values");
|
JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values");
|
||||||
return jsonArray.getJSONObject(jsonArray.length() - 1).getDouble("value");
|
return jsonArray.getJSONObject(jsonArray.length() - 1).getDouble("value");
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ logging.level.sun.rmi.transport=off
|
|||||||
logging.level.javax.management.remote.rmi=off
|
logging.level.javax.management.remote.rmi=off
|
||||||
logging.level.java.rmi.server=off
|
logging.level.java.rmi.server=off
|
||||||
extractor.custom-projects-dir=
|
extractor.custom-projects-dir=
|
||||||
|
server.error.include-stacktrace=always
|
||||||
|
server.error.include-exception=true
|
||||||
|
server.error.include-message=always
|
||||||
# Thymeleaf Settings
|
# Thymeleaf Settings
|
||||||
spring.thymeleaf.cache=false
|
spring.thymeleaf.cache=false
|
||||||
messages.basename.path=messages_en.properties
|
messages.basename.path=messages_en.properties
|
||||||
|
@ -32,16 +32,26 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="collapse" id="collapseExample">
|
<div class="collapse" id="collapseExample">
|
||||||
<p class="card card-body">
|
<p class="card card-body">
|
||||||
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div>
|
<div>
|
||||||
</p>
|
<span><strong>Status</strong></span>
|
||||||
<div th:if="${exception != null}" th:utext="'Exception: ' + ${exception.message}" th:remove="tag">
|
<span th:text="${status}"></span>
|
||||||
${exception.message}
|
</div>
|
||||||
|
<div>
|
||||||
|
<span><strong>Error</strong></span>
|
||||||
|
<span th:text="${error}"></span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span><strong>Message</strong></span>
|
||||||
|
<span th:text="${message}"></span>
|
||||||
|
</div>
|
||||||
|
<div th:if="${exception != null}">
|
||||||
|
<span><strong>Exception</strong></span>
|
||||||
|
<span th:text="${exception}"></span>
|
||||||
|
</div>
|
||||||
|
<div th:if="${trace != null}">
|
||||||
|
<span><strong>Stacktrace</strong></span>
|
||||||
|
<span th:text="${trace}"></span>
|
||||||
</div>
|
</div>
|
||||||
<ul th:remove="tag">
|
|
||||||
<li th:if="${exception != null && exception.stackTrace != null}" th:each="ste : ${exception.stackTrace}"
|
|
||||||
th:remove="tag"><span
|
|
||||||
th:utext="${ste}" th:remove="tag">${ste}</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user