Files
ttx-project-doc/集波/SHOPEE_010_出库集波V1.2_WaveRuleMatchService_流程图.md
T

6.3 KiB

WaveRuleMatchService 当前流程图

对应当前 WaveRuleMatchService.groovy,不包含已删除的历史方法或未落地占位流程。

1. 总入口

assignShopeeWaveToAcceptedWorkStations(session, warehouseCode, workStationCode)
│
├─ 查询启用且可接单的拣选工作站
├─ 按空格口数降序、工作站 ID 升序
└─ for each workstation
   └─ matchByStation(session, workstation)
      ├─ 校验 status / warehouseCode / acceptStatus
      ├─ 获取 ruleLockKey(warehouseCode)
      ├─ ORDER_PICK
      │  └─ assignSingles
      └─ BATCH_PICK
         ├─ 操作员技能与工作站 waveRule 取交集
         ├─ fillShortage
         └─ 无补单结果时按 ticketType 分流
            ├─ 1/5 → assignTaskTicket
            ├─ 2/3/4 → assignOrder
            └─ 6 → assignRt

2. 快速拣选

assignSingles(warehouseCode, workstation)
├─ findSingleEmptyCells
├─ findSingleShipments
└─ for each shipment
   ├─ findShipmentExt
   ├─ 波次号来源
   │  ├─ 已有 shopeeWaveCode → 复用
   │  ├─ RT → shipmentCode
   │  └─ 其他 → acquireWave
   ├─ RT → backfillRtShopeeWaveCode
   ├─ 已有外部波次号 → createInternalShopeeWave
   ├─ occupySingleCell
   ├─ createWave
   ├─ syncShopeePickingTaskAndFilterAcceptedShipments(ticketType)
   │  └─ RT 跳过外部调用
   ├─ updateLocalShopeeWaveBinding(ruleCode='')
   └─ addToWave

3. 任务单

assignTaskTicket(warehouseCode, workstation, rule, ticketType)
│  ticketType = SALES_TASK / MTO_TASK
│
├─ findSingleEmptyCells(workstation.id, rule)
├─ findTaskTicketShipments
└─ for each shipment
   ├─ 读取 shipment_header_ext1.shopeeWaveCode
   ├─ createInternalShopeeWave
   ├─ occupySingleCell
   ├─ createWave
   ├─ syncShopeePickingTaskAndFilterAcceptedShipments(ticketType)
   ├─ updateLocalShopeeWaveBinding
   └─ addToWave

4. 普通订单

assignOrder(warehouseCode, workstation, rule, ticketType)
│  ticketType = SALES_ORDER / RTS / MTO_ORDER
│
├─ findUnusedCells(workstation.id, rule)
└─ 首个可用格口
   ├─ findAvailableShipments
   ├─ hasEmptyCellMinShipments
   ├─ acquireWave
   └─ assignAcquiredWaveToCell
      └─ assignToCell

5. RT

assignRt(warehouseCode, workstation, rule)
├─ findSingleEmptyCells(workstation.id, rule)
├─ findRtTicketShipments
└─ for each shipment
   ├─ shipmentCode 作为本地 Shopee 波次号
   ├─ backfillRtShopeeWaveCode
   ├─ occupySingleCell
   ├─ createWave
   ├─ updateLocalShopeeWaveBinding
   └─ addToWave

RT 不申请接口号段,不调用 Shopee picking task 外部接口。

6. 缺口补单

fillShortage(warehouseCode, workstation)
├─ findShortage(workstation.id)
│  └─ 只选择关联 shopee_wave.status=200 的格口
└─ for each cell
   ├─ 按 currentWaveRule 读取启用规则
   ├─ calcNeedQty
   ├─ 记录需补单格口处理日志
   ├─ resolveBoundShipmentGroup
   ├─ findAvailableShipmentBatch(..., shopeeWaveCode, groupKey)
   └─ assignToCell

7. 单格口分配

assignToCell(...)
├─ 获取 cellLockKey(cell.id)
├─ pickCellShipments
├─ occupyCell
├─ createWave
├─ Shopee 同步
│  ├─ 新格口 → syncShopeePickingTaskAndFilterAcceptedShipments
│  └─ 同波次补单 → syncShopeeAppendOrderAndFilterAcceptedShipments
├─ bindBatchShipmentWave
│  ├─ waveBindLockKey
│  ├─ isWaveAvailable
│  └─ updateLocalShopeeWaveBinding
├─ addToWave
├─ 达到 maxShipments → status=FULL
└─ finally unlock

8. Shopee 同步

syncShopeePickingTaskAndFilterAcceptedShipments(..., ticketType)
├─ RT → 返回 acceptedIds,不调用外部接口
└─ 其他类型
   ├─ sendShopeePickingTaskRequest
   ├─ updateShopeeWaveStartPickUploadStatus
   ├─ resolveKickedShipmentIds
   ├─ markKickOut
   └─ writePickingTaskSyncWaveCode
syncShopeeAppendOrderAndFilterAcceptedShipments(...)
├─ sendShopeeAppendOrderRequest
├─ resolveKickedShipmentIds
├─ markKickOut
└─ 返回 acceptedIds

9. 波次号与本地绑定

acquireWave(warehouseCode, ticketType)
├─ waveAcquireLockKey(ticketType)
└─ shopee_wave
   ├─ ticketType 匹配
   ├─ sourceType=INTERFACE
   ├─ waveDate >= now - 10 hours
   ├─ status=UNUSED
   └─ order by rand() limit 1
createInternalShopeeWave(shopeeWaveCode, ticketType)
├─ code + ticketType 已存在 → success
└─ 不存在 → 创建 INTERNAL / USING 记录
updateLocalShopeeWaveBinding(...)
├─ resolveShipmentTicketType
├─ sortingWallCellLockKey(cell.id)
├─ 更新 wcs_sorting_wall_cell
├─ 更新内部 wave
└─ 更新 shopee_wave.status

10. 失败处理

格口占用失败       → 返回错误
createWave 失败    → releaseSingleCell
Shopee 同步失败    → releaseSingleCell + cancelWave
Shopee 踢单        → markKickOut
本地绑定失败       → releaseSingleCell + cancelWave
addToWave 失败     → releaseSingleCell + cancelWave

11. 方法映射

方法 当前职责
assignShopeeWaveToAcceptedWorkStations 工作站扫描与调度
matchByStation 单工作站统一入口
assignSingles 快速拣选
assignTaskTicket SALES_TASK / MTO_TASK
assignOrder SALES_ORDER / RTS / MTO_ORDER
assignRt RT 专用分流
fillShortage USING 波次格口补单
assignToCell 普通订单单格口完整分配
assignAcquiredWaveToCell 使用已取得号段进入单格口分配
createWave 创建内部 wave
addToWave 加单并运行内部 wave
updateLocalShopeeWaveBinding 回写格口、内部 wave、shopee_wave
bindBatchShipmentWave 普通订单波次校验与本地绑定
acquireWave 从接口号段池选择 UNUSED 号段
createInternalShopeeWave 补建单据已有波次号记录
backfillRtShopeeWaveCode RT 本地波次记录维护
releaseSingleCell 释放无未完成任务的格口
cancelWave 取消失败内部 wave