feat(xq0084): 导入前先查工资卡并去重回写(v0.3.0)

This commit is contained in:
2026-11-27 17:18:47 +08:00
parent 5cca982509
commit f0747b6fea
11 changed files with 300 additions and 61 deletions
@@ -72,8 +72,9 @@ def _ocr(id_no=ID, name="张三", card=CARD, bank="招商银行"):
def _wage_row(**kw):
base = {
"conclusion": "通过", "trust": "", "emp_name": "张三", "holder": "张三",
"table_bank": "招商银行", "table_branch": "深圳分行", "table_card": CARD,
"table_id": ID, "record_id": "rec1", "hr_status": "", "hr_note": "",
"emp_no": "37000001", "table_bank": "招商银行", "table_branch": "深圳分行",
"table_card": CARD, "table_id": ID, "record_id": "rec1",
"hr_status": "", "hr_note": "",
}
base.update(kw)
return base
@@ -89,6 +90,26 @@ def _wage_cases():
return dedup
def _existing_index(card=CARD, id_no=ID, code="37000001"):
wage = importlib.import_module(f"{verify.__module__.rsplit('.', 2)[0]}.logic.wage")
if not id_no:
return wage.build_card_index([{"BANK_ACCOUNT": card, "base_code": code}])
return wage.build_card_index([{"BANK_ACCOUNT": card, "CARD_IDCARD": id_no,
"IDCARD": id_no, "base_code": code, "IS_MAIN": "主卡"}])
def _existing_cases():
"""导入前查 HR:卡号已一致 -> 不导入只回写;卡号不同/未命中 -> 照常导入。"""
return [
("HR已一致跳过导入", _wage_row(), _existing_index(), 0, "已一致", "无需重复导入"),
("HR卡号不同要更新", _wage_row(), _existing_index(card=CARD_CCB), 1, "", "将更新为"),
("HR无此人照常导入", _wage_row(), _existing_index(id_no="500228198001011234",
code="37009999"), 1, "", ""),
("HR按工号命中一致", _wage_row(), _existing_index(id_no=""), 0, "已一致", "无需重复导入"),
("不查重走导入", _wage_row(), None, 1, "", ""),
]
def main():
cases = [
("全部一致", _item(), _ocr(), "通过"),
@@ -139,7 +160,21 @@ def main():
extra = f"{data_rows[0][:6]}…" if expect_n else row["hr_note"]
print(f"{'OK ' if ok else 'FAIL'} 工资卡导入-{name}: 目标 {len(targets)} 条 {extra}")
print(f"完成:{len(cases) + len(_wage_cases()) - failed}/{len(cases) + len(_wage_cases())} 通过")
for name, row, index, expect_n, expect_status, note_kw in _existing_cases():
targets, data_rows = wage.build_wage_rows([row], index)
guards = [
len(targets) == expect_n,
row["hr_status"] == expect_status,
note_kw in (row["hr_note"] or ""),
all(len(d) == 10 for d in data_rows),
]
ok = all(guards)
failed += 0 if ok else 1
print(f"{'OK ' if ok else 'FAIL'} HR查重-{name}: 目标 {len(targets)} 条 "
f"状态「{row['hr_status'] or '-'}」{row['hr_note']}")
total = len(cases) + len(_wage_cases()) + len(_existing_cases())
print(f"完成:{total - failed}/{total} 通过")
return failed