mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 20:05:41 +00:00
feat(train-crew): implement crew assignment functionality
- Added TrainCrewAssignment module with controller and service for managing crew assignments. - Integrated TrainCrewAssignmentService into TrainSchedulingService to ensure crew readiness before train dispatch. - Updated TrainScheduling module to include TrainCrewModule for dependency injection. - Introduced new permissions for assigning train crew in freight permissions registry. - Enhanced front-end ScheduleCrewPage to allow assignment of crew members to train schedules, including validation and UI for adding/removing drivers and support crew. - Created trainCrewAssignment.service to handle API interactions for crew assignments.
This commit is contained in:
@@ -66,6 +66,7 @@ import { WagonBookingAllocation } from '../../train-schedules/entities/wagon-boo
|
||||
import { TrainScheduleBookingsRepository } from '../../train-schedules/train-schedule-bookings.repository';
|
||||
import { TrainSchedulesRepository } from '../../train-schedules/train-schedules.repository';
|
||||
import { TrainCompositionRemovalLogRepository } from '../../train-schedules/train-composition-removal-log.repository';
|
||||
import { TrainCrewAssignmentService } from '../../train-crew/train-crew-assignment.service';
|
||||
import { WagonAllocationBulkLoadsRepository } from '../../train-schedules/wagon-allocation-bulk-loads.repository';
|
||||
import { WagonAllocationContainerItemsRepository } from '../../train-schedules/wagon-allocation-container-items.repository';
|
||||
import { WagonBookingAllocationsRepository } from '../../train-schedules/wagon-booking-allocations.repository';
|
||||
@@ -449,6 +450,9 @@ export class TrainSchedulingService {
|
||||
// Trailing + @Optional so the positional constructors in the existing specs
|
||||
// keep working; production always resolves it from ExportsModule.
|
||||
@Optional() private readonly tabularExport?: TabularExportService,
|
||||
// Crew composition gate (ITLMS Rolling Stock §1.2 "prior to departure").
|
||||
// Trailing + @Optional for the same positional-spec reason as above.
|
||||
@Optional() private readonly trainCrewAssignments?: TrainCrewAssignmentService,
|
||||
) {}
|
||||
|
||||
/** Physical wagons behind a set of booking allocations (via their slots), for cargo history rows. */
|
||||
@@ -3027,6 +3031,11 @@ export class TrainSchedulingService {
|
||||
'End the loading window at the origin station before dispatching',
|
||||
);
|
||||
}
|
||||
// On-board crew must be complete before the train leaves — ITLMS Rolling
|
||||
// Stock §1.2 enforces composition "prior to departure", so an incomplete
|
||||
// crew saves freely on the assignment page but cannot depart. Optional
|
||||
// dependency: the positional spec constructors omit it.
|
||||
await this.trainCrewAssignments?.assertCrewReadyForDispatch(scheduleId);
|
||||
// Staff may record the departure after the fact — past is fine, future is not.
|
||||
const now = dto.actualDepartureAt ? new Date(dto.actualDepartureAt) : new Date();
|
||||
this.assertNotFuture(now, 'Departure time');
|
||||
|
||||
Reference in New Issue
Block a user