# -*- coding: utf-8 -*- """XQ0033 插件 - 执行摘要组装(summary 文本 + detail 结构化数据)。""" def build_summary(today, t2, target_path, stats, push_result=None): """按执行结果拼装 {summary, detail}。 stats: report_rows/selected/new/fix/del/gap/rejoin_new/rejoin_total/cleared 计数; update=False 表示本轮仅推送(不展示更新计数)。 push_result: {label: {success, message}} 或 None(未执行推送)。 """ if stats.get("update", True): detail = { "运行日": today.isoformat(), "积分日期(T-2)": t2.isoformat(), "工作簿": target_path, "报表人数": stats.get("report_rows", 0), "圈人命中": stats.get("selected", 0), "新增积分行": stats.get("new", 0), "补漏日期数": stats.get("gap", 0), "修正补积分行": stats.get("fix", 0), "修正删积分行": stats.get("del", 0), "再入职新增行": stats.get("rejoin_new", 0), "再入职台账人数": stats.get("rejoin_total", 0), "踢除无效积分格": stats.get("cleared", 0), } lines = [ f"XQ0033 完成(运行日 {today},积分日期 T-2={t2}):" f"报表 {stats.get('report_rows', 0)} 人 / 圈人 {stats.get('selected', 0)} 人;" f"积分导入新增 {stats.get('new', 0)} 行、修正补 {stats.get('fix', 0)} 行;" f"积分删除 {stats.get('del', 0)} 行;当月再入职新增 {stats.get('rejoin_new', 0)} 行。", f"工作簿:{target_path}", ] if stats.get("cleared"): lines.append(f"已踢除离职当月再入职人员无效积分段 {stats['cleared']} 个考勤状态。") if stats.get("gap"): lines.append(f"检测到漏处理日期 {stats['gap']} 天,已按新增段口径全量补齐。") else: detail = {"运行日": today.isoformat(), "工作簿": target_path} lines = [f"XQ0033 完成(运行日 {today},仅推送):工作簿 {target_path}"] if push_result: parts = [] for label, res in push_result.items(): if res.get("success") is None: parts.append(f"{label}:{res.get('message') or '未上传'}") else: parts.append(f"{label}:{'成功' if res.get('success') else '失败'}({res.get('message')})") lines.append("OPM 推送:" + ";".join(parts)) detail["OPM推送"] = push_result return "\n".join(lines), detail