diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-06-15 10:14:26 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 10:14:26 +1200 |
commit | 86099e8094713c1d645c091c83aa0e5db4b3d6c5 (patch) | |
tree | f80935a9210c86062f37c09c67cde7ad7a261472 /src/org/traccar/api/resource/ReportResource.java | |
parent | ce9f1791ff8d10434392ea5853ccacf0cb2548f1 (diff) | |
parent | 106a36a73f3e40f1ee4d18ee73ee6cb12cb4ed00 (diff) | |
download | trackermap-server-86099e8094713c1d645c091c83aa0e5db4b3d6c5.tar.gz trackermap-server-86099e8094713c1d645c091c83aa0e5db4b3d6c5.tar.bz2 trackermap-server-86099e8094713c1d645c091c83aa0e5db4b3d6c5.zip |
Merge pull request #3247 from Abyss777/report_stops
Imlement Stops report
Diffstat (limited to 'src/org/traccar/api/resource/ReportResource.java')
-rw-r--r-- | src/org/traccar/api/resource/ReportResource.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java index a0f686e80..7c472e84d 100644 --- a/src/org/traccar/api/resource/ReportResource.java +++ b/src/org/traccar/api/resource/ReportResource.java @@ -22,9 +22,11 @@ import org.traccar.model.Position; import org.traccar.reports.Events; import org.traccar.reports.Summary; import org.traccar.reports.Trips; +import org.traccar.reports.model.StopReport; import org.traccar.reports.model.SummaryReport; import org.traccar.reports.model.TripReport; import org.traccar.reports.Route; +import org.traccar.reports.Stops; @Path("reports") @Produces(MediaType.APPLICATION_JSON) @@ -129,4 +131,29 @@ public class ReportResource extends BaseResource { .header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE_XLSX).build(); } + @Path("stops") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Collection<StopReport> getStops( + @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, + @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException { + return Stops.getObjects(getUserId(), deviceIds, groupIds, + DateUtil.parseDate(from), DateUtil.parseDate(to)); + } + + @Path("stops") + @GET + @Produces(XLSX) + public Response getStopsExcel( + @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, + @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException, IOException { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + Stops.getExcel(stream, getUserId(), deviceIds, groupIds, + DateUtil.parseDate(from), DateUtil.parseDate(to)); + + return Response.ok(stream.toByteArray()) + .header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE_XLSX).build(); + } + + } |