Subversion Repositories SmartDukaan

Rev

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

Rev 27492 Rev 27493
Line 15... Line 15...
15
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.LogManager;
16
import org.apache.logging.log4j.Logger;
16
import org.apache.logging.log4j.Logger;
17
import org.json.JSONArray;
17
import org.json.JSONArray;
18
import org.json.JSONObject;
18
import org.json.JSONObject;
19
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.beans.factory.annotation.Autowired;
-
 
20
import org.springframework.format.annotation.DateTimeFormat;
20
import org.springframework.http.MediaType;
21
import org.springframework.http.MediaType;
21
import org.springframework.http.ResponseEntity;
22
import org.springframework.http.ResponseEntity;
22
import org.springframework.stereotype.Controller;
23
import org.springframework.stereotype.Controller;
23
import org.springframework.transaction.annotation.Transactional;
24
import org.springframework.transaction.annotation.Transactional;
24
import org.springframework.web.bind.annotation.RequestBody;
25
import org.springframework.web.bind.annotation.RequestBody;
Line 183... Line 184...
183
	@ApiImplicitParams({
184
	@ApiImplicitParams({
184
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
185
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
185
	@ApiOperation(value = "")
186
	@ApiOperation(value = "")
186
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
187
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
187
			@RequestParam(name = "deviceId") int deviceId, @RequestParam(name = "punchType") PunchType punchType,
188
			@RequestParam(name = "deviceId") int deviceId, @RequestParam(name = "punchType") PunchType punchType,
188
			@RequestParam(name = "punch") String punch, @RequestParam(name = "dateTime") LocalDateTime dateTime) {
189
			@RequestParam(name = "punch") String punch) {
189
 
190
 
190
		EmployeeAttendance employeeAttendance = new EmployeeAttendance();
191
		EmployeeAttendance employeeAttendance = new EmployeeAttendance();
191
		employeeAttendance.setUserId(userId);
192
		employeeAttendance.setUserId(userId);
192
		employeeAttendance.setDeviceId(deviceId);
193
		employeeAttendance.setDeviceId(deviceId);
193
		employeeAttendance.setPunch(punch);
194
		employeeAttendance.setPunch(punch);
Line 220... Line 221...
220
					endTime = null;
221
					endTime = null;
221
				}
222
				}
222
 
223
 
223
			}
224
			}
224
 
225
 
-
 
226
			/*
225
			if (employeeAttendances.get(0).getPunch().equals("punchIn")) {
227
			 * if (employeeAttendances.get(0).getPunch().equals("punchIn")) { LocalTime
226
				LocalTime punchInTime = employeeAttendances.get(0).getCreateTimestamp().toLocalTime();
228
			 * punchInTime = employeeAttendances.get(0).getCreateTimestamp().toLocalTime();
227
				Long totalPunchSeconds = ChronoUnit.SECONDS.between(punchInTime, dateTime.toLocalTime());
229
			 * Long totalPunchSeconds = ChronoUnit.SECONDS.between(punchInTime,
228
				long punchHours = totalPunchSeconds / 3600;
230
			 * dateTime.toLocalTime()); long punchHours = totalPunchSeconds / 3600; long
229
				long punchMinutes = (totalPunchSeconds % 3600) / 60;
231
			 * punchMinutes = (totalPunchSeconds % 3600) / 60; long punchSeconds =
230
				long punchSeconds = totalPunchSeconds % 60;
232
			 * totalPunchSeconds % 60; punchTotalHour = punchHours + ":" + punchMinutes +
231
				punchTotalHour = punchHours + ":" + punchMinutes + ":" + punchSeconds;
233
			 * ":" + punchSeconds;
232
 
234
			 * 
233
			}
235
			 * }
-
 
236
			 */
234
			LOGGER.info("employeeAttendance" + employeeAttendances);
237
			LOGGER.info("employeeAttendance" + employeeAttendances);
235
 
238
 
236
			hours = totalSeconds / 3600;
239
			hours = totalSeconds / 3600;
237
			minutes = (totalSeconds % 3600) / 60;
240
			minutes = (totalSeconds % 3600) / 60;
238
			seconds = totalSeconds % 60;
241
			seconds = totalSeconds % 60;
239
			EmployeeAttendanceModel emm = new EmployeeAttendanceModel();
242
			EmployeeAttendanceModel emm = new EmployeeAttendanceModel();
240
			emm.setHours(hours);
243
			emm.setHours(hours);
241
			emm.setMinutes(minutes);
244
			emm.setMinutes(minutes);
242
			emm.setSeconds(seconds);
245
			emm.setSeconds(seconds);
243
			emm.setTotalPunchHour(punchTotalHour);
246
			// emm.setTotalPunchHour(punchTotalHour);
244
			return responseSender.ok(emm);
247
			return responseSender.ok(emm);
245
 
248
 
246
		}
249
		}
247
		return responseSender.ok(true);
250
		return responseSender.ok(true);
248
	}
251
	}