Subversion Repositories SmartDukaan

Rev

Rev 27449 | Rev 27490 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27449 Rev 27475
Line 172... Line 172...
172
			}
172
			}
173
			return (dist);
173
			return (dist);
174
		}
174
		}
175
	}
175
	}
176
 
176
 
-
 
177
	@RequestMapping(value = "/getPunchHistory", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
178
	public ResponseEntity<?> getPunchHistory(HttpServletRequest request, @RequestParam int userId,
-
 
179
			@RequestParam int deviceId) {
-
 
180
 
-
 
181
		List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository.selectByUserIdKey(userId, deviceId,
-
 
182
				LocalDate.now());
-
 
183
 
-
 
184
		return responseSender.ok(employeeAttendances);
-
 
185
	}
-
 
186
 
177
	@RequestMapping(value = "/employee/attendance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
187
	@RequestMapping(value = "/employee/attendance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
178
	@ApiImplicitParams({
188
	@ApiImplicitParams({
179
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
189
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
180
	@ApiOperation(value = "")
190
	@ApiOperation(value = "")
181
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
191
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
Line 232... Line 242...
232
 
242
 
233
	@RequestMapping(value = "/create/geofence", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
243
	@RequestMapping(value = "/create/geofence", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
234
	public ResponseEntity<?> createGeofence(HttpServletRequest request)
244
	public ResponseEntity<?> createGeofence(HttpServletRequest request)
235
			throws IOException, ProfitMandiBusinessException {
245
			throws IOException, ProfitMandiBusinessException {
236
 
246
 
-
 
247
		/*
237
		List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
248
		 * List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores(); for
238
		for (FofoStore fofoStore : fofoStores) {
249
		 * (FofoStore fofoStore : fofoStores) { if (fofoStore.getLatitude() != null &&
239
			if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
250
		 * fofoStore.getLongitude() != null) { CustomRetailer customRetailer =
240
				CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
251
		 * retailerService.getFofoRetailer(fofoStore.getId());
-
 
252
		 */
241
				OkHttpClient client = new OkHttpClient();
253
		OkHttpClient client = new OkHttpClient();
242
 
-
 
243
				okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
-
 
244
				JSONObject geofe = new JSONObject();
-
 
245
				JSONArray geofences = new JSONArray();
-
 
246
				JSONObject geometry = new JSONObject();
-
 
247
				JSONObject geo = new JSONObject();
-
 
248
				JSONArray coordinates = new JSONArray();
-
 
249
				coordinates.put(fofoStore.getLongitude());
-
 
250
				coordinates.put(fofoStore.getLatitude());
-
 
251
				geo.put("type", "Point");
-
 
252
				geo.put("coordinates", coordinates);
-
 
253
				geometry.put("geometry", geo);
-
 
254
				JSONObject metadata = new JSONObject();
-
 
255
				metadata.put("name", customRetailer.getBusinessName());
-
 
256
				metadata.put("city", customRetailer.getAddress().getCity());
-
 
257
				geometry.put("metadata", metadata);
-
 
258
				geometry.put("radius", 500);
-
 
259
 
-
 
260
				geofences.put(geometry);
-
 
261
				geofe.put("geofences", geofences);
-
 
262
				okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
-
 
263
				String authString = "Basic "
-
 
264
						+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
-
 
265
 
254
 
-
 
255
		okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
-
 
256
		JSONObject geofe = new JSONObject();
-
 
257
		JSONArray geofences = new JSONArray();
-
 
258
		JSONObject geometry = new JSONObject();
-
 
259
		JSONObject geo = new JSONObject();
-
 
260
		JSONArray coordinates = new JSONArray();
-
 
261
		coordinates.put(77.08596155373755);
-
 
262
		coordinates.put(28.64944201113976);
-
 
263
		geo.put("type", "Point");
-
 
264
		geo.put("coordinates", coordinates);
-
 
265
		geometry.put("geometry", geo);
-
 
266
		JSONObject metadata = new JSONObject();
-
 
267
		metadata.put("name", "Test");
-
 
268
		geometry.put("radius", 500);
-
 
269
		geofences.put(geometry);
-
 
270
		geofe.put("geofences", geofences);
266
				Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
271
		okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
267
						.addHeader("Authorization", authString).build();
272
		String authString = "Basic "
-
 
273
				+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
268
 
274
 
-
 
275
		Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
269
				Response response = client.newCall(request1).execute();
276
				.addHeader("Authorization", authString).build();
270
 
277
 
-
 
278
		Response response = client.newCall(request1).execute();
-
 
279
		String geofenceId = null;
271
				LOGGER.info("response" + response.body().string());
280
		JSONArray ja = new JSONArray(response.body().string());
-
 
281
		for (int i = 0; i < ja.length(); i++) {
272
			}
282
			JSONObject c = ja.getJSONObject(i);
-
 
283
			geofenceId = c.getString("geofence_id");
273
		}
284
		}
-
 
285
 
-
 
286
		LOGGER.info("response" + response.body().string());
-
 
287
 
274
		return responseSender.ok(true);
288
		return responseSender.ok(geofenceId);
275
 
289
 
276
	}
290
	}
277
 
291
 
278
	@RequestMapping(value = "/getgeofence", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
292
	@RequestMapping(value = "/getgeofence", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
279
	public ResponseEntity<?> getAllGeofences(HttpServletRequest request)
293
	public ResponseEntity<?> getAllGeofences(HttpServletRequest request)
Line 289... Line 303...
289
				.addHeader("Authorization", authString).build();
303
				.addHeader("Authorization", authString).build();
290
 
304
 
291
		Response response = client.newCall(request1).execute();
305
		Response response = client.newCall(request1).execute();
292
		return responseSender.ok(response.body().string());
306
		return responseSender.ok(response.body().string());
293
 
307
 
-
 
308
	}
-
 
309
 
-
 
310
	@RequestMapping(value = "/deletegeofence", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
311
	public ResponseEntity<?> deleteGeofences(HttpServletRequest request, String geofenceId)
-
 
312
			throws IOException, ProfitMandiBusinessException {
-
 
313
		OkHttpClient client = new OkHttpClient();
-
 
314
 
-
 
315
		String authString = "Basic "
-
 
316
				+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
-
 
317
 
-
 
318
		Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences/" + geofenceId).delete()
-
 
319
				.addHeader("Authorization", authString).build();
-
 
320
 
-
 
321
		Response response = client.newCall(request1).execute();
-
 
322
		return responseSender.ok(response.body().string());
-
 
323
 
294
	}
324
	}
295
 
325
 
296
}
326
}