Commit Graph

5 Commits

Author SHA1 Message Date
OoO
1af96f5be4 feat(ppt): period_review unified generator for quarterly/half/annual/ttm
All checks were successful
CD Pipeline / deploy (push) Successful in 3m37s
Wave 1.2:用一份 generator 解 4 種時間維度報表(季/半年/年/TTM)。

generate_period_review_ppt(services/ppt_generator.py)— 12 頁
- 期間類型徽章自動切換(季報/半年報/年報/TTM 滾動)
- P1 封面:含業績狀態徽章 + elevator pitch + 期間動能
- P2 執行摘要:KPI v2 含 △% (vs 上季/上半/去年) + AI 解讀 + YoY 對比帶
- P3 月度業績走勢(matplotlib 折線:本期 + 上期 + 月均線 + 高低點)+ 4 卡指標
- P4 品類分析:橫條 + 帕雷托雙視圖
- P5-P7 TOP 50 商品(自動分頁)
- P8 TOP 30 廠商
- P9 MCP 市場情報
- P10 AI 結構化洞察
- P11 附錄

query_period_summary(routes/openclaw_bot_routes.py)
- 一次拉齊:kpis / monthly_breakdown / top_products(50) / top_categories(8) /
  top_vendors(30)
- 自動算月度聚合(PostgreSQL TO_CHAR)

路由層加 4 種 sub_type 分支:
- /ppt quarterly [YYYY/Q1-4]    當季或指定季
- /ppt half_yearly [YYYY/H1-2]  當半年或指定半年
- /ppt annual [YYYY]            當年或指定年
- /ppt ttm                      最近 12 個月(自動算到本月底)

每種自動抓三段資料:本期 + 上期同等 + 去年同期
- quarterly: 上季 + 去年同季
- half_yearly: 上半年 + 去年同半年
- annual: 去年 + 前年
- ttm: 上一個 TTM (24-12 月前) + 同上

_ppt_ai_analysis 加 is_period 分支
- 角色:策略顧問 + BU 主管 + CFO 三合一視角
- 結構:整體解讀 / 市場趨勢對位 / 月度走勢分析 / 品類結構 / 戰略級 SMART /
  風險預警
- SMART 行動分三層:下期立即啟動(30 天)/ 下期戰略(60-90 天)/
  下下期預備(6-12 月)
- max_tokens 2600,字數 1000-1300

Telegram 按鈕:報表選單加 4 顆季/半/年/TTM 按鈕

bump TEMPLATE_VERSIONS:quarterly / half_yearly / annual / ttm 全 v3.1.0

煙霧測試:4 種全綠,每份 12 頁 220KB。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:10:14 +08:00
OoO
b6fdb4f473 feat(ppt): awaken vendor report + v3.1.0 procurement strategy upgrade
All checks were successful
CD Pipeline / deploy (push) Successful in 2m32s
Wave 1.1:把沉睡的 vendor generator 喚醒並全面升 v3.1.0:

generate_vendor_ppt(services/ppt_generator.py)— 8 頁
- P1 封面:含集中度警示徽章(健康分散 / 偏高 / 過高)+ 三句話策略要點
- P2 執行摘要:4 KPI 含 △% vs 上期 + 帕雷托 80/20 集中度結論帶
- P3 廠商業績排行:橫條 + 帕雷托雙視圖(matplotlib 暖色系)
- P4-P5 廠商明細表 TOP 30:含 △ 排名變化、🆕 新進榜、業績佔比 bar、
  毛利率紅綠燈(綠 ≥15% / 黃 8~15% / 紅 <8%)
- P6 AI 採購策略洞察(結構化 8 段)
- P7 附錄

query_vendor_summary(routes/openclaw_bot_routes.py)
- 期間(單月/自訂日期區間)廠商業績聚合
- 計算 sales / profit / margin / qty / orders
- 同步抓上期同等期間做 vs 上期 △ 比對

_ppt_ai_analysis 加 is_vendor 分支
- 角色:採購主管 + 供應鏈管理顧問
- 結構:整體解讀 / 集中度與供應風險 / 議價優先 / SMART 行動 / 風險預警
- SMART 行動分三層:立即執行 / 中期強化 / 長期結構(含 OEM/ODM 自有品牌)
- 引用 MARKET_TREND_2026 共用知識基底
- max_tokens 1800,字數 800-1000

路由綁定 _generate_ppt_cmd
- /ppt vendor          當月廠商報告
- /ppt vendor 2026/04  指定月份
- /ppt vendor 2026/04/01-2026/04/15  自訂期間
- 自動抓上期同等期間做 △ 比對

Telegram 按鈕(menu_keyboards.py 的 _submenu_reports)
- 新增「🏭 廠商業績報告」進報表選單

bump TEMPLATE_VERSIONS['vendor'] v2.0 (DEPRECATED) → v3.1.0

煙霧測試:本機 venv 跑 vendor PPT 生成 8 頁 200KB 全綠。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:04:41 +08:00
OoO
1a886d962b fix(telegram): dedupe webhook+polling updates via shared DB guard
All checks were successful
CD Pipeline / deploy (push) Successful in 8m50s
Webhook (Flask) and polling (momo-telegram-bot) consumed the same
Telegram update_id, causing /menu callbacks to fire twice. Add a
shared dedup module backed by telegram_update_dedup table (300s TTL,
60s cleanup) with in-memory fallback, wired into both paths.

Polling launcher now skips startup when webhook is configured to
prevent dual-consumption at the source.

38 tests across webhook, menu keyboards, telegram_api, dedup guard,
and trend bot service.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 12:01:04 +08:00
OoO
dd35306399 refactor(openclaw): 抽出選單鍵盤 builders
All checks were successful
CD Pipeline / deploy (push) Successful in 1m46s
2026-04-30 23:17:19 +08:00
OoO
fb9c4ad1b5 refactor(openclaw): 抽出 Telegram API helper
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-04-30 14:24:45 +08:00