Files
shanxia2.0/backend/app/models/pl_dispatch_calendar.py
T
wuzilong fcbf8a9b65 feat: 为现场日历增加单据类型并同步派车记录,减少重复录入。
按起止地关键词生成现场出入库计划,同步来源修改和删除,保留历史记录不补录。调整卡片及复制文本的单据类型格式,并记录测试库和生产库迁移结果。
2026-10-30 14:04:24 +08:00

43 lines
2.6 KiB
Python

"""独立手工派车记录,与运输计划无写入联动。"""
from datetime import datetime
from sqlalchemy import Column, Date, DateTime, Index, Integer, SmallInteger, String, UniqueConstraint
from app.core.database import Base
class PlDispatchCalendar(Base):
__tablename__ = "pl_dispatch_calendar"
__table_args__ = (
Index("idx_dispatch_calendar_month", "tenant_no", "del_flag", "dispatch_date"),
Index("idx_dispatch_calendar_vehicle", "tenant_no", "vehicle_id", "dispatch_date"),
UniqueConstraint("tenant_no", "source_record_id", name="uk_dispatch_calendar_source"),
)
id = Column(String(64), primary_key=True, comment="主键UUID")
dispatch_date = Column(Date, nullable=False, comment="派车日期")
vehicle_id = Column(String(64), nullable=False, comment="车辆ID")
license_plate = Column(String(20), nullable=False, comment="车牌快照")
product_id = Column(String(64), nullable=False, comment="产品ID")
product_name = Column(String(200), nullable=False, comment="产品名称快照")
origin = Column(String(255), nullable=False, comment="始发地")
destination = Column(String(255), nullable=False, comment="目的地")
quantity = Column(String(16), nullable=True, comment="数量文本(吨),最多两位小数,不参与汇总")
calendar_kind = Column(
String(16), nullable=False, default="acid", server_default="acid",
comment="日历类型:acid酸派车 alkali碱派车 other其他 site现场",
)
document_type = Column(String(50), nullable=True, comment="单据类型(现场日历,支持自定义)")
site_sync_enabled = Column(SmallInteger, nullable=False, default=0, server_default="0",
comment="是否启用现场同步:仅新建来源置1,历史为0")
source_record_id = Column(String(64), nullable=True, comment="自动现场记录的来源派车ID,手工记录为空")
tenant_no = Column(String(64), nullable=False, comment="租户编号")
order_num = Column(Integer, nullable=True, comment="排序号")
remark = Column(String(500), 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="删除标记")