Files
dpb/backend/app/api/v1/module_bre/environment_condition/model.py
T
34047007@qq.com b95053c52c init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
2026-08-06 00:17:49 +08:00

49 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""环境因子(气象) 数据模型"""
from decimal import Decimal
from sqlalchemy import ForeignKey, Index, Integer, Numeric, String
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import MappedBase, ModelMixin, UserMixin
class EnvironmentConditionModel(ModelMixin, UserMixin, MappedBase):
"""环境因子(规格 §3.9G×E 协变量,site×year 唯一)。"""
__tablename__ = "bre_environment_condition"
site_id: Mapped[int] = mapped_column(
Integer, ForeignKey("bre_site.id"), index=True, nullable=False, comment="试验基地"
)
year: Mapped[int] = mapped_column(Integer, nullable=False, comment="年份")
chilling_hours: Mapped[Decimal | None] = mapped_column(
Numeric(8, 1), nullable=True, comment="需冷量(小时)", default=None
)
growing_degree_days: Mapped[Decimal | None] = mapped_column(
Numeric(8, 1), nullable=True, comment="生长度日 GDD", default=None
)
rainfall_mm: Mapped[Decimal | None] = mapped_column(
Numeric(8, 1), nullable=True, comment="降水量(mm)", default=None
)
temp_avg: Mapped[Decimal | None] = mapped_column(
Numeric(6, 1), nullable=True, comment="年均温度(℃)", default=None
)
soil_moisture: Mapped[Decimal | None] = mapped_column(
Numeric(6, 1), nullable=True, comment="土壤湿度", default=None
)
source: Mapped[str | None] = mapped_column(String(32), nullable=True, comment="数据来源", default=None)
remark: Mapped[str | None] = mapped_column(String(512), nullable=True, comment="备注", default=None)
__table_args__ = (
Index("ix_bre_environment_condition_created_deleted", "created_time", "is_deleted"),
Index("uq_env_site_year", "site_id", "year", unique=True),
)