| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493 |
- """运输计划管理模块数据模型"""
- from datetime import datetime
- from decimal import Decimal
- from sqlalchemy import (
- BigInteger,
- Column,
- DECIMAL,
- Date,
- DateTime,
- Integer,
- SmallInteger,
- String,
- Text,
- CHAR,
- ForeignKey,
- )
- from sqlalchemy.orm import relationship
- from app.core.database import Base
- # =============================================================================
- # 1. 基础数据:承运商、车辆、司机
- # =============================================================================
- class PlCarrier(Base):
- """承运商表 pl_carrier"""
- __tablename__ = "pl_carrier"
- id = Column(String(64), primary_key=True, comment="主键ID")
- carrier_name = Column(String(200), nullable=False, comment="承运商名称")
- contact_name = Column(String(100), nullable=True, comment="联系人")
- contact_phone = Column(String(32), nullable=True, comment="联系电话")
- status = Column(CHAR(1), nullable=False, default="1", comment="合作状态 1-合作中 0-已终止")
- business_license_urls = Column(String(2000), nullable=True, comment="营业执照附件URL,逗号分隔")
- road_transport_license_urls = Column(String(2000), nullable=True, comment="道路经营许可证附件URL,逗号分隔")
- transport_agreement_urls = Column(String(2000), nullable=True, comment="运输协议附件URL,逗号分隔")
- transport_agreement_expire_date = Column(Date, nullable=True, comment="运输协议有效期")
- audit_status = Column(String(20), nullable=False, default="pending", comment="审核状态 pending-待审核 approved-已通过 rejected-已驳回")
- audit_by = Column(String(64), nullable=True, comment="审核人id")
- audit_time = Column(DateTime, nullable=True, comment="审核时间")
- audit_remark = Column(String(512), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicle(Base):
- """车辆表 pl_vehicle"""
- __tablename__ = "pl_vehicle"
- id = Column(String(64), primary_key=True, comment="主键ID")
- vehicle_type = Column(String(20), nullable=False, comment="车辆类型 self-自有 carrier-承运商")
- carrier_id = Column(String(64), nullable=True, comment="承运商ID(类型为承运商时必填)")
- carrier_name = Column(String(200), nullable=True, comment="承运商名称(冗余)")
- license_plate = Column(String(20), nullable=False, unique=True, comment="车牌号")
- trailer_no = Column(String(20), nullable=True, comment="挂车号")
- default_driver_id = Column(String(64), nullable=True, comment="默认司机ID")
- default_driver_name = Column(String(100), nullable=True, comment="默认司机姓名(冗余)")
- load_capacity = Column(DECIMAL(10, 2), nullable=True, comment="载重(吨)")
- vehicle_status = Column(String(20), nullable=False, default="available", comment="车辆状态 available-可用 maintaining-维修中 scrapped-报废")
- photo_urls = Column(String(2000), nullable=True, comment="车辆照片URL,逗号分隔")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPersonnel(Base):
- """人员表 pl_personnel"""
- __tablename__ = "pl_personnel"
- id = Column(String(64), primary_key=True, comment="主键ID")
- personnel_name = Column(String(100), nullable=False, comment="姓名")
- phone_no = Column(String(32), nullable=True, comment="手机号(非必填)")
- age = Column(Integer, nullable=True, comment="年龄")
- id_card_no = Column(String(32), nullable=True, comment="身份证号")
- personnel_type = Column(
- String(20),
- nullable=False,
- default="both",
- comment="人员类型 driver-驾驶员 escort-押运员 both-驾驶员兼押运员",
- )
- personnel_affiliation = Column(
- String(20),
- nullable=False,
- default="self",
- comment="人员归属 self-山峡 carrier-非山峡",
- )
- status = Column(CHAR(1), nullable=False, default="1", comment="状态 1-在职 0-停用")
- photo_urls = Column(String(2000), nullable=True, comment="人员照片URL,逗号分隔")
- sys_user_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="备注")
- 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="删除标记:0-正常 1-已删除")
- class PlTransportAddress(Base):
- """运输通用地址库 pl_transport_address"""
- __tablename__ = "pl_transport_address"
- id = Column(String(64), primary_key=True, comment="主键ID")
- address_name = Column(String(200), nullable=False, comment="地址名称")
- full_address = Column(String(500), nullable=False, comment="详细地址")
- lng = Column(DECIMAL(10, 6), nullable=False, comment="经度")
- lat = Column(DECIMAL(10, 6), nullable=False, comment="纬度")
- contact_name = Column(String(100), nullable=True, comment="联系人")
- contact_phone = Column(String(32), nullable=True, comment="联系电话")
- notes = Column(String(500), nullable=True, comment="注意事项")
- status = Column(CHAR(1), nullable=False, default="1", comment="状态 1-启用 0-停用")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlCustomerStopPref(Base):
- """客户装/送货物流默认记忆 pl_customer_stop_pref"""
- __tablename__ = "pl_customer_stop_pref"
- id = Column(String(64), primary_key=True, comment="主键ID")
- customer_id = Column(String(64), nullable=False, comment="客户ID")
- customer_name = Column(String(200), nullable=True, comment="客户名称")
- stop_type = Column(String(20), nullable=False, comment="load-装货 delivery-送货")
- address = Column(String(500), nullable=True, comment="地址")
- lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
- lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
- contact = Column(String(200), nullable=True, comment="联系方式")
- notes = Column(String(500), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlCert(Base):
- """证书表 pl_cert"""
- __tablename__ = "pl_cert"
- id = Column(String(64), primary_key=True, comment="主键ID")
- owner_type = Column(String(20), nullable=False, comment="归属类型 vehicle-车辆 personnel-人员")
- owner_id = Column(String(64), nullable=False, comment="归属主体ID")
- vehicle_part = Column(String(20), nullable=True, comment="车辆部位 head-主车 trailer-挂车,人员证书为空")
- cert_name = Column(String(100), nullable=False, comment="证书名称")
- cert_no = Column(String(64), nullable=True, comment="证号")
- expire_date = Column(Date, nullable=True, comment="有效期")
- remind_days = Column(Integer, nullable=False, default=30, comment="提前提醒天数")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL(逗号分隔)")
- status = Column(String(20), nullable=False, default="valid", comment="状态 valid-有效 expired-已过期 revoked-已作废")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlDriver(Base):
- """司机表 pl_driver(兼容旧表,迁移后逐步废弃)"""
- __tablename__ = "pl_driver"
- id = Column(String(64), primary_key=True, comment="主键ID")
- driver_name = Column(String(100), nullable=False, comment="姓名")
- phone_no = Column(String(32), nullable=False, comment="手机号")
- id_card_no = Column(String(32), nullable=True, comment="身份证号")
- driving_license_no = Column(String(32), nullable=True, comment="驾驶证号")
- driving_license_expire = Column(Date, nullable=True, comment="驾驶证有效期")
- vehicle_license_no = Column(String(32), nullable=True, comment="行驶证号")
- vehicle_license_expire = Column(Date, nullable=True, comment="行驶证有效期")
- hazmat_cert_no = Column(String(32), nullable=True, comment="危化品证号")
- hazmat_cert_expire = Column(Date, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehiclePersonnel(Base):
- """车辆-人员关联表 pl_vehicle_personnel"""
- __tablename__ = "pl_vehicle_personnel"
- id = Column(String(64), primary_key=True, comment="主键ID")
- vehicle_id = Column(String(64), nullable=False, comment="车辆ID")
- personnel_id = Column(String(64), nullable=False, comment="人员ID")
- role = Column(String(20), nullable=False, default="driver", comment="角色 driver-司机 escort-押运员")
- is_default = Column(SmallInteger, nullable=False, default=0, comment="是否默认司机 0-否 1-是")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleDriver(Base):
- """车辆-司机关联表 pl_vehicle_driver(兼容旧表)"""
- __tablename__ = "pl_vehicle_driver"
- id = Column(String(64), primary_key=True, comment="主键ID")
- vehicle_id = Column(String(64), nullable=False, comment="车辆ID")
- driver_id = Column(String(64), nullable=False, comment="司机ID")
- is_default = Column(SmallInteger, nullable=False, default=0, comment="是否默认 0-否 1-是")
- 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="创建人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="删除标记:0-正常 1-已删除")
- # =============================================================================
- # 2. 计划管理:计划主表、产品明细、变更记录
- # =============================================================================
- class PlPlan(Base):
- """计划主表 pl_plan"""
- __tablename__ = "pl_plan"
- id = Column(String(64), primary_key=True, comment="主键ID")
- # 编号信息
- plan_no = Column(String(32), nullable=False, unique=True, comment="计划订单编号 POYYYYMMDD###")
- create_date = Column(Date, nullable=False, comment="创建日期")
- plan_date = Column(Date, nullable=True, comment="计划日期")
- # 基本信息
- belongs_company = Column(String(20), nullable=False, comment="归属公司 shanxia-安庆山峡 yundong-安徽云栋")
- plan_type = Column(String(20), nullable=False, comment="单据类型 direct-直销单 inbound-入库单 outbound-出库单")
- follow_status = Column(
- String(30),
- nullable=False,
- default="pending_arrange",
- comment="跟进状态 wait_notice-等通知 pending_arrange-待安排 arranged-已安排 completed-已完成 cancelled-已取消",
- )
- transport_status = Column(String(20), nullable=False, default="pending", comment="运输安排状态 pending-待安排 arranged-已安排")
- archive_status = Column(String(20), nullable=False, default="unarchived", comment="归档状态 unarchived-未归档 draft-已暂存 archived-已归档")
- complete_status = Column(String(10), nullable=False, default="no", comment="完成状态 yes-是 no-否")
- # 合同关联
- contract_id = Column(String(64), nullable=True, comment="CRM合同ID")
- contract_no = Column(String(50), nullable=True, comment="合同编号")
- # 供应商与目的地
- supplier_id = Column(String(64), nullable=True, comment="供应商ID")
- supplier_name = Column(String(200), nullable=True, comment="供应商名称")
- destination_id = Column(String(64), nullable=True, comment="目的地ID")
- destination_name = Column(String(200), nullable=True, comment="目的地名称")
- # 客户信息(冗余自合同)
- customer_id = Column(String(64), nullable=True, comment="客户ID")
- customer_name = Column(String(200), nullable=True, comment="客户名称")
- contact_name = Column(String(100), nullable=True, comment="联系人")
- contact_phone = Column(String(32), nullable=True, comment="联系电话")
- party_a = Column(String(200), nullable=True, comment="甲方")
- party_b = Column(String(200), nullable=True, comment="乙方")
- # 合同有效期
- contract_start_date = Column(Date, nullable=True, comment="合同开始日期")
- contract_end_date = Column(Date, nullable=True, comment="合同结束日期")
- # 送货与结算
- delivery_method = Column(String(20), nullable=True, comment="送货方式 self_pick-山峡自提 one_ticket-一票制 customer_pick-客户自提")
- settlement_method = Column(String(50), nullable=True, comment="结算方式")
- # 运输信息
- has_freight = Column(SmallInteger, nullable=False, default=0, comment="是否有运输费用 0-否 1-是")
- pickup_address = Column(String(500), nullable=True, comment="取货地址")
- pickup_lng = Column(DECIMAL(10, 6), nullable=True, comment="取货经度")
- pickup_lat = Column(DECIMAL(10, 6), nullable=True, comment="取货纬度")
- pickup_time = Column(DateTime, nullable=True, comment="取货时间")
- pickup_contact = Column(String(200), nullable=True, comment="取货联系方式")
- pickup_notes = Column(String(500), nullable=True, comment="取货注意事项")
- destination_address = Column(String(500), nullable=True, comment="目的地地址")
- destination_lng = Column(DECIMAL(10, 6), nullable=True, comment="送货经度")
- destination_lat = Column(DECIMAL(10, 6), nullable=True, comment="送货纬度")
- delivery_time = Column(DateTime, nullable=True, comment="送达时间")
- delivery_contact = Column(String(200), nullable=True, comment="送货联系方式")
- destination_notes = Column(String(500), nullable=True, comment="目的地注意事项")
- transport_id = Column(String(64), nullable=True, comment="运输ID")
- transport_no = Column(String(32), nullable=True, comment="运输编号")
- vehicle_id = Column(String(64), nullable=True, comment="车辆ID")
- license_plate = Column(String(20), nullable=True, comment="车牌号")
- trailer_no = Column(String(20), nullable=True, comment="挂车号(安排运输时快照)")
- driver_id = Column(String(64), nullable=True, comment="司机ID")
- driver_name = Column(String(100), nullable=True, comment="司机姓名")
- escort_id = Column(String(64), nullable=True, comment="押运员人员ID")
- escort_name = Column(String(100), nullable=True, comment="押运员姓名")
- escort_phone = Column(String(32), nullable=True, comment="押运员电话")
- personnel_summary = Column(String(500), nullable=True, comment="关联人员摘要(安排运输时快照)")
- resource_snapshot = Column(Text, nullable=True, comment="车辆/人员/证件整包快照 JSON")
- # 金额汇总
- total_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="计划总金额")
- freight_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运费合计")
- freight_remark = Column(String(512), nullable=True, comment="运费备注")
- # 通知信息
- notify_message = Column(Text, nullable=True, comment="通知信息(标准模板)")
- slip_template_content = Column(Text, nullable=True, comment="入库单打印模板内容(富文本HTML)")
- delivery_slip_template_content = Column(Text, nullable=True, comment="送(提)货单打印模板内容(富文本HTML)")
- subpack_slip_template_content = Column(Text, nullable=True, comment="分装单打印模板内容(富文本HTML)")
- subpack_slip_no = Column(String(32), nullable=True, comment="分装单号 NO:SXFZYYYYMMDD-序号")
- # 跟进人
- follow_user_id = Column(String(64), nullable=True, comment="跟进人ID")
- follow_user_name = Column(String(100), nullable=True, comment="跟进人姓名")
- # 危化品证书齐备(人工确认)
- hazard_cert_ready = Column(SmallInteger, nullable=False, default=0, comment="危化品证书是否已人工确认齐备 0-否 1-是")
- hazard_cert_ready_by = Column(String(64), nullable=True, comment="危化品证书确认人")
- hazard_cert_ready_time = Column(DateTime, nullable=True, comment="危化品证书确认时间")
- erp_entered = Column(SmallInteger, nullable=False, default=0, comment="是否已录入ERP 0-否 1-是")
- # 公共字段
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanContract(Base):
- """运输计划-合同关联(分侧多选) pl_plan_contract"""
- __tablename__ = "pl_plan_contract"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="运输计划ID")
- side = Column(String(20), nullable=False, comment="supplier-供方 demander-需方 load-装货 delivery-送货")
- stop_id = Column(String(64), nullable=True, comment="停靠段ID(装货段或送货段)")
- contract_id = Column(String(64), nullable=False, comment="CRM合同ID")
- contract_no = Column(String(50), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanProduct(Base):
- """计划产品明细表 pl_plan_product"""
- __tablename__ = "pl_plan_product"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- # 产品信息
- product_id = Column(String(64), nullable=False, comment="产品ID")
- product_no = Column(String(50), nullable=False, comment="产品编号")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- brand_mode = Column(String(20), nullable=True, comment="required/any")
- brand_id = Column(String(64), nullable=True, comment="指定品牌ID")
- brand_name = Column(String(100), nullable=True, comment="品牌名快照")
- model = Column(String(100), nullable=True, comment="规格型号")
- unit = Column(String(20), nullable=False, default="吨", comment="单位")
- category_name = Column(String(200), nullable=True, comment="产品分类")
- package_spec = Column(String(200), nullable=True, comment="包装规格")
- delivery_method = Column(String(50), nullable=True, comment="送货方式")
- quantity = Column(DECIMAL(15, 3), nullable=True, comment="合同数量")
- actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
- tax_price = Column(DECIMAL(15, 4), nullable=True, comment="含税单价")
- tax_amount = Column(DECIMAL(15, 2), nullable=True, comment="税费")
- tax_subtotal = Column(DECIMAL(15, 2), nullable=True, comment="含税总价")
- # 产品属性(冗余自产品主数据)
- is_explosive = Column(SmallInteger, nullable=False, default=0, comment="是否易制爆 0-否 1-是")
- is_toxic = Column(SmallInteger, nullable=False, default=0, comment="是否易制毒 0-否 1-是")
- # 危化品证书(按 is_toxic / is_explosive 决定所需种类)
- purchase_cert_url = Column(String(2000), nullable=True, comment="购买证URL,逗号分隔")
- transport_cert_url = Column(String(2000), nullable=True, comment="运输证URL,逗号分隔")
- legal_use_cert_url = Column(String(2000), nullable=True, comment="合法使用证明URL,逗号分隔")
- # 入库信息
- inbound_estimate_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库预估数")
- inbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库数")
- inbound_price = Column(DECIMAL(15, 4), nullable=True, comment="入库价")
- inbound_amount = Column(DECIMAL(15, 2), nullable=True, comment="入库金额")
- # 出库信息
- outbound_estimate_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库预估数")
- outbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库数")
- outbound_price = Column(DECIMAL(15, 4), nullable=True, comment="出库单价")
- outbound_amount = Column(DECIMAL(15, 2), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanProductBrandQty(Base):
- """计划产品归档品牌数量 pl_plan_product_brand_qty
- stop_product_id 为空:计划产品级汇总;非空:装货/送货段产品行上的填写值。
- """
- __tablename__ = "pl_plan_product_brand_qty"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品明细ID")
- stop_type = Column(String(20), nullable=True, comment="load/delivery,空=计划级汇总")
- stop_product_id = Column(String(64), nullable=True, comment="段产品行ID,空=计划级汇总")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,空串=无品牌键")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌归档实际数量")
- unit_price = Column(DECIMAL(15, 4), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanChange(Base):
- """计划变更记录表 pl_plan_change"""
- __tablename__ = "pl_plan_change"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- change_type = Column(String(30), nullable=False, comment="变更类型")
- change_content = Column(Text, nullable=True, comment="变更内容")
- change_user_id = Column(String(64), nullable=True, comment="变更人ID")
- change_user_name = Column(String(100), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanLoad(Base):
- """运输计划-装货段 pl_plan_load(plan 1:1)"""
- __tablename__ = "pl_plan_load"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- customer_id = Column(String(64), nullable=True, comment="装货客户ID")
- customer_name = Column(String(200), nullable=True, comment="装货客户名称")
- address = Column(String(500), nullable=True, comment="装货地址")
- lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
- lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
- load_time = Column(DateTime, nullable=True, comment="装货时间")
- contact = Column(String(200), nullable=True, comment="联系方式")
- notes = Column(String(500), nullable=True, comment="注意事项")
- generate_dibang = Column(SmallInteger, nullable=False, default=0, comment="是否生成地磅单 0-否 1-是")
- dibang_direction = Column(String(20), nullable=True, comment="地磅方向 outbound-出库 inbound-入库 none-无")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanLoadProduct(Base):
- """运输计划-装货段产品明细 pl_plan_load_product"""
- __tablename__ = "pl_plan_load_product"
- id = Column(String(64), primary_key=True, comment="主键ID")
- load_id = Column(String(64), nullable=False, comment="装货段ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- product_id = Column(String(64), nullable=False, comment="产品ID")
- product_no = Column(String(50), nullable=False, comment="产品编号")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- model = Column(String(100), nullable=True, comment="规格型号")
- unit = Column(String(20), nullable=False, default="吨", comment="单位")
- package_spec = Column(String(200), nullable=True, comment="包装规格")
- delivery_method = Column(String(50), nullable=True, comment="送货方式")
- plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="本段计划数量")
- inbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库数量(归档)")
- inbound_price = Column(DECIMAL(15, 4), nullable=True, comment="入库单价(归档)")
- inbound_amount = Column(DECIMAL(15, 2), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanDelivery(Base):
- """运输计划-送货段 pl_plan_delivery(plan 1:N)"""
- __tablename__ = "pl_plan_delivery"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- seq = Column(Integer, nullable=False, default=1, comment="顺序号(打印、链接展示)")
- customer_id = Column(String(64), nullable=True, comment="送货客户ID")
- customer_name = Column(String(200), nullable=True, comment="送货客户名称")
- address = Column(String(500), nullable=True, comment="送货地址")
- lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
- lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
- delivery_time = Column(DateTime, nullable=True, comment="送货时间")
- contact = Column(String(200), nullable=True, comment="联系方式")
- notes = Column(String(500), nullable=True, comment="注意事项")
- generate_dibang = Column(SmallInteger, nullable=False, default=0, comment="是否生成地磅单 0-否 1-是")
- dibang_direction = Column(String(20), nullable=True, comment="地磅方向 outbound-出库 inbound-入库 none-无")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanDeliveryProduct(Base):
- """运输计划-送货段产品明细 pl_plan_delivery_product"""
- __tablename__ = "pl_plan_delivery_product"
- id = Column(String(64), primary_key=True, comment="主键ID")
- delivery_id = Column(String(64), nullable=False, comment="送货段ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- product_id = Column(String(64), nullable=False, comment="产品ID")
- product_no = Column(String(50), nullable=False, comment="产品编号")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- model = Column(String(100), nullable=True, comment="规格型号")
- unit = Column(String(20), nullable=False, default="吨", comment="单位")
- package_spec = Column(String(200), nullable=True, comment="包装规格")
- delivery_method = Column(String(50), nullable=True, comment="送货方式")
- plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="本段计划数量")
- outbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库数量(归档)")
- outbound_price = Column(DECIMAL(15, 4), nullable=True, comment="出库单价(归档)")
- outbound_amount = Column(DECIMAL(15, 2), 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="创建人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="删除标记:0-正常 1-已删除")
- # =============================================================================
- # 3. 运输管理:运输表、审批记录
- # =============================================================================
- class PlTransport(Base):
- """运输表 pl_transport"""
- __tablename__ = "pl_transport"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_no = Column(String(32), nullable=False, unique=True, comment="运输编号 SXYS######")
- # 车辆与司机
- vehicle_id = Column(String(64), nullable=True, comment="车辆ID")
- license_plate = Column(String(20), nullable=True, comment="车牌号")
- trailer_no = Column(String(20), nullable=True, comment="挂车号(安排运输时快照)")
- driver_id = Column(String(64), nullable=True, comment="司机ID")
- driver_name = Column(String(100), nullable=True, comment="司机姓名")
- driver_phone = Column(String(32), nullable=True, comment="司机电话")
- escort_id = Column(String(64), nullable=True, comment="押运员人员ID")
- escort_name = Column(String(100), nullable=True, comment="押运员姓名")
- escort_phone = Column(String(32), nullable=True, comment="押运员电话")
- resource_snapshot = Column(Text, nullable=True, comment="车辆/人员/证件整包快照 JSON")
- # 承运商
- carrier_id = Column(String(64), nullable=True, comment="承运商ID")
- carrier_name = Column(String(200), nullable=True, comment="承运商名称")
- # 运输信息
- transport_medium = Column(String(100), nullable=True, comment="运输介质")
- start_point = Column(String(200), nullable=True, comment="运输起点")
- end_point = Column(String(200), nullable=True, comment="运输终点")
- distance_km = Column(DECIMAL(10, 2), nullable=True, comment="运输公里数")
- unit = Column(String(20), nullable=True, comment="计量单位 吨/趟")
- transport_qty = Column(DECIMAL(15, 3), nullable=True, comment="运输量(按重量计费基数)")
- # 运费
- freight_price = Column(DECIMAL(15, 4), nullable=True, comment="运输单价")
- freight_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运输费用")
- freight_type = Column(String(20), nullable=False, default="by_weight", comment="运费计算方式 by_weight-按重量 by_trip-按趟次")
- has_invoice = Column(SmallInteger, nullable=False, default=0, comment="是否开票 0-否 1-是")
- # 二维码
- qr_code = Column(String(500), nullable=True, comment="二维码内容")
- qr_expire_date = Column(Date, nullable=True, comment="二维码有效期")
- driver_access_token = Column(String(64), nullable=True, comment="司机免登录访问令牌")
- site_access_token = Column(String(64), nullable=True, comment="现场免登录访问令牌")
- # 运输状态
- transport_status = Column(String(20), nullable=False, default="draft", comment="运输状态 draft-草稿 pending-待执行 executing-执行中 completed-已完成 cancelled-已取消")
- approval_status = Column(String(20), nullable=False, default="none", comment="审批状态 none-无需 pending-审批中 approved-已通过 rejected-已拒绝")
- # 司机回传信息
- feedback_time = Column(DateTime, nullable=True, comment="回传时间")
- feedback_qty = Column(DECIMAL(15, 3), nullable=True, comment="回传数量")
- feedback_images = Column(Text, nullable=True, comment="回传图片URLs(JSON数组)")
- feedback_remark = Column(String(500), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlTransportProductFeedback(Base):
- """运输单按产品回传 pl_transport_product_feedback"""
- __tablename__ = "pl_transport_product_feedback"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- actual_qty = Column(DECIMAL(15, 3), nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlTransportProductBrandQty(Base):
- """运输单产品回传品牌数量 pl_transport_product_brand_qty"""
- __tablename__ = "pl_transport_product_brand_qty"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- feedback_id = Column(String(64), nullable=True, comment="产品回传行ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- qty = Column(DECIMAL(15, 3), nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlTransportDbLink(Base):
- """运输-地磅出入库关联 pl_transport_db_link"""
- __tablename__ = "pl_transport_db_link"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_id = Column(String(64), nullable=False, comment="运输计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- stop_type = Column(String(20), nullable=True, comment="停靠段类型 load-装货 delivery-送货")
- stop_id = Column(String(64), nullable=True, comment="停靠段ID")
- db_purchase_plan_id = Column(String(64), nullable=False, comment="地磅计划ID")
- db_inventory_id = Column(String(64), nullable=False, comment="出入库单ID")
- contributed_qty = Column(DECIMAL(15, 3), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlPlanTransport(Base):
- """计划-运输关联表 pl_plan_transport"""
- __tablename__ = "pl_plan_transport"
- id = Column(String(64), primary_key=True, comment="主键ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- transport_id = Column(String(64), nullable=False, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlTransportDriverStopFeedback(Base):
- """运输单-司机按段附件回传 pl_transport_driver_stop_feedback"""
- __tablename__ = "pl_transport_driver_stop_feedback"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- stop_type = Column(String(20), nullable=False, comment="停靠段类型 load-装货 delivery-送货")
- stop_id = Column(String(64), nullable=False, comment="停靠段ID")
- attachment_urls = Column(Text, nullable=True, comment="附件URLs(JSON数组)")
- product_feedbacks = Column(
- Text,
- nullable=True,
- comment="段产品回传 JSON:[{stopProductId,actualQty,brandQtys}]",
- )
- remark = Column(String(500), nullable=True, comment="备注")
- feedback_time = Column(DateTime, nullable=True, comment="回传时间")
- tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
- order_num = Column(Integer, 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="删除标记:0-正常 1-已删除")
- class PlTransportSiteStopFeedback(Base):
- """运输单-现场按段回传 pl_transport_site_stop_feedback"""
- __tablename__ = "pl_transport_site_stop_feedback"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_id = Column(String(64), nullable=False, comment="计划ID")
- stop_type = Column(String(20), nullable=False, comment="停靠段类型 load-装货 delivery-送货")
- stop_id = Column(String(64), nullable=False, comment="停靠段ID")
- business_type = Column(String(20), nullable=False, comment="业务类型:入库/出库")
- quantity = Column(DECIMAL(15, 3), nullable=True, comment="现场回传数量")
- attachment_urls = Column(Text, nullable=True, comment="附件URLs(JSON数组)")
- product_feedbacks = Column(
- Text,
- nullable=True,
- comment="段产品回传 JSON:[{stopProductId,actualQty,brandQtys}]",
- )
- remark = Column(String(500), nullable=True, comment="备注")
- feedback_time = Column(DateTime, nullable=True, comment="回传时间")
- tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
- order_num = Column(Integer, 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="删除标记:0-正常 1-已删除")
- class PlTransportSiteLink(Base):
- """运输计划现场链接 pl_transport_site_link(与地磅出入库单解耦)"""
- __tablename__ = "pl_transport_site_link"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- plan_id = Column(String(64), nullable=False, comment="运输计划ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- site_access_token = Column(String(64), nullable=False, comment="现场人员免登录访问令牌")
- business_type = Column(String(20), nullable=False, comment="业务类型:入库/出库")
- partner_company = Column(String(200), nullable=True, comment="往来单位")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- product = Column(String(200), nullable=True, comment="产品名称快照")
- specification = Column(String(200), nullable=True, comment="规格快照")
- quantity = Column(DECIMAL(15, 3), nullable=True, comment="数量(吨)")
- vehicle_no = Column(String(32), nullable=True, comment="车牌号")
- plan_no = Column(String(64), nullable=True, comment="运输计划号")
- plan_date = Column(Date, 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="现场回执保存时间")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlInboundOrder(Base):
- """运输计划-入库单 pl_inbound_order"""
- __tablename__ = "pl_inbound_order"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_no = Column(String(32), nullable=False, comment="入库单号")
- plan_id = Column(String(64), nullable=False, comment="运输计划ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- status = Column(String(20), nullable=False, default="in_progress", comment="in_progress/completed/voided")
- partner_company = Column(String(200), nullable=True, comment="往来单位快照")
- vehicle_no = Column(String(32), nullable=True, comment="车牌快照")
- plan_no = Column(String(64), nullable=True, comment="计划号快照")
- plan_date = Column(Date, nullable=True, comment="计划日期快照")
- site_access_token = Column(String(64), nullable=False, 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="最近现场提交时间")
- site_first_submitted_at = Column(DateTime, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlInboundOrderItem(Base):
- """运输计划-入库单明细 pl_inbound_order_item"""
- __tablename__ = "pl_inbound_order_item"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_id = Column(String(64), nullable=False, comment="入库单ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- product_name = Column(String(200), nullable=True, comment="产品名称快照")
- specification = Column(String(200), nullable=True, comment="规格快照")
- unit = Column(String(32), nullable=True, comment="单位")
- plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="计划数量")
- actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
- qty_source = Column(String(20), nullable=True, default="plan", comment="plan/dibang/manual")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlInboundOrderItemBrandQty(Base):
- """入库明细品牌数量 pl_inbound_order_item_brand_qty"""
- __tablename__ = "pl_inbound_order_item_brand_qty"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_id = Column(String(64), nullable=False, comment="入库单ID")
- order_item_id = Column(String(64), nullable=False, comment="入库明细ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- qty = Column(DECIMAL(15, 3), nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlOutboundOrder(Base):
- """运输计划-出库单 pl_outbound_order"""
- __tablename__ = "pl_outbound_order"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_no = Column(String(32), nullable=False, comment="出库单号")
- plan_id = Column(String(64), nullable=False, comment="运输计划ID")
- transport_id = Column(String(64), nullable=False, comment="运输单ID")
- status = Column(String(20), nullable=False, default="in_progress", comment="in_progress/completed/voided")
- partner_company = Column(String(200), nullable=True, comment="往来单位快照")
- vehicle_no = Column(String(32), nullable=True, comment="车牌快照")
- plan_no = Column(String(64), nullable=True, comment="计划号快照")
- plan_date = Column(Date, nullable=True, comment="计划日期快照")
- site_access_token = Column(String(64), nullable=False, 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="最近现场提交时间")
- site_first_submitted_at = Column(DateTime, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlOutboundOrderItem(Base):
- """运输计划-出库单明细 pl_outbound_order_item"""
- __tablename__ = "pl_outbound_order_item"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_id = Column(String(64), nullable=False, comment="出库单ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- product_id = Column(String(64), nullable=True, comment="CRM产品ID")
- product_name = Column(String(200), nullable=True, comment="产品名称快照")
- specification = Column(String(200), nullable=True, comment="规格快照")
- unit = Column(String(32), nullable=True, comment="单位")
- plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="计划数量")
- actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
- qty_source = Column(String(20), nullable=True, default="plan", comment="plan/dibang/manual")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlOutboundOrderItemBrandQty(Base):
- """出库明细品牌数量 pl_outbound_order_item_brand_qty"""
- __tablename__ = "pl_outbound_order_item_brand_qty"
- id = Column(String(64), primary_key=True, comment="主键ID")
- order_id = Column(String(64), nullable=False, comment="出库单ID")
- order_item_id = Column(String(64), nullable=False, comment="出库明细ID")
- plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- qty = Column(DECIMAL(15, 3), nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlTransportApproval(Base):
- """运输审批记录表 pl_transport_approval"""
- __tablename__ = "pl_transport_approval"
- id = Column(String(64), primary_key=True, comment="主键ID")
- transport_id = Column(String(64), nullable=False, comment="运输ID")
- approver_id = Column(String(64), nullable=False, comment="审批人ID")
- approver_name = Column(String(100), nullable=False, comment="审批人姓名")
- approval_order = Column(Integer, nullable=False, comment="审批顺序")
- status = Column(String(20), nullable=False, default="pending", comment="审批状态 pending-待审批 approved-已通过 rejected-已拒绝")
- comment = Column(String(500), nullable=True, comment="审批意见")
- approval_time = Column(DateTime, 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="创建人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="删除标记:0-正常 1-已删除")
- # =============================================================================
- # 4. 运费结算
- # =============================================================================
- class PlFreightSettlement(Base):
- """运费结算表 pl_freight_settlement"""
- __tablename__ = "pl_freight_settlement"
- id = Column(String(64), primary_key=True, comment="主键ID")
- settlement_no = Column(String(32), nullable=False, unique=True, comment="结算单编号")
- # 结算金额
- total_freight = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运费合计")
- invoice_amount = Column(DECIMAL(15, 2), nullable=True, comment="发票金额")
- # 发票信息
- invoice_no = Column(String(50), nullable=True, comment="发票号")
- invoice_date = Column(Date, nullable=True, comment="开票日期")
- invoice_attachment_urls = Column(Text, nullable=True, comment="发票附件URLs,逗号分隔")
- # 结算状态
- settlement_status = Column(String(20), nullable=False, default="pending", comment="结算状态 pending-待提交 submitted-已提交 approved-审核通过 confirmed-已确认")
- # 公共字段
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlFreightSettlementApproval(Base):
- """运费结算审批 pl_freight_settlement_approval"""
- __tablename__ = "pl_freight_settlement_approval"
- id = Column(String(64), primary_key=True, comment="主键ID")
- settlement_id = Column(String(64), nullable=False, comment="结算单ID")
- step = Column(Integer, nullable=False, default=1, comment="步骤序号")
- step_name = Column(String(50), nullable=True, comment="步骤名称")
- approver_id = Column(String(64), nullable=False, comment="审批人ID")
- approver_name = Column(String(64), nullable=True, comment="审批人姓名")
- approval_type = Column(String(20), nullable=False, default="sequential", comment="审批类型")
- approval_result = Column(String(20), nullable=False, default="pending", comment="审批结果")
- approval_opinion = Column(String(500), nullable=True, comment="审批意见")
- approval_time = Column(DateTime, nullable=True, comment="审批时间")
- is_current = Column(SmallInteger, nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlFreightSettlementTransport(Base):
- """结算单-运输关联表 pl_freight_settlement_transport"""
- __tablename__ = "pl_freight_settlement_transport"
- id = Column(String(64), primary_key=True, comment="主键ID")
- settlement_id = Column(String(64), nullable=False, comment="结算单ID")
- transport_id = Column(String(64), nullable=False, comment="运输ID")
- freight_amount = Column(DECIMAL(15, 2), nullable=False, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlRemittanceVoucher(Base):
- """汇款凭证表 pl_remittance_voucher"""
- __tablename__ = "pl_remittance_voucher"
- id = Column(String(64), primary_key=True, comment="主键ID")
- settlement_id = Column(String(64), nullable=False, comment="结算单ID")
- voucher_no = Column(String(32), nullable=True, comment="凭证编号")
- remittance_date = Column(Date, nullable=True, comment="汇款日期")
- remittance_amount = Column(DECIMAL(15, 2), nullable=True, comment="汇款金额")
- voucher_urls = Column(Text, nullable=True, comment="凭证文件URLs(JSON数组)")
- 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="创建人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="删除标记:0-正常 1-已删除")
- # =============================================================================
- # 5. 库存管理
- # =============================================================================
- class PlInventory(Base):
- """库存表 pl_inventory"""
- __tablename__ = "pl_inventory"
- id = Column(String(64), primary_key=True, comment="主键ID")
- product_id = Column(String(64), nullable=False, comment="产品ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- product_no = Column(String(50), nullable=False, comment="产品编号")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- model = Column(String(100), nullable=True, comment="规格型号")
- unit = Column(String(20), nullable=False, default="吨", comment="单位")
- # 库存数量与金额
- stock_qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="库存数量")
- stock_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="库存金额")
- # 预警阈值
- low_stock_warning = Column(DECIMAL(15, 3), nullable=True, comment="最低库存预警值")
- high_stock_warning = Column(DECIMAL(15, 3), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlInventoryTransaction(Base):
- """库存流水表 pl_inventory_transaction"""
- __tablename__ = "pl_inventory_transaction"
- id = Column(String(64), primary_key=True, comment="主键ID")
- product_id = Column(String(64), nullable=False, comment="产品ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- transaction_type = Column(String(20), nullable=False, comment="事务类型 inbound-入库 outbound-出库")
- plan_id = Column(String(64), nullable=True, comment="计划ID")
- plan_no = Column(String(32), nullable=True, comment="计划编号")
- # 数量与价格
- qty = Column(DECIMAL(15, 3), nullable=False, comment="变动数量(正数入库/负数出库)")
- unit_price = Column(DECIMAL(15, 4), nullable=False, comment="单价")
- amount = Column(DECIMAL(15, 2), nullable=False, comment="金额")
- stock_after = Column(DECIMAL(15, 3), nullable=False, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlInventoryWarning(Base):
- """库存预警表 pl_inventory_warning"""
- __tablename__ = "pl_inventory_warning"
- id = Column(String(64), primary_key=True, comment="主键ID")
- product_id = Column(String(64), nullable=False, comment="产品ID")
- brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
- brand_name = Column(String(100), nullable=True, comment="品牌名称")
- product_name = Column(String(200), nullable=False, comment="产品名称")
- warning_type = Column(String(20), nullable=False, comment="预警类型 low-低于最低 high-高于最高")
- current_qty = Column(DECIMAL(15, 3), nullable=False, comment="当前库存")
- threshold_value = Column(DECIMAL(15, 3), nullable=False, comment="阈值")
- status = Column(String(20), nullable=False, default="pending", comment="状态 pending-待处理 resolved-已处理")
- resolve_time = Column(DateTime, nullable=True, comment="处理时间")
- resolve_remark = Column(String(500), 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="创建人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="删除标记:0-正常 1-已删除")
- class PlDocumentReminder(Base):
- """证件到期提醒表 pl_document_reminder"""
- __tablename__ = "pl_document_reminder"
- id = Column(String(64), primary_key=True, comment="主键ID")
- cert_id = Column(String(64), nullable=True, comment="证书ID")
- owner_type = Column(String(20), nullable=True, comment="归属类型 vehicle/personnel")
- owner_id = Column(String(64), nullable=True, comment="归属主体ID")
- owner_label = Column(String(200), nullable=True, comment="归属展示名(车牌/姓名)")
- driver_id = Column(String(64), nullable=True, comment="司机/人员ID(兼容)")
- driver_name = Column(String(100), nullable=True, comment="司机/人员姓名(兼容)")
- document_type = Column(String(100), nullable=False, comment="证件类型/证书名称")
- document_no = Column(String(50), nullable=True, comment="证件号")
- expire_date = Column(Date, nullable=False, comment="到期日期")
- days_remaining = Column(Integer, nullable=False, comment="剩余天数")
- status = Column(String(20), nullable=False, default="pending", comment="状态 pending-待处理 resolved-已处理")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleFuelRegister(Base):
- """车辆加油登记 pl_vehicle_fuel_register"""
- __tablename__ = "pl_vehicle_fuel_register"
- id = Column(String(64), primary_key=True, comment="主键ID")
- register_no = Column(String(32), nullable=False, unique=True, comment="登记单号")
- fuel_category = Column(
- String(20), nullable=False, comment="加油类别 bailian/gas_station/shanxia_factory(山峡)"
- )
- register_date = Column(Date, nullable=False, comment="日期")
- registrant_id = Column(String(64), nullable=False, comment="登记人用户ID")
- license_plate = Column(String(20), nullable=False, comment="车牌号")
- odometer_km = Column(DECIMAL(10, 1), nullable=True, comment="期初公里数")
- fuel_liters = Column(DECIMAL(10, 2), nullable=False, comment="加油升数")
- fuel_tons = Column(DECIMAL(10, 3), nullable=True, comment="加油/吨(升÷1176)")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- status = Column(String(20), nullable=False, default="normal", 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleRechargeApply(Base):
- """车辆ETC/加油充值申请 pl_vehicle_recharge_apply"""
- __tablename__ = "pl_vehicle_recharge_apply"
- id = Column(String(64), primary_key=True, comment="主键ID")
- apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
- license_plate = Column(String(20), nullable=False, comment="车牌号")
- recharge_type = Column(String(20), nullable=False, comment="充值类型 etc/fuel")
- apply_date = Column(Date, nullable=False, comment="申请日期")
- odometer_km = Column(DECIMAL(10, 1), nullable=True, comment="期初公里数")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- applicant_id = Column(String(64), nullable=False, comment="申请人ID")
- status = Column(String(20), nullable=False, default="pending", 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleMaintenanceApply(Base):
- """车辆维保申请 pl_vehicle_maintenance_apply"""
- __tablename__ = "pl_vehicle_maintenance_apply"
- id = Column(String(64), primary_key=True, comment="主键ID")
- apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
- license_plate = Column(String(20), nullable=False, comment="车牌号")
- applicant_id = Column(String(64), nullable=False, comment="申请人ID")
- apply_date = Column(Date, nullable=False, comment="申请时间")
- maintenance_type = Column(String(64), nullable=False, comment="维保类型")
- start_date = Column(Date, nullable=False, comment="维保开始时间")
- expected_pickup_date = Column(Date, nullable=True, comment="预计取车时间")
- maintenance_content = Column(String(1000), nullable=True, comment="维保内容")
- shop_address = Column(String(500), nullable=True, comment="维保店铺地址")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- status = Column(String(20), nullable=False, default="pending", 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleMaintenanceProcess(Base):
- """车辆维保处理登记 pl_vehicle_maintenance_process"""
- __tablename__ = "pl_vehicle_maintenance_process"
- id = Column(String(64), primary_key=True, comment="主键ID")
- process_no = Column(String(32), nullable=False, unique=True, comment="处理单号")
- apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
- license_plate = Column(String(20), nullable=True, comment="车牌号冗余")
- amount = Column(DECIMAL(10, 2), nullable=True, comment="金额")
- handler_id = Column(String(64), nullable=False, comment="处理人ID")
- process_date = Column(Date, nullable=False, comment="处理时间")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleUreaApply(Base):
- """车辆尿素申请 pl_vehicle_urea_apply"""
- __tablename__ = "pl_vehicle_urea_apply"
- id = Column(String(64), primary_key=True, comment="主键ID")
- apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
- license_plate = Column(String(20), nullable=False, comment="车牌号")
- applicant_id = Column(String(64), nullable=False, comment="申请人ID")
- apply_date = Column(Date, nullable=False, comment="申请时间")
- warehouse_in_date = Column(Date, nullable=False, comment="入库时间")
- unit = Column(String(32), nullable=False, comment="单位")
- quantity = Column(DECIMAL(10, 2), nullable=False, comment="入库数")
- apply_amount = Column(DECIMAL(10, 2), nullable=False, comment="申请金额")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- status = Column(String(20), nullable=False, default="pending", 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleUreaDisburse(Base):
- """车辆尿素发放登记 pl_vehicle_urea_disburse"""
- __tablename__ = "pl_vehicle_urea_disburse"
- id = Column(String(64), primary_key=True, comment="主键ID")
- disburse_no = Column(String(32), nullable=False, unique=True, comment="发放单号")
- apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
- license_plate = Column(String(20), nullable=True, comment="车牌号冗余")
- amount = Column(DECIMAL(10, 2), nullable=False, comment="发放金额")
- handler_id = Column(String(64), nullable=False, comment="处理人ID")
- disburse_date = Column(Date, nullable=False, comment="发放时间")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- 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="创建人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="删除标记:0-正常 1-已删除")
- class PlOcrUsageMonth(Base):
- """阿里云 OCR 月度调用计数 pl_ocr_usage_month(按自然月全局统计)"""
- __tablename__ = "pl_ocr_usage_month"
- id = Column(String(64), primary_key=True, comment="主键ID")
- usage_month = Column(String(7), nullable=False, unique=True, comment="自然月 YYYY-MM")
- used_count = Column(Integer, nullable=False, default=0, 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="创建人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="删除标记:0-正常 1-已删除")
- class PlVehicleRechargeRecord(Base):
- """车辆ETC/加油充值发放登记 pl_vehicle_recharge_record"""
- __tablename__ = "pl_vehicle_recharge_record"
- id = Column(String(64), primary_key=True, comment="主键ID")
- recharge_order_no = Column(String(32), nullable=False, unique=True, comment="充值订单号")
- recharge_date = Column(Date, nullable=False, comment="充值日期")
- recharge_type = Column(String(20), nullable=False, comment="充值类型")
- card_no = Column(String(64), nullable=True, comment="卡号")
- gas_station = Column(String(200), nullable=True, comment="加油站/渠道")
- amount = Column(DECIMAL(10, 2), nullable=False, comment="充值金额")
- attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
- apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
- license_plate = Column(String(20), 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="创建人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="删除标记:0-正常 1-已删除")
|