Files
shanxia2.0/backend/app/models/material.py
T
2026-05-21 03:48:06 +08:00

53 lines
3.3 KiB
Python

from datetime import datetime
from sqlalchemy import Column, DateTime, Integer, Numeric, SmallInteger, String
from app.core.database import Base
class BizMaterial(Base):
__tablename__ = "biz_material"
id = Column(String(64), primary_key=True, comment="主键ID")
material_code = Column(String(64), nullable=False, comment="物料编码")
material_name = Column(String(200), nullable=False, comment="物料名称")
category = Column(String(50), nullable=True, comment="物料分类")
spec_model = Column(String(200), nullable=True, comment="规格型号")
unit = Column(String(32), nullable=True, comment="单位")
stock_qty = Column(Numeric(18, 4), nullable=False, default=0, comment="当前库存量")
warning_qty = Column(Numeric(18, 4), nullable=False, default=0, comment="预警库存量")
status = Column(String(1), nullable=False, default="1", comment="1-启用 0-停用")
image_urls = Column(String(2000), nullable=True, comment="物料图片(逗号分隔)")
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
order_num = Column(Integer, nullable=True, comment="排序号")
remark = Column(String(512), nullable=True, comment="备注")
create_by = Column(String(64), nullable=True, comment="创建人id")
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
update_by = Column(String(64), nullable=True, comment="更新人id")
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
class BizMaterialStockLog(Base):
__tablename__ = "biz_material_stock_log"
id = Column(String(64), primary_key=True, comment="主键ID")
material_id = Column(String(64), nullable=False, comment="物料ID")
material_code = Column(String(64), nullable=True, comment="物料编码快照")
material_name = Column(String(200), nullable=True, comment="物料名称快照")
change_type = Column(String(16), nullable=False, comment="变动类型: rk入库 / ck出库")
change_qty = Column(Numeric(18, 4), nullable=False, comment="变动数量(正数)")
stock_before = Column(Numeric(18, 4), nullable=False, comment="变动前库存")
stock_after = Column(Numeric(18, 4), nullable=False, comment="变动后库存")
receiver = Column(String(64), nullable=True, comment="领用人(出库时)")
purpose = Column(String(512), nullable=True, comment="用途/事由")
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
remark = Column(String(512), nullable=True, comment="备注")
create_by = Column(String(64), nullable=True, comment="创建人id")
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
update_by = Column(String(64), nullable=True, comment="更新人id")
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")