| name | wps-attendance |
| description | 考勤打卡统计。把考勤机导出的打卡数据丢进来,自动统计每个人的
迟到、早退、缺勤、加班时长,生成月度考勤汇总表,异常考勤自动标红。
用于帮助HR处理考勤数据。当用户提到考勤、打卡、迟到、加班统计时触发。
Attendance tracker - generates summary reports from clock-in records.
|
| license | MIT |
| user-invocable | true |
| argument-hint | [考勤数据/需求描述] |
| allowed-tools | Read, Grep, Glob, Bash, Write, Edit |
| metadata | {"author":"BWKYD","title":"考勤统计","description_zh":"导入打卡记录,自动统计迟到早退缺勤加班,生成月度考勤汇总表","tags":["考勤","打卡","HR","加班","WPS"],"version":"1.0.1","license":"MIT"} |
考勤统计工具
打卡记录 → 考勤汇总 → 月度报表。HR每月必用。
When to Use
- 处理考勤机导出的打卡数据
- 统计迟到、早退、缺勤、加班
- 生成月度考勤汇总表
- 用户说"帮我统计考勤""处理打卡记录"
When NOT to Use
- 工资计算 → 使用
wps-salary
- 排班表制作 → 使用
wps-schedule
考勤规则配置
标准班制(可自定义):
上班时间:09:00
下班时间:18:00
午休:12:00-13:00
迟到容忍:10分钟(09:10前不算迟到)
早退判定:17:30前离开
加班起算:18:30之后
缺勤判定:无打卡记录且无请假
工作流程
Step 1: 读取打卡数据
支持常见考勤机导出格式:
常见格式:
A列:工号/姓名
B列:日期
C列:打卡时间1(上班)
D列:打卡时间2(下班)
(或合并在一列,多次打卡用逗号分隔)
Step 2: 考勤计算引擎
from openpyxl import Workbook, load_workbook
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
from datetime import datetime, timedelta
import os
import re
class AttendanceCalculator:
"""考勤计算器"""
def __init__(self, config=None):
default = {
'work_start': '09:00',
'work_end': '18:00',
'late_tolerance': 10,
'early_leave_before': '17:30',
'overtime_after': '18:30',
'lunch_start': '12:00',
'lunch_end': '13:00',
}
self.config = {**default, **(config or {})}
def _parse_time(self, t):
if isinstance(t, datetime):
return t
if isinstance(t, str):
for fmt in ['%H:%M:%S', '%H:%M', '%Y-%m-%d %H:%M:%S']:
try:
return datetime.strptime(t.strip(), fmt)
ValueError:
():
result = {
: ,
: ,
: ,
: ,
: ,
}
is_workday:
clock_in clock_out:
result[] =
ci = ._parse_time(clock_in)
co = ._parse_time(clock_out)
ci co:
result[] = (
((co - ci).total_seconds() / ) - , )
result
clock_in clock_out:
result[] =
result[] =
result
work_start = ._parse_time(.config[])
ci = ._parse_time(clock_in)
ci work_start:
diff = ((ci - work_start).total_seconds() / )
diff > .config[]:
result[] = diff
result[] =
work_end = ._parse_time(.config[])
early_limit = ._parse_time(.config[])
overtime_start = ._parse_time(.config[])
co = ._parse_time(clock_out)
co early_limit:
co < early_limit:
diff = ((early_limit - co).total_seconds() / )
result[] = diff
result[] = result[] == \
result[] +
co overtime_start:
co > overtime_start:
result[] = (
(co - overtime_start).total_seconds() / )
result
():
calc = AttendanceCalculator(config)
wb_data = load_workbook(data_path)
ws_data = wb_data.active
wb_out = Workbook()
ws = wb_out.active
ws.title =
headers = [, , , , ,
, , , ]
header_fill = PatternFill(, fgColor=)
header_font = Font(name=, size=, bold=, color=)
col, h (headers, ):
cell = ws.cell(row=, column=col, value=h)
cell.font = header_font
cell.fill = header_fill
cell.alignment = Alignment(horizontal=)
wb_out.save(output_path)
os.path.abspath(output_path)
Step 3: 生成汇总报表
考勤月报模板:
┌────────────────────────────────────────────┐
│ XX公司 2026年3月 考勤汇总表 │
├────┬────┬────┬────┬────┬────┬────┬────┬───┤
│姓名│部门│应勤│实勤│迟到│早退│缺勤│加班│备注│
├────┼────┼────┼────┼────┼────┼────┼────┼───┤
│张三│技术│22 │21 │1 │0 │1 │8h │病假│
│李四│销售│22 │22 │0 │0 │0 │12h │ │
│王五│行政│22 │20 │2 │1 │2 │0 │事假│
├────┴────┴────┴────┴────┴────┴────┴────┴───┤
│ 部门汇总 / 异常标记 / 审批签字栏 │
└────────────────────────────────────────────┘
Step 4: 交付
- 生成月度考勤汇总Excel(含格式和条件格式高亮异常)
- 个人考勤明细表(可选)
- 异常考勤提醒列表
考勤公式速查(WPS表格内直接用)
# 判断迟到(C列为打卡时间)
=IF(C2>"09:10","迟到"&TEXT(C2-"09:00","h小时m分"),"正常")
# 计算加班时长(D列为下班打卡)
=IF(D2>"18:30",TEXT(D2-"18:30","h:mm"),"无")
# 统计迟到次数
=COUNTIF(E2:E32,"迟到*")
# 统计出勤天数
=COUNTA(C2:C32)-COUNTBLANK(C2:C32)
示例
/wps-attendance 帮我统计这个月的考勤,打卡数据在attendance_march.xlsx
/wps-attendance 生成3月份考勤汇总表,标准班制9点到6点
/wps-attendance 统计一下这个月每个人的加班时长