# school_attendance 表文档 ## 表概述 **表名**: school_attendance **功能**: 考勤管理表,存储教务系统中所有员工的考勤记录,包括签到签退时间、请假信息、考勤状态等核心数据 ## 字段说明 ``` Field Type Collation Null Key Default Extra Privileges Comment id int NULL NO PRI NULL auto_increment select,insert,update,references 考勤编号 campus_id int NULL NO NULL select,insert,update,references 校区ID staff_id int NULL NO NULL select,insert,update,references 人员ID attendance_date date NULL NO NULL select,insert,update,references 考勤日期 check_in_time time NULL YES NULL select,insert,update,references 签到时间 check_out_time time NULL YES NULL select,insert,update,references 签退时间 leave_start_time time NULL YES NULL select,insert,update,references 请假开始时间|默认null,只有status=请假的时候本字段必须有值 leave_end_time time NULL YES NULL select,insert,update,references 请假结束时间|默认null,只有status=请假的时候本字段必须有值 status enum('present','absent','late','leave_early','leave') utf8mb4_general_ci NO NULL select,insert,update,references 考勤状态: present-出勤, absent-缺勤, late-迟到, leave_early-早退,leave-请假 remarks text utf8mb4_general_ci YES NULL select,insert,update,references 备注 created_at timestamp NULL YES CURRENT_TIMESTAMP DEFAULT_GENERATED select,insert,update,references 创建时间 updated_at timestamp NULL YES CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP select,insert,update,references 修改时间 coordinate varchar(255) utf8mb4_general_ci YES NULL select,insert,update,references 坐标|经度,纬度 ``` ## 功能用途 ### 主要功能 1. **考勤记录管理**: 记录员工每日的签到签退时间 2. **请假管理**: 管理员工请假的开始和结束时间 3. **考勤状态跟踪**: 自动判断和记录考勤状态(出勤、缺勤、迟到、早退、请假) 4. **地理位置验证**: 通过坐标字段验证员工打卡位置 5. **校区考勤管理**: 按校区分别管理员工考勤 6. **考勤异常处理**: 记录和处理考勤异常情况 7. **考勤备注管理**: 支持考勤异常或特殊情况的备注说明 ### 业务场景 1. **日常打卡**: 员工上下班时进行签到签退操作 2. **请假申请**: 员工申请请假时记录请假时间段 3. **考勤统计**: 按月度、季度统计员工考勤情况 4. **薪资计算**: 根据考勤记录计算员工工资和绩效 5. **异常处理**: 处理迟到、早退、缺勤等异常考勤 6. **位置验证**: 验证员工是否在指定地点打卡 7. **考勤报表**: 生成各类考勤统计报表 8. **人事管理**: 为人事决策提供考勤数据支持 ## 关联关系 ### 主要关联表 1. **school_personnel**: 人员表(staff_id字段关联) 2. **school_campus**: 校区表(campus_id字段关联) 3. **school_salary**: 薪资表(考勤数据用于薪资计算) 4. **school_performance_records**: 绩效记录表(考勤影响绩效) 5. **school_sys_schedule**: 排班表(与排班计划对比) 6. **school_approval_process**: 审批流程表(请假审批关联) ### 关联说明 1. **人员关联**: 通过staff_id与人员表关联,确定考勤记录所属员工 2. **校区关联**: 通过campus_id关联校区,实现多校区考勤管理 3. **薪资关联**: 考勤数据作为薪资计算的重要依据 4. **绩效关联**: 考勤情况影响员工绩效评估 5. **排班关联**: 与排班计划对比,判断考勤是否正常 6. **审批关联**: 请假等需要审批的考勤状态与审批流程关联 ## 索引建议 1. **主键索引**: id(已存在) 2. **外键索引**: - staff_id(员工关联查询) - campus_id(校区关联查询) 3. **普通索引**: - attendance_date(考勤日期查询) - status(考勤状态筛选) - created_at(创建时间排序) 4. **复合索引**: - (staff_id, attendance_date)(员工+日期查询) - (campus_id, attendance_date)(校区+日期查询) - (attendance_date, status)(日期+状态查询) - (staff_id, status, attendance_date)(员工+状态+日期查询) ## 注意事项 1. **时间逻辑**: check_in_time应早于check_out_time 2. **请假时间**: 请假状态时leave_start_time和leave_end_time必须有值 3. **状态一致性**: 考勤状态需要与时间字段保持逻辑一致 4. **唯一性约束**: 同一员工同一天只能有一条考勤记录 5. **坐标验证**: 打卡坐标需要在允许的范围内 6. **数据完整性**: 签到时间为必填,签退时间可为空(未签退) 7. **状态自动判断**: 系统应根据时间自动判断迟到、早退等状态 8. **异常处理**: 需要处理跨天打卡、忘记打卡等异常情况 9. **权限控制**: 员工只能查看自己的考勤记录 10. **数据备份**: 考勤数据涉及薪资计算,需要定期备份