Files
edr-platform/apps/edr-freight-api/src/modules/warehouses/warehouses.module.ts
Hagernesh a6ea1a48ac 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
2026-08-28 16:09:41 +00:00

146 lines
6.6 KiB
TypeScript

import { Module, forwardRef } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { registerExchangeModule } from '../exchange-settings/exchange-module-options';
import { BillingModule } from '../billing/billing.module';
import { DocumentsModule } from '../billing/documents/documents.module';
import { FilesModule } from '../files/files.module';
import { InterchangeDocumentsModule } from '../interchange-documents/interchange-documents.module';
import { LastMileModule } from '../last-mile/last-mile.module';
import { NotificationsModule } from '../notifications/notifications.module';
import { NotificationInboxModule } from '../notification-inbox/notification-inbox.module';
import { SignaturesModule } from '../signatures/signatures.module';
import { WarehouseActivityLog } from './entities/warehouse-activity-log.entity';
import { WarehouseAllocationRule } from './entities/warehouse-allocation-rule.entity';
import { WarehouseFeeRule } from './entities/warehouse-fee-rule.entity';
import { WarehouseInspectionReport } from './entities/warehouse-inspection-report.entity';
import { WarehouseInventory } from './entities/warehouse-inventory.entity';
import { BookingHandover } from './entities/booking-handover.entity';
import { HandoverService } from './handover.service';
import { WarehouseInventoryMovement } from './entities/warehouse-inventory-movement.entity';
import { WarehouseLoading } from './entities/warehouse-loading.entity';
import { WarehouseYard } from './entities/warehouse-yard.entity';
import { WarehouseZone } from './entities/warehouse-zone.entity';
import { WarehouseZoneSlot } from './entities/warehouse-zone-slot.entity';
import { WarehouseZoneStack } from './entities/warehouse-zone-stack.entity';
import { Warehouse } from './entities/warehouse.entity';
import { SchedulingReadFacade } from './scheduling-read.facade';
import { WarehouseActivityLogRepository } from './warehouse-activity-log.repository';
import { WarehouseActivityLogService } from './warehouse-activity-log.service';
import { WarehouseDashboardService } from './warehouse-dashboard.service';
import { WarehouseInspectionController } from './warehouse-inspection.controller';
import { WarehouseInspectionRepository } from './warehouse-inspection.repository';
import { WarehouseInspectionService } from './warehouse-inspection.service';
import { WarehouseInventoryController } from './warehouse-inventory.controller';
import { WarehouseInventoryMovementRepository } from './warehouse-inventory-movement.repository';
import { WarehouseInventoryRepository } from './warehouse-inventory.repository';
import { WarehouseInventoryService } from './warehouse-inventory.service';
import { WarehouseLoadingRepository } from './warehouse-loading.repository';
import { WarehouseLoadingsController } from './warehouse-loadings.controller';
import { WarehouseReleaseDocumentService } from './warehouse-release-document.service';
import { WarehouseAllocationRuleRepository } from './warehouse-allocation-rule.repository';
import { WarehouseAllocationService } from './warehouse-allocation.service';
import { WarehouseFeeRuleRepository } from './warehouse-fee-rule.repository';
import { WarehouseFeeService } from './warehouse-fee.service';
import { WarehouseInvoiceController } from './warehouse-invoice.controller';
import { WarehouseInvoiceService } from './warehouse-invoice.service';
import { WarehouseRulesController } from './warehouse-rules.controller';
import { WarehouseSchedulingAdapterService } from './warehouse-scheduling-adapter.service';
import { WarehouseYardsController } from './warehouse-yards.controller';
import { WarehouseYardsRepository } from './warehouse-yards.repository';
import { WarehouseYardsService } from './warehouse-yards.service';
import { WarehousePlacementService } from './warehouse-placement.service';
import { WarehouseZoneSlotsRepository } from './warehouse-zone-slots.repository';
import { WarehouseZoneStacksController } from './warehouse-zone-stacks.controller';
import { WarehouseZoneStacksRepository } from './warehouse-zone-stacks.repository';
import { WarehouseZoneStacksService } from './warehouse-zone-stacks.service';
import { WarehouseZonesController } from './warehouse-zones.controller';
import { WarehouseZonesRepository } from './warehouse-zones.repository';
import { WarehouseZonesService } from './warehouse-zones.service';
import { WarehousesController } from './warehouses.controller';
import { WarehousesRepository } from './warehouses.repository';
import { WarehousesService } from './warehouses.service';
@Module({
imports: [
TypeOrmModule.forFeature([
Warehouse,
WarehouseYard,
WarehouseZone,
WarehouseZoneStack,
WarehouseZoneSlot,
WarehouseInventory,
WarehouseInventoryMovement,
WarehouseActivityLog,
WarehouseLoading,
WarehouseInspectionReport,
WarehouseAllocationRule,
WarehouseFeeRule,
BookingHandover,
]),
BillingModule,
DocumentsModule,
FilesModule,
InterchangeDocumentsModule,
forwardRef(() => LastMileModule),
NotificationsModule,
NotificationInboxModule,
SignaturesModule,
registerExchangeModule(),
],
controllers: [
WarehousesController,
WarehouseYardsController,
WarehouseZonesController,
WarehouseZoneStacksController,
WarehouseInventoryController,
WarehouseLoadingsController,
WarehouseInspectionController,
WarehouseRulesController,
WarehouseInvoiceController,
],
providers: [
WarehousesRepository,
WarehouseYardsRepository,
WarehouseZonesRepository,
WarehouseZoneStacksRepository,
WarehouseZoneSlotsRepository,
WarehouseInventoryRepository,
WarehouseInventoryMovementRepository,
WarehouseActivityLogRepository,
WarehouseLoadingRepository,
WarehouseInspectionRepository,
WarehouseAllocationRuleRepository,
WarehouseFeeRuleRepository,
WarehousesService,
WarehouseYardsService,
WarehouseZonesService,
WarehouseZoneStacksService,
WarehousePlacementService,
WarehouseInventoryService,
WarehouseActivityLogService,
WarehouseDashboardService,
WarehouseInspectionService,
WarehouseAllocationService,
WarehouseFeeService,
WarehouseInvoiceService,
WarehouseSchedulingAdapterService,
WarehouseReleaseDocumentService,
SchedulingReadFacade,
HandoverService,
],
exports: [
WarehousesService,
WarehouseYardsService,
WarehouseZonesService,
WarehouseZoneStacksService,
WarehousePlacementService,
WarehouseInventoryService,
WarehouseAllocationService,
WarehouseFeeService,
WarehouseSchedulingAdapterService,
WarehouseReleaseDocumentService,
],
})
export class WarehousesModule {}