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

53 lines
2.4 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 date
from sqlalchemy import Date, Float, ForeignKey, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import MappedBase, ModelMixin, UserMixin
class FieldOperationModel(ModelMixin, UserMixin, MappedBase):
"""农事操作(§3.3;施肥/喷药/修剪/灌溉/疏果/套袋/采收)。
tree_id/plot_id 可空二选一:既可针对单株记录,也可针对整块小区记录。
"""
__tablename__ = "bre_field_operation"
tree_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_tree.id", ondelete="CASCADE"), index=True, nullable=True, comment="单株(可空)", default=None
)
plot_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_plot.id", ondelete="CASCADE"), index=True, nullable=True, comment="小区(可空)", default=None
)
op_type: Mapped[str] = mapped_column(
String(32), nullable=False, comment="操作类型(field_operation字典: fertilize/spray/prune/irrigate/thinning/bagging/harvest)"
)
op_date: Mapped[date | None] = mapped_column(Date, nullable=True, comment="操作日期", default=None)
op_detail: Mapped[str | None] = mapped_column(Text, nullable=True, comment="操作详情/用量", default=None)
yield_kg: Mapped[float | None] = mapped_column(Float, nullable=True, comment="单株产量(kgop_type=harvest)", default=None)
fruit_count: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="果实个数(op_type=harvest)", default=None)
avg_fruit_weight: Mapped[float | None] = mapped_column(Float, nullable=True, comment="平均单果重(gop_type=harvest)", default=None)
marketable_rate: Mapped[float | None] = mapped_column(Float, nullable=True, comment="好果率(%op_type=harvest)", default=None)
operator_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("bre_personnel.id", ondelete="CASCADE"), index=True, nullable=True, comment="操作人(育种人员)", default=None
)
remark: Mapped[str | None] = mapped_column(String(512), nullable=True, comment="备注", default=None)
status: Mapped[int] = mapped_column(Integer, nullable=False, default=1, comment="状态(1正常/0停用)")
__table_args__ = (
Index("ix_bre_field_operation_created_deleted", "created_time", "is_deleted"),
)