From 64888cfc53cceaf6ca545186b3eb44019923a954 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 14 Jun 2017 11:39:15 +0500 Subject: Imlement Stops report --- src/org/traccar/api/resource/ReportResource.java | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/org/traccar/api') 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 getStops( + @QueryParam("deviceId") final List deviceIds, @QueryParam("groupId") final List 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 deviceIds, @QueryParam("groupId") final List 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(); + } + + } -- cgit v1.2.3