Files
FTC25009/docs/superpowers/plans/2026-07-14-warehouse-03-cargo-spaces.md

108 lines
4.0 KiB
Markdown

# Warehouse 03 Cargo Spaces Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Create the five-floor warehouse 03 dense-storage layout shown in the supplied diagram, with stable status values and lane-level `group_coding`.
**Architecture:** Add one safe, one-time SQL migration that seeds warehouse/roadway metadata, derives every valid coordinate from compact layout ranges, classifies equipment and mother-channel nodes, and inserts five floors inside a transaction. The migration refuses to overwrite existing warehouse 03 data and aborts unless all expected totals, status counts, coordinate uniqueness rules, and lane grouping rules pass.
**Tech Stack:** SQL Server T-SQL, `dbo.bas_warehouse`, `dbo.bas_roadway`, `dbo.bas_cargo_space`, RuoYi dictionary tables.
---
### Task 1: Add the warehouse 03 layout migration
**Files:**
- Create: `sql/20260714_warehouse_03_cargo_spaces.sql`
- [x] **Step 1: Encode the valid diagram footprint**
Create an in-memory layout from these inclusive column ranges. `the_platoon` is the diagram's horizontal 排 coordinate and `the_column` is its vertical 列 coordinate.
```sql
insert into @footprint(the_column, platoon_from, platoon_to)
values
(1,1,3),(2,1,3),(3,1,3),
(4,1,5),(4,9,13),
(5,1,7),(5,9,13),
(6,1,13),
(7,1,13),(8,1,13),(9,1,13),(10,1,13),(11,1,13),
(12,1,13),(13,1,13),(14,1,13),(15,1,13),(16,1,13),
(17,1,13),(18,1,13),(19,1,13),(20,1,13),(21,1,13),
(22,1,5),(22,9,13),(23,9,13),(24,9,13);
```
- [x] **Step 2: Classify all five floors**
Use the eight-digit ID `03 + 排(2) + 列(2) + 层(2)`. Apply statuses in this precedence order:
```sql
case
when the_platoon = 7 and the_column in (5,21) then '7'
when the_platoon = 7 and the_column in (6,20) then '8'
when the_column in (7,13,19)
or (the_platoon = 7 and the_column between 7 and 19) then '9'
else '1'
end
```
Set `this_cargo_area` to zones 1-8 for ordinary storage coordinates. Leave equipment and mother-channel nodes unzoned.
- [x] **Step 3: Assign stable lane groups**
For ordinary positions only, define a lane as the same warehouse, 排, floor, and one of the four storage bands `01-06`, `08-12`, `14-18`, or `20-25`. Use that lane's lowest existing cargo-space ID as `group_coding`; special nodes keep `group_coding = NULL`.
```sql
min(cargo_space_id) over (
partition by the_platoon, the_floor, channel_band
)
```
- [x] **Step 4: Seed metadata and insert atomically**
Insert warehouse `03` as `密集库`, roadway `1` as `密集库巷道`, and dictionary values 7/8/9 when missing. Refuse to overwrite existing warehouse 03 cargo-space rows; insert all generated rows in one transaction.
### Task 2: Verify the generated data
**Files:**
- Verify: `sql/20260714_warehouse_03_cargo_spaces.sql`
- [x] **Step 1: Run the migration against FTC25009-WMS**
Run the SQL through the configured project SQL Server connection. Expected result: one committed transaction and `1295` warehouse 03 rows.
- [x] **Step 2: Verify totals and status distribution**
```sql
select status, count(*)
from dbo.bas_cargo_space
where warehouse_id = '03'
group by status;
```
Expected: status 1 = 1030, status 7 = 10, status 8 = 10, status 9 = 245.
- [x] **Step 3: Verify IDs and lane grouping**
```sql
select count(*) as invalid_ids
from dbo.bas_cargo_space
where warehouse_id = '03'
and cargo_space_id not like '03[0-9][0-9][0-9][0-9][0-9][0-9]';
select count(distinct group_coding) as lane_groups
from dbo.bas_cargo_space
where warehouse_id = '03' and status = '1';
```
Expected: `invalid_ids = 0` and `lane_groups = 240` (48 physical lanes on each of five floors).
- [ ] **Step 4: Commit**
```bash
git add docs/superpowers/plans/2026-07-14-warehouse-03-cargo-spaces.md sql/20260714_warehouse_03_cargo_spaces.sql
git commit -m "feat: add warehouse 03 cargo spaces"
```
Only perform this step when the user explicitly requests a Git commit.