feat: initial commit and ignore qwen files
This commit is contained in:
78
backend/app/models/inventory.py
Normal file
78
backend/app/models/inventory.py
Normal file
@ -0,0 +1,78 @@
|
||||
"""库存系统 ORM 模型(只读,从现有数据库逆向生成)"""
|
||||
from sqlalchemy import Column, Integer, String, Numeric, Boolean, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class SysUser(Base):
|
||||
"""系统用户表(只读,从旧库映射)"""
|
||||
__tablename__ = "sys_user"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(100), unique=True, nullable=False, index=True)
|
||||
password = Column(String(255), nullable=False)
|
||||
real_name = Column(String(100))
|
||||
department = Column(String(100))
|
||||
is_active = Column(Integer, default=1)
|
||||
|
||||
|
||||
class MaterialBase(Base):
|
||||
"""物料基础表(只读)"""
|
||||
__tablename__ = "material_base"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(255), nullable=False)
|
||||
spec_model = Column(String(255))
|
||||
unit = Column(String(50))
|
||||
|
||||
|
||||
class BomTable(Base):
|
||||
"""BOM物料清单表(只读)"""
|
||||
__tablename__ = "bom_table"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
parent_id = Column(Integer, ForeignKey("material_base.id"), nullable=False)
|
||||
child_id = Column(Integer, ForeignKey("material_base.id"), nullable=False)
|
||||
dosage = Column(Numeric(10, 4), nullable=False)
|
||||
bom_no = Column(String(100), nullable=True)
|
||||
version = Column(String(50), nullable=True)
|
||||
is_enabled = Column(Boolean, default=True)
|
||||
|
||||
parent = relationship("MaterialBase", foreign_keys=[parent_id])
|
||||
child = relationship("MaterialBase", foreign_keys=[child_id])
|
||||
|
||||
|
||||
class StockProduct(Base):
|
||||
"""库存产品表(只读)"""
|
||||
__tablename__ = "stock_product"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
base_id = Column(Integer, ForeignKey("material_base.id"), nullable=False)
|
||||
stock_quantity = Column(Numeric(10, 2), default=0)
|
||||
work_order_id = Column(Integer, nullable=True)
|
||||
|
||||
material = relationship("MaterialBase", foreign_keys=[base_id])
|
||||
|
||||
|
||||
class TransOutbound(Base):
|
||||
"""出库记录表(只读)"""
|
||||
__tablename__ = "trans_outbound"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
outbound_no = Column(String(100), unique=True, nullable=False)
|
||||
stock_id = Column(Integer, ForeignKey("stock_product.id"), nullable=False)
|
||||
quantity = Column(Numeric(10, 2), nullable=False)
|
||||
consumer_name = Column(String(255))
|
||||
|
||||
stock = relationship("StockProduct", foreign_keys=[stock_id])
|
||||
|
||||
|
||||
class StockBuy(Base):
|
||||
"""原材料库存表(只读)"""
|
||||
__tablename__ = "stock_buy"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
base_id = Column(Integer, ForeignKey("material_base.id"), nullable=False)
|
||||
stock_quantity = Column(Numeric(10, 2), default=0)
|
||||
|
||||
material = relationship("MaterialBase", foreign_keys=[base_id])
|
||||
Reference in New Issue
Block a user