diff options
Diffstat (limited to 'src/org/traccar/api')
-rw-r--r-- | src/org/traccar/api/resource/ReportResource.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java index cf11cd4e4..0885a3638 100644 --- a/src/org/traccar/api/resource/ReportResource.java +++ b/src/org/traccar/api/resource/ReportResource.java @@ -12,6 +12,7 @@ import javax.ws.rs.core.Response.ResponseBuilder; import org.traccar.api.BaseResource; import org.traccar.reports.Events; +import org.traccar.reports.General; import org.traccar.reports.ReportUtils; import org.traccar.reports.Route; import org.traccar.web.JsonConverter; @@ -54,4 +55,21 @@ public class ReportResource extends BaseResource { return response.build(); } + @Path("general") + @GET + public Response getGeneral( + @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, + @QueryParam("from") String from, @QueryParam("to") String to) throws SQLException { + if (getAcceptHeader().equals("application/ms-excel")) { + ResponseBuilder response = Response.ok(ReportUtils.getOut(General.getCsv(getUserId(), deviceIds, groupIds, + JsonConverter.parseDate(from), JsonConverter.parseDate(to)))); + response.type("application/ms-excel"); + return response.build(); + } + ResponseBuilder response = Response.ok(General.getJson(getUserId(), deviceIds, groupIds, + JsonConverter.parseDate(from), JsonConverter.parseDate(to))); + response.type(MediaType.APPLICATION_JSON); + return response.build(); + } + } |