diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-20 13:13:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-20 13:13:09 +0300 |
commit | 6c6b62351aadd68928b9bd3e39e2bf96d78695e8 (patch) | |
tree | 8d9f5617aada94e3c8784c0bee6a201fbced54b3 /src/org/traccar/api | |
parent | 6b6d28695600fee509ee37a7225dd6518879ac9c (diff) | |
parent | 804c56a76dc8406e4ff072289a4a9f97322dfe83 (diff) | |
download | trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.gz trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.bz2 trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.zip |
Merge pull request #2228 from Abyss777/reports_trips
Implement trips reports
Diffstat (limited to 'src/org/traccar/api')
-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(); + } + } |