pl_models.py 94 KB

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