next and running inspections

This commit is contained in:
Julian Krauser 2025-07-10 13:22:29 +02:00
parent 8747baaf2e
commit 705297ba50
6 changed files with 142 additions and 7 deletions

View file

@ -24,7 +24,7 @@ export async function getAllInspectionsSortedNotHavingNewer(req: Request, res: R
let [inspections, total] = await InspectionService.getAllSortedNotHavingNewer({ offset, count, noLimit });
res.json({
inspections: InspectionFactory.mapToBase(inspections),
inspections: InspectionFactory.mapToBaseNext(inspections),
total: total,
offset: offset,
count: count,
@ -45,7 +45,7 @@ export async function getAllInspectionsRunning(req: Request, res: Response): Pro
let [inspections, total] = await InspectionService.getAllRunning({ offset, count, noLimit });
res.json({
inspections: InspectionFactory.mapToBase(inspections),
inspections: InspectionFactory.mapToBaseMinified(inspections),
total: total,
offset: offset,
count: count,
@ -112,6 +112,13 @@ export async function createInspection(req: Request, res: Response): Promise<any
if (assigned != "equipment" && assigned != "vehicle" && assigned != "wearable")
throw new BadRequestException("set assigned to equipment or vehicle or wearable");
let existsUnfinished = await InspectionService.existsUnfinishedInspectionToPlan(
inspectionPlanId,
assigned,
relatedId
);
if (existsUnfinished) throw new ForbiddenRequestException("there is already an unfinished inspection existing");
let createInspection: CreateInspectionCommand = {
context,
nextInspection,