fix: 战略地图P0修复 — KPI code统一+放开同层连线+数据迁移
This commit is contained in:
@@ -214,6 +214,61 @@ class MapObjective(Base):
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
class KPICausality(Base):
|
||||
"""KPI因果链 — 记录KPI间的因果关系"""
|
||||
__tablename__ = "kpi_causality"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
source_kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False, comment="源KPI(因)")
|
||||
target_kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False, comment="目标KPI(果)")
|
||||
strength = Column(Float, default=0.5, comment="影响强度 0~1")
|
||||
lag_months = Column(Integer, default=1, comment="滞后期(月)")
|
||||
formula = Column(String(500), nullable=True, comment="影响公式描述")
|
||||
direction = Column(String(10), default="positive", comment="positive/negative 正向/负向影响")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
class KpiDataQualityLog(Base):
|
||||
"""数据质量监控日志"""
|
||||
__tablename__ = "kpi_data_quality_log"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False, comment="关联KPI")
|
||||
check_type = Column(String(30), nullable=False, comment="abnormal_change/flat_data/missing_data/value_outlier")
|
||||
severity = Column(String(20), default="warning", comment="info/warning/critical")
|
||||
detail = Column(JSON, nullable=True, comment="检测详情")
|
||||
suggestion = Column(String(500), nullable=True, comment="建议操作")
|
||||
status = Column(String(20), default="open", comment="open/resolved/ignored")
|
||||
resolved_at = Column(DateTime, nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
|
||||
class BiReportTemplate(Base):
|
||||
"""BI报表模板"""
|
||||
__tablename__ = "bi_report_templates"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(200), nullable=False, comment="模板名称")
|
||||
report_type = Column(String(50), nullable=False, comment="overview/trend/comparison/topn/causality")
|
||||
config = Column(JSON, nullable=False, comment="报表配置")
|
||||
is_system = Column(Integer, default=0, comment="系统预置模板")
|
||||
created_by = Column(Integer, nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
class BiReport(Base):
|
||||
"""用户保存的BI报表"""
|
||||
__tablename__ = "bi_reports"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
template_id = Column(Integer, ForeignKey("bi_report_templates.id"), nullable=True)
|
||||
name = Column(String(200), nullable=False, comment="报表名称")
|
||||
config = Column(JSON, nullable=False, comment="报表配置(行/列/值)")
|
||||
chart_type = Column(String(50), default="auto", comment="图表类型")
|
||||
is_shared = Column(Integer, default=0, comment="是否分享")
|
||||
created_by = Column(Integer, nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
# 兼容性: P2开发新增的模板API需要的模型
|
||||
# KPIDefinition 已存在,KPITemplate映射到同一定义
|
||||
KPITemplate = KPIDefinition
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user