extend wearable and enable maintenance
This commit is contained in:
parent
aeb1ccbc42
commit
b8b2186c58
20 changed files with 457 additions and 93 deletions
|
@ -34,13 +34,20 @@ export async function getAllDamageReportsByStatus(req: Request, res: Response):
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
export async function getAllDamageReportsForRelated(req: Request, res: Response): Promise<any> {
|
export async function getAllDamageReportsForRelated(req: Request, res: Response): Promise<any> {
|
||||||
let relation = req.params.related as "vehicle" | "equipment";
|
let relation = req.params.related as "vehicle" | "equipment" | "wearable";
|
||||||
let relationId = req.params.relatedId as string;
|
let relationId = req.params.relatedId as string;
|
||||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
let count = parseInt((req.query.count as string) ?? "25");
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
let noLimit = req.query.noLimit === "true";
|
let noLimit = req.query.noLimit === "true";
|
||||||
|
|
||||||
let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
|
let where;
|
||||||
|
if (relation == "equipment") {
|
||||||
|
where = { equipmentId: relationId };
|
||||||
|
} else if (relation == "vehicle") {
|
||||||
|
where = { vehicleId: relationId };
|
||||||
|
} else {
|
||||||
|
where = { wearableId: relationId };
|
||||||
|
}
|
||||||
let [damageReports, total] = await DamageReportService.getAllForRelated(where, { offset, count, noLimit });
|
let [damageReports, total] = await DamageReportService.getAllForRelated(where, { offset, count, noLimit });
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
|
|
@ -16,13 +16,20 @@ import BadRequestException from "../../../exceptions/badRequestException";
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
export async function getAllInspectionsForRelated(req: Request, res: Response): Promise<any> {
|
export async function getAllInspectionsForRelated(req: Request, res: Response): Promise<any> {
|
||||||
let relation = req.params.related as "vehicle" | "equipment";
|
let relation = req.params.related as "vehicle" | "equipment" | "wearable";
|
||||||
let relationId = req.params.relatedId as string;
|
let relationId = req.params.relatedId as string;
|
||||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
let count = parseInt((req.query.count as string) ?? "25");
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
let noLimit = req.query.noLimit === "true";
|
let noLimit = req.query.noLimit === "true";
|
||||||
|
|
||||||
let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
|
let where;
|
||||||
|
if (relation == "equipment") {
|
||||||
|
where = { equipmentId: relationId };
|
||||||
|
} else if (relation == "vehicle") {
|
||||||
|
where = { vehicleId: relationId };
|
||||||
|
} else {
|
||||||
|
where = { wearableId: relationId };
|
||||||
|
}
|
||||||
let [inspections, total] = await InspectionService.getAllForRelated(where, { offset, count, noLimit });
|
let [inspections, total] = await InspectionService.getAllForRelated(where, { offset, count, noLimit });
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
@ -59,8 +66,8 @@ export async function createInspection(req: Request, res: Response): Promise<any
|
||||||
const assigned = req.body.assigned;
|
const assigned = req.body.assigned;
|
||||||
const nextInspection = req.body.nextInspection || null;
|
const nextInspection = req.body.nextInspection || null;
|
||||||
|
|
||||||
if (assigned != "equipment" && assigned != "vehicle")
|
if (assigned != "equipment" && assigned != "vehicle" && assigned != "wearable")
|
||||||
throw new BadRequestException("set assigned to equipment or vehicle");
|
throw new BadRequestException("set assigned to equipment or vehicle or wearable");
|
||||||
|
|
||||||
let createInspection: CreateInspectionCommand = {
|
let createInspection: CreateInspectionCommand = {
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -46,7 +46,7 @@ export async function getAllInspectionPlans(req: Request, res: Response): Promis
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise<any> {
|
export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise<any> {
|
||||||
let relation = req.params.related as "vehicle" | "equipment";
|
let relation = req.params.related as "vehicle" | "equipment" | "wearable";
|
||||||
let relationId = req.params.relatedId as string;
|
let relationId = req.params.relatedId as string;
|
||||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
let count = parseInt((req.query.count as string) ?? "25");
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
|
@ -54,7 +54,14 @@ export async function getAllInspectionPlansForRelated(req: Request, res: Respons
|
||||||
let noLimit = req.query.noLimit === "true";
|
let noLimit = req.query.noLimit === "true";
|
||||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||||
|
|
||||||
let where = relation === "equipment" ? { equipmentTypeId: relationId } : { vehicleTypeId: relationId };
|
let where;
|
||||||
|
if (relation == "equipment") {
|
||||||
|
where = { equipmentTypeId: relationId };
|
||||||
|
} else if (relation == "vehicle") {
|
||||||
|
where = { vehicleTypeId: relationId };
|
||||||
|
} else {
|
||||||
|
where = { wearableTypeId: relationId };
|
||||||
|
}
|
||||||
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, {
|
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, {
|
||||||
offset,
|
offset,
|
||||||
count,
|
count,
|
||||||
|
@ -100,8 +107,8 @@ export async function createInspectionPlan(req: Request, res: Response): Promise
|
||||||
TypeTester.testPlanTimeDefinition(inspectionInterval, "inspectionInterval", true);
|
TypeTester.testPlanTimeDefinition(inspectionInterval, "inspectionInterval", true);
|
||||||
TypeTester.testPlanTimeDefinition(remindTime, "remindTime", true);
|
TypeTester.testPlanTimeDefinition(remindTime, "remindTime", true);
|
||||||
|
|
||||||
if (assigned != "equipment" && assigned != "vehicle")
|
if (assigned != "equipment" && assigned != "vehicle" && assigned != "wearable")
|
||||||
throw new BadRequestException("set assigned to equipment or vehicle");
|
throw new BadRequestException("set assigned to equipment or vehicle or wearable");
|
||||||
|
|
||||||
let createInspectionPlan: CreateInspectionPlanCommand = {
|
let createInspectionPlan: CreateInspectionPlanCommand = {
|
||||||
title,
|
title,
|
||||||
|
|
119
src/controller/admin/unit/maintenanceController.ts
Normal file
119
src/controller/admin/unit/maintenanceController.ts
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
import MaintenanceService from "../../../service/unit/maintenanceService";
|
||||||
|
import MaintenanceFactory from "../../../factory/admin/unit/maintenance";
|
||||||
|
import { CreateMaintenanceCommand, UpdateMaintenanceCommand } from "../../../command/unit/maintenanceCommand";
|
||||||
|
import MaintenanceCommandHandler from "../../../command/unit/maintenanceCommandHandler";
|
||||||
|
import BadRequestException from "../../../exceptions/badRequestException";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description get all maintenances by status
|
||||||
|
* @param req {Request} Express req object
|
||||||
|
* @param res {Response} Express res object
|
||||||
|
* @returns {Promise<*>}
|
||||||
|
*/
|
||||||
|
export async function getAllMaintenancesByStatus(req: Request, res: Response): Promise<any> {
|
||||||
|
let done = req.query.done === "true";
|
||||||
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
|
let noLimit = req.query.noLimit === "true";
|
||||||
|
|
||||||
|
let [maintenances, total] = await MaintenanceService.getAll(done, { offset, count, noLimit });
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
maintenances: MaintenanceFactory.mapToBase(maintenances),
|
||||||
|
total: total,
|
||||||
|
offset: offset,
|
||||||
|
count: count,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description get all maintenances for related id
|
||||||
|
* @param req {Request} Express req object
|
||||||
|
* @param res {Response} Express res object
|
||||||
|
* @returns {Promise<*>}
|
||||||
|
*/
|
||||||
|
export async function getAllMaintenancesForRelated(req: Request, res: Response): Promise<any> {
|
||||||
|
let relation = req.params.related as "vehicle" | "equipment" | "wearable";
|
||||||
|
let relationId = req.params.relatedId as string;
|
||||||
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||||
|
let count = parseInt((req.query.count as string) ?? "25");
|
||||||
|
let noLimit = req.query.noLimit === "true";
|
||||||
|
|
||||||
|
let where;
|
||||||
|
if (relation == "equipment") {
|
||||||
|
where = { equipmentId: relationId };
|
||||||
|
} else if (relation == "vehicle") {
|
||||||
|
where = { vehicleId: relationId };
|
||||||
|
} else {
|
||||||
|
where = { wearableId: relationId };
|
||||||
|
}
|
||||||
|
let [maintenances, total] = await MaintenanceService.getAllForRelated(where, { offset, count, noLimit });
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
maintenances: MaintenanceFactory.mapToBase(maintenances),
|
||||||
|
total: total,
|
||||||
|
offset: offset,
|
||||||
|
count: count,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description get maintenance by id
|
||||||
|
* @param req {Request} Express req object
|
||||||
|
* @param res {Response} Express res object
|
||||||
|
* @returns {Promise<*>}
|
||||||
|
*/
|
||||||
|
export async function getMaintenanceById(req: Request, res: Response): Promise<any> {
|
||||||
|
const maintenanceId = req.params.id;
|
||||||
|
let maintenance = await MaintenanceService.getById(maintenanceId);
|
||||||
|
|
||||||
|
res.json(MaintenanceFactory.mapToSingle(maintenance));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description create maintenance
|
||||||
|
* @param req {Request} Express req object
|
||||||
|
* @param res {Response} Express res object
|
||||||
|
* @returns {Promise<*>}
|
||||||
|
*/
|
||||||
|
export async function createMaintenance(req: Request, res: Response): Promise<any> {
|
||||||
|
const description = req.body.description;
|
||||||
|
const affectedId = req.body.affectedId;
|
||||||
|
const affected = req.body.affected;
|
||||||
|
|
||||||
|
if (affected != "equipment" && affected != "vehicle" && affected != "wearable")
|
||||||
|
throw new BadRequestException("set assigned to equipment or vehicle or wearable");
|
||||||
|
|
||||||
|
let createMaintenance: CreateMaintenanceCommand = {
|
||||||
|
description,
|
||||||
|
affectedId,
|
||||||
|
affected,
|
||||||
|
};
|
||||||
|
let maintenanceId = await MaintenanceCommandHandler.create(createMaintenance);
|
||||||
|
|
||||||
|
res.status(200).send(maintenanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description update maintenance by id
|
||||||
|
* @param req {Request} Express req object
|
||||||
|
* @param res {Response} Express res object
|
||||||
|
* @returns {Promise<*>}
|
||||||
|
*/
|
||||||
|
export async function updateMaintenanceById(req: Request, res: Response): Promise<any> {
|
||||||
|
const maintenanceId = req.params.id;
|
||||||
|
const description = req.body.description;
|
||||||
|
const status = req.body.status;
|
||||||
|
const done = req.body.done;
|
||||||
|
|
||||||
|
let updateMaintenance: UpdateMaintenanceCommand = {
|
||||||
|
id: maintenanceId,
|
||||||
|
description,
|
||||||
|
status,
|
||||||
|
done,
|
||||||
|
};
|
||||||
|
await MaintenanceCommandHandler.update(updateMaintenance);
|
||||||
|
|
||||||
|
res.sendStatus(204);
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||||
import { vehicle } from "../vehicle/vehicle";
|
import { vehicle } from "../vehicle/vehicle";
|
||||||
import { equipment } from "../equipment/equipment";
|
import { equipment } from "../equipment/equipment";
|
||||||
import { inspectionPointResult } from "./inspectionPointResult";
|
import { inspectionPointResult } from "./inspectionPointResult";
|
||||||
|
import { wearable } from "../wearable/wearable";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class inspection {
|
export class inspection {
|
||||||
|
@ -35,6 +36,9 @@ export class inspection {
|
||||||
@Column({ nullable: true, default: null })
|
@Column({ nullable: true, default: null })
|
||||||
vehicleId?: string;
|
vehicleId?: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true, default: null })
|
||||||
|
wearableId?: string;
|
||||||
|
|
||||||
@ManyToOne(() => inspectionPlan, {
|
@ManyToOne(() => inspectionPlan, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: "RESTRICT",
|
onDelete: "RESTRICT",
|
||||||
|
@ -63,6 +67,13 @@ export class inspection {
|
||||||
})
|
})
|
||||||
vehicle: vehicle;
|
vehicle: vehicle;
|
||||||
|
|
||||||
|
@ManyToOne(() => wearable, {
|
||||||
|
nullable: true,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
wearable: wearable;
|
||||||
|
|
||||||
@OneToMany(() => inspectionPointResult, (ipr) => ipr.inspection)
|
@OneToMany(() => inspectionPointResult, (ipr) => ipr.inspection)
|
||||||
pointResults: inspectionPointResult[];
|
pointResults: inspectionPointResult[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspection/ins
|
||||||
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||||
import { equipmentType } from "../equipment/equipmentType";
|
import { equipmentType } from "../equipment/equipmentType";
|
||||||
import { vehicleType } from "../vehicle/vehicleType";
|
import { vehicleType } from "../vehicle/vehicleType";
|
||||||
|
import { wearableType } from "../wearable/wearableType";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class inspectionPlan {
|
export class inspectionPlan {
|
||||||
|
@ -27,6 +28,9 @@ export class inspectionPlan {
|
||||||
@Column({ nullable: true, default: null })
|
@Column({ nullable: true, default: null })
|
||||||
vehicleTypeId?: string;
|
vehicleTypeId?: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true, default: null })
|
||||||
|
wearableTypeId?: string;
|
||||||
|
|
||||||
@ManyToOne(() => equipmentType, {
|
@ManyToOne(() => equipmentType, {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
onDelete: "CASCADE",
|
onDelete: "CASCADE",
|
||||||
|
@ -41,6 +45,13 @@ export class inspectionPlan {
|
||||||
})
|
})
|
||||||
vehicleType?: vehicleType;
|
vehicleType?: vehicleType;
|
||||||
|
|
||||||
|
@ManyToOne(() => wearableType, {
|
||||||
|
nullable: true,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
wearableType?: wearableType;
|
||||||
|
|
||||||
@OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, {
|
@OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, {
|
||||||
cascade: ["insert"],
|
cascade: ["insert"],
|
||||||
})
|
})
|
||||||
|
|
|
@ -47,4 +47,7 @@ export class wearable {
|
||||||
|
|
||||||
@OneToMany(() => damageReport, (d) => d.wearable, { cascade: ["insert"] })
|
@OneToMany(() => damageReport, (d) => d.wearable, { cascade: ["insert"] })
|
||||||
reports: damageReport[];
|
reports: damageReport[];
|
||||||
|
|
||||||
|
@OneToMany(() => inspection, (i) => i.wearable)
|
||||||
|
inspections: inspection[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { wearable as wearable } from "./wearable";
|
import { wearable as wearable } from "./wearable";
|
||||||
|
import { inspectionPlan } from "../inspection/inspectionPlan";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class wearableType {
|
export class wearableType {
|
||||||
|
@ -14,4 +15,7 @@ export class wearableType {
|
||||||
|
|
||||||
@OneToMany(() => wearable, (e) => e.wearableType, { cascade: ["insert"] })
|
@OneToMany(() => wearable, (e) => e.wearableType, { cascade: ["insert"] })
|
||||||
wearable: wearable[];
|
wearable: wearable[];
|
||||||
|
|
||||||
|
@OneToMany(() => inspectionPlan, (ip) => ip.wearableType)
|
||||||
|
inspectionPlans: inspectionPlan[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { inspection } from "../../../../entity/unit/inspection/inspection";
|
import { inspection } from "../../../../entity/unit/inspection/inspection";
|
||||||
import { InspectionViewModel } from "../../../../viewmodel/admin/unit/inspection/inspection.models";
|
import { InspectionRelated, InspectionViewModel } from "../../../../viewmodel/admin/unit/inspection/inspection.models";
|
||||||
import EquipmentFactory from "../equipment/equipment";
|
import EquipmentFactory from "../equipment/equipment";
|
||||||
import VehicleFactory from "../vehicle/vehicle";
|
import VehicleFactory from "../vehicle/vehicle";
|
||||||
|
import WearableFactory from "../wearable/wearable";
|
||||||
import InspectionPlanFactory from "./inspectionPlan";
|
import InspectionPlanFactory from "./inspectionPlan";
|
||||||
import InspectionPointResultFactory from "./inspectionPointResult";
|
import InspectionPointResultFactory from "./inspectionPointResult";
|
||||||
import InspectionVersionedPlanFactory from "./inspectionVersionedPlan";
|
import InspectionVersionedPlanFactory from "./inspectionVersionedPlan";
|
||||||
|
@ -13,6 +14,27 @@ export default abstract class InspectionFactory {
|
||||||
* @returns {InspectionViewModel}
|
* @returns {InspectionViewModel}
|
||||||
*/
|
*/
|
||||||
public static mapToSingle(record: inspection): InspectionViewModel {
|
public static mapToSingle(record: inspection): InspectionViewModel {
|
||||||
|
let related: InspectionRelated;
|
||||||
|
if (record?.equipmentId) {
|
||||||
|
related = {
|
||||||
|
relatedId: record.equipmentId,
|
||||||
|
assigned: "equipment",
|
||||||
|
related: EquipmentFactory.mapToSingle(record.equipment),
|
||||||
|
};
|
||||||
|
} else if (record?.vehicleId) {
|
||||||
|
related = {
|
||||||
|
relatedId: record.vehicleId,
|
||||||
|
assigned: "vehicle",
|
||||||
|
related: VehicleFactory.mapToSingle(record.vehicle),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
related = {
|
||||||
|
relatedId: record.wearableId,
|
||||||
|
assigned: "wearable",
|
||||||
|
related: WearableFactory.mapToSingle(record.wearable),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: record.id,
|
id: record.id,
|
||||||
inspectionPlanId: record.inspectionPlanId,
|
inspectionPlanId: record.inspectionPlanId,
|
||||||
|
@ -25,17 +47,7 @@ export default abstract class InspectionFactory {
|
||||||
isOpen: record?.finishedAt == undefined,
|
isOpen: record?.finishedAt == undefined,
|
||||||
nextInspection: record?.nextInspection,
|
nextInspection: record?.nextInspection,
|
||||||
checks: InspectionPointResultFactory.mapToBase(record.pointResults),
|
checks: InspectionPointResultFactory.mapToBase(record.pointResults),
|
||||||
...(record.equipmentId
|
...related,
|
||||||
? {
|
|
||||||
relatedId: record.equipmentId,
|
|
||||||
assigned: "equipment",
|
|
||||||
related: EquipmentFactory.mapToSingle(record.equipment),
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
relatedId: record.vehicleId,
|
|
||||||
assigned: "vehicle",
|
|
||||||
related: VehicleFactory.mapToSingle(record.vehicle),
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import { inspectionPlan } from "../../../../entity/unit/inspection/inspectionPlan";
|
import { inspectionPlan } from "../../../../entity/unit/inspection/inspectionPlan";
|
||||||
import { InspectionPlanViewModel } from "../../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
import {
|
||||||
|
InspectionPlanRelated,
|
||||||
|
InspectionPlanViewModel,
|
||||||
|
} from "../../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
||||||
import EquipmentFactory from "../equipment/equipment";
|
import EquipmentFactory from "../equipment/equipment";
|
||||||
import EquipmentTypeFactory from "../equipment/equipmentType";
|
import EquipmentTypeFactory from "../equipment/equipmentType";
|
||||||
import VehicleFactory from "../vehicle/vehicle";
|
import VehicleFactory from "../vehicle/vehicle";
|
||||||
import VehicleTypeFactory from "../vehicle/vehicleType";
|
import VehicleTypeFactory from "../vehicle/vehicleType";
|
||||||
|
import WearableTypeFactory from "../wearable/wearableType";
|
||||||
import InspectionPointFactory from "./inspectionPoint";
|
import InspectionPointFactory from "./inspectionPoint";
|
||||||
|
|
||||||
export default abstract class InspectionPlanFactory {
|
export default abstract class InspectionPlanFactory {
|
||||||
|
@ -13,6 +17,27 @@ export default abstract class InspectionPlanFactory {
|
||||||
* @returns {InspectionPlanViewModel}
|
* @returns {InspectionPlanViewModel}
|
||||||
*/
|
*/
|
||||||
public static mapToSingle(record: inspectionPlan): InspectionPlanViewModel {
|
public static mapToSingle(record: inspectionPlan): InspectionPlanViewModel {
|
||||||
|
let related: InspectionPlanRelated;
|
||||||
|
if (record?.equipmentTypeId) {
|
||||||
|
related = {
|
||||||
|
relatedId: record.equipmentTypeId,
|
||||||
|
assigned: "equipment",
|
||||||
|
related: EquipmentTypeFactory.mapToSingle(record.equipmentType),
|
||||||
|
};
|
||||||
|
} else if (record?.vehicleTypeId) {
|
||||||
|
related = {
|
||||||
|
relatedId: record.vehicleTypeId,
|
||||||
|
assigned: "vehicle",
|
||||||
|
related: VehicleTypeFactory.mapToSingle(record.vehicleType),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
related = {
|
||||||
|
relatedId: record.wearableTypeId,
|
||||||
|
assigned: "wearable",
|
||||||
|
related: WearableTypeFactory.mapToSingle(record.wearableType),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: record.id,
|
id: record.id,
|
||||||
title: record.title,
|
title: record.title,
|
||||||
|
@ -23,17 +48,7 @@ export default abstract class InspectionPlanFactory {
|
||||||
inspectionPoints: record.latestVersionedPlan
|
inspectionPoints: record.latestVersionedPlan
|
||||||
? InspectionPointFactory.mapToBase(record.latestVersionedPlan.inspectionPoints)
|
? InspectionPointFactory.mapToBase(record.latestVersionedPlan.inspectionPoints)
|
||||||
: [],
|
: [],
|
||||||
...(record.equipmentTypeId
|
...related,
|
||||||
? {
|
|
||||||
relatedId: record.equipmentTypeId,
|
|
||||||
assigned: "equipment",
|
|
||||||
related: EquipmentTypeFactory.mapToSingle(record.equipmentType),
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
relatedId: record.vehicleTypeId,
|
|
||||||
assigned: "vehicle",
|
|
||||||
related: VehicleTypeFactory.mapToSingle(record.vehicleType),
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import wearableType from "./unit/wearableType";
|
||||||
import inspection from "./unit/inspection";
|
import inspection from "./unit/inspection";
|
||||||
import inspectionPlan from "./unit/inspectionPlan";
|
import inspectionPlan from "./unit/inspectionPlan";
|
||||||
import damageReport from "./unit/damageReport";
|
import damageReport from "./unit/damageReport";
|
||||||
|
import maintenance from "./unit/maintenance";
|
||||||
|
|
||||||
var router = express.Router({ mergeParams: true });
|
var router = express.Router({ mergeParams: true });
|
||||||
|
|
||||||
|
@ -189,39 +190,75 @@ router.use(
|
||||||
router.use("/setting", PermissionHelper.passCheckMiddleware("read", "management", "setting"), setting);
|
router.use("/setting", PermissionHelper.passCheckMiddleware("read", "management", "setting"), setting);
|
||||||
|
|
||||||
/** unit */
|
/** unit */
|
||||||
router.use("/equipment", PermissionHelper.passCheckMiddleware("read", "unit", "equipment"), equipment);
|
router.use(
|
||||||
|
"/equipment",
|
||||||
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
|
]),
|
||||||
|
equipment
|
||||||
|
);
|
||||||
router.use(
|
router.use(
|
||||||
"/equipmenttype",
|
"/equipmenttype",
|
||||||
PermissionHelper.passCheckSomeMiddleware([
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
{ requiredPermission: "read", section: "unit", module: "equipment_type" },
|
{ requiredPermission: "read", section: "unit", module: "equipment_type" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
]),
|
]),
|
||||||
equipmentType
|
equipmentType
|
||||||
);
|
);
|
||||||
router.use("/vehicle", PermissionHelper.passCheckMiddleware("read", "unit", "vehicle"), vehicle);
|
router.use(
|
||||||
|
"/vehicle",
|
||||||
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
|
]),
|
||||||
|
vehicle
|
||||||
|
);
|
||||||
router.use(
|
router.use(
|
||||||
"/vehicletype",
|
"/vehicletype",
|
||||||
PermissionHelper.passCheckSomeMiddleware([
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
{ requiredPermission: "read", section: "unit", module: "vehicle_type" },
|
{ requiredPermission: "read", section: "unit", module: "vehicle_type" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
]),
|
]),
|
||||||
vehicleType
|
vehicleType
|
||||||
);
|
);
|
||||||
router.use("/wearable", PermissionHelper.passCheckMiddleware("read", "unit", "wearable"), wearable);
|
router.use(
|
||||||
|
"/wearable",
|
||||||
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
|
]),
|
||||||
|
wearable
|
||||||
|
);
|
||||||
router.use(
|
router.use(
|
||||||
"/wearabletype",
|
"/wearabletype",
|
||||||
PermissionHelper.passCheckSomeMiddleware([
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
{ requiredPermission: "read", section: "unit", module: "wearable_type" },
|
{ requiredPermission: "read", section: "unit", module: "wearable_type" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
]),
|
]),
|
||||||
wearableType
|
wearableType
|
||||||
);
|
);
|
||||||
router.use("/inspection", PermissionHelper.passCheckMiddleware("read", "unit", "inspection"), inspection);
|
router.use(
|
||||||
|
"/inspection",
|
||||||
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "inspection" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
||||||
|
]),
|
||||||
|
inspection
|
||||||
|
);
|
||||||
router.use(
|
router.use(
|
||||||
"/inspectionplan",
|
"/inspectionplan",
|
||||||
PermissionHelper.passCheckSomeMiddleware([
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
{ requiredPermission: "read", section: "unit", module: "inspection_plan" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "inspection" },
|
{ requiredPermission: "read", section: "unit", module: "inspection" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "equipment_type" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "vehicle_type" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "wearable_type" },
|
||||||
]),
|
]),
|
||||||
inspectionPlan
|
inspectionPlan
|
||||||
);
|
);
|
||||||
|
@ -229,11 +266,22 @@ router.use(
|
||||||
"/damagereport",
|
"/damagereport",
|
||||||
PermissionHelper.passCheckSomeMiddleware([
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
{ requiredPermission: "read", section: "unit", module: "damage_report" },
|
{ requiredPermission: "read", section: "unit", module: "damage_report" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "maintenance" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
||||||
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
||||||
]),
|
]),
|
||||||
damageReport
|
damageReport
|
||||||
);
|
);
|
||||||
|
router.use(
|
||||||
|
"/mainenance",
|
||||||
|
PermissionHelper.passCheckSomeMiddleware([
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "maintenance" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "equipment" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "vehicle" },
|
||||||
|
{ requiredPermission: "read", section: "unit", module: "wearable" },
|
||||||
|
]),
|
||||||
|
maintenance
|
||||||
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -10,15 +10,20 @@ import {
|
||||||
|
|
||||||
var router = express.Router({ mergeParams: true });
|
var router = express.Router({ mergeParams: true });
|
||||||
|
|
||||||
router.get(["/vehicle/:relatedId", "/equipment/:relatedId"], async (req: Request, res: Response) => {
|
router.get(
|
||||||
if (req.path.startsWith("/vehicle")) {
|
["/vehicle/:relatedId", "/equipment/:relatedId", "/wearable/:relatedId"],
|
||||||
req.params.related = "vehicle";
|
async (req: Request, res: Response) => {
|
||||||
} else {
|
if (req.path.startsWith("/vehicle")) {
|
||||||
req.params.related = "equipment";
|
req.params.related = "vehicle";
|
||||||
}
|
} else if (req.path.startsWith("/equipment")) {
|
||||||
|
req.params.related = "equipment";
|
||||||
|
} else {
|
||||||
|
req.params.related = "wearable";
|
||||||
|
}
|
||||||
|
|
||||||
await getAllInspectionsForRelated(req, res);
|
await getAllInspectionsForRelated(req, res);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
router.get("/:id", async (req: Request, res: Response) => {
|
router.get("/:id", async (req: Request, res: Response) => {
|
||||||
await getInspectionById(req, res);
|
await getInspectionById(req, res);
|
||||||
|
|
|
@ -15,15 +15,20 @@ router.get("/", async (req: Request, res: Response) => {
|
||||||
await getAllInspectionPlans(req, res);
|
await getAllInspectionPlans(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get(["/vehicle/:relatedId", "/equipment/:relatedId"], async (req: Request, res: Response) => {
|
router.get(
|
||||||
if (req.path.startsWith("/vehicle")) {
|
["/vehicle/:relatedId", "/equipment/:relatedId", "/wearable/:relatedId"],
|
||||||
req.params.related = "vehicle";
|
async (req: Request, res: Response) => {
|
||||||
} else {
|
if (req.path.startsWith("/vehicle")) {
|
||||||
req.params.related = "equipment";
|
req.params.related = "vehicle";
|
||||||
}
|
} else if (req.path.startsWith("/equipment")) {
|
||||||
|
req.params.related = "equipment";
|
||||||
|
} else {
|
||||||
|
req.params.related = "wearable";
|
||||||
|
}
|
||||||
|
|
||||||
await getAllInspectionPlansForRelated(req, res);
|
await getAllInspectionPlansForRelated(req, res);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
router.get("/:id", async (req: Request, res: Response) => {
|
router.get("/:id", async (req: Request, res: Response) => {
|
||||||
await getInspectionPlanById(req, res);
|
await getInspectionPlanById(req, res);
|
||||||
|
|
43
src/routes/admin/unit/maintenance.ts
Normal file
43
src/routes/admin/unit/maintenance.ts
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import express, { Request, Response } from "express";
|
||||||
|
import PermissionHelper from "../../../helpers/permissionHelper";
|
||||||
|
import {
|
||||||
|
getAllMaintenancesByStatus,
|
||||||
|
getAllMaintenancesForRelated,
|
||||||
|
getMaintenanceById,
|
||||||
|
updateMaintenanceById,
|
||||||
|
} from "../../../controller/admin/unit/maintenanceController";
|
||||||
|
|
||||||
|
var router = express.Router({ mergeParams: true });
|
||||||
|
|
||||||
|
router.get("/", async (req: Request, res: Response) => {
|
||||||
|
await getAllMaintenancesByStatus(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
["/vehicle/:relatedId", "/equipment/:relatedId", "/wearable/:relatedId"],
|
||||||
|
async (req: Request, res: Response) => {
|
||||||
|
if (req.path.startsWith("/vehicle")) {
|
||||||
|
req.params.related = "vehicle";
|
||||||
|
} else if (req.path.startsWith("/equipment")) {
|
||||||
|
req.params.related = "equipment";
|
||||||
|
} else {
|
||||||
|
req.params.related = "wearable";
|
||||||
|
}
|
||||||
|
|
||||||
|
await getAllMaintenancesForRelated(req, res);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
router.get("/:id", async (req: Request, res: Response) => {
|
||||||
|
await getMaintenanceById(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.patch(
|
||||||
|
"/:id",
|
||||||
|
PermissionHelper.passCheckMiddleware("update", "unit", "inspection"),
|
||||||
|
async (req: Request, res: Response) => {
|
||||||
|
await updateMaintenanceById(req, res);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default router;
|
|
@ -16,7 +16,8 @@ export default abstract class InspectionPlanService {
|
||||||
)
|
)
|
||||||
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
|
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
|
||||||
.leftJoinAndSelect("inspectionPlan.equipmentType", "equipmentType")
|
.leftJoinAndSelect("inspectionPlan.equipmentType", "equipmentType")
|
||||||
.leftJoinAndSelect("inspectionPlan.vehicleType", "vehicleType");
|
.leftJoinAndSelect("inspectionPlan.vehicleType", "vehicleType")
|
||||||
|
.leftJoinAndSelect("inspectionPlan.wearableType", "wearableType");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get all inspectionPlans for related
|
* @description get all inspectionPlans for related
|
||||||
|
@ -67,7 +68,7 @@ export default abstract class InspectionPlanService {
|
||||||
* @returns {Promise<[Array<inspectionPlan>, number]>}
|
* @returns {Promise<[Array<inspectionPlan>, number]>}
|
||||||
*/
|
*/
|
||||||
static async getAllForRelated(
|
static async getAllForRelated(
|
||||||
where: { equipmentTypeId: string } | { vehicleTypeId: string },
|
where: { equipmentTypeId: string } | { vehicleTypeId: string } | { wearableTypeId: string },
|
||||||
{
|
{
|
||||||
offset = 0,
|
offset = 0,
|
||||||
count = 25,
|
count = 25,
|
||||||
|
|
|
@ -13,14 +13,15 @@ export default abstract class InspectionService {
|
||||||
.leftJoinAndSelect("inspection.pointResults", "pointResults")
|
.leftJoinAndSelect("inspection.pointResults", "pointResults")
|
||||||
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
|
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
|
||||||
.leftJoinAndSelect("inspection.equipment", "equipment")
|
.leftJoinAndSelect("inspection.equipment", "equipment")
|
||||||
.leftJoinAndSelect("inspection.vehicle", "vehicle");
|
.leftJoinAndSelect("inspection.vehicle", "vehicle")
|
||||||
|
.leftJoinAndSelect("inspection.wearable", "wearable");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get all inspections for related
|
* @description get all inspections for related
|
||||||
* @returns {Promise<Array<inspection>>}
|
* @returns {Promise<Array<inspection>>}
|
||||||
*/
|
*/
|
||||||
static async getAllForRelated(
|
static async getAllForRelated(
|
||||||
where: { equipmentId: string } | { vehicleId: string },
|
where: { equipmentId: string } | { vehicleId: string } | { wearableId: string },
|
||||||
{
|
{
|
||||||
offset = 0,
|
offset = 0,
|
||||||
count = 25,
|
count = 25,
|
||||||
|
|
|
@ -3,20 +3,72 @@ import { maintenance } from "../../entity/unit/maintenance";
|
||||||
import DatabaseActionException from "../../exceptions/databaseActionException";
|
import DatabaseActionException from "../../exceptions/databaseActionException";
|
||||||
|
|
||||||
export default abstract class MaintenanceService {
|
export default abstract class MaintenanceService {
|
||||||
/**
|
private static query = () =>
|
||||||
* @description get all maintenances
|
dataSource
|
||||||
* @returns {Promise<Array<maintenance>>}
|
|
||||||
*/
|
|
||||||
static async getAll(): Promise<Array<maintenance>> {
|
|
||||||
return await dataSource
|
|
||||||
.getRepository(maintenance)
|
.getRepository(maintenance)
|
||||||
.createQueryBuilder("maintenance")
|
.createQueryBuilder("maintenance")
|
||||||
.leftJoinAndSelect("maintenance.equipment", "equipment")
|
.leftJoinAndSelect("maintenance.equipment", "equipment")
|
||||||
.leftJoinAndSelect("maintenance.vehicle", "vehicle")
|
.leftJoinAndSelect("maintenance.vehicle", "vehicle")
|
||||||
.leftJoinAndSelect("maintenance.wearable", "wearable")
|
.leftJoinAndSelect("maintenance.wearable", "wearable")
|
||||||
.leftJoinAndSelect("maintenance.reports", "reports")
|
.leftJoinAndSelect("maintenance.reports", "reports");
|
||||||
.orderBy("type", "ASC")
|
|
||||||
.getMany()
|
/**
|
||||||
|
* @description get all maintenances
|
||||||
|
* @returns {Promise<[Array<maintenance>, number]>}
|
||||||
|
*/
|
||||||
|
static async getAll(
|
||||||
|
done = false,
|
||||||
|
{
|
||||||
|
offset = 0,
|
||||||
|
count = 25,
|
||||||
|
noLimit = false,
|
||||||
|
}: {
|
||||||
|
offset?: number;
|
||||||
|
count?: number;
|
||||||
|
noLimit?: boolean;
|
||||||
|
}
|
||||||
|
): Promise<[Array<maintenance>, number]> {
|
||||||
|
let query = this.query().where({ done });
|
||||||
|
if (!noLimit) {
|
||||||
|
query = query.offset(offset).limit(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await query
|
||||||
|
.orderBy("maintenance.type", "ASC")
|
||||||
|
.getManyAndCount()
|
||||||
|
.then((res) => {
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw new DatabaseActionException("SELECT", "maintenance", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description get all maintenances By related
|
||||||
|
* @returns {Promise<[Array<maintenance>, number]>}
|
||||||
|
*/
|
||||||
|
static async getAllForRelated(
|
||||||
|
where: { equipmentId: string } | { vehicleId: string } | { wearableId: string },
|
||||||
|
{
|
||||||
|
offset = 0,
|
||||||
|
count = 25,
|
||||||
|
noLimit = false,
|
||||||
|
}: {
|
||||||
|
offset?: number;
|
||||||
|
count?: number;
|
||||||
|
noLimit?: boolean;
|
||||||
|
}
|
||||||
|
): Promise<[Array<maintenance>, number]> {
|
||||||
|
let query = this.query().where(where);
|
||||||
|
|
||||||
|
if (!noLimit) {
|
||||||
|
query = query.offset(offset).limit(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await query
|
||||||
|
.orderBy("maintenance.createdAt", "ASC")
|
||||||
|
.getManyAndCount()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
|
@ -30,13 +82,7 @@ export default abstract class MaintenanceService {
|
||||||
* @returns {Promise<maintenance>}
|
* @returns {Promise<maintenance>}
|
||||||
*/
|
*/
|
||||||
static async getById(id: string): Promise<maintenance> {
|
static async getById(id: string): Promise<maintenance> {
|
||||||
return await dataSource
|
return await this.query()
|
||||||
.getRepository(maintenance)
|
|
||||||
.createQueryBuilder("maintenance")
|
|
||||||
.leftJoinAndSelect("maintenance.equipment", "equipment")
|
|
||||||
.leftJoinAndSelect("maintenance.vehicle", "vehicle")
|
|
||||||
.leftJoinAndSelect("maintenance.wearable", "wearable")
|
|
||||||
.leftJoinAndSelect("maintenance.reports", "reports")
|
|
||||||
.where({ id })
|
.where({ id })
|
||||||
.getOneOrFail()
|
.getOneOrFail()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
|
@ -21,6 +21,7 @@ export type PermissionModule =
|
||||||
| "respiratory_wearer"
|
| "respiratory_wearer"
|
||||||
| "respiratory_mission"
|
| "respiratory_mission"
|
||||||
| "damage_report"
|
| "damage_report"
|
||||||
|
| "maintenance"
|
||||||
// configuration
|
// configuration
|
||||||
| "qualification"
|
| "qualification"
|
||||||
| "award"
|
| "award"
|
||||||
|
@ -95,6 +96,7 @@ export const permissionModules: Array<PermissionModule> = [
|
||||||
"respiratory_wearer",
|
"respiratory_wearer",
|
||||||
"respiratory_mission",
|
"respiratory_mission",
|
||||||
"damage_report",
|
"damage_report",
|
||||||
|
"maintenance",
|
||||||
// configuration
|
// configuration
|
||||||
"qualification",
|
"qualification",
|
||||||
"award",
|
"award",
|
||||||
|
@ -131,6 +133,7 @@ export const sectionsAndModules: SectionsAndModulesObject = {
|
||||||
"respiratory_wearer",
|
"respiratory_wearer",
|
||||||
"respiratory_mission",
|
"respiratory_mission",
|
||||||
"damage_report",
|
"damage_report",
|
||||||
|
"maintenance",
|
||||||
],
|
],
|
||||||
configuration: [
|
configuration: [
|
||||||
"qualification",
|
"qualification",
|
||||||
|
|
|
@ -5,6 +5,24 @@ import type {
|
||||||
InspectionVersionedPlanViewModel,
|
InspectionVersionedPlanViewModel,
|
||||||
} from "./inspectionPlan.models";
|
} from "./inspectionPlan.models";
|
||||||
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
||||||
|
import { WearableViewModel } from "../wearable/wearable.models";
|
||||||
|
|
||||||
|
export type InspectionRelated = {
|
||||||
|
relatedId: string;
|
||||||
|
} & (
|
||||||
|
| {
|
||||||
|
assigned: "equipment";
|
||||||
|
related: EquipmentViewModel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
assigned: "vehicle";
|
||||||
|
related: VehicleViewModel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
assigned: "wearable";
|
||||||
|
related: WearableViewModel;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export type InspectionViewModel = {
|
export type InspectionViewModel = {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -18,17 +36,7 @@ export type InspectionViewModel = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
nextInspection?: Date;
|
nextInspection?: Date;
|
||||||
checks: Array<InspectionPointResultViewModel>;
|
checks: Array<InspectionPointResultViewModel>;
|
||||||
relatedId: string;
|
} & InspectionRelated;
|
||||||
} & (
|
|
||||||
| {
|
|
||||||
assigned: "equipment";
|
|
||||||
related: EquipmentViewModel;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
assigned: "vehicle";
|
|
||||||
related: VehicleViewModel;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface InspectionPointResultViewModel {
|
export interface InspectionPointResultViewModel {
|
||||||
inspectionId: string;
|
inspectionId: string;
|
||||||
|
|
|
@ -3,17 +3,11 @@ import type { EquipmentViewModel } from "../equipment/equipment.models";
|
||||||
import { EquipmentTypeViewModel } from "../equipment/equipmentType.models";
|
import { EquipmentTypeViewModel } from "../equipment/equipmentType.models";
|
||||||
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
||||||
import { VehicleTypeViewModel } from "../vehicle/vehicleType.models";
|
import { VehicleTypeViewModel } from "../vehicle/vehicleType.models";
|
||||||
|
import { WearableTypeViewModel } from "../wearable/wearableType.models";
|
||||||
|
|
||||||
export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`;
|
export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`;
|
||||||
|
|
||||||
export type InspectionPlanViewModel = {
|
export type InspectionPlanRelated = {
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
inspectionInterval: PlanTimeDefinition;
|
|
||||||
remindTime: PlanTimeDefinition;
|
|
||||||
version: number;
|
|
||||||
created: Date;
|
|
||||||
inspectionPoints: InspectionPointViewModel[];
|
|
||||||
relatedId: string;
|
relatedId: string;
|
||||||
} & (
|
} & (
|
||||||
| {
|
| {
|
||||||
|
@ -24,8 +18,22 @@ export type InspectionPlanViewModel = {
|
||||||
assigned: "vehicle";
|
assigned: "vehicle";
|
||||||
related: VehicleTypeViewModel;
|
related: VehicleTypeViewModel;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
assigned: "wearable";
|
||||||
|
related: WearableTypeViewModel;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export type InspectionPlanViewModel = {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
inspectionInterval: PlanTimeDefinition;
|
||||||
|
remindTime: PlanTimeDefinition;
|
||||||
|
version: number;
|
||||||
|
created: Date;
|
||||||
|
inspectionPoints: InspectionPointViewModel[];
|
||||||
|
} & InspectionPlanRelated;
|
||||||
|
|
||||||
export interface InspectionVersionedPlanViewModel {
|
export interface InspectionVersionedPlanViewModel {
|
||||||
id: string;
|
id: string;
|
||||||
version: number;
|
version: number;
|
||||||
|
|
Loading…
Add table
Reference in a new issue