pl_models.py 98 KB

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