aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/ReportResource.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-19 10:45:33 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-19 10:45:33 +0500
commit1c7437d6de01fffbe3f69853717808b1790413fd (patch)
treeae6fa7144b30321e754773af4a2d464c9e52c624 /src/org/traccar/api/resource/ReportResource.java
parent3826a93f1009942e22ec80c1e13be71e8e917b01 (diff)
downloadtrackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.gz
trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.bz2
trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.zip
- Added trips report
- Refactored reports models - Added tests for ReportUtils - Added speed to test-generator.py - Other changes
Diffstat (limited to 'src/org/traccar/api/resource/ReportResource.java')
-rw-r--r--src/org/traccar/api/resource/ReportResource.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java
index e87d6401c..0dd0452ff 100644
--- a/src/org/traccar/api/resource/ReportResource.java
+++ b/src/org/traccar/api/resource/ReportResource.java
@@ -15,6 +15,7 @@ import javax.ws.rs.core.Response;
import org.traccar.api.BaseResource;
import org.traccar.reports.Events;
import org.traccar.reports.Summary;
+import org.traccar.reports.Trips;
import org.traccar.reports.Route;
import org.traccar.web.JsonConverter;
@@ -93,4 +94,26 @@ public class ReportResource extends BaseResource {
.build();
}
+ @Path("trips")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getTripsJson(
+ @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
+ @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
+ return Response.ok(Trips.getJson(getUserId(), deviceIds, groupIds,
+ JsonConverter.parseDate(from), JsonConverter.parseDate(to))).build();
+ }
+
+ @Path("trips")
+ @GET
+ @Produces(TEXT_CSV)
+ public Response getTripsCsv(
+ @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
+ @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
+ return Response.ok(Trips.getCsv(getUserId(), deviceIds, groupIds,
+ JsonConverter.parseDate(from), JsonConverter.parseDate(to)))
+ .header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE)
+ .build();
+ }
+
}