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

64 lines
2.7 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 datetime import datetime
from sqlalchemy import Float, ForeignKey, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import MappedBase, ModelMixin, UserMixin
class SeedlingModel(ModelMixin, UserMixin, MappedBase):
"""育苗管理 主数据表。"""
__tablename__ = "bre_seedling"
combination_id: Mapped[int] = mapped_column(
Integer, ForeignKey("bre_cross_combination.id", ondelete="CASCADE"),
index=True, nullable=False, comment="杂交组合"
)
treatment_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_seed_treatment.id", ondelete="SET NULL"),
index=True, nullable=True, comment="来源种子处理(一次处理可生成多个育苗批次)"
)
seed_lot_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_seed_lot.id", ondelete="SET NULL"),
index=True, nullable=True, comment="来源种子批(选择强度链,规格 §3.13)"
)
batch_no: Mapped[str | None] = mapped_column(
String(50), index=True, nullable=True, comment="育苗批次号(自动生成,格式 YP-{组合ID}-{播种日期}-{序号}"
)
sowing_date: Mapped[str | None] = mapped_column(String(20), nullable=True, comment="播种日期", default=None)
tray_no: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="穴盘号", default=None)
nursery: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="苗圃", default=None)
seedling_count: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="出苗数", default=None)
emergence_date: Mapped[str | None] = mapped_column(String(20), nullable=True, comment="出苗日期", default=None)
strong_seedling_date: Mapped[str | None] = mapped_column(String(20), nullable=True, comment="壮苗日期", default=None)
strong_seedling_count: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="壮苗数", default=None)
stage: Mapped[str | None] = mapped_column(
String(1), nullable=True, default="1", comment="当前阶段:1播种/2出苗/3壮苗"
)
bre_personnel_id: Mapped[int] = mapped_column(
Integer, ForeignKey("bre_personnel.id", ondelete="CASCADE"),
index=True, nullable=True, comment="育苗人"
)
remark: Mapped[str | None] = mapped_column(Text, nullable=True, comment="备注", default=None)
# 无 status 列:覆盖基类默认 ix_<表>_status_deleted 索引,
# 仅保留 (created_time, is_deleted) 复合索引用于数据权限过滤。
__table_args__ = (
Index("ix_bre_seedling_created_deleted", "created_time", "is_deleted"),
)