!3740 添加功能

Merge pull request !3740 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-07-08 12:25:15 +00:00
committed by Gitee
@@ -266,6 +266,7 @@ class AppletAttendance(Controller):
# 本月的节假日
holiday_data = self.get_holiday_data(current_month_first.date(), current_month_last.date())
# 本月考勤记录
leave_days = 0
current_attendance = request.env(user=SUPERUSER_ID)['hr.attendance'].sudo().search([
('employee_id.user_id', '=', user_id),
('current_data', '>=', current_month_first.date()),
@@ -277,8 +278,10 @@ class AppletAttendance(Controller):
('employee_id.user_id', '=', user_id),
('date_from', '>=', current_month_first),
('date_to', '<=', current_month_last),
('state', 'in', ['confirm', 'validate1'])
('state', 'in', ['validate'])
])
for leave in leave_ids:
leave_days += leave.number_of_days
# 本月异常次数
current_stats = {
@@ -286,7 +289,7 @@ class AppletAttendance(Controller):
'is_early_card': sum(1 for rec in current_attendance if rec.is_early_card),
'is_late_card': sum(1 for rec in current_attendance if rec.is_late_card),
'is_abnormal': sum(1 for rec in current_attendance if rec.is_abnormal),
'is_holiday': 0,
'is_holiday': leave_days,
'is_no_work': sum(1 for rec in current_attendance if rec.absenteeism_card),
}
current_records = self.process_attendances(current_attendance, user_id)
@@ -295,10 +298,7 @@ class AppletAttendance(Controller):
'message': 'OK',
'data': {
'current_month': {
'holiday_data': {
"holiday_list": [],
"shift_days_list": [],
},
'holiday_data': holiday_data,
'banner_rote': current_stats,
'attendance_data': current_records,
},
@@ -348,18 +348,16 @@ class AppletAttendance(Controller):
check_out_status = '缺卡' if not check_out else ('早退' if is_early_card else '正常')
check_in_str = (check_in + timedelta(hours=8)).strftime('%H:%M:%S') if check_in else '缺卡'
check_out_str = (check_out + timedelta(hours=8)).strftime('%H:%M:%S') if check_out else '缺卡'
check_in_html = f'<p style="color:red">{check_in_status}</p>' if check_in_status in ['迟到', '早退', '缺卡'] else f'<p style="color:green">{check_in_status}</p>'
check_out_html = f'<p style="color:red">{check_out_status}</p>' if check_out_status in ['迟到', '早退','缺卡'] else f'<p style="color:green">{check_out_status}</p>'
check_in_color = 'red' if check_in_status in ['迟到', '早退', '缺卡'] else 'green'
check_out_color = 'red' if check_out_status in ['迟到', '早退', '缺卡'] else 'green'
# 添加到记录列表
records.append({
'date': att.current_data.strftime('%Y-%m-%d'),
'class': [f"{att.shift_name}{standard_check_in_str}-{standard_check_out_str}"],
'class': [f"{att.shift_name}",f"{standard_check_in_str}-{standard_check_out_str}"],
'user_id': user_id,
'check_in': check_in_str,
'check_in_state': check_in_html,
'check_out': check_out_str,
'check_out_state': check_out_html,
})
'check_in': f"<p style=\"color:{check_in_color}\">{check_in_str} {check_in_status}</p>",
'check_out': f"<p style=\"color:{check_out_color}\">{check_out_str} {check_out_status}</p>",
})
return records
def get_holiday_data(self, start_date, end_date):
@@ -408,7 +406,7 @@ class AppletAttendance(Controller):
day = start_date_obj + timedelta(days=i)
# 只添加年份和月份匹配的日期
if day.year == target_year and day.month == target_month:
formatted_date = f"{day.year}年{day.month}月{day.day}日"
formatted_date = f"{day.month}月{day.day}日"
holidays_list.append(formatted_date)
# 处理调班补班
@@ -421,7 +419,7 @@ class AppletAttendance(Controller):
# 只添加月份匹配的日期
if month == target_month:
formatted_date = f"{target_year}年{month}月{day}日"
formatted_date = f"{month}月{day}日"
shift_days_list.append(formatted_date)
return {