Subversion Repositories SmartDukaan

Rev

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

Rev 27475 Rev 27490
Line 12... Line 12...
12
import javax.mail.MessagingException;
12
import javax.mail.MessagingException;
13
import javax.servlet.http.HttpServletRequest;
13
import javax.servlet.http.HttpServletRequest;
14
 
14
 
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.apache.velocity.app.VelocityEngine;
-
 
18
import org.json.JSONArray;
17
import org.json.JSONArray;
19
import org.json.JSONObject;
18
import org.json.JSONObject;
20
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.http.MediaType;
20
import org.springframework.http.MediaType;
22
import org.springframework.http.ResponseEntity;
21
import org.springframework.http.ResponseEntity;
Line 26... Line 25...
26
import org.springframework.web.bind.annotation.RequestMapping;
25
import org.springframework.web.bind.annotation.RequestMapping;
27
import org.springframework.web.bind.annotation.RequestMethod;
26
import org.springframework.web.bind.annotation.RequestMethod;
28
import org.springframework.web.bind.annotation.RequestParam;
27
import org.springframework.web.bind.annotation.RequestParam;
29
 
28
 
30
import com.google.gson.Gson;
29
import com.google.gson.Gson;
31
import com.ibm.icu.impl.duration.Period;
-
 
32
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
30
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
33
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
34
import com.spice.profitmandi.common.web.util.ResponseSender;
31
import com.spice.profitmandi.common.web.util.ResponseSender;
35
import com.spice.profitmandi.dao.entity.dtr.EmployeeAttendance;
32
import com.spice.profitmandi.dao.entity.dtr.EmployeeAttendance;
36
import com.spice.profitmandi.dao.entity.dtr.HyperTrackKeyModel;
33
import com.spice.profitmandi.dao.entity.dtr.HyperTrackKeyModel;
37
import com.spice.profitmandi.dao.entity.dtr.HypertrackKey;
34
import com.spice.profitmandi.dao.entity.dtr.HypertrackKey;
38
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
-
 
39
import com.spice.profitmandi.dao.enumuration.dtr.PunchType;
35
import com.spice.profitmandi.dao.enumuration.dtr.PunchType;
40
import com.spice.profitmandi.dao.model.EmployeeAttendanceModel;
36
import com.spice.profitmandi.dao.model.EmployeeAttendanceModel;
41
import com.spice.profitmandi.dao.repository.dtr.EmployeeAttendanceRepository;
37
import com.spice.profitmandi.dao.repository.dtr.EmployeeAttendanceRepository;
42
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
38
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
43
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
-
 
44
import com.spice.profitmandi.dao.repository.user.HypertrackKeyRepository;
39
import com.spice.profitmandi.dao.repository.user.HypertrackKeyRepository;
45
import com.spice.profitmandi.service.user.RetailerService;
40
import com.spice.profitmandi.service.user.RetailerService;
46
 
41
 
47
import io.swagger.annotations.ApiImplicitParam;
42
import io.swagger.annotations.ApiImplicitParam;
48
import io.swagger.annotations.ApiImplicitParams;
43
import io.swagger.annotations.ApiImplicitParams;
Line 188... Line 183...
188
	@ApiImplicitParams({
183
	@ApiImplicitParams({
189
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
184
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
190
	@ApiOperation(value = "")
185
	@ApiOperation(value = "")
191
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
186
	public ResponseEntity<?> employeeAttendance(HttpServletRequest request, @RequestParam(name = "userId") int userId,
192
			@RequestParam(name = "deviceId") int deviceId, @RequestParam(name = "punchType") PunchType punchType,
187
			@RequestParam(name = "deviceId") int deviceId, @RequestParam(name = "punchType") PunchType punchType,
193
			@RequestParam(name = "punch") String punch) {
188
			@RequestParam(name = "punch") String punch, @RequestParam(name = "time") LocalDateTime dateTime) {
194
 
189
 
195
		EmployeeAttendance employeeAttendance = new EmployeeAttendance();
190
		EmployeeAttendance employeeAttendance = new EmployeeAttendance();
196
		employeeAttendance.setUserId(userId);
191
		employeeAttendance.setUserId(userId);
197
		employeeAttendance.setDeviceId(deviceId);
192
		employeeAttendance.setDeviceId(deviceId);
198
		employeeAttendance.setPunch(punch);
193
		employeeAttendance.setPunch(punch);
Line 204... Line 199...
204
					deviceId, LocalDate.now());
199
					deviceId, LocalDate.now());
205
			long hours = 0;
200
			long hours = 0;
206
			long minutes = 0;
201
			long minutes = 0;
207
			long seconds = 0;
202
			long seconds = 0;
208
			long totalSeconds = 0;
203
			long totalSeconds = 0;
-
 
204
			String punchTotalHour = null;
209
			LocalTime startTime = null;
205
			LocalTime startTime = null;
210
			LocalTime endTime = null;
206
			LocalTime endTime = null;
211
			List<Long> hghg = new ArrayList<>();
207
			List<Long> hghg = new ArrayList<>();
212
 
208
 
213
			for (EmployeeAttendance em : employeeAttendances) {
209
			for (EmployeeAttendance em : employeeAttendances) {
Line 223... Line 219...
223
					startTime = null;
219
					startTime = null;
224
					endTime = null;
220
					endTime = null;
225
				}
221
				}
226
 
222
 
227
			}
223
			}
-
 
224
 
-
 
225
			if (employeeAttendances.get(0).getPunch().equals("punchIn")) {
-
 
226
				LocalTime punchInTime = employeeAttendances.get(0).getCreateTimestamp().toLocalTime();
-
 
227
				Long totalPunchSeconds = ChronoUnit.SECONDS.between(punchInTime, dateTime.toLocalTime());
-
 
228
				long punchHours = totalPunchSeconds / 3600;
-
 
229
				long punchMinutes = (totalPunchSeconds % 3600) / 60;
-
 
230
				long punchSeconds = totalPunchSeconds % 60;
-
 
231
				punchTotalHour = punchHours + ":" + punchMinutes + ":" + punchSeconds;
-
 
232
 
-
 
233
			}
228
			LOGGER.info("employeeAttendance" + employeeAttendances);
234
			LOGGER.info("employeeAttendance" + employeeAttendances);
229
 
235
 
230
			hours = totalSeconds / 3600;
236
			hours = totalSeconds / 3600;
231
			minutes = (totalSeconds % 3600) / 60;
237
			minutes = (totalSeconds % 3600) / 60;
232
			seconds = totalSeconds % 60;
238
			seconds = totalSeconds % 60;
233
			EmployeeAttendanceModel emm = new EmployeeAttendanceModel();
239
			EmployeeAttendanceModel emm = new EmployeeAttendanceModel();
234
			emm.setHours(hours);
240
			emm.setHours(hours);
235
			emm.setMinutes(minutes);
241
			emm.setMinutes(minutes);
236
			emm.setSeconds(seconds);
242
			emm.setSeconds(seconds);
-
 
243
			emm.setTotalPunchHour(punchTotalHour);
237
			return responseSender.ok(emm);
244
			return responseSender.ok(emm);
238
 
245
 
239
		}
246
		}
240
		return responseSender.ok(true);
247
		return responseSender.ok(true);
241
	}
248
	}