考勤记录显示记录人,默认出勤写入原因;撤销"节前上课"特殊类型

1. 考勤记录查询关联 users 表返回记录人姓名(修复记录人为空)
2. 默认出勤生成的记录原因写为"默认出勤";整天请假未填原因时默认"请假(整天)"
3. "假前下午上课"属于偶发情况,默认不做:移除 pre_holiday 校历类型,需要时按正常考勤流程单独补录下午记录
4. 已确认:默认出勤记录可被异常考勤覆盖(覆盖时按异常状态正常扣分)
This commit is contained in:
canglan committed 2026-11-26 09:53:51 +08:00
1 parent 97f2de5d83
commit 0ac933a3a5
6 files changed
+14 -18

No files matched your search

+4 -2
View File
@@ -40,9 +40,11 @@ class AttendanceModel:
slot: str = None
) -> List[Dict[str, Any]]:
sql = """
SELECT ar.*, s.name as student_name, s.student_no
SELECT ar.*, s.name as student_name, s.student_no,
u.real_name as recorder_name
FROM attendance_records ar
JOIN students s ON ar.student_id = s.student_id
LEFT JOIN users u ON ar.recorder_id = u.user_id
WHERE 1=1
"""
params = []
@@ -140,7 +142,7 @@ class AttendanceModel:
chunk_size = 200
for i in range(0, len(rows), chunk_size):
chunk = rows[i:i + chunk_size]
values = ", ".join(["(%s, %s, 'present', NULL, %s, %s, %s, 0)"] * len(chunk))
values = ", ".join(["(%s, %s, 'present', '默认出勤', %s, %s, %s, 0)"] * len(chunk))
params = []
for student_id, day, slot, recorder_id, semester_id in chunk:
params.extend([student_id, day, slot, recorder_id, semester_id])
+1 -1
View File
@@ -91,7 +91,7 @@ class FullDayLeaveRequest(BaseModel):
class CalendarDayRequest(BaseModel):
"""校历手动设置请求"""
date: date
day_type: str = Field(..., pattern=r'^(holiday|makeup|pre_holiday)$', description="类型: holiday=放假, makeup=补课, pre_holiday=节前上课(早+中)")
day_type: str = Field(..., pattern=r'^(holiday|makeup)$', description="类型: holiday=放假, makeup=补课")
note: Optional[str] = Field(None, max_length=100, description="备注")
+5 -7
View File
@@ -34,7 +34,7 @@ ATTENDANCE_STATUS_MAP = {
# 手动校历设置的存储前缀与类型
CALENDAR_KEY_PREFIX = 'calendar_day:'
CALENDAR_TYPES = ('holiday', 'makeup', 'pre_holiday')
CALENDAR_TYPES = ('holiday', 'makeup')
VALID_SLOTS = ('morning', 'afternoon', 'evening')
MAX_DEFAULT_DAYS = 180
@@ -232,7 +232,7 @@ class AttendanceService:
iso = day.isoformat()
manual = calendar_info['manual'].get(iso)
if manual:
return manual['type'] != 'holiday'
return manual['type'] == 'makeup'
if iso in calendar_info['holidays']:
return False
if iso in calendar_info['workdays']:
@@ -248,7 +248,7 @@ class AttendanceService:
"""按学校常规作息返回某天实际考勤时段
- 上课日且次日仍上课:所选时段(早/中/晚)
- 放假前一天(次日不上课):仅上午;手动设为 pre_holiday 时按早+中
- 放假前一天(次日不上课):仅上午
- 返校日(非上课日、次日上课):仅晚修
- 其他休息日:无
"""
@@ -260,9 +260,6 @@ class AttendanceService:
if school_today:
if school_next:
return list(selected)
manual_type = calendar_info['manual'].get(day.isoformat(), {}).get('type')
if manual_type == 'pre_holiday':
return [s for s in selected if s in ('morning', 'afternoon')]
return [s for s in selected if s == 'morning']
if school_next:
return [s for s in selected if s == 'evening']
@@ -292,6 +289,7 @@ class AttendanceService:
if not slots:
return {"success": False, "message": "该日期没有考勤时段(休息日)"}
effective_reason = (reason or '').strip() or '请假(整天)'
created_count = 0
last_error = None
for student_id in student_ids:
@@ -300,7 +298,7 @@ class AttendanceService:
student_id=student_id,
date=date_str,
status='leave',
reason=reason,
reason=effective_reason,
apply_deduction=True,
recorder_id=recorder_id,
custom_deduction=None,