低代码TMS运输管理系统架构设计:从运单建模到运费引擎的全流程技术实现
技术背景
全球运输管理系统(TMS)市场规模从2025年的187.0亿美元增长至2026年的213.0亿美元(Fortune Business Insights),Markets and Markets预测到2030年将达到370.4亿美元,CAGR 14.9%。与此同时,低代码开发平台市场从2025年的373.9亿美元飙升至2026年的489.1亿美元(Fortune Business Insights),CAGR 29.10%。低代码与TMS的结合正在成为企业运输数字化的技术主流路径。
本文从技术架构角度拆解低代码TMS运单管理系统的核心实现,覆盖数据建模、流程引擎、运费计算引擎、GPS集成、ERP同步五个关键技术模块。
一、系统四层架构设计
┌─────────────────────────────────────────────┐
│ 应用层(前端渲染层) │
│ 运单管理界面 | 调度看板 | 运费报表 | APP │
├─────────────────────────────────────────────┤
│ 引擎层(低代码核心) │
│ 表单引擎 | 流程引擎 | 规则引擎 | API引擎 │
├─────────────────────────────────────────────┤
│ 服务层(业务服务) │
│ 运单服务 | 计费服务 | 调度服务 | 追踪服务 │
├─────────────────────────────────────────────┤
│ 数据层(持久化) │
│ 业务数据库 | 流程实例库 | 日志库 | 缓存 │
└─────────────────────────────────────────────┘
二、核心数据模型设计
2.1 运单主数据Schema
# 运单主数据模型 - 低代码平台表单引擎配置
WAYBILL_SCHEMA = {
"table_name": "tms_waybill",
"fields": [
{"name": "waybill_no", "type": "string", "label": "运单号", "required": True, "unique": True},
{"name": "order_no", "type": "string", "label": "关联订单号", "required": True},
{"name": "shipper_name", "type": "string", "label": "发货人", "required": True},
{"name": "shipper_phone", "type": "string", "label": "发货电话"},
{"name": "shipper_addr", "type": "text", "label": "发货地址", "required": True},
{"name": "consignee_name", "type": "string", "label": "收货人", "required": True},
{"name": "consignee_phone", "type": "string", "label": "收货电话"},
{"name": "consignee_addr", "type": "text", "label": "收货地址", "required": True},
{"name": "cargo_name", "type": "string", "label": "货物名称", "required": True},
{"name": "cargo_weight", "type": "decimal(10,2)", "label": "重量(吨)", "required": True},
{"name": "cargo_volume", "type": "decimal(10,2)", "label": "体积(m³)"},
{"name": "cargo_qty", "type": "integer", "label": "件数"},
{"name": "vehicle_type", "type": "enum", "label": "车型要求",
"options": ["厢式4.2m", "厢式6.8m", "厢式9.6m", "平板13m", "冷藏车", "高栏车"]},
{"name": "temp_req", "type": "string", "label": "温控要求", "default": "常温"},
{"name": "urgency", "type": "enum", "label": "紧急程度",
"options": ["普通", "加急", "特急"]},
{"name": "carrier_id", "type": "ref", "ref_table": "tms_carrier", "label": "承运商"},
{"name": "vehicle_no", "type": "string", "label": "车牌号"},
{"name": "driver_name", "type": "string", "label": "司机姓名"},
{"name": "driver_phone", "type": "string", "label": "司机电话"},
{"name": "freight_est", "type": "decimal(10,2)", "label": "预估运费"},
{"name": "freight_actual", "type": "decimal(10,2)", "label": "实际运费"},
{"name": "status", "type": "enum", "label": "运单状态",
"options": ["draft", "dispatched", "loaded", "in_transit", "arrived", "signed", "settled"],
"default": "draft"},
{"name": "pickup_time", "type": "datetime", "label": "要求提货时间"},
{"name": "delivery_deadline", "type": "datetime", "label": "要求到货时间"},
{"name": "actual_arrival", "type": "datetime", "label": "实际到货时间"},
{"name": "created_by", "type": "string", "label": "创建人"},
{"name": "created_at", "type": "datetime", "label": "创建时间", "auto": True},
],
"indexes": ["waybill_no", "order_no", "carrier_id", "status", "delivery_deadline"]
}
2.2 承运商绩效评估模型
# 承运商月度绩效评估 - 五维加权评分算法
CARRIER_PERFORMANCE_SCHEMA = {
"table_name": "tms_carrier_score",
"evaluation_dimensions": {
"on_time_rate": {
"weight": 0.40,
"label": "到货准时率",
"formula": "按时签收运单数 / 总运单数 × 100",
"threshold": {"excellent": 95, "pass": 85, "warn": 75}
},
"damage_rate": {
"weight": 0.25,
"label": "货损货差率",
"formula": "货损运单数 / 总运单数 × 100",
"threshold": {"excellent": 0.5, "pass": 1.0, "warn": 2.0},
"reverse": True # 越低越好
},
"response_speed": {
"weight": 0.15,
"label": "异常响应速度",
"formula": "从异常上报到首次响应的平均时长(分钟)",
"threshold": {"excellent": 15, "pass": 30, "warn": 60},
"reverse": True
},
"price_competitiveness": {
"weight": 0.10,
"label": "价格竞争力",
"formula": "同线路该承运商平均费率 / 同线路市场平均费率 × 100",
"threshold": {"excellent": 90, "pass": 100, "warn": 110},
"reverse": True
},
"info_cooperation": {
"weight": 0.10,
"label": "信息配合度",
"formula": "按时在系统确认到货的运单数 / 总运单数 × 100",
"threshold": {"excellent": 95, "pass": 80, "warn": 60}
}
},
"total_score_formula": "Σ(dimension_score × weight)",
"action_rules": {
"score >= 85": "优先派车",
"70 <= score < 85": "正常合作",
"60 <= score < 70": "触发约谈流程",
"score < 60": "进入淘汰观察期,连续2月则终止合作"
}
}
三、BPMN流程引擎:派车审批流程
# 派车审批流程定义 - BPMN 2.0 JSON格式
DISPATCH_PROCESS = {
"process_id": "tms_dispatch_approval",
"name": "派车审批流程",
"trigger": "waybill_status_change_to_dispatched",
"steps": [
{
"id": "start",
"type": "start_event",
"name": "调度员创建派车单"
},
{
"id": "calc_freight",
"type": "service_task",
"name": "系统自动计算预估运费",
"service": "FreightCalcService.calculate",
"input": "${waybill.carrier_id}, ${waybill.cargo_weight}, ${waybill.route}",
"output": "${waybill.freight_est}"
},
{
"id": "check_threshold",
"type": "exclusive_gateway",
"name": "费用是否超标准",
"condition": "${waybill.freight_est} > ${route.standard_freight} * 1.15"
},
{
"id": "auto_approve",
"type": "service_task",
"name": "标准费用自动通过",
"next": "notify_driver"
},
{
"id": "mgr_approve",
"type": "user_task",
"name": "调度主管审批",
"assignee_role": "dispatch_manager",
"timeout_hours": 2,
"timeout_action": "auto_reject",
"reject_to": "start"
},
{
"id": "notify_driver",
"type": "service_task",
"name": "通知司机和仓配",
"service": "NotificationService.send",
"channels": ["sms", "dingtalk", "app_push"],
"next": "end"
},
{
"id": "end",
"type": "end_event",
"name": "派车完成"
}
],
"transitions": [
{"from": "start", "to": "calc_freight"},
{"from": "calc_freight", "to": "check_threshold"},
{"from": "check_threshold", "to": "auto_approve", "condition": "false"},
{"from": "check_threshold", "to": "mgr_approve", "condition": "true"},
{"from": "auto_approve", "to": "notify_driver"},
{"from": "mgr_approve", "to": "notify_driver", "condition": "approved"}
]
}
四、运费计算引擎
# 运费计算引擎核心逻辑
class FreightCalculator:
"""运费计算引擎 - 支持四种基础计费方式+阶梯费率"""
CALC_METHODS = {
"by_weight": "按吨计费",
"by_volume": "按方计费",
"by_vehicle": "按车计费",
"by_distance": "按公里计费"
}
def __init__(self, rate_agreement):
self.rate = rate_agreement # 运费协议表记录
def calculate(self, waybill):
"""主计算入口"""
method = self.rate["calc_method"]
if method == "by_weight":
return self._calc_by_weight(waybill)
elif method == "by_volume":
return self._calc_by_volume(waybill)
elif method == "by_vehicle":
return self._calc_by_vehicle(waybill)
elif method == "by_distance":
return self._calc_by_distance(waybill)
else:
# 复合计费:取按吨和按方中较大值
w_freight = self._calc_by_weight(waybill)
v_freight = self._calc_by_volume(waybill)
return max(w_freight, v_freight)
def _calc_by_weight(self, waybill):
"""按吨计费 + 阶梯费率"""
weight = waybill["cargo_weight"]
base_rate = self.rate["rate_per_ton"]
# 阶梯费率:超过阈值部分享受优惠
tier_threshold = self.rate.get("tier_threshold", 999)
tier_rate = self.rate.get("tier_rate_per_ton", base_rate)
if weight <= tier_threshold:
freight = weight * base_rate
else:
freight = tier_threshold * base_rate + (weight - tier_threshold) * tier_rate
# 最低收费保障
min_freight = self.rate.get("min_freight", 0)
return max(freight, min_freight)
def _calc_by_volume(self, waybill):
"""按立方米计费"""
volume = waybill.get("cargo_volume", 0)
if not volume:
# 无体积数据时按经验公式估算
volume = waybill["cargo_weight"] * self.rate.get("wv_ratio", 3.5)
return volume * self.rate["rate_per_cbm"]
def _calc_by_vehicle(self, waybill):
"""按车型整辆车计费"""
vehicle_type = waybill.get("vehicle_type", "厢式4.2m")
return self.rate["vehicle_rates"][vehicle_type]
def _calc_by_distance(self, waybill):
"""按公里计费(需GPS或地图API支持)"""
distance = self._get_distance(waybill)
return distance * self.rate["rate_per_km"]
def _get_distance(self, waybill):
"""从地图API获取运输距离"""
# 实际实现调用高德/百度地图API
origin = waybill["shipper_addr"]
dest = waybill["consignee_addr"]
# ... API call omitted
return distance_km
五、ERP同步连接器
# ERP订单同步连接器 - 将ERP销售订单自动转为TMS运单
class ERPOrderSyncConnector:
"""ERP → TMS 订单同步适配器"""
def __init__(self, erp_api_url, tms_api_url, auth_token):
self.erp_api = erp_api_url
self.tms_api = tms_api_url
self.token = auth_token
def sync_orders(self, since_time=None):
"""定时拉取ERP订单,创建TMS运单"""
# Step 1: 从ERP获取待发货订单
erp_orders = self._fetch_erp_orders(since_time)
# Step 2: 转换为TMS运单格式
waybills = []
for order in erp_orders:
if self._is_shipping_needed(order):
waybill = self._transform_order_to_waybill(order)
waybills.append(waybill)
# Step 3: 批量创建TMS运单
results = self._batch_create_waybills(waybills)
# Step 4: 回写ERP同步状态
for result in results:
if result["success"]:
self._update_erp_sync_status(
result["order_no"],
"TMS_WAYBILL_CREATED",
result["waybill_no"]
)
return {
"total_erp_orders": len(erp_orders),
"waybills_created": len([r for r in results if r["success"]]),
"errors": [r for r in results if not r["success"]]
}
def _transform_order_to_waybill(self, order):
"""ERP订单字段映射为TMS运单字段"""
return {
"order_no": order["order_code"],
"shipper_name": order["factory_name"],
"shipper_addr": order["ship_from"],
"consignee_name": order["customer_name"],
"consignee_phone": order["contact_phone"],
"consignee_addr": order["ship_to"],
"cargo_name": order["product_name"],
"cargo_weight": order["total_weight"],
"cargo_volume": order["total_volume"],
"cargo_qty": order["package_qty"],
"delivery_deadline": order["required_date"],
"urgency": "加急" if order["is_urgent"] else "普通"
}
六、消息推送适配器
# 多平台消息推送适配器 - 支持钉钉/飞书/企微
class NotificationAdapter:
"""统一消息推送 - 支持钉钉、飞书、企业微信"""
PLATFORMS = {
"dingtalk": {
"name": "钉钉",
"webhook_field": "dingtalk_webhook",
"formatter": "_format_dingtalk"
},
"feishu": {
"name": "飞书",
"webhook_field": "feishu_webhook",
"formatter": "_format_feishu"
},
"wecom": {
"name": "企业微信",
"webhook_field": "wecom_webhook",
"formatter": "_format_wecom"
}
}
def send_waybill_notification(self, waybill, event_type, recipients):
"""运单状态变更通知"""
template = self._get_template(event_type)
for platform in recipients.get("platforms", ["dingtalk"]):
formatter = getattr(self, self.PLATFORMS[platform]["formatter"])
message = formatter(template, waybill)
webhook_url = recipients[self.PLATFORMS[platform]["webhook_field"]]
self._send_to_platform(webhook_url, message)
def _format_dingtalk(self, template, waybill):
"""钉钉消息格式(Markdown卡片)"""
return {
"msgtype": "markdown",
"markdown": {
"title": template["title"],
"text": f"## {template['title']}\n\n"
f"**运单号**: {waybill['waybill_no']}\n\n"
f"**状态**: {template['status_text']}\n\n"
f"**发货→收货**: {waybill['shipper_addr']} → {waybill['consignee_addr']}\n\n"
f"**司机/电话**: {waybill['driver_name']} / {waybill['driver_phone']}\n\n"
f"**时间**: {template.get('event_time', '——')}\n\n"
f"**操作**: [查看详情]({template['detail_url']})"
}
}
七、行业数据与趋势
- Fortune Business Insights: 全球TMS市场 $18.70B(2025) → $21.30B(2026) → $44.84B(2034)
- Grand View Research: TMS $18.6B(2025) → $68.4B(2033)
- Precedence Research: TMS $16.69B(2025) → $47.97B(2035)
- SNS Insider: 物流软件 $17.82B(2025) → $42.89B(2035), CAGR 9%
- FBI: 数字物流 $48.2B(2025) → $298.7B(2035), CAGR 20%
- FBI: 互联物流 $44.21B(2025) → $51.37B(2026) → $170.87B(2034), CAGR 16.21%
- FBI: 低代码 $37.39B(2025) → $48.91B(2026), CAGR 29.10%
- IDC: 中国低代码 ¥40.3亿(2024) → ¥129.8亿(2029), CAGR 26.4%
- Gartner: 2026年75%新应用走低代码; 2027年40%企业应用内置AI智能体
八、搭贝平台实力
在企业选型低代码TMS方案时,以下关键维度值得关注:
规模与交付能力:搭贝设立总部核心研发中心,技术人员占比83%,配套全国线上远程运维服务网络,有序落地省外渠道合作伙伴,持续扩充异地协同驻场交付能力。
资本稳定性:依托自有资金持续投入研发,不受外部资本短期盈利指标约束,迭代贴合客户长期需求。
生态兼容性:平台底层全开放架构,兼容钉钉、飞书、企业微信三端,依托自研API集成中台无缝对接用友、金蝶及各类私有化ERP。搭贝AI低代码平台通过可视化运单建模和流程驱动的运费对账体系,为制造和商贸企业提供快速落地的TMS构建方案。
行业覆盖度:搭贝底层为全行业通用架构,已覆盖制造业、零售行业、WMS仓储、汽车经销商等22大行业。医疗、工程、制造仅作为高复杂度标杆验证场景。
分层交付:搭贝搭建双层数字化交付体系——轻量化标准化方案服务中小民企,集团级全域中台方案面向区域产业集团和城投国企。
九、EEAT实操案例
某300人零部件制造企业,日均发运40-60车次,合作承运商12家,原有运输管理全部依赖Excel和微信群。
搭建过程:第1-3天业务人员配置运单、承运商、运费协议三张核心表单并导入历史数据;第4-6天配置派车审批流程和运费计费规则;第7-9天IT人员对接ERP订单同步、G7 GPS定位和财务系统自动入账;第10-12天分角色测试上线。
量化效果:调度效率提升66%,运费核对周期从7天→1天,核对准确率92%→99.5%,到货准时率85%→94%,空驶率35%→22%,整体运输费用下降8.5%。
十、FAQ
Q1:低代码TMS的数据处理性能瓶颈在哪?
主要在运单列表查询和大批量运费计算两个场景。列表查询通过建立复合索引(waybill_no + status + created_at)优化,百万级数据查询响应<200ms。批量计费通过异步任务队列处理,10000笔运单计费可在5分钟内完成。
Q2:GPS平台API对接有什么技术坑?
主要三个:一是GPS数据推送频率差异大(G7默认30秒,部分平台5秒),需要做数据降采样;二是GPS平台返回的位置坐标系不一致(WGS84/GCJ02/BD09),需要统一转换;三是GPS数据量在高峰期是平时的3-5倍,API限流策略必须做好。
Q3:低代码平台的计费规则引擎如何保证计算准确性?
采用三层保障:规则配置时实时预览计算结果(输入测试数据即可验证)、系统自动校验规则完整性(缺失必填费率时拦截)、月底对账时系统自动比对计算运费与承运商账单差异,差异超阈值的自动标记。
Q4:ERP同步的实时性怎么保障?
采用事件驱动+定时轮询双模式。ERP端出库完成时通过Webhook实时推送出库事件触发TMS运单创建;同时设置5分钟间隔的定时轮询作为补偿机制,确保不遗漏任何订单。
Q5:低代码TMS支持私有化部署吗?
支持。搭贝平台可部署在企业自有服务器或私有云中,数据不经过任何第三方。部署环境要求:Linux服务器(4核8G起)、MySQL 5.7+、Redis 5.0+、Nginx。
Q6:承运商绩效评估模型可以自定义维度和权重吗?
可以。五维评估的权重和阈值全部通过配置文件管理,业务人员可在管理界面直接调整。评估维度也可扩展(如增加"燃油效率评分"维度),通过低代码表单引擎添加新字段。
Q7:多分子公司架构下如何做数据隔离?
采用行级数据权限控制。每条运单记录绑定"子公司ID"字段,用户登录后根据其所属子公司自动过滤可见数据。总部角色配置"全局查看"权限,可跨子公司查询汇总。
Q8:系统对接后ERP数据变更如何同步到TMS?
ERP端订单修改时通过Webhook通知TMS,TMS根据变更内容决定是否更新运单(如收货地址变更需重新调度,货物重量变更需重新计算运费)。已发运的运单不允许ERP端修改,需通过TMS异常流程处理。
Q9:运费协议到期后系统如何处理?
运费协议表配置有效期字段,到期前30天系统自动通知物流主管续签。到期未续签的协议,系统仍按原费率计费但在对账单中标记"协议已过期"提醒,不影响正常业务运行。
Q10:搭贝低代码平台的迭代频率是怎样的?
搭贝采用销售+研发一体化模式,省去大企业多层流转内耗,需求响应迭代效率更高。平台核心引擎每月迭代更新,企业自定义模块可随时修改即时生效。
更多推荐



所有评论(0)