I want to read data for last 30 days from database for each day..
ItemReader - Read data for each day ItemProcessor - Process data for each day ItemWriter - Write the processed data into database.
I want to repeat this process till date..
public boolean processTicketStatistics() {
LocalDate startDate = LocalDate.now().minus(Period.ofDays(30));
LocalDate endDate = LocalDate.now().plus(Period.ofDays(1));
for (LocalDate d = startDate; d.isBefore(endDate); d = d.plusDays(1)) {
TicketStatistics statistics = new TicketStatistics();
statistics.setDate(localDateTimeToDate(d.atStartOfDay()));
statistics.setTickets(ticketRepository.count(TicketSpecification.ticketHasDateRange(
localDateTimeToDate(d.atStartOfDay()),
localDateTimeToDate(d.atTime(LocalTime.MAX)))));
ticketStatisticsRepository.save(statistics);
}
return true;
}
Can you please help me how to achieve this in Spring batch?