This commit is contained in:
李鹏宇
2025-07-03 15:11:45 +08:00
parent 69bb2b218a
commit 7b3a7bbf42
@@ -47,18 +47,16 @@ class AppletAttendance(Controller):
current_data = fields.Date.today()
user_id = request.env(user=SUPERUSER_ID)["res.users"].search([('id', '=', int(kw['user_id']))])
employee_id = request.env(user=SUPERUSER_ID)["hr.employee"].search([('name', '=', user_id.name)])
address_id = request.env(user=SUPERUSER_ID)["applet.address"].search(
[('address_name', '=', employee_id.company_id.name)])
address_id = request.env(user=SUPERUSER_ID)["applet.address"].search([('address_name', '=', employee_id.company_id.name)])
self_address = self.get_address_from_coords(kw['att_latitude'], kw['att_longitude'])
_logger.info(f"打卡经度{kw['att_longitude']}打卡纬度{kw['att_latitude']}__________")
_logger.info(f"人员{employee_id.name}地址{self_address['formatted_address']}__________")
card_rice = address_id.card_rice * 0.001 # 打卡范围
attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search(
[('employee_id', '=', employee_id.id), ('current_data', '=', current_data)])
check_in = attendance_id.check_in + timedelta(hours=8)
check_out = attendance_id.check_out + timedelta(hours=8)
attendance_id = request.env(user=SUPERUSER_ID)["hr.attendance"].search([('employee_id', '=', employee_id.id), ('current_data', '=', current_data)])
check_in = attendance_id.check_in + timedelta(hours=8) if attendance_id.check_in else ''
check_out = attendance_id.check_out + timedelta(hours=8) if attendance_id.check_out else ''
check_in_start = attendance_id.shift_id.template_id.check_in_start
check_out_end = attendance_id.shift_id.template_id.check_out_end
start_minute = int((check_in_start - int(check_in_start)) * 60)
@@ -78,21 +76,17 @@ class AppletAttendance(Controller):
state_result = '缺卡'
check_in_str = check_in.strftime('%H:%M:%S') if check_in else ' '
check_out_str = check_out.strftime('%H:%M:%S') if check_out else ' '
check_in_html = f'<p style="color:red">{check_in_str}</p>' if check_in_status in ['迟到', '早退',
'缺卡'] else f'<p style="color:green">{check_in_str}</p>'
check_out_html = f'<p style="color:red">{check_out_str}</p>' if check_out_status in ['迟到', '早退',
'缺卡'] else f'<p style="color:green">{check_out_str}</p>'
check_in_html = f'<p style="color:red">{check_in_str}</p>' if check_in_status in ['迟到', '早退', '缺卡'] else f'<p style="color:green">{check_in_str}</p>'
check_out_html = f'<p style="color:red">{check_out_str}</p>' if check_out_status in ['迟到', '早退', '缺卡'] else f'<p style="color:green">{check_out_str}</p>'
if not self.is_within_radius_geopy(kw['att_latitude'], kw['att_longitude'], address_id.latitude, address_id.longitude, card_rice):
message = "超出范围,不允许打卡"
state = "no"
state_result = "超出范围"
_logger.info("-------触发超出范围,不允许打卡---------")
else:
state = 'yes'
message = 'ok'
state_result = ''
data = {
'location': '%s' % address_id.address_name,
'location': self_address['formatted_address'],
'user_id': user_id.id,
'class': f"{attendance_id.shift_name}{start_time_str}-{end_time_str}",
'state_result': state_result,