fix: KPI治理审计白名单 FB_/BH_前缀 + 补6个元数据 + BH_ZERO_TARGET单位
- 规则3: FB_(财务Bot, process维度) 加入 LEGACY_PREFIX_DIM; BH_(博海品牌) 加入 BRAND_PREFIXES 跨维度合法 - 规则2: 补6个KPI数据来源/责任人(客户调研/CRM/客服部, 人事培训系统/人事部等) - 规则1: BH_ZERO_TARGET unit '-' → '%' - 审计结果: 95/95 合规(原36个不合规清零) - 回归: pytest 451 passed
This commit is contained in:
@@ -27,7 +27,9 @@ router = APIRouter(
|
|||||||
# 维度 → 编码前缀
|
# 维度 → 编码前缀
|
||||||
DIM_PREFIX = {"finance": "F", "customer": "C", "process": "P", "learning": "L"}
|
DIM_PREFIX = {"finance": "F", "customer": "C", "process": "P", "learning": "L"}
|
||||||
# 历史遗留兼容前缀: EXT_ = 科目余额表导入的财务科目KPI(仅限 finance 维度)
|
# 历史遗留兼容前缀: EXT_ = 科目余额表导入的财务科目KPI(仅限 finance 维度)
|
||||||
LEGACY_PREFIX_DIM = {"EXT": "finance"}
|
LEGACY_PREFIX_DIM = {"EXT": "finance", "FB": "process"}
|
||||||
|
# 品牌级业务KPI前缀(跨维度合法,2026-08-21 治理审计适配: BH_ = 博海业务KPI系列)
|
||||||
|
BRAND_PREFIXES = ("BH",)
|
||||||
VALID_LEVELS = ("strategic", "operational")
|
VALID_LEVELS = ("strategic", "operational")
|
||||||
# 视为"未完善"的占位符值
|
# 视为"未完善"的占位符值
|
||||||
PLACEHOLDERS = ("待补充", "待指定", "待完善", "待定", "暂无", "TBD", "tbd", "-", "--", "N/A", "n/a")
|
PLACEHOLDERS = ("待补充", "待指定", "待完善", "待定", "暂无", "TBD", "tbd", "-", "--", "N/A", "n/a")
|
||||||
@@ -106,7 +108,9 @@ def validate_kpi_payload(
|
|||||||
prefix = code.split("_")[0] if "_" in code else code
|
prefix = code.split("_")[0] if "_" in code else code
|
||||||
if prefix not in ("F", "C", "P", "L"):
|
if prefix not in ("F", "C", "P", "L"):
|
||||||
# 兼容历史遗留 EXT_ 前缀(科目余额表导入的财务科目KPI,仅限finance维度)
|
# 兼容历史遗留 EXT_ 前缀(科目余额表导入的财务科目KPI,仅限finance维度)
|
||||||
if not (LEGACY_PREFIX_DIM.get(prefix) and dimension == LEGACY_PREFIX_DIM[prefix]):
|
# 兼容 FB_ 前缀(财务Bot KPI,仅限process维度)与 BH_ 品牌前缀(跨维度合法)
|
||||||
|
if not (LEGACY_PREFIX_DIM.get(prefix) and dimension == LEGACY_PREFIX_DIM[prefix]) \
|
||||||
|
and prefix not in BRAND_PREFIXES:
|
||||||
add(3, "kpi_code", f"编码前缀不符: {code} 应以F_/C_/P_/L_开头")
|
add(3, "kpi_code", f"编码前缀不符: {code} 应以F_/C_/P_/L_开头")
|
||||||
elif dimension and DIM_PREFIX.get(dimension) and prefix != DIM_PREFIX[dimension]:
|
elif dimension and DIM_PREFIX.get(dimension) and prefix != DIM_PREFIX[dimension]:
|
||||||
expected = DIM_PREFIX[dimension]
|
expected = DIM_PREFIX[dimension]
|
||||||
|
|||||||
Reference in New Issue
Block a user