feat(xq0011): 支持检查项选择并增加岗位等核心字段到异常名单

This commit is contained in:
2026-09-29 08:47:27 +08:00
parent 87f995ca47
commit f8f108af5d
100 changed files with 11920 additions and 1121 deletions
@@ -71,17 +71,29 @@ def _normalize_month(month) -> str:
# ==================== 主流程 ====================
def run_all_checks(month: str = None, save_dir: str = None,
roster_path: str = None, transfer_path: str = None) -> Dict[str, object]:
"""依次运行检查1~6,返回各检查异常名单行列表(每项含编号/sheet/类型/行列表)。"""
def run_all_checks(month: str = None, save_dir: str = None, roster_path: str = None,
transfer_path: str = None, checks: List[str] = None) -> Dict[str, object]:
"""依次运行检查1~6,返回各检查异常名单行列表(每项含编号/sheet/类型/列/行列表)。
checks:需要执行的检查编号列表(如 ["检查1", "检查3"]);为空/None = 全部执行。
"""
ym = _normalize_month(month)
save_dir = save_dir or DEFAULT_SAVE_DIR
logger.info("===== 考勤月报封存检查(汇总)月份:%s =====", ym)
metas = CHECK_META
if checks:
want = {str(c).strip() for c in checks}
metas = [m for m in CHECK_META if m[0] in want]
if not metas:
raise RuntimeError(f"未选择任何有效检查项:{checks}")
logger.info("===== 考勤月报封存检查(汇总)月份:%s,检查项:%s =====",
ym, "、".join(m[0] for m in metas))
results: List[dict] = []
total = 0
notes: List[str] = []
for no, sheet_name, label, run_fn, _cols, kwargs in CHECK_META:
for no, sheet_name, label, run_fn, cols, kwargs in metas:
kw = dict(kwargs)
if no == "检查1":
kw["roster_path"] = roster_path
if no == "检查4":
kw["transfer_path"] = transfer_path
if no in ("检查5", "检查6"):
@@ -96,6 +108,7 @@ def run_all_checks(month: str = None, save_dir: str = None,
"no": no,
"sheet_name": sheet_name,
"label": label,
"cols": cols,
"rows": rows,
})
total += len(rows)
@@ -127,8 +140,9 @@ def write_workbook(result: Dict[str, object], save_dir: str = None) -> str:
with pd.ExcelWriter(save_path, engine="openpyxl") as writer:
pd.DataFrame(summary_rows).to_excel(
writer, sheet_name="汇总", index=False)
for it, (_, _, _, _, cols, _) in zip(result["results"], CHECK_META):
for it in result["results"]:
rows = it["rows"]
cols = it["cols"]
sheet_name = it["sheet_name"]
if not rows:
# 空结果也保留 sheet,便于人工核对