pl_models.py 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545
  1. """运输计划管理模块数据模型"""
  2. from datetime import datetime
  3. from decimal import Decimal
  4. from sqlalchemy import (
  5. BigInteger,
  6. Column,
  7. DECIMAL,
  8. Date,
  9. DateTime,
  10. Integer,
  11. SmallInteger,
  12. String,
  13. Text,
  14. CHAR,
  15. ForeignKey,
  16. )
  17. from sqlalchemy.orm import relationship
  18. from app.core.database import Base
  19. # =============================================================================
  20. # 1. 基础数据:承运商、车辆、司机
  21. # =============================================================================
  22. class PlCarrier(Base):
  23. """承运商表 pl_carrier"""
  24. __tablename__ = "pl_carrier"
  25. id = Column(String(64), primary_key=True, comment="主键ID")
  26. carrier_name = Column(String(200), nullable=False, comment="承运商名称")
  27. contact_name = Column(String(100), nullable=True, comment="联系人")
  28. contact_phone = Column(String(32), nullable=True, comment="联系电话")
  29. status = Column(CHAR(1), nullable=False, default="1", comment="合作状态 1-合作中 0-已终止")
  30. business_license_urls = Column(String(2000), nullable=True, comment="营业执照附件URL,逗号分隔")
  31. road_transport_license_urls = Column(String(2000), nullable=True, comment="道路经营许可证附件URL,逗号分隔")
  32. transport_agreement_urls = Column(String(2000), nullable=True, comment="运输协议附件URL,逗号分隔")
  33. transport_agreement_expire_date = Column(Date, nullable=True, comment="运输协议有效期")
  34. audit_status = Column(String(20), nullable=False, default="pending", comment="审核状态 pending-待审核 approved-已通过 rejected-已驳回")
  35. audit_by = Column(String(64), nullable=True, comment="审核人id")
  36. audit_time = Column(DateTime, nullable=True, comment="审核时间")
  37. audit_remark = Column(String(512), nullable=True, comment="审核备注(驳回原因等)")
  38. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  39. order_num = Column(Integer, nullable=True, comment="排序号")
  40. remark = Column(String(512), nullable=True, comment="备注")
  41. create_by = Column(String(64), nullable=True, comment="创建人id")
  42. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  43. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  44. update_by = Column(String(64), nullable=True, comment="更新人id")
  45. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  46. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  47. class PlVehicle(Base):
  48. """车辆表 pl_vehicle"""
  49. __tablename__ = "pl_vehicle"
  50. id = Column(String(64), primary_key=True, comment="主键ID")
  51. vehicle_type = Column(String(20), nullable=False, comment="车辆类型 self-自有 carrier-承运商")
  52. carrier_id = Column(String(64), nullable=True, comment="承运商ID(类型为承运商时必填)")
  53. carrier_name = Column(String(200), nullable=True, comment="承运商名称(冗余)")
  54. license_plate = Column(String(20), nullable=False, unique=True, comment="车牌号")
  55. trailer_no = Column(String(20), nullable=True, comment="挂车号")
  56. default_driver_id = Column(String(64), nullable=True, comment="默认司机ID")
  57. default_driver_name = Column(String(100), nullable=True, comment="默认司机姓名(冗余)")
  58. load_capacity = Column(DECIMAL(10, 2), nullable=True, comment="载重(吨)")
  59. vehicle_status = Column(String(20), nullable=False, default="available", comment="车辆状态 available-可用 maintaining-维修中 scrapped-报废")
  60. photo_urls = Column(String(2000), nullable=True, comment="车辆照片URL,逗号分隔")
  61. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  62. order_num = Column(Integer, nullable=True, comment="排序号")
  63. remark = Column(String(512), nullable=True, comment="备注")
  64. create_by = Column(String(64), nullable=True, comment="创建人id")
  65. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  66. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  67. update_by = Column(String(64), nullable=True, comment="更新人id")
  68. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  69. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  70. class PlPersonnel(Base):
  71. """人员表 pl_personnel"""
  72. __tablename__ = "pl_personnel"
  73. id = Column(String(64), primary_key=True, comment="主键ID")
  74. personnel_name = Column(String(100), nullable=False, comment="姓名")
  75. phone_no = Column(String(32), nullable=True, comment="手机号(非必填)")
  76. age = Column(Integer, nullable=True, comment="年龄")
  77. id_card_no = Column(String(32), nullable=True, comment="身份证号")
  78. personnel_type = Column(
  79. String(20),
  80. nullable=False,
  81. default="both",
  82. comment="人员类型 driver-驾驶员 escort-押运员 both-驾驶员兼押运员",
  83. )
  84. personnel_affiliation = Column(
  85. String(20),
  86. nullable=False,
  87. default="self",
  88. comment="人员归属 self-山峡 carrier-非山峡",
  89. )
  90. status = Column(CHAR(1), nullable=False, default="1", comment="状态 1-在职 0-停用")
  91. photo_urls = Column(String(2000), nullable=True, comment="人员照片URL,逗号分隔")
  92. sys_user_id = Column(String(64), nullable=True, comment="关联系统用户ID")
  93. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  94. order_num = Column(Integer, nullable=True, comment="排序号")
  95. remark = Column(String(512), nullable=True, comment="备注")
  96. create_by = Column(String(64), nullable=True, comment="创建人id")
  97. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  98. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  99. update_by = Column(String(64), nullable=True, comment="更新人id")
  100. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  101. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  102. class PlTransportAddress(Base):
  103. """运输通用地址库 pl_transport_address"""
  104. __tablename__ = "pl_transport_address"
  105. id = Column(String(64), primary_key=True, comment="主键ID")
  106. address_name = Column(String(200), nullable=False, comment="地址名称")
  107. full_address = Column(String(500), nullable=False, comment="详细地址")
  108. lng = Column(DECIMAL(10, 6), nullable=False, comment="经度")
  109. lat = Column(DECIMAL(10, 6), nullable=False, comment="纬度")
  110. contact_name = Column(String(100), nullable=True, comment="联系人")
  111. contact_phone = Column(String(32), nullable=True, comment="联系电话")
  112. notes = Column(String(500), nullable=True, comment="注意事项")
  113. status = Column(CHAR(1), nullable=False, default="1", comment="状态 1-启用 0-停用")
  114. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  115. order_num = Column(Integer, nullable=True, comment="排序号")
  116. remark = Column(String(512), nullable=True, comment="备注")
  117. create_by = Column(String(64), nullable=True, comment="创建人id")
  118. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  119. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  120. update_by = Column(String(64), nullable=True, comment="更新人id")
  121. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  122. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  123. class PlCustomerStopPref(Base):
  124. """客户装/送货物流默认记忆 pl_customer_stop_pref"""
  125. __tablename__ = "pl_customer_stop_pref"
  126. id = Column(String(64), primary_key=True, comment="主键ID")
  127. customer_id = Column(String(64), nullable=False, comment="客户ID")
  128. customer_name = Column(String(200), nullable=True, comment="客户名称")
  129. stop_type = Column(String(20), nullable=False, comment="load-装货 delivery-送货")
  130. address = Column(String(500), nullable=True, comment="地址")
  131. lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
  132. lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
  133. contact = Column(String(200), nullable=True, comment="联系方式")
  134. notes = Column(String(500), nullable=True, comment="注意事项")
  135. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  136. order_num = Column(Integer, nullable=True, comment="排序号")
  137. remark = Column(String(512), nullable=True, comment="备注")
  138. create_by = Column(String(64), nullable=True, comment="创建人id")
  139. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  140. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  141. update_by = Column(String(64), nullable=True, comment="更新人id")
  142. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  143. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  144. class PlCert(Base):
  145. """证书表 pl_cert"""
  146. __tablename__ = "pl_cert"
  147. id = Column(String(64), primary_key=True, comment="主键ID")
  148. owner_type = Column(String(20), nullable=False, comment="归属类型 vehicle-车辆 personnel-人员")
  149. owner_id = Column(String(64), nullable=False, comment="归属主体ID")
  150. vehicle_part = Column(String(20), nullable=True, comment="车辆部位 head-主车 trailer-挂车,人员证书为空")
  151. cert_name = Column(String(100), nullable=False, comment="证书名称")
  152. cert_no = Column(String(64), nullable=True, comment="证号")
  153. expire_date = Column(Date, nullable=True, comment="有效期")
  154. remind_days = Column(Integer, nullable=False, default=30, comment="提前提醒天数")
  155. attachment_urls = Column(String(2000), nullable=True, comment="附件URL(逗号分隔)")
  156. status = Column(String(20), nullable=False, default="valid", comment="状态 valid-有效 expired-已过期 revoked-已作废")
  157. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  158. order_num = Column(Integer, nullable=True, comment="排序号")
  159. remark = Column(String(512), nullable=True, comment="备注")
  160. create_by = Column(String(64), nullable=True, comment="创建人id")
  161. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  162. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  163. update_by = Column(String(64), nullable=True, comment="更新人id")
  164. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  165. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  166. class PlDriver(Base):
  167. """司机表 pl_driver(兼容旧表,迁移后逐步废弃)"""
  168. __tablename__ = "pl_driver"
  169. id = Column(String(64), primary_key=True, comment="主键ID")
  170. driver_name = Column(String(100), nullable=False, comment="姓名")
  171. phone_no = Column(String(32), nullable=False, comment="手机号")
  172. id_card_no = Column(String(32), nullable=True, comment="身份证号")
  173. driving_license_no = Column(String(32), nullable=True, comment="驾驶证号")
  174. driving_license_expire = Column(Date, nullable=True, comment="驾驶证有效期")
  175. vehicle_license_no = Column(String(32), nullable=True, comment="行驶证号")
  176. vehicle_license_expire = Column(Date, nullable=True, comment="行驶证有效期")
  177. hazmat_cert_no = Column(String(32), nullable=True, comment="危化品证号")
  178. hazmat_cert_expire = Column(Date, nullable=True, comment="危化品证有效期")
  179. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  180. order_num = Column(Integer, nullable=True, comment="排序号")
  181. remark = Column(String(512), nullable=True, comment="备注")
  182. create_by = Column(String(64), nullable=True, comment="创建人id")
  183. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  184. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  185. update_by = Column(String(64), nullable=True, comment="更新人id")
  186. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  187. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  188. class PlVehiclePersonnel(Base):
  189. """车辆-人员关联表 pl_vehicle_personnel"""
  190. __tablename__ = "pl_vehicle_personnel"
  191. id = Column(String(64), primary_key=True, comment="主键ID")
  192. vehicle_id = Column(String(64), nullable=False, comment="车辆ID")
  193. personnel_id = Column(String(64), nullable=False, comment="人员ID")
  194. role = Column(String(20), nullable=False, default="driver", comment="角色 driver-司机 escort-押运员")
  195. is_default = Column(SmallInteger, nullable=False, default=0, comment="是否默认司机 0-否 1-是")
  196. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  197. order_num = Column(Integer, nullable=True, comment="排序号")
  198. remark = Column(String(512), nullable=True, comment="关联备注")
  199. create_by = Column(String(64), nullable=True, comment="创建人id")
  200. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  201. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  202. update_by = Column(String(64), nullable=True, comment="更新人id")
  203. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  204. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  205. class PlVehicleDriver(Base):
  206. """车辆-司机关联表 pl_vehicle_driver(兼容旧表)"""
  207. __tablename__ = "pl_vehicle_driver"
  208. id = Column(String(64), primary_key=True, comment="主键ID")
  209. vehicle_id = Column(String(64), nullable=False, comment="车辆ID")
  210. driver_id = Column(String(64), nullable=False, comment="司机ID")
  211. is_default = Column(SmallInteger, nullable=False, default=0, comment="是否默认 0-否 1-是")
  212. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  213. order_num = Column(Integer, nullable=True, comment="排序号")
  214. remark = Column(String(512), nullable=True, comment="备注")
  215. create_by = Column(String(64), nullable=True, comment="创建人id")
  216. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  217. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  218. update_by = Column(String(64), nullable=True, comment="更新人id")
  219. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  220. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  221. # =============================================================================
  222. # 2. 计划管理:计划主表、产品明细、变更记录
  223. # =============================================================================
  224. class PlPlan(Base):
  225. """计划主表 pl_plan"""
  226. __tablename__ = "pl_plan"
  227. id = Column(String(64), primary_key=True, comment="主键ID")
  228. # 编号信息
  229. plan_no = Column(String(32), nullable=False, unique=True, comment="计划订单编号 POYYYYMMDD###")
  230. create_date = Column(Date, nullable=False, comment="创建日期")
  231. plan_date = Column(Date, nullable=True, comment="计划日期")
  232. # 基本信息
  233. belongs_company = Column(String(20), nullable=False, comment="归属公司 shanxia-安庆山峡 yundong-安徽云栋")
  234. plan_type = Column(String(20), nullable=False, comment="单据类型 direct-直销单 inbound-入库单 outbound-出库单")
  235. follow_status = Column(
  236. String(30),
  237. nullable=False,
  238. default="pending_arrange",
  239. comment="跟进状态 wait_notice-等通知 pending_arrange-待安排 arranged-已安排 completed-已完成 cancelled-已取消",
  240. )
  241. transport_status = Column(String(20), nullable=False, default="pending", comment="运输安排状态 pending-待安排 arranged-已安排")
  242. archive_status = Column(String(20), nullable=False, default="unarchived", comment="归档状态 unarchived-未归档 draft-已暂存 archived-已归档")
  243. complete_status = Column(String(10), nullable=False, default="no", comment="完成状态 yes-是 no-否")
  244. # 合同关联
  245. contract_id = Column(String(64), nullable=True, comment="CRM合同ID")
  246. contract_no = Column(String(50), nullable=True, comment="合同编号")
  247. # 供应商与目的地
  248. supplier_id = Column(String(64), nullable=True, comment="供应商ID")
  249. supplier_name = Column(String(200), nullable=True, comment="供应商名称")
  250. destination_id = Column(String(64), nullable=True, comment="目的地ID")
  251. destination_name = Column(String(200), nullable=True, comment="目的地名称")
  252. # 客户信息(冗余自合同)
  253. customer_id = Column(String(64), nullable=True, comment="客户ID")
  254. customer_name = Column(String(200), nullable=True, comment="客户名称")
  255. contact_name = Column(String(100), nullable=True, comment="联系人")
  256. contact_phone = Column(String(32), nullable=True, comment="联系电话")
  257. party_a = Column(String(200), nullable=True, comment="甲方")
  258. party_b = Column(String(200), nullable=True, comment="乙方")
  259. # 合同有效期
  260. contract_start_date = Column(Date, nullable=True, comment="合同开始日期")
  261. contract_end_date = Column(Date, nullable=True, comment="合同结束日期")
  262. # 送货与结算
  263. delivery_method = Column(String(20), nullable=True, comment="送货方式 self_pick-山峡自提 one_ticket-一票制 customer_pick-客户自提")
  264. settlement_method = Column(String(50), nullable=True, comment="结算方式")
  265. # 运输信息
  266. has_freight = Column(SmallInteger, nullable=False, default=0, comment="是否有运输费用 0-否 1-是")
  267. pickup_address = Column(String(500), nullable=True, comment="取货地址")
  268. pickup_lng = Column(DECIMAL(10, 6), nullable=True, comment="取货经度")
  269. pickup_lat = Column(DECIMAL(10, 6), nullable=True, comment="取货纬度")
  270. pickup_time = Column(DateTime, nullable=True, comment="取货时间")
  271. pickup_contact = Column(String(200), nullable=True, comment="取货联系方式")
  272. pickup_notes = Column(String(500), nullable=True, comment="取货注意事项")
  273. destination_address = Column(String(500), nullable=True, comment="目的地地址")
  274. destination_lng = Column(DECIMAL(10, 6), nullable=True, comment="送货经度")
  275. destination_lat = Column(DECIMAL(10, 6), nullable=True, comment="送货纬度")
  276. delivery_time = Column(DateTime, nullable=True, comment="送达时间")
  277. delivery_contact = Column(String(200), nullable=True, comment="送货联系方式")
  278. destination_notes = Column(String(500), nullable=True, comment="目的地注意事项")
  279. transport_id = Column(String(64), nullable=True, comment="运输ID")
  280. transport_no = Column(String(32), nullable=True, comment="运输编号")
  281. vehicle_id = Column(String(64), nullable=True, comment="车辆ID")
  282. license_plate = Column(String(20), nullable=True, comment="车牌号")
  283. trailer_no = Column(String(20), nullable=True, comment="挂车号(安排运输时快照)")
  284. driver_id = Column(String(64), nullable=True, comment="司机ID")
  285. driver_name = Column(String(100), nullable=True, comment="司机姓名")
  286. escort_id = Column(String(64), nullable=True, comment="押运员人员ID")
  287. escort_name = Column(String(100), nullable=True, comment="押运员姓名")
  288. escort_phone = Column(String(32), nullable=True, comment="押运员电话")
  289. personnel_summary = Column(String(500), nullable=True, comment="关联人员摘要(安排运输时快照)")
  290. resource_snapshot = Column(Text, nullable=True, comment="车辆/人员/证件整包快照 JSON")
  291. # 金额汇总
  292. total_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="计划总金额")
  293. freight_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运费合计")
  294. freight_remark = Column(String(512), nullable=True, comment="运费备注")
  295. # 通知信息
  296. notify_message = Column(Text, nullable=True, comment="通知信息(标准模板)")
  297. slip_template_content = Column(Text, nullable=True, comment="入库单打印模板内容(富文本HTML)")
  298. delivery_slip_template_content = Column(Text, nullable=True, comment="送(提)货单打印模板内容(富文本HTML)")
  299. subpack_slip_template_content = Column(Text, nullable=True, comment="分装单打印模板内容(富文本HTML)")
  300. subpack_slip_no = Column(String(32), nullable=True, comment="分装单号 NO:SXFZYYYYMMDD-序号")
  301. # 跟进人
  302. follow_user_id = Column(String(64), nullable=True, comment="跟进人ID")
  303. follow_user_name = Column(String(100), nullable=True, comment="跟进人姓名")
  304. # 危化品证书齐备(人工确认)
  305. hazard_cert_ready = Column(SmallInteger, nullable=False, default=0, comment="危化品证书是否已人工确认齐备 0-否 1-是")
  306. hazard_cert_ready_by = Column(String(64), nullable=True, comment="危化品证书确认人")
  307. hazard_cert_ready_time = Column(DateTime, nullable=True, comment="危化品证书确认时间")
  308. erp_entered = Column(SmallInteger, nullable=False, default=0, comment="是否已录入ERP 0-否 1-是")
  309. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  310. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  311. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  312. # 公共字段
  313. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  314. order_num = Column(Integer, nullable=True, comment="排序号")
  315. remark = Column(String(512), nullable=True, comment="备注")
  316. create_by = Column(String(64), nullable=True, comment="创建人id")
  317. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  318. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  319. update_by = Column(String(64), nullable=True, comment="更新人id")
  320. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  321. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  322. class PlPlanContract(Base):
  323. """运输计划-合同关联(分侧多选) pl_plan_contract"""
  324. __tablename__ = "pl_plan_contract"
  325. id = Column(String(64), primary_key=True, comment="主键ID")
  326. plan_id = Column(String(64), nullable=False, comment="运输计划ID")
  327. side = Column(String(20), nullable=False, comment="supplier-供方 demander-需方 load-装货 delivery-送货")
  328. stop_id = Column(String(64), nullable=True, comment="停靠段ID(装货段或送货段)")
  329. contract_id = Column(String(64), nullable=False, comment="CRM合同ID")
  330. contract_no = Column(String(50), nullable=True, comment="合同编号快照")
  331. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  332. order_num = Column(Integer, nullable=True, comment="排序号")
  333. remark = Column(String(512), nullable=True, comment="备注")
  334. create_by = Column(String(64), nullable=True, comment="创建人id")
  335. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  336. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  337. update_by = Column(String(64), nullable=True, comment="更新人id")
  338. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  339. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  340. class PlPlanProduct(Base):
  341. """计划产品明细表 pl_plan_product"""
  342. __tablename__ = "pl_plan_product"
  343. id = Column(String(64), primary_key=True, comment="主键ID")
  344. plan_id = Column(String(64), nullable=False, comment="计划ID")
  345. # 产品信息
  346. product_id = Column(String(64), nullable=False, comment="产品ID")
  347. product_no = Column(String(50), nullable=False, comment="产品编号")
  348. product_name = Column(String(200), nullable=False, comment="产品名称")
  349. brand_mode = Column(String(20), nullable=True, comment="required/any")
  350. brand_id = Column(String(64), nullable=True, comment="指定品牌ID")
  351. brand_name = Column(String(100), nullable=True, comment="品牌名快照")
  352. model = Column(String(100), nullable=True, comment="规格型号")
  353. unit = Column(String(20), nullable=False, default="吨", comment="单位")
  354. category_name = Column(String(200), nullable=True, comment="产品分类")
  355. package_spec = Column(String(200), nullable=True, comment="包装规格")
  356. delivery_method = Column(String(50), nullable=True, comment="送货方式")
  357. quantity = Column(DECIMAL(15, 3), nullable=True, comment="合同数量")
  358. actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
  359. tax_price = Column(DECIMAL(15, 4), nullable=True, comment="含税单价")
  360. tax_amount = Column(DECIMAL(15, 2), nullable=True, comment="税费")
  361. tax_subtotal = Column(DECIMAL(15, 2), nullable=True, comment="含税总价")
  362. # 产品属性(冗余自产品主数据)
  363. is_explosive = Column(SmallInteger, nullable=False, default=0, comment="是否易制爆 0-否 1-是")
  364. is_toxic = Column(SmallInteger, nullable=False, default=0, comment="是否易制毒 0-否 1-是")
  365. # 危化品证书(按 is_toxic / is_explosive 决定所需种类)
  366. purchase_cert_url = Column(String(2000), nullable=True, comment="购买证URL,逗号分隔")
  367. transport_cert_url = Column(String(2000), nullable=True, comment="运输证URL,逗号分隔")
  368. legal_use_cert_url = Column(String(2000), nullable=True, comment="合法使用证明URL,逗号分隔")
  369. # 入库信息
  370. inbound_estimate_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库预估数")
  371. inbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库数")
  372. inbound_price = Column(DECIMAL(15, 4), nullable=True, comment="入库价")
  373. inbound_amount = Column(DECIMAL(15, 2), nullable=True, comment="入库金额")
  374. # 出库信息
  375. outbound_estimate_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库预估数")
  376. outbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库数")
  377. outbound_price = Column(DECIMAL(15, 4), nullable=True, comment="出库单价")
  378. outbound_amount = Column(DECIMAL(15, 2), nullable=True, comment="出库金额")
  379. # 公共字段
  380. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  381. order_num = Column(Integer, nullable=True, comment="排序号")
  382. remark = Column(String(512), nullable=True, comment="备注")
  383. create_by = Column(String(64), nullable=True, comment="创建人id")
  384. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  385. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  386. update_by = Column(String(64), nullable=True, comment="更新人id")
  387. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  388. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  389. class PlPlanProductBrandQty(Base):
  390. """计划产品归档品牌数量 pl_plan_product_brand_qty
  391. stop_product_id 为空:计划产品级汇总;非空:装货/送货段产品行上的填写值。
  392. """
  393. __tablename__ = "pl_plan_product_brand_qty"
  394. id = Column(String(64), primary_key=True, comment="主键ID")
  395. plan_id = Column(String(64), nullable=False, comment="计划ID")
  396. plan_product_id = Column(String(64), nullable=False, comment="计划产品明细ID")
  397. stop_type = Column(String(20), nullable=True, comment="load/delivery,空=计划级汇总")
  398. stop_product_id = Column(String(64), nullable=True, comment="段产品行ID,空=计划级汇总")
  399. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,空串=无品牌键")
  400. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  401. qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌归档实际数量")
  402. unit_price = Column(DECIMAL(15, 4), nullable=True, comment="本品牌归档单价")
  403. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  404. order_num = Column(Integer, nullable=True, comment="排序号")
  405. remark = Column(String(512), nullable=True, comment="备注")
  406. create_by = Column(String(64), nullable=True, comment="创建人id")
  407. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  408. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  409. update_by = Column(String(64), nullable=True, comment="更新人id")
  410. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  411. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  412. class PlPlanChange(Base):
  413. """计划变更记录表 pl_plan_change"""
  414. __tablename__ = "pl_plan_change"
  415. id = Column(String(64), primary_key=True, comment="主键ID")
  416. plan_id = Column(String(64), nullable=False, comment="计划ID")
  417. change_type = Column(String(30), nullable=False, comment="变更类型")
  418. change_content = Column(Text, nullable=True, comment="变更内容")
  419. change_user_id = Column(String(64), nullable=True, comment="变更人ID")
  420. change_user_name = Column(String(100), nullable=True, comment="变更人姓名")
  421. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  422. order_num = Column(Integer, nullable=True, comment="排序号")
  423. remark = Column(String(512), nullable=True, comment="备注")
  424. create_by = Column(String(64), nullable=True, comment="创建人id")
  425. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  426. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  427. update_by = Column(String(64), nullable=True, comment="更新人id")
  428. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  429. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  430. class PlPlanLoad(Base):
  431. """运输计划-装货段 pl_plan_load(plan 1:1)"""
  432. __tablename__ = "pl_plan_load"
  433. id = Column(String(64), primary_key=True, comment="主键ID")
  434. plan_id = Column(String(64), nullable=False, comment="计划ID")
  435. customer_id = Column(String(64), nullable=True, comment="装货客户ID")
  436. customer_name = Column(String(200), nullable=True, comment="装货客户名称")
  437. address = Column(String(500), nullable=True, comment="装货地址")
  438. lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
  439. lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
  440. load_time = Column(DateTime, nullable=True, comment="装货时间")
  441. contact = Column(String(200), nullable=True, comment="联系方式")
  442. notes = Column(String(500), nullable=True, comment="注意事项")
  443. generate_dibang = Column(SmallInteger, nullable=False, default=0, comment="是否生成地磅单 0-否 1-是")
  444. dibang_direction = Column(String(20), nullable=True, comment="地磅方向 outbound-出库 inbound-入库 none-无")
  445. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  446. order_num = Column(Integer, nullable=True, comment="排序号")
  447. remark = Column(String(512), nullable=True, comment="备注")
  448. create_by = Column(String(64), nullable=True, comment="创建人id")
  449. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  450. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  451. update_by = Column(String(64), nullable=True, comment="更新人id")
  452. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  453. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  454. class PlPlanLoadProduct(Base):
  455. """运输计划-装货段产品明细 pl_plan_load_product"""
  456. __tablename__ = "pl_plan_load_product"
  457. id = Column(String(64), primary_key=True, comment="主键ID")
  458. load_id = Column(String(64), nullable=False, comment="装货段ID")
  459. plan_id = Column(String(64), nullable=False, comment="计划ID")
  460. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  461. product_id = Column(String(64), nullable=False, comment="产品ID")
  462. product_no = Column(String(50), nullable=False, comment="产品编号")
  463. product_name = Column(String(200), nullable=False, comment="产品名称")
  464. model = Column(String(100), nullable=True, comment="规格型号")
  465. unit = Column(String(20), nullable=False, default="吨", comment="单位")
  466. package_spec = Column(String(200), nullable=True, comment="包装规格")
  467. delivery_method = Column(String(50), nullable=True, comment="送货方式")
  468. plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="本段计划数量")
  469. inbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="入库数量(归档)")
  470. inbound_price = Column(DECIMAL(15, 4), nullable=True, comment="入库单价(归档)")
  471. inbound_amount = Column(DECIMAL(15, 2), nullable=True, comment="入库金额(归档)")
  472. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  473. order_num = Column(Integer, nullable=True, comment="排序号")
  474. remark = Column(String(512), nullable=True, comment="备注")
  475. create_by = Column(String(64), nullable=True, comment="创建人id")
  476. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  477. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  478. update_by = Column(String(64), nullable=True, comment="更新人id")
  479. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  480. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  481. class PlPlanDelivery(Base):
  482. """运输计划-送货段 pl_plan_delivery(plan 1:N)"""
  483. __tablename__ = "pl_plan_delivery"
  484. id = Column(String(64), primary_key=True, comment="主键ID")
  485. plan_id = Column(String(64), nullable=False, comment="计划ID")
  486. seq = Column(Integer, nullable=False, default=1, comment="顺序号(打印、链接展示)")
  487. customer_id = Column(String(64), nullable=True, comment="送货客户ID")
  488. customer_name = Column(String(200), nullable=True, comment="送货客户名称")
  489. address = Column(String(500), nullable=True, comment="送货地址")
  490. lng = Column(DECIMAL(10, 6), nullable=True, comment="经度")
  491. lat = Column(DECIMAL(10, 6), nullable=True, comment="纬度")
  492. delivery_time = Column(DateTime, nullable=True, comment="送货时间")
  493. contact = Column(String(200), nullable=True, comment="联系方式")
  494. notes = Column(String(500), nullable=True, comment="注意事项")
  495. generate_dibang = Column(SmallInteger, nullable=False, default=0, comment="是否生成地磅单 0-否 1-是")
  496. dibang_direction = Column(String(20), nullable=True, comment="地磅方向 outbound-出库 inbound-入库 none-无")
  497. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  498. order_num = Column(Integer, nullable=True, comment="排序号")
  499. remark = Column(String(512), nullable=True, comment="备注")
  500. create_by = Column(String(64), nullable=True, comment="创建人id")
  501. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  502. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  503. update_by = Column(String(64), nullable=True, comment="更新人id")
  504. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  505. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  506. class PlPlanDeliveryProduct(Base):
  507. """运输计划-送货段产品明细 pl_plan_delivery_product"""
  508. __tablename__ = "pl_plan_delivery_product"
  509. id = Column(String(64), primary_key=True, comment="主键ID")
  510. delivery_id = Column(String(64), nullable=False, comment="送货段ID")
  511. plan_id = Column(String(64), nullable=False, comment="计划ID")
  512. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  513. product_id = Column(String(64), nullable=False, comment="产品ID")
  514. product_no = Column(String(50), nullable=False, comment="产品编号")
  515. product_name = Column(String(200), nullable=False, comment="产品名称")
  516. model = Column(String(100), nullable=True, comment="规格型号")
  517. unit = Column(String(20), nullable=False, default="吨", comment="单位")
  518. package_spec = Column(String(200), nullable=True, comment="包装规格")
  519. delivery_method = Column(String(50), nullable=True, comment="送货方式")
  520. plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="本段计划数量")
  521. outbound_qty = Column(DECIMAL(15, 3), nullable=True, comment="出库数量(归档)")
  522. outbound_price = Column(DECIMAL(15, 4), nullable=True, comment="出库单价(归档)")
  523. outbound_amount = Column(DECIMAL(15, 2), nullable=True, comment="出库金额(归档)")
  524. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  525. order_num = Column(Integer, nullable=True, comment="排序号")
  526. remark = Column(String(512), nullable=True, comment="备注")
  527. create_by = Column(String(64), nullable=True, comment="创建人id")
  528. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  529. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  530. update_by = Column(String(64), nullable=True, comment="更新人id")
  531. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  532. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  533. # =============================================================================
  534. # 3. 运输管理:运输表、审批记录
  535. # =============================================================================
  536. class PlTransport(Base):
  537. """运输表 pl_transport"""
  538. __tablename__ = "pl_transport"
  539. id = Column(String(64), primary_key=True, comment="主键ID")
  540. transport_no = Column(String(32), nullable=False, unique=True, comment="运输编号 SXYS######")
  541. # 车辆与司机
  542. vehicle_id = Column(String(64), nullable=True, comment="车辆ID")
  543. license_plate = Column(String(20), nullable=True, comment="车牌号")
  544. trailer_no = Column(String(20), nullable=True, comment="挂车号(安排运输时快照)")
  545. driver_id = Column(String(64), nullable=True, comment="司机ID")
  546. driver_name = Column(String(100), nullable=True, comment="司机姓名")
  547. driver_phone = Column(String(32), nullable=True, comment="司机电话")
  548. escort_id = Column(String(64), nullable=True, comment="押运员人员ID")
  549. escort_name = Column(String(100), nullable=True, comment="押运员姓名")
  550. escort_phone = Column(String(32), nullable=True, comment="押运员电话")
  551. resource_snapshot = Column(Text, nullable=True, comment="车辆/人员/证件整包快照 JSON")
  552. # 承运商
  553. carrier_id = Column(String(64), nullable=True, comment="承运商ID")
  554. carrier_name = Column(String(200), nullable=True, comment="承运商名称")
  555. # 运输信息
  556. transport_medium = Column(String(100), nullable=True, comment="运输介质")
  557. start_point = Column(String(200), nullable=True, comment="运输起点")
  558. end_point = Column(String(200), nullable=True, comment="运输终点")
  559. distance_km = Column(DECIMAL(10, 2), nullable=True, comment="运输公里数")
  560. unit = Column(String(20), nullable=True, comment="计量单位 吨/趟")
  561. transport_qty = Column(DECIMAL(15, 3), nullable=True, comment="运输量(按重量计费基数)")
  562. # 运费
  563. freight_price = Column(DECIMAL(15, 4), nullable=True, comment="运输单价")
  564. freight_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运输费用")
  565. freight_type = Column(String(20), nullable=False, default="by_weight", comment="运费计算方式 by_weight-按重量 by_trip-按趟次")
  566. has_invoice = Column(SmallInteger, nullable=False, default=0, comment="是否开票 0-否 1-是")
  567. # 二维码
  568. qr_code = Column(String(500), nullable=True, comment="二维码内容")
  569. qr_expire_date = Column(Date, nullable=True, comment="二维码有效期")
  570. driver_access_token = Column(String(64), nullable=True, comment="司机免登录访问令牌")
  571. site_access_token = Column(String(64), nullable=True, comment="现场免登录访问令牌")
  572. # 运输状态
  573. transport_status = Column(String(20), nullable=False, default="draft", comment="运输状态 draft-草稿 pending-待执行 executing-执行中 completed-已完成 cancelled-已取消")
  574. approval_status = Column(String(20), nullable=False, default="none", comment="审批状态 none-无需 pending-审批中 approved-已通过 rejected-已拒绝")
  575. # 司机回传信息
  576. feedback_time = Column(DateTime, nullable=True, comment="回传时间")
  577. feedback_qty = Column(DECIMAL(15, 3), nullable=True, comment="回传数量")
  578. feedback_images = Column(Text, nullable=True, comment="回传图片URLs(JSON数组)")
  579. feedback_remark = Column(String(500), nullable=True, comment="回传备注")
  580. # 公共字段
  581. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  582. order_num = Column(Integer, nullable=True, comment="排序号")
  583. remark = Column(String(512), nullable=True, comment="备注")
  584. create_by = Column(String(64), nullable=True, comment="创建人id")
  585. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  586. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  587. update_by = Column(String(64), nullable=True, comment="更新人id")
  588. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  589. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  590. class PlTransportProductFeedback(Base):
  591. """运输单按产品回传 pl_transport_product_feedback"""
  592. __tablename__ = "pl_transport_product_feedback"
  593. id = Column(String(64), primary_key=True, comment="主键ID")
  594. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  595. plan_id = Column(String(64), nullable=False, comment="计划ID")
  596. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  597. actual_qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="该产品回传总量")
  598. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  599. order_num = Column(Integer, nullable=True, comment="排序号")
  600. remark = Column(String(512), nullable=True, comment="备注")
  601. create_by = Column(String(64), nullable=True, comment="创建人id")
  602. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  603. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  604. update_by = Column(String(64), nullable=True, comment="更新人id")
  605. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  606. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  607. class PlTransportProductBrandQty(Base):
  608. """运输单产品回传品牌数量 pl_transport_product_brand_qty"""
  609. __tablename__ = "pl_transport_product_brand_qty"
  610. id = Column(String(64), primary_key=True, comment="主键ID")
  611. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  612. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  613. feedback_id = Column(String(64), nullable=True, comment="产品回传行ID")
  614. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
  615. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  616. qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌数量")
  617. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  618. order_num = Column(Integer, nullable=True, comment="排序号")
  619. remark = Column(String(512), nullable=True, comment="备注")
  620. create_by = Column(String(64), nullable=True, comment="创建人id")
  621. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  622. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  623. update_by = Column(String(64), nullable=True, comment="更新人id")
  624. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  625. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  626. class PlTransportDbLink(Base):
  627. """运输-地磅出入库关联 pl_transport_db_link"""
  628. __tablename__ = "pl_transport_db_link"
  629. id = Column(String(64), primary_key=True, comment="主键ID")
  630. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  631. plan_id = Column(String(64), nullable=False, comment="运输计划ID")
  632. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  633. stop_type = Column(String(20), nullable=True, comment="停靠段类型 load-装货 delivery-送货")
  634. stop_id = Column(String(64), nullable=True, comment="停靠段ID")
  635. db_purchase_plan_id = Column(String(64), nullable=False, comment="地磅计划ID")
  636. db_inventory_id = Column(String(64), nullable=False, comment="出入库单ID")
  637. contributed_qty = Column(DECIMAL(15, 3), nullable=True, comment="本次联动贡献量(吨)")
  638. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  639. order_num = Column(Integer, nullable=True, comment="排序号")
  640. remark = Column(String(512), nullable=True, comment="备注")
  641. create_by = Column(String(64), nullable=True, comment="创建人id")
  642. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  643. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  644. update_by = Column(String(64), nullable=True, comment="更新人id")
  645. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  646. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  647. class PlPlanTransport(Base):
  648. """计划-运输关联表 pl_plan_transport"""
  649. __tablename__ = "pl_plan_transport"
  650. id = Column(String(64), primary_key=True, comment="主键ID")
  651. plan_id = Column(String(64), nullable=False, comment="计划ID")
  652. transport_id = Column(String(64), nullable=False, comment="运输ID")
  653. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  654. order_num = Column(Integer, nullable=True, comment="排序号")
  655. remark = Column(String(512), nullable=True, comment="备注")
  656. create_by = Column(String(64), nullable=True, comment="创建人id")
  657. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  658. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  659. update_by = Column(String(64), nullable=True, comment="更新人id")
  660. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  661. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  662. class PlTransportDriverStopFeedback(Base):
  663. """运输单-司机按段附件回传 pl_transport_driver_stop_feedback"""
  664. __tablename__ = "pl_transport_driver_stop_feedback"
  665. id = Column(String(64), primary_key=True, comment="主键ID")
  666. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  667. plan_id = Column(String(64), nullable=False, comment="计划ID")
  668. stop_type = Column(String(20), nullable=False, comment="停靠段类型 load-装货 delivery-送货")
  669. stop_id = Column(String(64), nullable=False, comment="停靠段ID")
  670. attachment_urls = Column(Text, nullable=True, comment="附件URLs(JSON数组)")
  671. product_feedbacks = Column(
  672. Text,
  673. nullable=True,
  674. comment="段产品回传 JSON:[{stopProductId,actualQty,brandQtys}]",
  675. )
  676. remark = Column(String(500), nullable=True, comment="备注")
  677. feedback_time = Column(DateTime, nullable=True, comment="回传时间")
  678. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  679. order_num = Column(Integer, nullable=True, comment="排序号")
  680. create_by = Column(String(64), nullable=True, comment="创建人id")
  681. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  682. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  683. update_by = Column(String(64), nullable=True, comment="更新人id")
  684. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  685. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  686. class PlTransportSiteStopFeedback(Base):
  687. """运输单-现场按段回传 pl_transport_site_stop_feedback"""
  688. __tablename__ = "pl_transport_site_stop_feedback"
  689. id = Column(String(64), primary_key=True, comment="主键ID")
  690. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  691. plan_id = Column(String(64), nullable=False, comment="计划ID")
  692. stop_type = Column(String(20), nullable=False, comment="停靠段类型 load-装货 delivery-送货")
  693. stop_id = Column(String(64), nullable=False, comment="停靠段ID")
  694. business_type = Column(String(20), nullable=False, comment="业务类型:入库/出库")
  695. quantity = Column(DECIMAL(15, 3), nullable=True, comment="现场回传数量")
  696. attachment_urls = Column(Text, nullable=True, comment="附件URLs(JSON数组)")
  697. product_feedbacks = Column(
  698. Text,
  699. nullable=True,
  700. comment="段产品回传 JSON:[{stopProductId,actualQty,brandQtys}]",
  701. )
  702. remark = Column(String(500), nullable=True, comment="备注")
  703. feedback_time = Column(DateTime, nullable=True, comment="回传时间")
  704. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  705. order_num = Column(Integer, nullable=True, comment="排序号")
  706. create_by = Column(String(64), nullable=True, comment="创建人id")
  707. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  708. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  709. update_by = Column(String(64), nullable=True, comment="更新人id")
  710. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  711. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  712. class PlTransportSiteLink(Base):
  713. """运输计划现场链接 pl_transport_site_link(与地磅出入库单解耦)"""
  714. __tablename__ = "pl_transport_site_link"
  715. id = Column(String(64), primary_key=True, comment="主键ID")
  716. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  717. plan_id = Column(String(64), nullable=False, comment="运输计划ID")
  718. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  719. site_access_token = Column(String(64), nullable=False, comment="现场人员免登录访问令牌")
  720. business_type = Column(String(20), nullable=False, comment="业务类型:入库/出库")
  721. partner_company = Column(String(200), nullable=True, comment="往来单位")
  722. product_id = Column(String(64), nullable=True, comment="CRM产品ID")
  723. product = Column(String(200), nullable=True, comment="产品名称快照")
  724. specification = Column(String(200), nullable=True, comment="规格快照")
  725. quantity = Column(DECIMAL(15, 3), nullable=True, comment="数量(吨)")
  726. vehicle_no = Column(String(32), nullable=True, comment="车牌号")
  727. plan_no = Column(String(64), nullable=True, comment="运输计划号")
  728. plan_date = Column(Date, nullable=True, comment="计划日期")
  729. site_feedback_remark = Column(String(500), nullable=True, comment="现场回执备注")
  730. site_feedback_images = Column(Text, nullable=True, comment="现场回执附件URLs(JSON数组)")
  731. site_feedback_time = Column(DateTime, nullable=True, comment="现场回执保存时间")
  732. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  733. order_num = Column(Integer, nullable=True, comment="排序号")
  734. remark = Column(String(512), nullable=True, comment="备注")
  735. create_by = Column(String(64), nullable=True, comment="创建人id")
  736. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  737. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  738. update_by = Column(String(64), nullable=True, comment="更新人id")
  739. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  740. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  741. class PlInboundOrder(Base):
  742. """运输计划-入库单 pl_inbound_order"""
  743. __tablename__ = "pl_inbound_order"
  744. id = Column(String(64), primary_key=True, comment="主键ID")
  745. order_no = Column(String(32), nullable=False, comment="入库单号")
  746. plan_id = Column(String(64), nullable=False, comment="运输计划ID")
  747. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  748. status = Column(String(20), nullable=False, default="in_progress", comment="in_progress/completed/voided")
  749. partner_company = Column(String(200), nullable=True, comment="往来单位快照")
  750. vehicle_no = Column(String(32), nullable=True, comment="车牌快照")
  751. plan_no = Column(String(64), nullable=True, comment="计划号快照")
  752. plan_date = Column(Date, nullable=True, comment="计划日期快照")
  753. site_access_token = Column(String(64), nullable=False, comment="现场免登录令牌")
  754. site_feedback_remark = Column(String(500), nullable=True, comment="现场备注")
  755. site_feedback_images = Column(Text, nullable=True, comment="现场附件URLs(JSON数组)")
  756. site_feedback_time = Column(DateTime, nullable=True, comment="最近现场提交时间")
  757. site_first_submitted_at = Column(DateTime, nullable=True, comment="首次现场提交时间")
  758. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  759. order_num = Column(Integer, nullable=True, comment="排序号")
  760. remark = Column(String(512), nullable=True, comment="备注")
  761. create_by = Column(String(64), nullable=True, comment="创建人id")
  762. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  763. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  764. update_by = Column(String(64), nullable=True, comment="更新人id")
  765. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  766. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  767. class PlInboundOrderItem(Base):
  768. """运输计划-入库单明细 pl_inbound_order_item"""
  769. __tablename__ = "pl_inbound_order_item"
  770. id = Column(String(64), primary_key=True, comment="主键ID")
  771. order_id = Column(String(64), nullable=False, comment="入库单ID")
  772. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  773. product_id = Column(String(64), nullable=True, comment="CRM产品ID")
  774. product_name = Column(String(200), nullable=True, comment="产品名称快照")
  775. specification = Column(String(200), nullable=True, comment="规格快照")
  776. unit = Column(String(32), nullable=True, comment="单位")
  777. plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="计划数量")
  778. actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
  779. qty_source = Column(String(20), nullable=True, default="plan", comment="plan/dibang/manual")
  780. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  781. order_num = Column(Integer, nullable=True, comment="排序号")
  782. remark = Column(String(512), nullable=True, comment="备注")
  783. create_by = Column(String(64), nullable=True, comment="创建人id")
  784. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  785. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  786. update_by = Column(String(64), nullable=True, comment="更新人id")
  787. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  788. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  789. class PlInboundOrderItemBrandQty(Base):
  790. """入库明细品牌数量 pl_inbound_order_item_brand_qty"""
  791. __tablename__ = "pl_inbound_order_item_brand_qty"
  792. id = Column(String(64), primary_key=True, comment="主键ID")
  793. order_id = Column(String(64), nullable=False, comment="入库单ID")
  794. order_item_id = Column(String(64), nullable=False, comment="入库明细ID")
  795. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  796. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
  797. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  798. qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌数量")
  799. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  800. order_num = Column(Integer, nullable=True, comment="排序号")
  801. remark = Column(String(512), nullable=True, comment="备注")
  802. create_by = Column(String(64), nullable=True, comment="创建人id")
  803. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  804. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  805. update_by = Column(String(64), nullable=True, comment="更新人id")
  806. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  807. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  808. class PlOutboundOrder(Base):
  809. """运输计划-出库单 pl_outbound_order"""
  810. __tablename__ = "pl_outbound_order"
  811. id = Column(String(64), primary_key=True, comment="主键ID")
  812. order_no = Column(String(32), nullable=False, comment="出库单号")
  813. plan_id = Column(String(64), nullable=False, comment="运输计划ID")
  814. transport_id = Column(String(64), nullable=False, comment="运输单ID")
  815. status = Column(String(20), nullable=False, default="in_progress", comment="in_progress/completed/voided")
  816. partner_company = Column(String(200), nullable=True, comment="往来单位快照")
  817. vehicle_no = Column(String(32), nullable=True, comment="车牌快照")
  818. plan_no = Column(String(64), nullable=True, comment="计划号快照")
  819. plan_date = Column(Date, nullable=True, comment="计划日期快照")
  820. site_access_token = Column(String(64), nullable=False, comment="现场免登录令牌")
  821. site_feedback_remark = Column(String(500), nullable=True, comment="现场备注")
  822. site_feedback_images = Column(Text, nullable=True, comment="现场附件URLs(JSON数组)")
  823. site_feedback_time = Column(DateTime, nullable=True, comment="最近现场提交时间")
  824. site_first_submitted_at = Column(DateTime, nullable=True, comment="首次现场提交时间")
  825. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  826. order_num = Column(Integer, nullable=True, comment="排序号")
  827. remark = Column(String(512), nullable=True, comment="备注")
  828. create_by = Column(String(64), nullable=True, comment="创建人id")
  829. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  830. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  831. update_by = Column(String(64), nullable=True, comment="更新人id")
  832. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  833. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  834. class PlOutboundOrderItem(Base):
  835. """运输计划-出库单明细 pl_outbound_order_item"""
  836. __tablename__ = "pl_outbound_order_item"
  837. id = Column(String(64), primary_key=True, comment="主键ID")
  838. order_id = Column(String(64), nullable=False, comment="出库单ID")
  839. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  840. product_id = Column(String(64), nullable=True, comment="CRM产品ID")
  841. product_name = Column(String(200), nullable=True, comment="产品名称快照")
  842. specification = Column(String(200), nullable=True, comment="规格快照")
  843. unit = Column(String(32), nullable=True, comment="单位")
  844. plan_qty = Column(DECIMAL(15, 3), nullable=True, comment="计划数量")
  845. actual_qty = Column(DECIMAL(15, 3), nullable=True, comment="实际数量")
  846. qty_source = Column(String(20), nullable=True, default="plan", comment="plan/dibang/manual")
  847. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  848. order_num = Column(Integer, nullable=True, comment="排序号")
  849. remark = Column(String(512), nullable=True, comment="备注")
  850. create_by = Column(String(64), nullable=True, comment="创建人id")
  851. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  852. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  853. update_by = Column(String(64), nullable=True, comment="更新人id")
  854. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  855. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  856. class PlOutboundOrderItemBrandQty(Base):
  857. """出库明细品牌数量 pl_outbound_order_item_brand_qty"""
  858. __tablename__ = "pl_outbound_order_item_brand_qty"
  859. id = Column(String(64), primary_key=True, comment="主键ID")
  860. order_id = Column(String(64), nullable=False, comment="出库单ID")
  861. order_item_id = Column(String(64), nullable=False, comment="出库明细ID")
  862. plan_product_id = Column(String(64), nullable=False, comment="计划产品行ID")
  863. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID")
  864. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  865. qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌数量")
  866. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  867. order_num = Column(Integer, nullable=True, comment="排序号")
  868. remark = Column(String(512), nullable=True, comment="备注")
  869. create_by = Column(String(64), nullable=True, comment="创建人id")
  870. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  871. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  872. update_by = Column(String(64), nullable=True, comment="更新人id")
  873. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  874. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  875. class PlTransportApproval(Base):
  876. """运输审批记录表 pl_transport_approval"""
  877. __tablename__ = "pl_transport_approval"
  878. id = Column(String(64), primary_key=True, comment="主键ID")
  879. transport_id = Column(String(64), nullable=False, comment="运输ID")
  880. approver_id = Column(String(64), nullable=False, comment="审批人ID")
  881. approver_name = Column(String(100), nullable=False, comment="审批人姓名")
  882. approval_order = Column(Integer, nullable=False, comment="审批顺序")
  883. status = Column(String(20), nullable=False, default="pending", comment="审批状态 pending-待审批 approved-已通过 rejected-已拒绝")
  884. comment = Column(String(500), nullable=True, comment="审批意见")
  885. approval_time = Column(DateTime, nullable=True, comment="审批时间")
  886. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  887. order_num = Column(Integer, nullable=True, comment="排序号")
  888. remark = Column(String(512), nullable=True, comment="备注")
  889. create_by = Column(String(64), nullable=True, comment="创建人id")
  890. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  891. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  892. update_by = Column(String(64), nullable=True, comment="更新人id")
  893. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  894. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  895. # =============================================================================
  896. # 4. 运费结算
  897. # =============================================================================
  898. class PlFreightSettlement(Base):
  899. """运费结算表 pl_freight_settlement"""
  900. __tablename__ = "pl_freight_settlement"
  901. id = Column(String(64), primary_key=True, comment="主键ID")
  902. settlement_no = Column(String(32), nullable=False, unique=True, comment="结算单编号")
  903. # 结算金额
  904. total_freight = Column(DECIMAL(15, 2), nullable=False, default=0, comment="运费合计")
  905. invoice_amount = Column(DECIMAL(15, 2), nullable=True, comment="发票金额")
  906. # 发票信息
  907. invoice_no = Column(String(50), nullable=True, comment="发票号")
  908. invoice_date = Column(Date, nullable=True, comment="开票日期")
  909. invoice_attachment_urls = Column(Text, nullable=True, comment="发票附件URLs,逗号分隔")
  910. # 结算状态
  911. settlement_status = Column(String(20), nullable=False, default="pending", comment="结算状态 pending-待提交 submitted-已提交 approved-审核通过 confirmed-已确认")
  912. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  913. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  914. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  915. # 公共字段
  916. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  917. order_num = Column(Integer, nullable=True, comment="排序号")
  918. remark = Column(String(512), nullable=True, comment="备注")
  919. create_by = Column(String(64), nullable=True, comment="创建人id")
  920. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  921. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  922. update_by = Column(String(64), nullable=True, comment="更新人id")
  923. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  924. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  925. class PlFreightSettlementApproval(Base):
  926. """运费结算审批 pl_freight_settlement_approval"""
  927. __tablename__ = "pl_freight_settlement_approval"
  928. id = Column(String(64), primary_key=True, comment="主键ID")
  929. settlement_id = Column(String(64), nullable=False, comment="结算单ID")
  930. step = Column(Integer, nullable=False, default=1, comment="步骤序号")
  931. step_name = Column(String(50), nullable=True, comment="步骤名称")
  932. approver_id = Column(String(64), nullable=False, comment="审批人ID")
  933. approver_name = Column(String(64), nullable=True, comment="审批人姓名")
  934. approval_type = Column(String(20), nullable=False, default="sequential", comment="审批类型")
  935. approval_result = Column(String(20), nullable=False, default="pending", comment="审批结果")
  936. approval_opinion = Column(String(500), nullable=True, comment="审批意见")
  937. approval_time = Column(DateTime, nullable=True, comment="审批时间")
  938. is_current = Column(SmallInteger, nullable=False, default=0, comment="是否当前节点")
  939. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  940. order_num = Column(Integer, nullable=True, comment="排序号")
  941. remark = Column(String(512), nullable=True, comment="备注")
  942. create_by = Column(String(64), nullable=True, comment="创建人id")
  943. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  944. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  945. update_by = Column(String(64), nullable=True, comment="更新人id")
  946. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  947. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  948. class PlFreightSettlementTransport(Base):
  949. """结算单-运输关联表 pl_freight_settlement_transport"""
  950. __tablename__ = "pl_freight_settlement_transport"
  951. id = Column(String(64), primary_key=True, comment="主键ID")
  952. settlement_id = Column(String(64), nullable=False, comment="结算单ID")
  953. transport_id = Column(String(64), nullable=False, comment="运输ID")
  954. freight_amount = Column(DECIMAL(15, 2), nullable=False, comment="运费金额")
  955. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  956. order_num = Column(Integer, nullable=True, comment="排序号")
  957. remark = Column(String(512), nullable=True, comment="备注")
  958. create_by = Column(String(64), nullable=True, comment="创建人id")
  959. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  960. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  961. update_by = Column(String(64), nullable=True, comment="更新人id")
  962. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  963. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  964. class PlRemittanceVoucher(Base):
  965. """汇款凭证表 pl_remittance_voucher"""
  966. __tablename__ = "pl_remittance_voucher"
  967. id = Column(String(64), primary_key=True, comment="主键ID")
  968. settlement_id = Column(String(64), nullable=False, comment="结算单ID")
  969. voucher_no = Column(String(32), nullable=True, comment="凭证编号")
  970. remittance_date = Column(Date, nullable=True, comment="汇款日期")
  971. remittance_amount = Column(DECIMAL(15, 2), nullable=True, comment="汇款金额")
  972. voucher_urls = Column(Text, nullable=True, comment="凭证文件URLs(JSON数组)")
  973. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  974. order_num = Column(Integer, nullable=True, comment="排序号")
  975. remark = Column(String(512), nullable=True, comment="备注")
  976. create_by = Column(String(64), nullable=True, comment="创建人id")
  977. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  978. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  979. update_by = Column(String(64), nullable=True, comment="更新人id")
  980. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  981. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  982. # =============================================================================
  983. # 5. 库存管理
  984. # =============================================================================
  985. class PlInventory(Base):
  986. """库存表 pl_inventory"""
  987. __tablename__ = "pl_inventory"
  988. id = Column(String(64), primary_key=True, comment="主键ID")
  989. product_id = Column(String(64), nullable=False, comment="产品ID")
  990. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
  991. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  992. product_no = Column(String(50), nullable=False, comment="产品编号")
  993. product_name = Column(String(200), nullable=False, comment="产品名称")
  994. model = Column(String(100), nullable=True, comment="规格型号")
  995. unit = Column(String(20), nullable=False, default="吨", comment="单位")
  996. # 库存数量与金额
  997. stock_qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="库存数量")
  998. stock_amount = Column(DECIMAL(15, 2), nullable=False, default=0, comment="库存金额")
  999. # 预警阈值
  1000. low_stock_warning = Column(DECIMAL(15, 3), nullable=True, comment="最低库存预警值")
  1001. high_stock_warning = Column(DECIMAL(15, 3), nullable=True, comment="最高库存预警值")
  1002. # 公共字段
  1003. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1004. order_num = Column(Integer, nullable=True, comment="排序号")
  1005. remark = Column(String(512), nullable=True, comment="备注")
  1006. create_by = Column(String(64), nullable=True, comment="创建人id")
  1007. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1008. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1009. update_by = Column(String(64), nullable=True, comment="更新人id")
  1010. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1011. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1012. class PlInventoryTransaction(Base):
  1013. """库存流水表 pl_inventory_transaction"""
  1014. __tablename__ = "pl_inventory_transaction"
  1015. id = Column(String(64), primary_key=True, comment="主键ID")
  1016. product_id = Column(String(64), nullable=False, comment="产品ID")
  1017. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
  1018. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  1019. product_name = Column(String(200), nullable=False, comment="产品名称")
  1020. transaction_type = Column(String(20), nullable=False, comment="事务类型 inbound-入库 outbound-出库")
  1021. plan_id = Column(String(64), nullable=True, comment="计划ID")
  1022. plan_no = Column(String(32), nullable=True, comment="计划编号")
  1023. # 数量与价格
  1024. qty = Column(DECIMAL(15, 3), nullable=False, comment="变动数量(正数入库/负数出库)")
  1025. unit_price = Column(DECIMAL(15, 4), nullable=False, comment="单价")
  1026. amount = Column(DECIMAL(15, 2), nullable=False, comment="金额")
  1027. stock_after = Column(DECIMAL(15, 3), nullable=False, comment="变动后库存")
  1028. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1029. order_num = Column(Integer, nullable=True, comment="排序号")
  1030. remark = Column(String(512), nullable=True, comment="备注")
  1031. create_by = Column(String(64), nullable=True, comment="创建人id")
  1032. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1033. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1034. update_by = Column(String(64), nullable=True, comment="更新人id")
  1035. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1036. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1037. class PlInventoryWarning(Base):
  1038. """库存预警表 pl_inventory_warning"""
  1039. __tablename__ = "pl_inventory_warning"
  1040. id = Column(String(64), primary_key=True, comment="主键ID")
  1041. product_id = Column(String(64), nullable=False, comment="产品ID")
  1042. brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
  1043. brand_name = Column(String(100), nullable=True, comment="品牌名称")
  1044. product_name = Column(String(200), nullable=False, comment="产品名称")
  1045. warning_type = Column(String(20), nullable=False, comment="预警类型 low-低于最低 high-高于最高")
  1046. current_qty = Column(DECIMAL(15, 3), nullable=False, comment="当前库存")
  1047. threshold_value = Column(DECIMAL(15, 3), nullable=False, comment="阈值")
  1048. status = Column(String(20), nullable=False, default="pending", comment="状态 pending-待处理 resolved-已处理")
  1049. resolve_time = Column(DateTime, nullable=True, comment="处理时间")
  1050. resolve_remark = Column(String(500), nullable=True, comment="处理备注")
  1051. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1052. order_num = Column(Integer, nullable=True, comment="排序号")
  1053. remark = Column(String(512), nullable=True, comment="备注")
  1054. create_by = Column(String(64), nullable=True, comment="创建人id")
  1055. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1056. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1057. update_by = Column(String(64), nullable=True, comment="更新人id")
  1058. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1059. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1060. class PlDocumentReminder(Base):
  1061. """证件到期提醒表 pl_document_reminder"""
  1062. __tablename__ = "pl_document_reminder"
  1063. id = Column(String(64), primary_key=True, comment="主键ID")
  1064. cert_id = Column(String(64), nullable=True, comment="证书ID")
  1065. owner_type = Column(String(20), nullable=True, comment="归属类型 vehicle/personnel")
  1066. owner_id = Column(String(64), nullable=True, comment="归属主体ID")
  1067. owner_label = Column(String(200), nullable=True, comment="归属展示名(车牌/姓名)")
  1068. driver_id = Column(String(64), nullable=True, comment="司机/人员ID(兼容)")
  1069. driver_name = Column(String(100), nullable=True, comment="司机/人员姓名(兼容)")
  1070. document_type = Column(String(100), nullable=False, comment="证件类型/证书名称")
  1071. document_no = Column(String(50), nullable=True, comment="证件号")
  1072. expire_date = Column(Date, nullable=False, comment="到期日期")
  1073. days_remaining = Column(Integer, nullable=False, comment="剩余天数")
  1074. status = Column(String(20), nullable=False, default="pending", comment="状态 pending-待处理 resolved-已处理")
  1075. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1076. order_num = Column(Integer, nullable=True, comment="排序号")
  1077. remark = Column(String(512), nullable=True, comment="备注")
  1078. create_by = Column(String(64), nullable=True, comment="创建人id")
  1079. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1080. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1081. update_by = Column(String(64), nullable=True, comment="更新人id")
  1082. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1083. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1084. class PlVehicleFuelRegister(Base):
  1085. """车辆加油登记 pl_vehicle_fuel_register"""
  1086. __tablename__ = "pl_vehicle_fuel_register"
  1087. id = Column(String(64), primary_key=True, comment="主键ID")
  1088. register_no = Column(String(32), nullable=False, unique=True, comment="登记单号")
  1089. fuel_category = Column(
  1090. String(20), nullable=False, comment="加油类别 bailian/gas_station/shanxia_factory(山峡)"
  1091. )
  1092. register_date = Column(Date, nullable=False, comment="日期")
  1093. registrant_id = Column(String(64), nullable=False, comment="登记人用户ID")
  1094. license_plate = Column(String(20), nullable=False, comment="车牌号")
  1095. odometer_km = Column(DECIMAL(10, 1), nullable=True, comment="期初公里数")
  1096. fuel_liters = Column(DECIMAL(10, 2), nullable=False, comment="加油升数")
  1097. fuel_tons = Column(DECIMAL(10, 3), nullable=True, comment="加油/吨(升÷1176)")
  1098. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1099. status = Column(String(20), nullable=False, default="normal", comment="状态")
  1100. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  1101. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  1102. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  1103. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1104. order_num = Column(Integer, nullable=True, comment="排序号")
  1105. remark = Column(String(512), nullable=True, comment="备注")
  1106. create_by = Column(String(64), nullable=True, comment="创建人id")
  1107. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1108. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1109. update_by = Column(String(64), nullable=True, comment="更新人id")
  1110. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1111. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1112. class PlVehicleRechargeApply(Base):
  1113. """车辆ETC/加油充值申请 pl_vehicle_recharge_apply"""
  1114. __tablename__ = "pl_vehicle_recharge_apply"
  1115. id = Column(String(64), primary_key=True, comment="主键ID")
  1116. apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
  1117. license_plate = Column(String(20), nullable=False, comment="车牌号")
  1118. recharge_type = Column(String(20), nullable=False, comment="充值类型 etc/fuel")
  1119. apply_date = Column(Date, nullable=False, comment="申请日期")
  1120. odometer_km = Column(DECIMAL(10, 1), nullable=True, comment="期初公里数")
  1121. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1122. applicant_id = Column(String(64), nullable=False, comment="申请人ID")
  1123. status = Column(
  1124. String(20),
  1125. nullable=False,
  1126. default="draft",
  1127. comment="draft/in_approval/rejected/disbursed/cancelled",
  1128. )
  1129. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  1130. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  1131. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  1132. wf_id = Column(String(64), nullable=True, comment="工作流定义ID")
  1133. current_node = Column(String(64), nullable=True, comment="当前节点ID")
  1134. approval_round = Column(Integer, nullable=False, default=0, comment="当前审批轮次")
  1135. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1136. order_num = Column(Integer, nullable=True, comment="排序号")
  1137. remark = Column(String(512), nullable=True, comment="备注")
  1138. create_by = Column(String(64), nullable=True, comment="创建人id")
  1139. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1140. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1141. update_by = Column(String(64), nullable=True, comment="更新人id")
  1142. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1143. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1144. class PlVehicleRechargeApproval(Base):
  1145. """车辆充值申请审批历史 pl_vehicle_recharge_approval"""
  1146. __tablename__ = "pl_vehicle_recharge_approval"
  1147. id = Column(String(64), primary_key=True, comment="主键ID")
  1148. apply_id = Column(String(64), nullable=False, comment="申请单ID")
  1149. approval_round = Column(Integer, nullable=False, default=1, comment="审批轮次")
  1150. node_id = Column(String(64), nullable=True, comment="节点ID快照")
  1151. node_name = Column(String(128), nullable=True, comment="节点名称快照")
  1152. approver_id = Column(String(64), nullable=False, comment="审批人用户ID")
  1153. approver_name = Column(String(64), nullable=False, comment="审批人姓名")
  1154. approval_status = Column(String(32), nullable=False, comment="approved/rejected/disbursed")
  1155. approval_opinion = Column(String(1024), nullable=True, comment="审批意见")
  1156. approval_time = Column(DateTime, nullable=False, comment="审批时间")
  1157. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1158. order_num = Column(Integer, nullable=True, comment="排序号")
  1159. remark = Column(String(512), nullable=True, comment="备注")
  1160. create_by = Column(String(64), nullable=True, comment="创建人id")
  1161. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1162. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1163. update_by = Column(String(64), nullable=True, comment="更新人id")
  1164. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1165. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1166. class PlVehicleMaintenanceApply(Base):
  1167. """车辆维保申请 pl_vehicle_maintenance_apply"""
  1168. __tablename__ = "pl_vehicle_maintenance_apply"
  1169. id = Column(String(64), primary_key=True, comment="主键ID")
  1170. apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
  1171. license_plate = Column(String(20), nullable=False, comment="车牌号")
  1172. applicant_id = Column(String(64), nullable=False, comment="申请人ID")
  1173. apply_date = Column(Date, nullable=False, comment="申请时间")
  1174. maintenance_type = Column(String(64), nullable=False, comment="维保类型")
  1175. start_date = Column(Date, nullable=False, comment="维保开始时间")
  1176. expected_pickup_date = Column(Date, nullable=True, comment="预计取车时间")
  1177. maintenance_content = Column(String(1000), nullable=True, comment="维保内容")
  1178. shop_address = Column(String(500), nullable=True, comment="维保店铺地址")
  1179. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1180. status = Column(String(20), nullable=False, default="pending", comment="申请状态")
  1181. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  1182. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  1183. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  1184. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1185. order_num = Column(Integer, nullable=True, comment="排序号")
  1186. remark = Column(String(512), nullable=True, comment="备注")
  1187. create_by = Column(String(64), nullable=True, comment="创建人id")
  1188. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1189. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1190. update_by = Column(String(64), nullable=True, comment="更新人id")
  1191. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1192. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1193. class PlVehicleMaintenanceProcess(Base):
  1194. """车辆维保处理登记 pl_vehicle_maintenance_process"""
  1195. __tablename__ = "pl_vehicle_maintenance_process"
  1196. id = Column(String(64), primary_key=True, comment="主键ID")
  1197. process_no = Column(String(32), nullable=False, unique=True, comment="处理单号")
  1198. apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
  1199. license_plate = Column(String(20), nullable=True, comment="车牌号冗余")
  1200. amount = Column(DECIMAL(10, 2), nullable=True, comment="金额")
  1201. handler_id = Column(String(64), nullable=False, comment="处理人ID")
  1202. process_date = Column(Date, nullable=False, comment="处理时间")
  1203. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1204. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1205. order_num = Column(Integer, nullable=True, comment="排序号")
  1206. remark = Column(String(512), nullable=True, comment="备注")
  1207. create_by = Column(String(64), nullable=True, comment="创建人id")
  1208. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1209. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1210. update_by = Column(String(64), nullable=True, comment="更新人id")
  1211. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1212. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1213. class PlVehicleUreaApply(Base):
  1214. """车辆尿素申请 pl_vehicle_urea_apply"""
  1215. __tablename__ = "pl_vehicle_urea_apply"
  1216. id = Column(String(64), primary_key=True, comment="主键ID")
  1217. apply_no = Column(String(32), nullable=False, unique=True, comment="申请单号")
  1218. license_plate = Column(String(20), nullable=False, comment="车牌号")
  1219. applicant_id = Column(String(64), nullable=False, comment="申请人ID")
  1220. apply_date = Column(Date, nullable=False, comment="申请时间")
  1221. warehouse_in_date = Column(Date, nullable=False, comment="入库时间")
  1222. unit = Column(String(32), nullable=False, comment="单位")
  1223. quantity = Column(DECIMAL(10, 2), nullable=False, comment="入库数")
  1224. apply_amount = Column(DECIMAL(10, 2), nullable=False, comment="申请金额")
  1225. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1226. status = Column(String(20), nullable=False, default="pending", comment="申请状态")
  1227. cancel_reason = Column(String(500), nullable=True, comment="作废原因")
  1228. cancel_time = Column(DateTime, nullable=True, comment="作废时间")
  1229. cancel_by = Column(String(64), nullable=True, comment="作废人ID")
  1230. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1231. order_num = Column(Integer, nullable=True, comment="排序号")
  1232. remark = Column(String(512), nullable=True, comment="备注")
  1233. create_by = Column(String(64), nullable=True, comment="创建人id")
  1234. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1235. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1236. update_by = Column(String(64), nullable=True, comment="更新人id")
  1237. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1238. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1239. class PlVehicleUreaDisburse(Base):
  1240. """车辆尿素发放登记 pl_vehicle_urea_disburse"""
  1241. __tablename__ = "pl_vehicle_urea_disburse"
  1242. id = Column(String(64), primary_key=True, comment="主键ID")
  1243. disburse_no = Column(String(32), nullable=False, unique=True, comment="发放单号")
  1244. apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
  1245. license_plate = Column(String(20), nullable=True, comment="车牌号冗余")
  1246. amount = Column(DECIMAL(10, 2), nullable=False, comment="发放金额")
  1247. handler_id = Column(String(64), nullable=False, comment="处理人ID")
  1248. disburse_date = Column(Date, nullable=False, comment="发放时间")
  1249. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1250. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1251. order_num = Column(Integer, nullable=True, comment="排序号")
  1252. remark = Column(String(512), nullable=True, comment="备注")
  1253. create_by = Column(String(64), nullable=True, comment="创建人id")
  1254. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1255. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1256. update_by = Column(String(64), nullable=True, comment="更新人id")
  1257. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1258. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1259. class PlOcrUsageMonth(Base):
  1260. """阿里云 OCR 月度调用计数 pl_ocr_usage_month(按自然月全局统计)"""
  1261. __tablename__ = "pl_ocr_usage_month"
  1262. id = Column(String(64), primary_key=True, comment="主键ID")
  1263. usage_month = Column(String(7), nullable=False, unique=True, comment="自然月 YYYY-MM")
  1264. used_count = Column(Integer, nullable=False, default=0, comment="当月已调用次数")
  1265. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1266. order_num = Column(Integer, nullable=True, comment="排序号")
  1267. remark = Column(String(512), nullable=True, comment="备注")
  1268. create_by = Column(String(64), nullable=True, comment="创建人id")
  1269. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1270. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1271. update_by = Column(String(64), nullable=True, comment="更新人id")
  1272. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1273. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
  1274. class PlVehicleRechargeRecord(Base):
  1275. """车辆ETC/加油充值发放登记 pl_vehicle_recharge_record"""
  1276. __tablename__ = "pl_vehicle_recharge_record"
  1277. id = Column(String(64), primary_key=True, comment="主键ID")
  1278. recharge_order_no = Column(String(32), nullable=False, unique=True, comment="充值订单号")
  1279. recharge_date = Column(Date, nullable=False, comment="充值日期")
  1280. recharge_type = Column(String(20), nullable=False, comment="充值类型")
  1281. card_no = Column(String(64), nullable=True, comment="卡号")
  1282. gas_station = Column(String(200), nullable=True, comment="加油站/渠道")
  1283. amount = Column(DECIMAL(10, 2), nullable=False, comment="充值金额")
  1284. attachment_urls = Column(String(2000), nullable=True, comment="附件URL")
  1285. apply_id = Column(String(64), nullable=True, unique=True, comment="关联申请单ID")
  1286. license_plate = Column(String(20), nullable=True, comment="车牌号冗余")
  1287. tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
  1288. order_num = Column(Integer, nullable=True, comment="排序号")
  1289. remark = Column(String(512), nullable=True, comment="备注")
  1290. create_by = Column(String(64), nullable=True, comment="创建人id")
  1291. create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
  1292. create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
  1293. update_by = Column(String(64), nullable=True, comment="更新人id")
  1294. update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
  1295. del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")