| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- """地磅(db)模块数据模型 — 对齐 docs/sql/db_tables.sql"""
- from datetime import datetime
- from sqlalchemy import Column, Date, DateTime, Float, Integer, SmallInteger, String, Text
- from app.core.database import Base
- class DbPurchasePlan(Base):
- __tablename__ = "db_purchase_plan"
- id = Column(String(64), primary_key=True, comment="主键ID(UUID)")
- plan_no = Column(String(255), nullable=True, comment="计划号")
- plan_date = Column(Date, nullable=False, comment="计划日期")
- start_date = Column(Date, nullable=True, comment="开始时间")
- end_date = Column(Date, nullable=True, comment="结束时间")
- business_type = Column(String(255), nullable=False, comment="业务类型")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- product = Column(String(255), nullable=False, comment="产品名称")
- specification = Column(String(255), nullable=True, comment="规格")
- planned_quantity = Column(Float, nullable=False, comment="计划数量(t)")
- vehicle_no = Column(String(255), nullable=True, default="", comment="车牌号")
- customer_name = Column(String(255), nullable=True, comment="往来单位")
- execution_status = Column(String(50), nullable=True, comment="执行状态")
- executed_at = Column(DateTime, nullable=True, comment="执行时间")
- last_weighing_slip_id = Column(String(64), nullable=True, comment="最后关联地磅单ID")
- executed_quantity = Column(Float, nullable=True, default=0, comment="已执行量(kg)")
- auto_generate_enabled = Column(SmallInteger, nullable=False, default=0, comment="是否自动按月生成")
- auto_generate_end_month = Column(String(7), nullable=True, comment="自动生成结束月份")
- auto_generate_last_month = Column(String(7), nullable=True, comment="最后一次自动生成月份")
- tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
- order_num = Column(Integer, nullable=True, comment="排序号")
- remark = Column(String(512), nullable=True, comment="备注")
- create_by = Column(String(64), nullable=True, comment="创建人")
- create_dept_id = Column(String(64), nullable=False, default="", comment="创建部门")
- create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
- update_by = Column(String(64), nullable=True, comment="更新人")
- update_time = Column(
- DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间"
- )
- del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
- class DbInboundOutbound(Base):
- __tablename__ = "db_inbound_outbound"
- id = Column(String(64), primary_key=True, comment="主键ID(租户内纯数字字符串)")
- date = Column(Date, nullable=False, comment="日期")
- partner_company = Column(String(255), nullable=False, comment="往来单位")
- business_type = Column(String(255), nullable=False, comment="业务类型")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- product = Column(String(255), nullable=False, comment="产品")
- specification = Column(String(255), nullable=True, comment="规格")
- quantity = Column(Float, nullable=False, comment="本次量(t)")
- plan_no = Column(String(255), nullable=True, comment="计划号")
- batch_no = Column(String(255), nullable=True, comment="批次号")
- vehicle_no = Column(String(255), nullable=False, comment="车牌号")
- status = Column(String(50), nullable=True, comment="状态")
- purchase_plan_id = Column(String(64), nullable=True, comment="关联计划ID")
- tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
- order_num = Column(Integer, nullable=True, comment="排序号")
- remark = Column(String(512), nullable=True, comment="备注")
- site_access_token = Column(String(64), nullable=True, comment="现场人员免登录访问令牌")
- site_feedback_remark = Column(String(500), nullable=True, comment="现场回执备注")
- site_feedback_images = Column(Text, nullable=True, comment="现场回执附件URLs(JSON数组)")
- site_feedback_time = Column(DateTime, nullable=True, comment="现场回执保存时间")
- create_by = Column(String(64), nullable=True, comment="创建人")
- create_dept_id = Column(String(64), nullable=False, default="", comment="创建部门")
- create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
- update_by = Column(String(64), nullable=True, comment="更新人")
- update_time = Column(
- DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间"
- )
- del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
- class DbWeighingSlip(Base):
- __tablename__ = "db_weighing_slip"
- id = Column(String(64), primary_key=True, comment="主键ID(UUID)")
- vehicle_no = Column(String(255), nullable=False, comment="车号")
- plan_no = Column(String(255), nullable=True, comment="计划单号")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- cargo_name = Column(String(255), nullable=False, comment="货物名称")
- specification = Column(String(255), nullable=True, comment="规格")
- business_type = Column(String(255), nullable=False, comment="业务类型")
- batch_no = Column(String(255), nullable=True, comment="批次号")
- supplier = Column(String(255), nullable=False, comment="供货单位")
- consignee = Column(String(255), nullable=False, comment="收货单位")
- gross_weight = Column(Float, nullable=False, comment="毛重(kg)")
- gross_weight_time = Column(DateTime, nullable=False, comment="毛重时间")
- tare_weight = Column(Float, nullable=False, comment="皮重(kg)")
- tare_weight_time = Column(DateTime, nullable=True, comment="皮重时间")
- deduction = Column(Float, nullable=True, default=0, comment="扣杂(kg)")
- net_weight = Column(Float, nullable=False, comment="净重(kg)")
- planned_quantity = Column(Float, nullable=True, comment="计划数量(kg)")
- executed_quantity = Column(Float, nullable=True, comment="执行数量(kg)")
- purchase_plan_id = Column(String(64), nullable=True, comment="关联计划ID")
- inbound_outbound_id = Column(String(64), nullable=True, comment="关联出入库单ID")
- weighing_point = Column(String(255), nullable=True, default="山峡地磅", comment="称重点")
- current_quantity = Column(Float, nullable=True, comment="本次量(kg)")
- is_voided = Column(SmallInteger, nullable=False, default=0, comment="是否作废")
- void_reason = Column(String(500), nullable=True, comment="作废原因")
- void_time = Column(DateTime, nullable=True, comment="作废时间")
- void_by = Column(String(64), nullable=True, comment="作废人ID")
- tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
- order_num = Column(Integer, nullable=True, comment="排序号")
- remark = Column(String(512), nullable=True, comment="备注")
- create_by = Column(String(64), nullable=True, comment="创建人")
- create_dept_id = Column(String(64), nullable=False, default="", comment="创建部门")
- create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
- update_by = Column(String(64), nullable=True, comment="更新人")
- update_time = Column(
- DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间"
- )
- del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
- class DbSequence(Base):
- """租户内业务序号(并发安全自增)。"""
- __tablename__ = "db_sequence"
- id = Column(String(64), primary_key=True, comment="主键ID(UUID)")
- tenant_no = Column(String(64), nullable=False, comment="租户编号")
- seq_name = Column(String(64), nullable=False, comment="序号名称")
- next_val = Column(Integer, nullable=False, comment="下一个待分配序号")
- update_time = Column(
- DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间"
- )
|