作为我正在开发的项目的一部分,我需要一些建议。
问题:我收到一份包含员工时钟记录的报告。我需要根据轮类设置确定当天的第一个时钟。例如,类次 A 从上午 8:00 开始,到晚上 17:00 结束。这是很困难的,但如果这个人加类到第二天凌晨 1:00,然后在 7:30 再次上类,7:45 下类,7:48 上类,会发生什么情况。如何确定当天的第一个打卡上类时间?
如果该人正常工作时间,我可以计算出罚款,但如果加类延长到第二天会发生什么?
最佳答案
通常,考勤是通过特定员工的 IN 时间加上他在工作中花费的时间,然后是 OUT 时间来衡量的。像这样的东西(只是伪代码)
employee_checks_in_event = in_time (a timer is started at this point)
fixed_out_time = expected_out_time (this is the normal out time of employee)
if employee_checks_in_again:
in_time = new_in_time # here the employee may have overlapped next shift IN time due to overtime
employee_checks_out_event = out_time - in_time (lets call it time_spent)
if time_spent < fixed_out_time:
employee_left_early
else:
we know employee completed his time and maybe he over-timed as well.
time_spent = over_time
现在您有了员工的 time_spent,您可以跟踪第二天的签到时间并确保它们不会重叠。请记住,您必须以某种方式区分 IN 和 OUT 时间。
另一种方法是将 checkin 和 checkout 保持在完全独立的时钟中,这样就可以很容易地确定 checkin 和 checkout 时间,并且维护加类会容易得多。
关于java - 时间和出勤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27156198/