feat: KPI通用化数据层改造
- 新增entities表(企业实体)+ 种子数据(酣客/博海) - kpi_definitions新增entity_id字段(DEFAULT 1,向后兼容) - 后端API list_kpis支持可选的entity_id过滤参数 - 新增 GET /api/cma/entities API返回企业列表 - 43个现有KPI自动获得entity_id=1(酣客) - 前端重新构建并部署
This commit is contained in:
@@ -7,6 +7,18 @@ from app.models.cost_model import StandardCost, ActualCost, AbcActivity, AbcAllo
|
||||
from app.models.knowledge import KnowledgeEvent, KnowledgeSummary
|
||||
|
||||
|
||||
class Entity(Base):
|
||||
"""企业实体"""
|
||||
__tablename__ = "entities"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(100), nullable=False, comment="企业全称")
|
||||
short_name = Column(String(50), comment="企业简称")
|
||||
industry = Column(String(50), comment="行业")
|
||||
status = Column(String(20), default="active", comment="active/inactive/demo")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""用户"""
|
||||
__tablename__ = "users"
|
||||
@@ -37,6 +49,7 @@ class KPIDefinition(Base):
|
||||
"""KPI字典"""
|
||||
__tablename__ = "kpi_definitions"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, default=1, comment="企业ID")
|
||||
map_id = Column(Integer, ForeignKey("strategic_maps.id"), nullable=True, comment="关联战略地图")
|
||||
kpi_code = Column(String(50), unique=True, nullable=False, comment="KPI编码")
|
||||
kpi_name = Column(String(200), nullable=False, comment="KPI名称")
|
||||
|
||||
Reference in New Issue
Block a user