aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/ReportUtils.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index e12968428..010c88b22 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
* Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -151,8 +151,10 @@ public final class ReportUtils {
return jxlsContext;
}
- public static void processTemplateWithSheets(InputStream templateStream, OutputStream targetStream,
+ public static void processTemplateWithSheets(
+ InputStream templateStream, OutputStream targetStream,
org.jxls.common.Context jxlsContext) throws IOException {
+
Transformer transformer = TransformerFactory.createTransformer(templateStream, targetStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
for (Area xlsArea : xlsAreas) {
@@ -166,6 +168,7 @@ public final class ReportUtils {
private static TripReport calculateTrip(
ArrayList<Position> positions, int startIndex, int endIndex, boolean ignoreOdometer) {
+
Position startTrip = positions.get(startIndex);
Position endTrip = positions.get(endIndex);
@@ -230,8 +233,9 @@ public final class ReportUtils {
return trip;
}
- private static StopReport calculateStop(ArrayList<Position> positions, int startIndex, int endIndex,
- boolean ignoreOdometer) {
+ private static StopReport calculateStop(
+ ArrayList<Position> positions, int startIndex, int endIndex, boolean ignoreOdometer) {
+
Position startStop = positions.get(startIndex);
Position endStop = positions.get(endIndex);
@@ -281,8 +285,9 @@ public final class ReportUtils {
}
- private static <T extends BaseReport> T calculateTripOrStop(ArrayList<Position> positions, int startIndex,
- int endIndex, boolean ignoreOdometer, Class<T> reportClass) {
+ private static <T extends BaseReport> T calculateTripOrStop(
+ ArrayList<Position> positions, int startIndex, int endIndex, boolean ignoreOdometer, Class<T> reportClass) {
+
if (reportClass.equals(TripReport.class)) {
return (T) calculateTrip(positions, startIndex, endIndex, ignoreOdometer);
} else {
@@ -310,12 +315,14 @@ public final class ReportUtils {
}
}
- public static <T extends BaseReport> Collection<T> detectTripsAndStops(Collection<Position> positionCollection,
+ public static <T extends BaseReport> Collection<T> detectTripsAndStops(
+ Collection<Position> positionCollection,
TripsConfig tripsConfig, boolean ignoreOdometer, Class<T> reportClass) {
+
Collection<T> result = new ArrayList<>();
ArrayList<Position> positions = new ArrayList<>(positionCollection);
- if (positions != null && !positions.isEmpty()) {
+ if (!positions.isEmpty()) {
boolean trips = reportClass.equals(TripReport.class);
MotionEventHandler motionHandler = new MotionEventHandler(tripsConfig);
DeviceState deviceState = new DeviceState();
@@ -354,6 +361,8 @@ public final class ReportUtils {
ignoreOdometer, reportClass));
}
}
+
return result;
}
+
}