Files
37duAutomation/plugins/XQ0001-0100/XQ0033 门店管理及服务岗出勤积分更新/report/summary.py
T

48 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- 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/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("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']} 个考勤状态。")
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