Initial commit: 智能项目定价模型
This commit is contained in:
55
后端服务/app/models/sensitivity_analysis.py
Normal file
55
后端服务/app/models/sensitivity_analysis.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""敏感性分析模型
|
||||
|
||||
记录价格变动对利润的敏感性分析结果
|
||||
"""
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import BigInteger, ForeignKey, DECIMAL
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import BaseModel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models.profit_simulation import ProfitSimulation
|
||||
|
||||
|
||||
class SensitivityAnalysis(BaseModel):
|
||||
"""敏感性分析表"""
|
||||
|
||||
__tablename__ = "sensitivity_analyses"
|
||||
|
||||
simulation_id: Mapped[int] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("profit_simulations.id"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="模拟ID"
|
||||
)
|
||||
price_change_rate: Mapped[Decimal] = mapped_column(
|
||||
DECIMAL(5, 2),
|
||||
nullable=False,
|
||||
comment="价格变动率(%):如 -20, -10, 0, 10, 20"
|
||||
)
|
||||
adjusted_price: Mapped[Decimal] = mapped_column(
|
||||
DECIMAL(12, 2),
|
||||
nullable=False,
|
||||
comment="调整后价格"
|
||||
)
|
||||
adjusted_profit: Mapped[Decimal] = mapped_column(
|
||||
DECIMAL(14, 2),
|
||||
nullable=False,
|
||||
comment="调整后利润"
|
||||
)
|
||||
profit_change_rate: Mapped[Decimal] = mapped_column(
|
||||
DECIMAL(5, 2),
|
||||
nullable=False,
|
||||
comment="利润变动率(%)"
|
||||
)
|
||||
|
||||
# 关系
|
||||
simulation: Mapped["ProfitSimulation"] = relationship(
|
||||
"ProfitSimulation",
|
||||
back_populates="sensitivity_analyses"
|
||||
)
|
||||
Reference in New Issue
Block a user