# -*- coding: utf-8 -*- from sqlalchemy import Text, String, DateTime, Integer,ForeignKey from sqlalchemy.orm import relationship,Mapped, mapped_column from app.core.base_model import ModelMixin, UserMixin class BizVarDictModel(ModelMixin, UserMixin): """ 变量信息表 """ __tablename__: str = 'biz_var_dict' __table_args__: dict[str, str] = {'comment': '变量信息'} __loader_options__: list[str] = ["crane","created_by", "updated_by"] var_code: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='变量code') var_name: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='变量名') mec_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='所属机构') data_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='数据类型') switch_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='指令灯颜色') is_alert: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='是否报警') modbus_address: Mapped[str | None] = mapped_column(String(50), nullable=True, comment='modbus地址') modbus_data_type: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='modubs数据类型') is_reverse: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='是否取反') unit: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='单位') order: Mapped[int | None] = mapped_column(Integer, nullable=True, comment='排序') crane_id: Mapped[int | None] = mapped_column( Integer, ForeignKey('biz_crane.id', ondelete="SET NULL", onupdate="CASCADE"), nullable=True, index=True, comment="行车ID" ) crane: Mapped["BizCraneModel | None"] = relationship( back_populates="var_dicts", foreign_keys=[crane_id], lazy="joined" )