考勤记录显示记录人,默认出勤写入原因;撤销"节前上课"特殊类型
1. 考勤记录查询关联 users 表返回记录人姓名(修复记录人为空) 2. 默认出勤生成的记录原因写为"默认出勤";整天请假未填原因时默认"请假(整天)" 3. "假前下午上课"属于偶发情况,默认不做:移除 pre_holiday 校历类型,需要时按正常考勤流程单独补录下午记录 4. 已确认:默认出勤记录可被异常考勤覆盖(覆盖时按异常状态正常扣分)
This commit is contained in:
1 parent
97f2de5d83
commit
0ac933a3a5
6 files changed
+14
-18
No files matched your search
@@ -40,9 +40,11 @@ class AttendanceModel:
|
|||||||
slot: str = None
|
slot: str = None
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
sql = """
|
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
|
FROM attendance_records ar
|
||||||
JOIN students s ON ar.student_id = s.student_id
|
JOIN students s ON ar.student_id = s.student_id
|
||||||
|
LEFT JOIN users u ON ar.recorder_id = u.user_id
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
"""
|
"""
|
||||||
params = []
|
params = []
|
||||||
@@ -140,7 +142,7 @@ class AttendanceModel:
|
|||||||
chunk_size = 200
|
chunk_size = 200
|
||||||
for i in range(0, len(rows), chunk_size):
|
for i in range(0, len(rows), chunk_size):
|
||||||
chunk = rows[i:i + 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 = []
|
params = []
|
||||||
for student_id, day, slot, recorder_id, semester_id in chunk:
|
for student_id, day, slot, recorder_id, semester_id in chunk:
|
||||||
params.extend([student_id, day, slot, recorder_id, semester_id])
|
params.extend([student_id, day, slot, recorder_id, semester_id])
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class FullDayLeaveRequest(BaseModel):
|
|||||||
class CalendarDayRequest(BaseModel):
|
class CalendarDayRequest(BaseModel):
|
||||||
"""校历手动设置请求"""
|
"""校历手动设置请求"""
|
||||||
date: date
|
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="备注")
|
note: Optional[str] = Field(None, max_length=100, description="备注")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ ATTENDANCE_STATUS_MAP = {
|
|||||||
|
|
||||||
# 手动校历设置的存储前缀与类型
|
# 手动校历设置的存储前缀与类型
|
||||||
CALENDAR_KEY_PREFIX = 'calendar_day:'
|
CALENDAR_KEY_PREFIX = 'calendar_day:'
|
||||||
CALENDAR_TYPES = ('holiday', 'makeup', 'pre_holiday')
|
CALENDAR_TYPES = ('holiday', 'makeup')
|
||||||
VALID_SLOTS = ('morning', 'afternoon', 'evening')
|
VALID_SLOTS = ('morning', 'afternoon', 'evening')
|
||||||
MAX_DEFAULT_DAYS = 180
|
MAX_DEFAULT_DAYS = 180
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ class AttendanceService:
|
|||||||
iso = day.isoformat()
|
iso = day.isoformat()
|
||||||
manual = calendar_info['manual'].get(iso)
|
manual = calendar_info['manual'].get(iso)
|
||||||
if manual:
|
if manual:
|
||||||
return manual['type'] != 'holiday'
|
return manual['type'] == 'makeup'
|
||||||
if iso in calendar_info['holidays']:
|
if iso in calendar_info['holidays']:
|
||||||
return False
|
return False
|
||||||
if iso in calendar_info['workdays']:
|
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_today:
|
||||||
if school_next:
|
if school_next:
|
||||||
return list(selected)
|
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']
|
return [s for s in selected if s == 'morning']
|
||||||
if school_next:
|
if school_next:
|
||||||
return [s for s in selected if s == 'evening']
|
return [s for s in selected if s == 'evening']
|
||||||
@@ -292,6 +289,7 @@ class AttendanceService:
|
|||||||
if not slots:
|
if not slots:
|
||||||
return {"success": False, "message": "该日期没有考勤时段(休息日)"}
|
return {"success": False, "message": "该日期没有考勤时段(休息日)"}
|
||||||
|
|
||||||
|
effective_reason = (reason or '').strip() or '请假(整天)'
|
||||||
created_count = 0
|
created_count = 0
|
||||||
last_error = None
|
last_error = None
|
||||||
for student_id in student_ids:
|
for student_id in student_ids:
|
||||||
@@ -300,7 +298,7 @@ class AttendanceService:
|
|||||||
student_id=student_id,
|
student_id=student_id,
|
||||||
date=date_str,
|
date=date_str,
|
||||||
status='leave',
|
status='leave',
|
||||||
reason=reason,
|
reason=effective_reason,
|
||||||
apply_deduction=True,
|
apply_deduction=True,
|
||||||
recorder_id=recorder_id,
|
recorder_id=recorder_id,
|
||||||
custom_deduction=None,
|
custom_deduction=None,
|
||||||
|
|||||||
+2
-4
@@ -169,7 +169,6 @@
|
|||||||
2. 点击工具栏"请假(整天)"按钮,系统按当天作息提交:
|
2. 点击工具栏"请假(整天)"按钮,系统按当天作息提交:
|
||||||
- 正常上课日(次日仍上课)→ **早/中/晚 3 条**
|
- 正常上课日(次日仍上课)→ **早/中/晚 3 条**
|
||||||
- 放假前一天(半天)→ **仅上午 1 条**
|
- 放假前一天(半天)→ **仅上午 1 条**
|
||||||
- 节前上课(校历手动标记"节前上课(早+中)")→ **早+中 2 条**
|
|
||||||
- 返校日晚修 → **晚修 1 条**
|
- 返校日晚修 → **晚修 1 条**
|
||||||
3. 每个时段按"请假"配置扣分(如 1 分/次:半天 1 分、正常日 3 分)
|
3. 每个时段按"请假"配置扣分(如 1 分/次:半天 1 分、正常日 3 分)
|
||||||
|
|
||||||
@@ -189,8 +188,7 @@
|
|||||||
作息规则(常规情况):
|
作息规则(常规情况):
|
||||||
- **返校日**(非上课日、次日上课,如周日)→ 仅生成**晚修**出勤
|
- **返校日**(非上课日、次日上课,如周日)→ 仅生成**晚修**出勤
|
||||||
- **上课日且次日仍上课** → 按所选时段生成(早/中/晚)
|
- **上课日且次日仍上课** → 按所选时段生成(早/中/晚)
|
||||||
- **放假前一天**(上课日、次日不上课)→ 仅生成**上午**出勤(中午离校,无下午/晚修)
|
- **放假前一天**(上课日、次日不上课)→ 仅生成**上午**出勤(中午离校,无下午/晚修);少数需要下午上课的,按正常流程单独补录下午记录即可
|
||||||
- **例外**:个别假前需要下午上课的,可在「节假日/补课」里把该日手动设为 **"节前上课(早+中)"**,则该日按早+中生成(无晚修)
|
|
||||||
- **跳过周末与法定节假日**(节假日/调休补班来自国内在线接口,失败时自动切换备用接口)
|
- **跳过周末与法定节假日**(节假日/调休补班来自国内在线接口,失败时自动切换备用接口)
|
||||||
- **调休补班日照常**(接口中的补班日按上课处理);**手动补课日照常**、手动放假日跳过
|
- **调休补班日照常**(接口中的补班日按上课处理);**手动补课日照常**、手动放假日跳过
|
||||||
- 已有的考勤记录(含缺勤/迟到/请假)**不会被覆盖**
|
- 已有的考勤记录(含缺勤/迟到/请假)**不会被覆盖**
|
||||||
@@ -200,7 +198,7 @@
|
|||||||
点击工具栏"节假日/补课"按钮打开校历设置:
|
点击工具栏"节假日/补课"按钮打开校历设置:
|
||||||
|
|
||||||
- **查询范围**:查看范围内的法定节假日(放假)、调休补班(按上课)——来自国内在线接口(失败时自动切换备用接口),只读
|
- **查询范围**:查看范围内的法定节假日(放假)、调休补班(按上课)——来自国内在线接口(失败时自动切换备用接口),只读
|
||||||
- **手动添加**:添加学校自己的安排,可选择「补课(按上课)」「节前上课(早+中)」或「放假(按休息)」,可填写备注;手动设置**优先于接口**(例如把某天调休补班改回放假,或把假前半天改为下午上课)
|
- **手动添加**:添加学校自己的安排,可选择「补课(按上课)」或「放假(按休息)」,可填写备注;手动设置**优先于接口**(例如把某天调休补班改回放假)
|
||||||
- 手动添加的记录可随时删除
|
- 手动添加的记录可随时删除
|
||||||
|
|
||||||
**默认扣分规则**:
|
**默认扣分规则**:
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ include __DIR__ . '/../includes/header.php';
|
|||||||
|
|
||||||
<!-- 学生方格网格 -->
|
<!-- 学生方格网格 -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-title">点击选择有考勤异常的学生</div>
|
<div class="card-title">点击选择有考勤异常的学生(默认出勤记录也可选中覆盖为异常)</div>
|
||||||
<div class="student-grid" id="studentGrid">
|
<div class="student-grid" id="studentGrid">
|
||||||
<!-- JS 动态生成 -->
|
<!-- JS 动态生成 -->
|
||||||
</div>
|
</div>
|
||||||
@@ -152,7 +152,6 @@ include __DIR__ . '/../includes/header.php';
|
|||||||
<input type="date" id="calendarNewDate" style="width:auto;">
|
<input type="date" id="calendarNewDate" style="width:auto;">
|
||||||
<select id="calendarNewType" style="width:auto;">
|
<select id="calendarNewType" style="width:auto;">
|
||||||
<option value="makeup">补课(按上课)</option>
|
<option value="makeup">补课(按上课)</option>
|
||||||
<option value="pre_holiday">节前上课(早+中)</option>
|
|
||||||
<option value="holiday">放假(按休息)</option>
|
<option value="holiday">放假(按休息)</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="text" id="calendarNewNote" placeholder="备注(选填)" maxlength="100" style="flex:1; min-width:120px;">
|
<input type="text" id="calendarNewNote" placeholder="备注(选填)" maxlength="100" style="flex:1; min-width:120px;">
|
||||||
|
|||||||
@@ -308,11 +308,10 @@ function renderCalendar(data) {
|
|||||||
items.push({ date: d, type: 'makeup', label: '调休', name: workdays[d], manual: false });
|
items.push({ date: d, type: 'makeup', label: '调休', name: workdays[d], manual: false });
|
||||||
});
|
});
|
||||||
Object.keys(manual).forEach(function(d) {
|
Object.keys(manual).forEach(function(d) {
|
||||||
const manualLabels = { holiday: '放假', makeup: '补课', pre_holiday: '节前上课' };
|
|
||||||
items.push({
|
items.push({
|
||||||
date: d,
|
date: d,
|
||||||
type: manual[d].type,
|
type: manual[d].type,
|
||||||
label: manualLabels[manual[d].type] || manual[d].type,
|
label: manual[d].type === 'holiday' ? '放假' : '补课',
|
||||||
name: manual[d].note || '',
|
name: manual[d].note || '',
|
||||||
manual: true
|
manual: true
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user