style: 去掉全部 emoji, 状态用颜色文字表达(一致/不一致/正常/过热/需关注)
emoji 在企微客户端渲染成大色块很扎眼; 改为纯文字+<font color> 三色, 状态词直接着色, 数据保持素色, 版式标题+单行结论+引用详情不变
This commit is contained in:
@@ -40,9 +40,12 @@ def _system_lines(name: str, report: dict, goods: dict, lines: list[str]) -> boo
|
||||
|
||||
g = goods or {}
|
||||
zero = g.get("zeroGoodsOrders", 0)
|
||||
goods_txt = f"{g.get('goods', 0):,} 行" + (f"(缺 {zero:,})" if zero else "")
|
||||
order_txt = f"订单 {remote_t:,} ✅" if ok else f"订单 远程 {remote_t:,} / 本地 {local_t:,} ⚠️"
|
||||
lines.append(f"**{name}** {order_txt} · 商品 {goods_txt} {'✅' if not zero else '⚠️'}")
|
||||
goods_txt = f"{g.get('goods', 0):,} 行" + (f'(<font color="warning">缺 {zero:,}</font>)' if zero else "")
|
||||
if ok:
|
||||
order_txt = f"订单 {remote_t:,} <font color=\"info\">一致</font>"
|
||||
else:
|
||||
order_txt = f"订单 远程 {remote_t:,} / 本地 {local_t:,} <font color=\"warning\">不一致</font>"
|
||||
lines.append(f"**{name}** {order_txt} · 商品 {goods_txt}")
|
||||
|
||||
diff_days = [d for d in days_r if not d.get("ok")]
|
||||
diff_units = sum(_affected_units(d.get("diff")) for d in diff_days)
|
||||
@@ -56,7 +59,7 @@ def build_daily_message(
|
||||
goods: dict, ocr_today: dict, ocr_pending: int, failures: list[dict],
|
||||
) -> tuple[str, bool]:
|
||||
"""拼装日报 markdown,返回 (消息, 是否需关注)。单行结论 + 引用详情的紧凑排版。"""
|
||||
lines = [f"## 📊 数据核验日报 {datetime.now():%m-%d %H:%M}(近 {days} 天 {window})"]
|
||||
lines = [f"## 数据核验日报 {datetime.now():%m-%d %H:%M}(近 {days} 天 {window})"]
|
||||
attention = False
|
||||
|
||||
for name, report in (("RIIN", riin), ("SDS", sds)):
|
||||
@@ -67,24 +70,25 @@ def build_daily_message(
|
||||
attention = True
|
||||
|
||||
processed, failed = (ocr_today or {}).get("processed", 0), (ocr_today or {}).get("failed", 0)
|
||||
ocr_txt = f"**OCR 今日** 处理 {processed:,} · 识别失败 {failed:,}" + (" ✅" if not failed else " ⚠️")
|
||||
ocr_txt = f"**OCR** 今日处理 {processed:,} · 识别失败 "
|
||||
ocr_txt += f'<font color="warning">{failed:,}</font>' if failed else "0"
|
||||
if ocr_pending:
|
||||
ocr_txt += f"(累计待处理 {ocr_pending:,})"
|
||||
ocr_txt += f" · 待处理 {ocr_pending:,}"
|
||||
lines.append(ocr_txt)
|
||||
|
||||
if failures:
|
||||
attention = True
|
||||
lines.append(f"**失败任务(24h)** {len(failures)} 次 🔴")
|
||||
lines.append(f'**任务** 失败 <font color="warning">{len(failures)} 次</font>(24h)')
|
||||
for f in failures[:6]:
|
||||
start = (f.get("start") or "")[5:] # MM-DD HH:MM
|
||||
lines.append(f"> {f.get('flow', '?')}「{f.get('name', '?')}」{f.get('state', '?')} · {start}")
|
||||
lines.append(f"> {f.get('flow', '?')}:{f.get('name', '?')} {f.get('state', '?')} {start}")
|
||||
if len(failures) > 6:
|
||||
lines.append(f"> …等共 {len(failures)} 次")
|
||||
else:
|
||||
lines.append("**失败任务(24h)** 0 ✅")
|
||||
lines.append("**任务** 失败 0 次(24h)")
|
||||
|
||||
lines.append('<font color="warning">⚠️ 存在需关注项,见上</font>' if attention
|
||||
else '<font color="info">✅ 数据全部一致,无异常</font>')
|
||||
lines.append('<font color="warning">存在需关注项,见上</font>' if attention
|
||||
else '<font color="info">数据全部一致,无异常</font>')
|
||||
return "\n".join(lines), attention
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user