Merge pull request #1045 from Tria-plc/freight_feature/usermanagement

Freight feature/usermanagement
This commit is contained in:
marshal
2026-07-31 15:14:40 +03:00
committed by GitHub
5 changed files with 264 additions and 25 deletions

View File

@@ -3718,6 +3718,30 @@ export class TrainSchedulingService {
// unload each one by hand. The final station is covered by
// arriveSchedule's bulk fallback above.
await this.bookingJourneyService.autoUnloadAtYard(scheduleId, station.yardId);
// A pass is also a position fix: the locomotives, every wagon still
// aboard, and the built train are physically AT this yard now — not at
// the origin they departed from. Wagons released at earlier stops no
// longer carry this schedule id and stay where they alighted; the final
// arrival settle still writes the wagon-movement ledger rows.
await this.dataSource.transaction(async (manager) => {
const locoIds = this.locomotivesOfTrainSet(schedule.trainSet).map((l) => l.id);
if (locoIds.length) {
await manager
.getRepository(Locomotive)
.update({ id: In(locoIds) }, { currentYardId: station.yardId });
}
await manager
.getRepository(Wagon)
.update(
{ currentTrainScheduleId: scheduleId },
{ currentYardId: station.yardId },
);
if (schedule.trainSet?.trainId) {
await manager
.getRepository(Train)
.update(schedule.trainSet.trainId, { currentYardId: station.yardId });
}
});
}
return this.getScheduleCheckpoints(scheduleId);