|
|
@ -136,10 +136,10 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
|
|
|
|
@Produces("application/json")
|
|
|
|
@Produces("application/json")
|
|
|
|
public Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
|
|
|
public Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
|
|
|
@QueryParam("to") long to) {
|
|
|
|
@QueryParam("to") long to) {
|
|
|
|
String fromDate = String.valueOf(from);
|
|
|
|
String fromDate = String.valueOf(from*1000); // converting time to ms
|
|
|
|
String toDate = String.valueOf(to);
|
|
|
|
String toDate = String.valueOf(to*1000); // converting time to ms
|
|
|
|
String query = "deviceId:" + deviceId + " AND deviceType:" +
|
|
|
|
String query = "meta_deviceId:" + deviceId + " AND meta_deviceType:" +
|
|
|
|
VirtualFireAlarmConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]";
|
|
|
|
VirtualFireAlarmConstants.DEVICE_TYPE + " AND meta_time : [" + fromDate + " TO " + toDate + "]";
|
|
|
|
String sensorTableName = VirtualFireAlarmConstants.TEMPERATURE_EVENT_TABLE;
|
|
|
|
String sensorTableName = VirtualFireAlarmConstants.TEMPERATURE_EVENT_TABLE;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(
|
|
|
|
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(
|
|
|
@ -148,7 +148,7 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
|
|
|
|
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
|
|
|
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<SortByField> sortByFields = new ArrayList<>();
|
|
|
|
List<SortByField> sortByFields = new ArrayList<>();
|
|
|
|
SortByField sortByField = new SortByField("time", SortType.ASC);
|
|
|
|
SortByField sortByField = new SortByField("meta_time", SortType.ASC);
|
|
|
|
sortByFields.add(sortByField);
|
|
|
|
sortByFields.add(sortByField);
|
|
|
|
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
|
|
|
|
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();
|
|
|
|