- 统一供应商异常统计为近3年数据口径 - 以近3年异常记录数作为合作频次代理值并明确提示 - 实现 A/B 缺陷占比与 S/A/B/C 层级判定 - 按供应商层级输出正常合作、加强巡检、驻厂及备选供应商等管理建议 - 完善风险卡片和供应商卡片的频次、层级、建议展示 - 补充供应商画像接口、测试和历史会话卡片兼容处理
75 lines
1.7 KiB
Python
75 lines
1.7 KiB
Python
"""Dashboard aggregation response contracts."""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import Field
|
|
|
|
from app.schemas.common import ApiSchema
|
|
|
|
|
|
class DashboardMetric(ApiSchema):
|
|
value: int | float | None = None
|
|
label: str
|
|
change_percent: float | None = None
|
|
|
|
|
|
class DashboardStage(ApiSchema):
|
|
name: str
|
|
count: int
|
|
share: float
|
|
risk_level: str
|
|
|
|
|
|
class DashboardCategory(ApiSchema):
|
|
name: str
|
|
count: int
|
|
share: float
|
|
risk_level: str
|
|
top_material: str | None = None
|
|
|
|
|
|
class DashboardMatrixRow(ApiSchema):
|
|
name: str
|
|
party_type: str
|
|
categories: dict[str, int]
|
|
cooperation_total: int | None
|
|
anomaly_count: int
|
|
anomaly_rate: float | None
|
|
tier: str
|
|
|
|
|
|
class DashboardDefect(ApiSchema):
|
|
level: str
|
|
label: str
|
|
count: int
|
|
share: float
|
|
|
|
|
|
class DashboardSupplierRank(ApiSchema):
|
|
name: str
|
|
party_type: str
|
|
count: int
|
|
tier: str
|
|
top_problem: str | None = None
|
|
|
|
|
|
class DashboardTrendPoint(ApiSchema):
|
|
month: str
|
|
label: str
|
|
count: int
|
|
|
|
|
|
class DashboardData(ApiSchema):
|
|
year: Literal["all", "2024", "2025", "2026"]
|
|
total_cases: int
|
|
metrics: list[DashboardMetric] = Field(default_factory=list)
|
|
stages: list[DashboardStage] = Field(default_factory=list)
|
|
categories: list[DashboardCategory] = Field(default_factory=list)
|
|
matrix_categories: list[str] = Field(default_factory=list)
|
|
matrix: list[DashboardMatrixRow] = Field(default_factory=list)
|
|
defects: list[DashboardDefect] = Field(default_factory=list)
|
|
supplier_ranking: list[DashboardSupplierRank] = Field(default_factory=list)
|
|
trend: list[DashboardTrendPoint] = Field(default_factory=list)
|
|
insight: str
|
|
warnings: list[str] = Field(default_factory=list)
|