派发 —— 计划方下发至执行方

当计划方的单据进入可执行状态时,派发承载相应的作业释放事件。执行方接收后将其展开为现场作业任务,并分配给工人、机器人或设备。

事件类型

类型

在计划方触发的条件

SHIPPER_RELEASED

出库单进入可拣货状态。

RECEIVER_EXPECTED

由 PO 或 ASN 创建了收货单。

WORKORDER_RELEASED

工单释放以待执行。

TRANSFER_OUT_RELEASED

调拨单在源仓库确认。

TRANSFER_IN_EXPECTED

调拨单进入运输中,目的地为本仓库。

VASORDER_RELEASED

增值服务(VAS)订单释放。

REFURBISH_ORDER_RELEASED

翻新工单释放。

CANCELLED

之前已释放的单据被取消、修改或重新排定优先级。

派发载荷以内联方式完整携带 Routing 配方 —— 有序的 Operation 列表,每个 Operation 附带预期时间/成本、BOM 增量及技能/资源要求。执行方在运行期不需要回调计划方拉取配方。理由参见 WMS ADR-0022 amendment 2026-05-24 与 ADR-0028。

典型的 v1 Routing(3–8 个 Operation)载荷远小于 10 KB;超 50 个 Operation 的复杂 Routing 接近 100 KB。下文两种传输都能承受。

选择传输方式

计划方与执行方对每个仓库选择一种传输方式。同一仓库不支持混用多种传输。

传输方式

选择时机

实现成本

Webhook POST

默认方式。计划方将每个事件 POST 到执行方注册的 URL。

低。仅需出站 HTTPS 加对消息体计算 HMAC。

Kafka 订阅

双方都能访问同一个 Kafka 集群,并希望使用有序、高吞吐的流式传输。

中。需共享 Kafka 访问权限并约定 topic 归属。

轮询

执行方无法接受入站请求,或计划方无法向共享 Kafka 发布。由执行方从计划方托管的队列拉取。

中。计划方暴露 /dispatch/pending 与 /dispatch/ack 两个端点。

对大多数第三方集成,推荐默认使用 Webhook。当双方部署在共享云基础设施中时,Kafka 更具吸引力。轮询则面向仅允许一侧出站 HTTPS 的受限网络。

顺序

顺序仅在每个仓库内保证,不做全局保序。

  • Kafka —— 分区键为 warehouse_frn。同一仓库的事件落入同一分区,并按发布顺序被消费。

  • Webhook —— 按 (planner_id, warehouse_id) 维度串行投递。前一个事件被确认或最终进入死信队列之前,同一仓库的下一个事件不会被发送。

  • 轮询 —— 计划方按内部游标返回有序事件。执行方必须严格按序处理每一页,且仅在持久化处理完成后才确认。

不保证跨仓库的顺序,业务也不应依赖此保证。如果计划方在同一毫秒内向不同仓库释放了两个出库单,执行方观察到的先后顺序可能任意。

投递语义

至少一次。计划方必须假设任一次投递都可能失败并被重试;因此执行方必须基于 (planner_id, correlation_id) 实现幂等 —— 参见幂等性与顺序。

Webhook 典型重试策略:

0s → 5s → 30s → 2m → 10m → 1h → ... → 24h cap → DLQ

重试持续失败 24 小时后,计划方将事件投入死信队列;通常会触发主管告警并由其处置。

Kafka 与轮询都依赖消费者自身的提交 / 确认语义 —— 计划方会重新投递最后已提交游标之后的所有事件。

取消、修改与重新排序

这三类操作都以 CANCELLED 事件的形式呈现,并引用原 correlation_id。语义被有意合并为同一种类型,以简化执行方的处理:进行中的单据停止、尚未开始的待执行任务丢弃,必要时等待新的释放事件。

修改与重新排序以一个 CANCELLED 加一个带新 correlation_id 的释放事件(如 SHIPPER_RELEASED、WORKORDER_RELEASED 等)的形式到达。执行方不得尝试修改进行中的作业 —— 只有新的释放事件才会产生新任务。

Webhook 载荷结构

{
  "kind": "SHIPPER_RELEASED",
  "correlation_id": "01J7Y6K1NQ3W2C0X4V0R5T6E7N",
  "planner_id": "fgai-wms",
  "warehouse_id": "WH-Tokyo-01",
  "document_ref": { "type": "SHIPPER", "id": "SH-2026-000183" },
  "routing": {
    "ops": [
      { "op_id": "op-1", "kind": "PICK", "sku": "SKU-WIDGET-RED-LG", "qty": 12, "from_location": "A.12.3.1" },
      { "op_id": "op-2", "kind": "PACK", "carton": "CTN-S" },
      { "op_id": "op-3", "kind": "SHIP", "dock": "DOCK-3" }
    ],
    "expected_duration_seconds": 420
  },
  "meta": {
    "released_at": "2026-05-24T03:14:01Z",
    "priority": "NORMAL"
  }
}

correlation_id 是合作方生成的幂等键 —— UUID v4 或 v7。完整载荷模式见 OpenAPI 参考;不同事件类型在 routing 与 meta 块上有所差异,但信封结构保持不变。

派发信封上的标签绑定(v1.3+)

根据 WES ADR-0022,自 OpenAPI v1.3 起,每个 *_RELEASED 信封(Shipper、Receiver、WorkOrder、Transfer-Out、Transfer-In)都会新增一个可选的 label_bindings[] 数组。计划方在派发时预打印标签(模式 A / B / C)时提供该数组;在 PackStation 后打印(模式 D / E)或使用外部/承运商已提供标签(模式 H)时,该数组不存在或为空。

"label_bindings": [
  {
    "label_id": "1Z999AA10123456784",
    "external_label_uri": "https://carrier.example/track/1Z999AA10123456784",
    "bound_to_type": "shipper",
    "bound_to_id": "SH-2026-000183",
    "print_mode": "pre-pick"
  }
]

print_mode 枚举:pre-pick | post-pick | external | at-cartonization(v1.4,根据 WES ADR-0023 —— 装箱机带标签子模式)。

bound_to_type 枚举:shipper | container | tote | slot | work_order_output | cluster | external。

9 种模式和端到端流程示例见 标签打印指南;at-cartonization 子模式见 高级装箱指南。

dispatch.label-issued.v1(v1.3+)

新的派发类事件用于闭合后打印往返流程(模式 D / E 以及装箱机带标签子模式)。执行方在实时反馈通道发出 label_print_requested 后,计划方通过同步 POST /wes/v1/labels/issue 端点返回响应,随后发布携带结果 label_bindings[] 的 dispatch.label-issued.v1。执行方将其视为对现有绑定行执行 print_state=printed 的 upsert。

{
  "kind": "DISPATCH_LABEL_ISSUED",
  "correlation_id": "01J7Y6K2NQ3W2C0X4V0R5T6E7M",
  "planner_id": "fgai-wms",
  "warehouse_id": "WH-Tokyo-01",
  "in_response_to_label_print_request_uuid": "01J7Y6K1NQ3W2C0X4V0R5T6E7Q",
  "label_bindings": [ ... ]
}

Webhook 接收方必须在解析前对原始请求体校验 X-FGAI-Signature: sha256=<hex> 头 —— 参见身份认证。

轮询模式结构

GET  /wes/v1/dispatch/pending?since={cursor}&limit=100
POST /wes/v1/dispatch/ack    { "cursor": "..." }

计划方返回一页有序的派发事件及 next_cursor。执行方完成持久化处理后,将游标 POST 到 /dispatch/ack。下一次 GET /dispatch/pending?since={cursor} 即跳过已确认事件。

若未确认,下一次拉取时计划方仍返回相同的一页。每页大小有限,next_cursor 不为空时请立即再次拉取。

Cancellation Outcome — Order-Level Aggregation

Per wes-contract ADR-0002 §3 + amendment 2026-05-28.

When the executor acknowledges a dispatch.cancelled.v1 event, the response carries a cancel_outcome enum plus binding-level breakdown arrays (custody_confirmed_for[], compensation_initiated_for[]). Because an Order can be bound to multiple Tasks (N:1 cardinality per WES ADR-0013 §1), the Order-level outcome is an aggregation across all bound Tasks.

Aggregation rule

Bound-Task states at cancel time

Order-level cancel_outcome

All bindings ACCEPTED (every Task was pre-custody and accepted the cancel)

ACCEPTED

All bindings TOO_LATE (every Task was past custody at cancel time)

TOO_LATE

Mixed — some bindings ACCEPTED, some TOO_LATE

ACCEPTED_PARTIAL

Any binding UNKNOWN (executor cannot determine state)

UNKNOWN (most-conservative aggregation)

The UNKNOWN rule is intentionally conservative: a single binding the executor cannot evaluate poisons the Order-level outcome, surfacing the case for supervisor reconciliation rather than reporting partial success that the planner might trust.

Sub-line binary rule

Within a single order_line_no, custody confirmation is binary. An order_line_no appears in custody_confirmed_for[] ONLY when the ENTIRE quantity of that line has crossed the Scheme's custody primitive. Sub-line partial physical confirmation (for example, an operator has voice-checked 1 of 3 SKU-99 from a split-bin sub-pick WorkItem before the cancellation arrives) routes the whole line through compensation_initiated_for[].

Rationale (per ADR-0002 §3 amendment 2026-05-28):

  • WorkItem IDs are WES-internal and not meaningful to the planner; the wire shape must not leak them.

  • The planner reasons about Order line items, not sub-line execution micro-state.

  • Any sub-line physical inventory is recoverable via the compensation flow's RecoveryStationArtifact disposition, so collapsing partial-line state to compensation widens the recovery surface in a planner-meaningful way.

This rule is uniform across all Schemes (Shipper, Receiver, WorkOrder, TransferOut, TransferIn) and is not per-Scheme-overridable.

Consequence: there is no "partially confirmed line" representation in the wire payload. A line either qualifies entirely for custody_confirmed_for[] or it routes entirely through compensation_initiated_for[].

Operational walkthrough

See the Cancellation guide for an end-to-end walkthrough — how the executor evaluates per-binding state, populates the two arrays, and signals the Order-level outcome the supervisor UI consumes.