diff options
author | Abyss777 <abyss@fox5.ru> | 2016-08-03 10:05:40 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-08-04 16:33:34 +0500 |
commit | a5c431069ca0dfe8240f0c8b43f0508189f8fc86 (patch) | |
tree | d3de1b83fbb8ec487a1e6cbef5cb13f2941c2868 /src/org/traccar/api | |
parent | 41668cae9763a523c775a8a998620fe286176c9e (diff) | |
download | trackermap-server-a5c431069ca0dfe8240f0c8b43f0508189f8fc86.tar.gz trackermap-server-a5c431069ca0dfe8240f0c8b43f0508189f8fc86.tar.bz2 trackermap-server-a5c431069ca0dfe8240f0c8b43f0508189f8fc86.zip |
- Added getGroupDevices to PermissionsManager
- Implemented Route Report
Diffstat (limited to 'src/org/traccar/api')
-rw-r--r-- | src/org/traccar/api/resource/ReportResource.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java new file mode 100644 index 000000000..598cbebf6 --- /dev/null +++ b/src/org/traccar/api/resource/ReportResource.java @@ -0,0 +1,43 @@ +package org.traccar.api.resource; + +import java.sql.SQLException; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.ResponseBuilder; + +import org.traccar.api.BaseResource; +import org.traccar.reports.ReportUtils; +import org.traccar.reports.Route; +import org.traccar.web.JsonConverter; + +@Path("reports") +public class ReportResource extends BaseResource { + + @Path("route") + @GET + public Response getRoute(@Context HttpHeaders headers, + @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, + @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException { + MultivaluedMap<String, String> headerParams = headers.getRequestHeaders(); + String accept = headerParams.getFirst("Accept"); + if (accept.equals("application/ms-excel")) { + ResponseBuilder response = Response.ok(ReportUtils.getOut(Route.getCsv(getUserId(), deviceIds, groupIds, + JsonConverter.parseDate(from), JsonConverter.parseDate(to)))); + response.type("application/ms-excel"); + return response.build(); + } + ResponseBuilder response = Response.ok(Route.getJson(getUserId(), deviceIds, groupIds, + JsonConverter.parseDate(from), JsonConverter.parseDate(to))); + response.type(MediaType.APPLICATION_JSON); + return response.build(); + } + +} |