feat(sdk): hr_sdk 0.2.4 工资卡导入、desktopauto 0.5.0 证件照识别、新增插件 XQ0084
- hr_sdk.wage_import:DrissionPage 注入 cookie 打开 HR 门户,页面内 WS 订阅 + fetch 上传,解析 over: 结果;build_xlsx 第 9 列卡号强制数值(修复「卡号必须是数字」) - 纯 HTTP 导入不可用:服务端异步任务与浏览器会话强绑定,且前端无轮询接口(已核实),结果通道只能用浏览器上下文 - desktopauto 0.5.0 新增 cardocr:身份证/银行卡 OCR、号码纠错、Luhn 与模 11-2 校验、交叉核对 - 新增插件 XQ0084 银行卡更新EHR系统:AI 表格待处理行 → 影像识别 → 一致性核对/异常名单 - .gitignore 忽略 tests/aitable_probe/_out/(含员工证件照,禁止入库)
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0084 输出层:核对结果工作簿。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Alignment, Font, PatternFill
|
||||
from openpyxl.utils import get_column_letter
|
||||
|
||||
from .. import config
|
||||
|
||||
COLUMNS = [
|
||||
("emp_no", "工号", 11),
|
||||
("holder", "持卡人姓名", 14),
|
||||
("reason", "变更原因", 24),
|
||||
("table_bank", "开户银行(表格)", 18),
|
||||
("table_card", "银行卡号(表格)", 23),
|
||||
("table_id", "身份证号(表格)", 23),
|
||||
("ocr_id", "身份证号(识别)", 23),
|
||||
("ocr_name", "姓名(识别)", 11),
|
||||
("ocr_card", "银行卡号(识别)", 23),
|
||||
("ocr_bank", "开户银行(识别)", 18),
|
||||
("id_status", "身份证核对", 11),
|
||||
("name_status", "姓名核对", 11),
|
||||
("card_status", "卡号核对", 11),
|
||||
("bank_status", "开户银行核对", 13),
|
||||
("self_check", "表格自检", 26),
|
||||
("triggers", "触发原因", 22),
|
||||
("conclusion", "核对结论", 22),
|
||||
("notes", "说明", 60),
|
||||
("image_count", "影像数", 8),
|
||||
("image_dir", "影像目录", 50),
|
||||
]
|
||||
|
||||
_HEAD_FILL = PatternFill("solid", fgColor="1F4E78")
|
||||
_HEAD_FONT = Font(color="FFFFFF", bold=True)
|
||||
_MANUAL_FILL = PatternFill("solid", fgColor="FFF2CC")
|
||||
_PASS_FILL = PatternFill("solid", fgColor="E2EFDA")
|
||||
_CASH_FILL = PatternFill("solid", fgColor="DDEBF7")
|
||||
|
||||
|
||||
def _write_sheet(ws, rows):
|
||||
ws.append([title for _, title, _ in COLUMNS])
|
||||
for col, (_, title, width) in enumerate(COLUMNS, start=1):
|
||||
cell = ws.cell(row=1, column=col)
|
||||
cell.fill = _HEAD_FILL
|
||||
cell.font = _HEAD_FONT
|
||||
cell.alignment = Alignment(horizontal="center", vertical="center")
|
||||
ws.column_dimensions[get_column_letter(col)].width = width
|
||||
ws.row_dimensions[1].height = 24
|
||||
ws.freeze_panes = "A2"
|
||||
|
||||
for record in rows:
|
||||
ws.append([record.get(key, "") for key, _, _ in COLUMNS])
|
||||
r = ws.max_row
|
||||
for col in range(1, len(COLUMNS) + 1):
|
||||
ws.cell(row=r, column=col).alignment = Alignment(vertical="center", wrap_text=True)
|
||||
conclusion = record.get("conclusion", "")
|
||||
fill = (_MANUAL_FILL if conclusion == "需人工核实"
|
||||
else _CASH_FILL if conclusion.startswith("现金发放") else _PASS_FILL)
|
||||
ws.cell(row=r, column=[k for k, _, _ in COLUMNS].index("conclusion") + 1).fill = fill
|
||||
ws.auto_filter.ref = f"A1:{get_column_letter(len(COLUMNS))}{max(ws.max_row, 1)}"
|
||||
|
||||
|
||||
def write_workbook(rows, path):
|
||||
"""写出「核对结果 / 异常名单」两个 sheet。"""
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = config.SHEET_FULL
|
||||
_write_sheet(ws, rows)
|
||||
|
||||
abnormal = [r for r in rows if r.get("conclusion") == "需人工核实"]
|
||||
ws2 = wb.create_sheet(config.SHEET_ABNORMAL)
|
||||
_write_sheet(ws2, abnormal)
|
||||
|
||||
wb.save(path)
|
||||
return path
|
||||
Reference in New Issue
Block a user