aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/schedule/TaskReports.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
committerIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
commit55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch)
treeb86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/schedule/TaskReports.java
parentc04ad7d48331253c095fc123ded1b00f6ff871d3 (diff)
parent2788174193def918a3a1a5be3bbed24c9613323f (diff)
downloadtrackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip
Merge tag 'tags/v6.3'
Diffstat (limited to 'src/main/java/org/traccar/schedule/TaskReports.java')
-rw-r--r--src/main/java/org/traccar/schedule/TaskReports.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/main/java/org/traccar/schedule/TaskReports.java b/src/main/java/org/traccar/schedule/TaskReports.java
index 070fa9d2b..32f6fea87 100644
--- a/src/main/java/org/traccar/schedule/TaskReports.java
+++ b/src/main/java/org/traccar/schedule/TaskReports.java
@@ -41,6 +41,8 @@ import org.traccar.storage.query.Condition;
import org.traccar.storage.query.Request;
import jakarta.inject.Inject;
+
+import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
@@ -50,7 +52,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-public class TaskReports implements ScheduleTask {
+public class TaskReports extends SingleScheduleTask {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskReports.class);
@@ -83,12 +85,12 @@ public class TaskReports implements ScheduleTask {
var lastEvents = calendar.findPeriods(lastCheck);
var currentEvents = calendar.findPeriods(currentCheck);
- Set<Period> finishedEvents = new HashSet<>(lastEvents);
+ Set<Period<Instant>> finishedEvents = new HashSet<>(lastEvents);
finishedEvents.removeAll(currentEvents);
- for (Period period : finishedEvents) {
+ for (Period<Instant> period : finishedEvents) {
RequestScoper scope = ServletScopes.scopeRequest(Collections.emptyMap());
try (RequestScoper.CloseableScope ignored = scope.open()) {
- executeReport(report, period.getStart(), period.getEnd());
+ executeReport(report, Date.from(period.getStart()), Date.from(period.getEnd()));
}
}
}
@@ -116,34 +118,32 @@ public class TaskReports implements ScheduleTask {
for (User user : users) {
LogAction.report(user.getId(), true, report.getType(), from, to, deviceIds, groupIds);
switch (report.getType()) {
- case "events":
+ case "events" -> {
var eventsReportProvider = injector.getInstance(EventsReportProvider.class);
reportMailer.sendAsync(user.getId(), stream -> eventsReportProvider.getExcel(
stream, user.getId(), deviceIds, groupIds, List.of(), from, to));
- break;
- case "route":
+ }
+ case "route" -> {
var routeReportProvider = injector.getInstance(RouteReportProvider.class);
reportMailer.sendAsync(user.getId(), stream -> routeReportProvider.getExcel(
stream, user.getId(), deviceIds, groupIds, from, to));
- break;
- case "summary":
+ }
+ case "summary" -> {
var summaryReportProvider = injector.getInstance(SummaryReportProvider.class);
reportMailer.sendAsync(user.getId(), stream -> summaryReportProvider.getExcel(
stream, user.getId(), deviceIds, groupIds, from, to, false));
- break;
- case "trips":
+ }
+ case "trips" -> {
var tripsReportProvider = injector.getInstance(TripsReportProvider.class);
reportMailer.sendAsync(user.getId(), stream -> tripsReportProvider.getExcel(
stream, user.getId(), deviceIds, groupIds, from, to));
- break;
- case "stops":
+ }
+ case "stops" -> {
var stopsReportProvider = injector.getInstance(StopsReportProvider.class);
reportMailer.sendAsync(user.getId(), stream -> stopsReportProvider.getExcel(
stream, user.getId(), deviceIds, groupIds, from, to));
- break;
- default:
- LOGGER.warn("Unsupported report type {}", report.getType());
- break;
+ }
+ default -> LOGGER.warn("Unsupported report type {}", report.getType());
}
}
}