89-time-series-by-cron #90

Merged
romanov73 merged 5 commits from 89-time-series-by-cron into master 2023-02-20 10:16:33 +04:00
2 changed files with 8 additions and 8 deletions
Showing only changes of commit a5c9d15d4f - Show all commits

View File

@ -22,13 +22,13 @@ public class ScheduledTimeSeriesService {
this.branchService = branchService;
}
@Scheduled(cron = "0 */5 * * * *", zone = "Europe/Samara")
@Scheduled(cron = "0 0 * * * *", zone = "Europe/Samara")
public void addTimeSeriesPoints() {
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started");
log.debug("Старт добавления новых точек временного ряда");
List<Branch> branches = branchService.findAll();
branches.forEach(branch -> {
scheduledTimeSeriesCreators.forEach(creator -> creator.addTimeSeriesValue(branch));
});
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished");
log.debug("Завершение добавления новых точек временного ряда");
}
}

View File

@ -47,13 +47,13 @@ public class TimeSeriesService {
@Transactional
public TimeSeries save(String timeSeriesName, Branch branch, TimeSeriesType timeSeriesType, List<TimeSeriesValue> timeSeriesValues) {
LOG.debug("Start save {} time series with {} time series values ", timeSeriesName, timeSeriesValues.size());
LOG.debug("Начало сохранения временного ряда {} с {} значениями", timeSeriesName, timeSeriesValues.size());
final TimeSeries timeSeries = findOrCreate(timeSeriesName, branch, timeSeriesType);
List<TimeSeriesValue> timeSeriesValuesToRemove = timeSeries.getValues();
timeSeries.setValues(timeSeriesValues);
LOG.debug("Save time series {} ", timeSeries.getName());
LOG.debug("Сохранение временного ряда {} ", timeSeries.getName());
TimeSeries savedTimeSeries = timeSeriesRepository.save(timeSeries);
LOG.debug("Clear {} time series values ", timeSeriesValuesToRemove.size());
LOG.debug("Очистить {} точек временного ряда", timeSeriesValuesToRemove.size());
timeSeriesValueRepository.deleteAll(timeSeriesValuesToRemove);
sendToTimeSeriesService(savedTimeSeries);
return savedTimeSeries;
@ -100,7 +100,7 @@ public class TimeSeriesService {
new Thread(() -> {
try {
httpService.post(TIME_SERIES_SAVE_SERVICE_URL, new JSONObject(new JsonTimeSeries(timeSeries)));
LOG.debug("Успешно отправлен на сервис");
LOG.debug("{} успешно отправлен на сервис временных рядов", timeSeries.getName());
} catch (Exception ex) {
LOG.debug(ex.getMessage());
}
@ -113,7 +113,7 @@ public class TimeSeriesService {
public TimeSeries getById(Integer tsId) {
return timeSeriesRepository.findById(tsId)
.orElseThrow(() -> new RuntimeException("Time series not found by id " + tsId));
.orElseThrow(() -> new RuntimeException("Временной ряд не найден по идентификатору " + tsId));
}
public List<TimeSeriesType> getAllTimeSeriesTypes() {