model.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # -*- coding: utf-8 -*-
  2. from sqlalchemy import Text, String, DateTime, Integer,ForeignKey
  3. from sqlalchemy.orm import relationship,Mapped, mapped_column
  4. from app.core.base_model import ModelMixin, UserMixin
  5. class BizVarDictModel(ModelMixin, UserMixin):
  6. """
  7. 变量信息表
  8. """
  9. __tablename__: str = 'biz_var_dict'
  10. __table_args__: dict[str, str] = {'comment': '变量信息'}
  11. __loader_options__: list[str] = ["crane","created_by", "updated_by"]
  12. var_code: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='变量code')
  13. var_name: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='变量名')
  14. mec_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='所属机构')
  15. data_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='数据类型')
  16. switch_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='指令灯颜色')
  17. is_alert: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='是否报警')
  18. modbus_address: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='modbus地址')
  19. modbus_data_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='modubs数据类型')
  20. is_reverse: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='是否取反')
  21. unit: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='单位')
  22. order: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='排序')
  23. crane_id: Mapped[int | None] = mapped_column(
  24. Integer,
  25. ForeignKey('biz_crane.id', ondelete="SET NULL", onupdate="CASCADE"),
  26. nullable=True,
  27. index=True,
  28. comment="行车ID"
  29. )
  30. crane: Mapped["BizCraneModel | None"] = relationship(
  31. back_populates="var_dicts",
  32. foreign_keys=[crane_id],
  33. lazy="joined"
  34. )