Fix traccar issues

merge-requests/926/head
shamalka 2 years ago
parent b7311af447
commit 1bd87e15f1

@ -532,12 +532,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
for (Device device : devices.getList()) {
TrackerDeviceInfo trackerDevice = DeviceAPIClientServiceImpl
.getTrackerDevice(device.getId(), tenantId);
int traccarDeviceId = trackerDevice.getTraccarDeviceId();
boolean getPermission = DeviceAPIClientServiceImpl.getUserIdofPermissionByDeviceIdNUserId(traccarDeviceId, userId);
traccarValidIdList.add(traccarDeviceId);
if (!getPermission) {
DeviceAPIClientServiceImpl.addTrackerUserDevicePermission(userId, traccarDeviceId);
if (trackerDevice != null) {
int traccarDeviceId = trackerDevice.getTraccarDeviceId();
boolean getPermission = DeviceAPIClientServiceImpl.getUserIdofPermissionByDeviceIdNUserId(traccarDeviceId, userId);
traccarValidIdList.add(traccarDeviceId);
if (!getPermission) {
DeviceAPIClientServiceImpl.addTrackerUserDevicePermission(userId, traccarDeviceId);
}
}
}
//Remove necessary
List<TrackerPermissionInfo> getAllUserDevices =
@ -569,6 +572,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
/*Get Device Id List*/
return Response.status(Response.Status.OK).entity(obj.getString("token")).build();
}

@ -465,6 +465,7 @@ public class TraccarClientImpl implements TraccarClient {
TrackerManagementDAOFactory.closeConnection();
}
//check if the device is already exist before updating the location
if (trackerDeviceInfo == null) {
//add device if not exist
@ -481,7 +482,8 @@ public class TraccarClientImpl implements TraccarClient {
executor.submit(new OkHttpClientThreadPool(url, null, TraccarHandlerConstants.Methods.GET,
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
"http://localhost:"));
Objects.requireNonNull(HttpReportingUtil.trackerServer()).split(":")[0] + ":" +
Objects.requireNonNull(HttpReportingUtil.trackerServer()).split(":")[1] + ":"));
}
}
@ -579,7 +581,7 @@ public class TraccarClientImpl implements TraccarClient {
authorizedKey(HttpReportingUtil.trackerUser(), HttpReportingUtil.trackerPassword()),
serverUrl(HttpReportingUtil.trackerServer())));
String result = res.get();
log.info("---------result--------");
if (result.charAt(0) == '{') {
JSONObject obj = new JSONObject(result);
if (obj.has("id")) {

Loading…
Cancel
Save