fix: decouple manual tidy from vehicle assignment

This commit is contained in:
zgw
2026-07-24 11:37:43 +08:00
parent 947edbdbc8
commit 8b84459072
11 changed files with 240 additions and 66 deletions

View File

@@ -30,12 +30,16 @@ On every manual tidy reconciliation cycle, WMS first performs workflow recovery
WMS asks the planner for candidates only when at least one slot exists. It starts at most the calculated number of workflows in planner order. No candidate is paired with a snapshot row, and no `vehicle_id` update is issued. WCS later receives the ordinary move job and chooses the actual vehicle using its existing dispatch rules.
The manual scheduling cycle is one database transaction. `TidyModeService.reconcile` reads the warehouse's `alg.tidy_mode` row with `UPDLOCK, HOLDLOCK`; keeping that lock until the scheduling transaction commits serializes capacity calculation and workflow creation for the same warehouse across WMS instances. Different warehouses continue to use different mode rows.
## Failure Handling
If the WCS snapshot URL is absent, the request fails, the response is empty, or the response cannot be parsed, the snapshot client returns an empty list. The calculated idle count is then zero, so WMS creates no new manual tidy workflows during that cycle. Existing workflows and WCS queues continue independently and can still complete.
This fail-closed behavior avoids building an unbounded WCS queue when real-time fleet availability is unknown. Operators can distinguish this condition through the existing snapshot warning log.
If any workflow creation fails, the scheduler logs the candidate type and propagates the exception. The complete scheduling batch rolls back so a partial batch cannot consume capacity outside the locked count. The next scheduled cycle can retry from a consistent database state.
## Compatibility
The existing `alg.tidy_workflow.vehicle_id` column, SQL Server index include, and diagnostic projection remain in place for schema and historical-data compatibility. Runtime code stops reading or writing the column for new manual tidy scheduling. No WCS API or database migration is required.
@@ -64,5 +68,7 @@ The implementation must prove the following behavior with tests written before p
4. Offline, unhealthy, and busy vehicles do not produce slots.
5. Manual scheduling starts workflows in planner order without reading or writing vehicle bindings.
6. The default configured maximum is `3`.
7. The scheduling cycle has a rollback transaction that holds the existing warehouse mode-row lock.
8. Workflow creation failures propagate and prevent later candidates in the same batch from starting.
Focused tests must pass before running the full Maven reactor test suite and package build.