This Project keep track of employee swap-in(login) swap-out(logout) details.
- Generate the employee login, logout data.
- Employee can do multiple login and logout in a day Calculate the following attribute.
- Average working time of each employee for last 7 days, 30 days, 60 days, 90 days
- Average absent time of each employee for last 7 days, 30 days, 60 days, 90 days
- Average Expected arrival time of each employee for last 30 days, 60 days, 90 days
Taking consideration
- Employee doesn't work on weekends(saturday and sunday)
- Employee will come to office in between 9am to 11am
- Working hours is 9am to 6pm
<!-- Time will be in epoch format -->
[
{ "Emp_id" : 31808, "loginTime": "2016-11-26 9:30 am", "logoutTime": "2016-11-26 10:30 am"},
{ "Emp_id" : 31808, "loginTime": "2016-11-26 11:30 am", "logoutTime": "2016-11-26 05:30 pm"}
] Generator will generate data daily and save into JSON file. For each day generator will generate one json file.
| Attributes | Computation | Comments |
|---|---|---|
| employeeId | "emp_" + Random(1000 , 9999) | "emp" is intial for all employee and i = 1001 |
| loginTime | Random(minArrivalTime , maxArrivalTime ) | intialize minArrivalTime as 9am and maxArrivalTime as 11am |
| logoutTime | Random(maxArrivalTime , maxLogoutTime) | intialize maxLogoutTime as 6pm |
There are following steps to generate login, logout data of a employee in a day :
Steps 1: choose the minArrivalTime = 9 , maxArrivalTime = 11 , maxLogoutTime = 18, loginTime = 0, logoutTime = 0, maxAbsentTime = 6, counter = 0;
<!-- For each employee, each day login, logout time generation -->
Step 2: generate random loginTime = Random(minArrivalTime , maxArrivalTime )
Step 3: if(logoutTime - loginTime) > 2hr then repeat Step2
Step 4: generate random logoutTime = Random(maxArrivalTime , maxLogoutTime)
Step 5: if(counter >= maxAbsentTime) logoutTime = maxLgoutTime
Step 6: update minArrivalTime and maxArrivalTime values: minArrivalTime = logoutTime, maxArrivalTime = maxLogoutTime
Step 7: counter = counter + (logoutTime - loginTime)
Step 8: create employee data object using employee id and calculated login and Logout Time
Step 9: repeat 2 to 9 steps while(maxArrivalTime + constant (lets assume 20 mins, because probability of coming exact maxLogoutTime is very less ) <= maxLogoutTime)
Step 8: Save generated data into json file.
<!-- Repeat the above steps to generate data for multiple day -->
Input : raw data json file generator by Generator and calculate the the working_Time, Absent_Time, Arival_Time. Output : Store data into cassendra table.
Read the JSON file and calculate the total working time, and total absent time of each user and save it in following format Sample Schema to save data for all month: Saving data in day wise.
PrimaryKey : Emp_id, period
| Emp_Id: text | Working_Time: long | Absent_Time: long | Arival_Time: long | Period: String |
|---|---|---|---|---|
| emp_01 | 8 | 0 | 9 | 2016-11-11 |
| emp_01 | 7 | 1 | 10 | 2016-12-11 |
| emp_01 | 15 | 1 | 9.5 | 1(week) |
To calculate the average expected arrival time, take arrival time of all day and and sort it and take median.
- Average working time for last 7 days = total_working_Time in 7 days / no of days
- Average working time for last 30 days = total_working_Time in 30 days / no of days
- Average absent time for last 7 days = total_absent_Time in 7 days / no of days
- Average absent time for last 30 days = total_absent_Time in 30 days / no of days
- Average working time for all employee in last 7 days = total_working_Time in 7 days / no of days
- Average working time for all employee in last 30 days = total_working_Time in 30 days / no of days
- Average absent time for all employee in last 7 days = total_absent_Time in 7 days / no of days
- Average absent time for all employee in last 30 days = total_absent_Time in 30 days / no of days