refactor: 重构审批流程与依赖,新增社保异动模块
1. 新增社保增减名单模块,支持参保/停保名单导出 2. 重构钉钉推送逻辑,先推摘要再按需推送完整报告 3. 优化假期/加班校验的天数比对逻辑,适配半天请假场景 4. 重写排班HTML解析器,兼容新的页面结构并提取班次全称 5. 重构审批报告生成逻辑,新增全量明细展示 6. 重构影刀脚本的日志与依赖管理,新增UI自动化聚焦输入框 7. 更新依赖包,新增uiautomation库支持
This commit is contained in:
@@ -154,9 +154,14 @@ def run_flow(
|
||||
report = generate_report(results)
|
||||
print("\n" + report)
|
||||
|
||||
# 推送「通过项汇总」到钉钉(测试阶段,env 控制;无通过项或失败均不影响主流程)
|
||||
# 先推送摘要到钉钉
|
||||
push_report(build_push_summary(results, subject), subject)
|
||||
|
||||
# 有驳回/人工复核/失败时,再推送完整报告(含明细表格)
|
||||
has_detail = any(r.get("decision") != "通过" for r in results)
|
||||
if has_detail:
|
||||
push_report(report, subject)
|
||||
|
||||
# 保存最新 cookies(SSO 已刷新 hr 域会话,供下次运行免登录复用)
|
||||
save_browser_cookies(browser)
|
||||
|
||||
|
||||
@@ -23,29 +23,47 @@ def parse_attendance_html(html: str) -> Dict[str, str]:
|
||||
"""
|
||||
解析排班 HTML 表格,提取每个日期的班次名称。
|
||||
|
||||
示例 HTML 片段:
|
||||
<a class='cale_a' ... data-temp='2026-08-01' ...>正常</a>
|
||||
或 <a ...>休息</a>
|
||||
实际 HTML 结构(属性用单引号):
|
||||
<a class='cale_a' title='经营正班A' short_bc_name='经营A'
|
||||
data-temp='2026-08-03' finalState='' onclick="...">正常</a>
|
||||
|
||||
- data-temp: 日期
|
||||
- title: 班次全称(如 经营正班A、职能正班A、休息)
|
||||
- 文本内容: 考勤状态(如 正常、异常、休息)
|
||||
|
||||
Args:
|
||||
html: 排班接口返回的 HTML 字符串
|
||||
|
||||
Returns:
|
||||
字典:{日期字符串: 班次名称}
|
||||
例如:{"2026-08-01": "正常", "2026-08-02": "休息"}
|
||||
例如:{"2026-08-01": "休息", "2026-08-03": "经营正班A"}
|
||||
"""
|
||||
# 正则匹配 <a> 标签中的 data-temp 和文本内容
|
||||
# 注意:实际接口返回的 HTML 中 data-temp 用单引号(data-temp='2026-08-04'),
|
||||
# 需同时兼容单/双引号,否则会解析出 0 条
|
||||
pattern = r'<a[^>]*data-temp=["\']([^"\']+)["\'][^>]*>([^<]+)</a>'
|
||||
matches = re.findall(pattern, html)
|
||||
if not html:
|
||||
return {}
|
||||
|
||||
result = {}
|
||||
for date, shift in matches:
|
||||
# 去除可能的空格
|
||||
date_clean = date.strip()
|
||||
shift_clean = shift.strip()
|
||||
result[date_clean] = shift_clean
|
||||
# 匹配含 data-temp 属性的 <a> 标签,兼容单引号和双引号
|
||||
a_tag_pattern = r"""<a\b[^>]*\bdata-temp=['"]([^'"]+)['"][^>]*>([^<]*)</a>"""
|
||||
|
||||
for match in re.finditer(a_tag_pattern, html, re.DOTALL):
|
||||
date_str = match.group(1).strip()
|
||||
text_content = match.group(2).strip()
|
||||
|
||||
# 从完整标签中提取 title 属性(班次名称),同样兼容单/双引号
|
||||
full_tag = match.group(0)
|
||||
title_match = re.search(r"""\btitle=['"]([^'"]*)['"]""", full_tag)
|
||||
shift_name = title_match.group(1).strip() if title_match else ""
|
||||
|
||||
# 优先使用 title(班次名称),休息日 title='休息'
|
||||
if shift_name:
|
||||
# 考勤异常时附加标注,便于报告展示
|
||||
if text_content and text_content == "异常":
|
||||
result[date_str] = f"{shift_name}(异常)"
|
||||
else:
|
||||
result[date_str] = shift_name
|
||||
else:
|
||||
result[date_str] = text_content
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user