material.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from datetime import datetime
  2. from sqlalchemy import Column, DateTime, Integer, Numeric, SmallInteger, String
  3. from app.core.database import Base
  4. class BizMaterial(Base):
  5. __tablename__ = "biz_material"
  6. id = Column(String(64), primary_key=True, comment="主键ID")
  7. material_code = Column(String(64), nullable=False, comment="物料编码")
  8. material_name = Column(String(200), nullable=False, comment="物料名称")
  9. category = Column(String(50), nullable=True, comment="物料分类")
  10. spec_model = Column(String(200), nullable=True, comment="规格型号")
  11. unit = Column(String(32), nullable=True, comment="单位")
  12. stock_qty = Column(Numeric(18, 4), nullable=False, default=0, comment="当前库存量")
  13. warning_qty = Column(Numeric(18, 4), nullable=False, default=0, comment="预警库存量")
  14. status = Column(String(1), nullable=False, default="1", comment="1-启用 0-停用")
  15. image_urls = Column(String(2000), nullable=True, comment="物料图片(逗号分隔)")
  16. tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
  17. order_num = Column(Integer, nullable=True, comment="排序号")
  18. remark = Column(String(512), nullable=True, comment="备注")
  19. create_by = Column(String(64), nullable=True, comment="创建人id")
  20. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  21. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  22. update_by = Column(String(64), nullable=True, comment="更新人id")
  23. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  24. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
  25. class BizMaterialStockLog(Base):
  26. __tablename__ = "biz_material_stock_log"
  27. id = Column(String(64), primary_key=True, comment="主键ID")
  28. material_id = Column(String(64), nullable=False, comment="物料ID")
  29. material_code = Column(String(64), nullable=True, comment="物料编码快照")
  30. material_name = Column(String(200), nullable=True, comment="物料名称快照")
  31. change_type = Column(String(16), nullable=False, comment="变动类型: rk入库 / ck出库")
  32. change_qty = Column(Numeric(18, 4), nullable=False, comment="变动数量(正数)")
  33. stock_before = Column(Numeric(18, 4), nullable=False, comment="变动前库存")
  34. stock_after = Column(Numeric(18, 4), nullable=False, comment="变动后库存")
  35. receiver = Column(String(64), nullable=True, comment="领用人(出库时)")
  36. purpose = Column(String(512), nullable=True, comment="用途/事由")
  37. tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
  38. remark = Column(String(512), nullable=True, comment="备注")
  39. create_by = Column(String(64), nullable=True, comment="创建人id")
  40. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  41. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  42. update_by = Column(String(64), nullable=True, comment="更新人id")
  43. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  44. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")