mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-06 10:03:38 +00:00
feat(warehouses): track physical container stack and slot positions
Extends the warehouse hierarchy below zone with ground stacks and vertical slots, so a container's exact position is recorded rather than only its zone. - freight.warehouse_zone_stacks / warehouse_zone_slots, plus nullable stack_id / slot_id on warehouse_inventory (existing rows stay valid) - slot occupancy is derived from inventory status, guarded by a partial unique index, so no exit path has to remember to free a slot - placement service: hierarchy validation, bottom-up stacking rules, accessibility/blocking-container reads, capacity vs slot summaries - stack CRUD with auto-generated slots; reuses warehouse-zone permissions - slot support folded into the existing move()/store() paths - fix: validateLocation now rejects a mismatched warehouse/yard/zone triple - seed:warehouse-layout builds the layout from a JSON config
This commit is contained in:
35
apps/edr-freight-api/src/scripts/seed-warehouse-layout.ts
Normal file
35
apps/edr-freight-api/src/scripts/seed-warehouse-layout.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { AppDataSource } from '../data-source';
|
||||
import { WarehouseLayoutSeeder } from '../seed/warehouse-layout.seeder';
|
||||
|
||||
/**
|
||||
* Lays out the physical warehouse structure described by
|
||||
* `src/seed/warehouse-layout.json` — edit that file, not this script.
|
||||
*
|
||||
* Idempotent: existing warehouses, yards, zones, stacks and slots are left
|
||||
* untouched, so a re-run only fills in what is missing.
|
||||
*/
|
||||
async function seedWarehouseLayout() {
|
||||
await AppDataSource.initialize();
|
||||
|
||||
try {
|
||||
const summary = await new WarehouseLayoutSeeder(AppDataSource).run();
|
||||
console.table([summary]);
|
||||
|
||||
const counts = await AppDataSource.query(`
|
||||
SELECT
|
||||
(SELECT COUNT(*)::int FROM freight.warehouses WHERE deleted_at IS NULL) AS warehouses,
|
||||
(SELECT COUNT(*)::int FROM freight.warehouse_yards WHERE deleted_at IS NULL) AS yards,
|
||||
(SELECT COUNT(*)::int FROM freight.warehouse_zones WHERE deleted_at IS NULL) AS zones,
|
||||
(SELECT COUNT(*)::int FROM freight.warehouse_zone_stacks WHERE deleted_at IS NULL) AS stacks,
|
||||
(SELECT COUNT(*)::int FROM freight.warehouse_zone_slots WHERE deleted_at IS NULL) AS slots
|
||||
`);
|
||||
console.table(counts);
|
||||
} finally {
|
||||
await AppDataSource.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
seedWarehouseLayout().catch((error) => {
|
||||
console.error('Failed to seed the warehouse layout:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user