添加功能
This commit is contained in:
@@ -327,6 +327,18 @@ class HrAttendanceDetail(models.Model):
|
||||
is_warning = False
|
||||
absenteeism_card = False
|
||||
|
||||
def remove_seconds(dt):
|
||||
"""清除datetime对象的秒数和微秒"""
|
||||
if dt:
|
||||
return dt.replace(second=0, microsecond=0)
|
||||
return dt
|
||||
|
||||
# 清除所有时间的秒数
|
||||
check_in = remove_seconds(check_in)
|
||||
check_out = remove_seconds(check_out)
|
||||
start_datetime = remove_seconds(start_datetime)
|
||||
end_datetime = remove_seconds(end_datetime)
|
||||
|
||||
if employee.department_id and employee.department_id.name == '厨卫':
|
||||
start_datetime = start_datetime.replace(hour=1, minute=0, second=0, microsecond=0)
|
||||
|
||||
@@ -344,32 +356,11 @@ class HrAttendanceDetail(models.Model):
|
||||
# 迟到判断
|
||||
if check_in and start_datetime and check_in > start_datetime:
|
||||
if employee.late_allowed > 0 :
|
||||
_logger.info(
|
||||
"检测到迟到情况 - "
|
||||
"签到时间: %s, "
|
||||
"应到时间: %s, "
|
||||
"员工ID: %s, "
|
||||
"员工姓名: %s",
|
||||
check_in.strftime('%Y-%m-%d %H:%M:%S'), # 格式化显示日期时间
|
||||
start_datetime.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
employee.id,
|
||||
employee.name
|
||||
)
|
||||
is_late_card = False
|
||||
employee.late_allowed -= 1
|
||||
else:
|
||||
is_late_card = True
|
||||
_logger.info(
|
||||
"检测到迟到情况 - "
|
||||
"签到时间: %s, "
|
||||
"应到时间: %s, "
|
||||
"员工ID: %s, "
|
||||
"员工姓名: %s",
|
||||
check_in.strftime('%Y-%m-%d %H:%M:%S'), # 格式化显示日期时间
|
||||
start_datetime.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
employee.id,
|
||||
employee.name
|
||||
)
|
||||
|
||||
late_delta = (check_in - start_datetime).total_seconds() / 60
|
||||
# 迟到超过60分钟标记为旷工
|
||||
if late_delta > 60:
|
||||
|
||||
Reference in New Issue
Block a user