fix event create conditions
This commit is contained in:
parent
6adc96761b
commit
2dc0b4e27c
@ -40,7 +40,8 @@ public class EventScheduler {
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void checkPeriodEvents() {
|
||||
log.debug("EventScheduler.checkPeriodEvents started");
|
||||
for (Event event : eventService.findAllFuture()) {
|
||||
//TODO: filter
|
||||
for (Event event : eventService.findAll()) {
|
||||
if (halfOfThePeriodHasPassed(event)) {
|
||||
eventService.createBasedOn(event, DateUtils.addDays(event.getExecuteDate(), getShiftInDays(event.getPeriod())));
|
||||
}
|
||||
@ -67,6 +68,6 @@ public class EventScheduler {
|
||||
private boolean halfOfThePeriodHasPassed(Event event) {
|
||||
return event.getPeriod() != null && event.getChild() == null
|
||||
&& new Date().after(
|
||||
DateUtils.addDays(event.getExecuteDate(), (int) -Math.round((double) getShiftInDays(event.getPeriod()) / 2)));
|
||||
DateUtils.addDays(event.getExecuteDate(), (int) Math.round((double) getShiftInDays(event.getPeriod()) / 2)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user