| Line 120... |
Line 120... |
| 120 |
Request request1 = new Request.Builder()
|
120 |
Request request1 = new Request.Builder()
|
| 121 |
.url("https://v3.api.hypertrack.com/devices/" + hyperTrackKey.getHypertrackKeyId()).get()
|
121 |
.url("https://v3.api.hypertrack.com/devices/" + hyperTrackKey.getHypertrackKeyId()).get()
|
| 122 |
.addHeader("Authorization", authString).build();
|
122 |
.addHeader("Authorization", authString).build();
|
| 123 |
|
123 |
|
| 124 |
Response response = client.newCall(request1).execute();
|
124 |
Response response = client.newCall(request1).execute();
|
| - |
|
125 |
LOGGER.info("employeeAttendance" + employeeAttendances);
|
| 125 |
JSONObject jsonObj = new JSONObject(response.body().string());
|
126 |
JSONObject jsonObj = new JSONObject(response.body().string());
|
| 126 |
JSONObject c = jsonObj.getJSONObject("location");
|
127 |
JSONObject c = jsonObj.getJSONObject("location");
|
| 127 |
JSONObject d = c.getJSONObject("geometry");
|
128 |
JSONObject d = c.getJSONObject("geometry");
|
| 128 |
JSONArray coords = d.getJSONArray("coordinates");
|
129 |
JSONArray coords = d.getJSONArray("coordinates");
|
| - |
|
130 |
|
| 129 |
double lat2 = coords.getDouble(1);
|
131 |
double lat2 = coords.getDouble(1);
|
| 130 |
double lng2 = coords.getDouble(0);
|
132 |
double lng2 = coords.getDouble(0);
|
| 131 |
double dist = distance(lat1, lng1, lat2, lng2, "m");
|
133 |
double dist = distance(lat1, lng1, lat2, lng2, "m");
|
| - |
|
134 |
|
| - |
|
135 |
JSONObject deviceStatus = jsonObj.getJSONObject("device_status");
|
| - |
|
136 |
JSONObject deviceData = deviceStatus.getJSONObject("data");
|
| - |
|
137 |
String status = deviceData.getString("value");
|
| - |
|
138 |
|
| 132 |
EmployeeAttendanceModel em = new EmployeeAttendanceModel();
|
139 |
EmployeeAttendanceModel em = new EmployeeAttendanceModel();
|
| 133 |
em.setDistance(dist);
|
140 |
em.setDistance(dist);
|
| 134 |
em.setLatitude(lat2);
|
141 |
em.setLatitude(lat2);
|
| 135 |
em.setLongitude(lng2);
|
142 |
em.setLongitude(lng2);
|
| - |
|
143 |
em.setDeviceStatus(status);
|
| 136 |
|
144 |
|
| 137 |
if (!employeeAttendances.isEmpty()) {
|
145 |
if (!employeeAttendances.isEmpty()) {
|
| 138 |
if (employeeAttendances.get(0).getCreateTimestamp().toLocalDate().equals(LocalDate.now())) {
|
146 |
if (employeeAttendances.get(0).getCreateTimestamp().toLocalDate().equals(LocalDate.now())) {
|
| 139 |
if (employeeAttendances.get(0).getPunch().equals("punchIn")) {
|
147 |
if (employeeAttendances.get(0).getPunch().equals("punchIn")) {
|
| 140 |
em.setPunchIn(true);
|
148 |
em.setPunchIn(true);
|