diff options
author | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-08-19 10:45:33 +0500 |
commit | 1c7437d6de01fffbe3f69853717808b1790413fd (patch) | |
tree | ae6fa7144b30321e754773af4a2d464c9e52c624 /src/org/traccar/api/resource/ReportResource.java | |
parent | 3826a93f1009942e22ec80c1e13be71e8e917b01 (diff) | |
download | trackermap-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.java | 23 |
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(); + } + } |