feat: 驱动因子计划 — 模式切换+行业包+敏感性分析

This commit is contained in:
Hermes CI Fix
2026-07-22 12:58:04 +08:00
parent 66554fb7fa
commit 2923e54366
8 changed files with 932 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
"""驱动因子预算模型 — 业务驱动因子 vs 科目模式"""
from sqlalchemy import Column, Integer, String, Float, DateTime, Text, JSON, func
from app.database import Base
class DriverFactorTemplate(Base):
"""驱动因子模板 — 通用/行业版本"""
__tablename__ = "driver_factor_templates"
id = Column(Integer, primary_key=True, index=True)
name = Column(String(200), nullable=False, comment="模板名称")
industry = Column(String(50), default="general", comment="行业标签: general/trade/it")
category = Column(String(50), default="revenue", comment="类别: revenue/expense")
formula_desc = Column(String(500), nullable=True, comment="公式说明")
formula_text = Column(String(500), nullable=False, comment="公式文本, 如: 客户数×客单价")
factors = Column(JSON, nullable=False, comment="驱动因子列表")
is_active = Column(Integer, default=1, comment="是否启用")
created_at = Column(DateTime, server_default=func.now())
class DriverFactorBudget(Base):
"""驱动因子预算计算结果"""
__tablename__ = "driver_factor_budgets"
id = Column(Integer, primary_key=True, index=True)
name = Column(String(200), nullable=False, comment="预算项名称")
industry = Column(String(50), default="general", comment="行业标签")
template_id = Column(Integer, nullable=True, comment="关联模板ID")
factors = Column(JSON, nullable=False, comment="驱动因子键值对")
calculated_value = Column(Float, nullable=False, comment="计算结果")
formula_text = Column(String(500), nullable=True, comment="公式文本")
period = Column(String(20), nullable=True, comment="期间")
sensitivity = Column(JSON, nullable=True, comment="敏感性分析结果")
created_by = Column(String(100), nullable=True)
created_at = Column(DateTime, server_default=func.now())