From 7b3fda2da562ce7b259a232bf9fc5f519c138283 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 20 Apr 2024 09:28:20 -0700 Subject: Fix overlapping report schedules --- src/main/java/org/traccar/model/Calendar.java | 5 ++--- src/main/java/org/traccar/schedule/TaskReports.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/model/Calendar.java b/src/main/java/org/traccar/model/Calendar.java index 03f1995ba..feef7286f 100644 --- a/src/main/java/org/traccar/model/Calendar.java +++ b/src/main/java/org/traccar/model/Calendar.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2024 Anton Tananaev (anton@traccar.org) * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -79,9 +79,8 @@ public class Calendar extends ExtendedModel { } public Collection findPeriods(Date date) { - var calendarDate = new net.fortuna.ical4j.model.Date(date); return findEvents(date).stream() - .flatMap((event) -> event.getConsumedTime(calendarDate, calendarDate).stream()) + .flatMap((e) -> e.calculateRecurrenceSet(new Period(new DateTime(date), Duration.ZERO)).stream()) .collect(Collectors.toSet()); } diff --git a/src/main/java/org/traccar/schedule/TaskReports.java b/src/main/java/org/traccar/schedule/TaskReports.java index 2102b2ee1..3989cd6a0 100644 --- a/src/main/java/org/traccar/schedule/TaskReports.java +++ b/src/main/java/org/traccar/schedule/TaskReports.java @@ -81,7 +81,7 @@ public class TaskReports implements ScheduleTask { var lastEvents = calendar.findPeriods(lastCheck); var currentEvents = calendar.findPeriods(currentCheck); - if (!lastEvents.isEmpty() && currentEvents.isEmpty()) { + if (!lastEvents.isEmpty() && !currentEvents.equals(lastEvents)) { Period period = lastEvents.iterator().next(); RequestScoper scope = ServletScopes.scopeRequest(Collections.emptyMap()); try (RequestScoper.CloseableScope ignored = scope.open()) { -- cgit v1.2.3