feat: Auto-Verify闭环 — verify API+定时验证+OKR联动+周报

This commit is contained in:
Hermes CI Fix
2026-08-10 23:15:19 +08:00
parent 7fed66d58c
commit e1ea5cd14d
9 changed files with 601 additions and 6 deletions
+7 -2
View File
@@ -273,10 +273,15 @@ def fetch_fallback(kpi: KPIDefinition, parsed: dict, db_session, period: str) ->
KPIValue.source_type.in_(["erp", "manual"]),
).order_by(KPIValue.period.desc()).first()
if existing and existing.actual_value is not None:
logger.info(f" [{kpi_code}] Fallback: 沿用最近期 {existing.period}={existing.actual_value}")
if existing and existing.actual_value is not None and existing.data_status == "verified":
logger.info(f" [{kpi_code}] Fallback: 沿用最近期 verified数据 {existing.period}={existing.actual_value}")
return existing.actual_value
# Bug3修复: 不沿用estimated旧值(可能失真,如4800万收入),避免污染当月数据
if existing and existing.actual_value is not None and existing.data_status != "verified":
logger.info(f" [{kpi_code}] Fallback: 最近期 {existing.period} 为estimated({existing.actual_value}),不沿用,返回None")
return None
# 特殊KPI的默认值
DEFAULTS = {
"SALES_TOTAL": 800000,