inspection data model
This commit is contained in:
parent
95d1113ff9
commit
3ff44f7370
9 changed files with 222 additions and 21 deletions
36
src/entity/unit/inspection/inspection.ts
Normal file
36
src/entity/unit/inspection/inspection.ts
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { Column, ColumnType, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { inspectionPlan } from "./inspectionPlan";
|
||||||
|
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||||
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||||
|
import { Vehicle } from "../vehicle/vehicle";
|
||||||
|
import { Equipment } from "../equipment/equipment";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class inspection {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "text" })
|
||||||
|
context: string;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true })
|
||||||
|
finished?: Date;
|
||||||
|
|
||||||
|
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true })
|
||||||
|
nextInspection?: Date;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspectionPlan)
|
||||||
|
inspectionPlan: inspectionPlan;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspectionVersionedPlan)
|
||||||
|
inspectionVersionedPlan: inspectionVersionedPlan;
|
||||||
|
|
||||||
|
@ManyToOne(() => Equipment)
|
||||||
|
equipment: Equipment;
|
||||||
|
|
||||||
|
@ManyToOne(() => Vehicle)
|
||||||
|
vehicle: Vehicle;
|
||||||
|
}
|
42
src/entity/unit/inspection/inspectionPlan.ts
Normal file
42
src/entity/unit/inspection/inspectionPlan.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { Equipment } from "../equipment/equipment";
|
||||||
|
import { Vehicle } from "../vehicle/vehicle";
|
||||||
|
import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||||
|
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class inspectionPlan {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
inspectionInterval: PlanTimeDefinition;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
remindTime: PlanTimeDefinition;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
created: Date;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
vehicleId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Equipment)
|
||||||
|
equipment: Equipment;
|
||||||
|
|
||||||
|
@ManyToOne(() => Vehicle)
|
||||||
|
vehicle: Vehicle;
|
||||||
|
|
||||||
|
@OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, {
|
||||||
|
cascade: ["insert"],
|
||||||
|
})
|
||||||
|
versionedPlans: inspectionVersionedPlan[];
|
||||||
|
|
||||||
|
latestVersionedPlan?: inspectionVersionedPlan;
|
||||||
|
}
|
39
src/entity/unit/inspection/inspectionPoint.ts
Normal file
39
src/entity/unit/inspection/inspectionPoint.ts
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { InspectionPointEnum } from "../../../enums/inspectionEnum";
|
||||||
|
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class inspectionPoint {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Column({ type: "text" })
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: "varchar",
|
||||||
|
length: 255,
|
||||||
|
transformer: {
|
||||||
|
to(value: InspectionPointEnum) {
|
||||||
|
return value.toString();
|
||||||
|
},
|
||||||
|
from(value: string) {
|
||||||
|
return InspectionPointEnum[value as keyof typeof InspectionPointEnum];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
type: InspectionPointEnum;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
min: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspectionVersionedPlan, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
versionedPlan: inspectionVersionedPlan;
|
||||||
|
}
|
19
src/entity/unit/inspection/inspectionPointResult.ts
Normal file
19
src/entity/unit/inspection/inspectionPointResult.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { inspection } from "./inspection";
|
||||||
|
import { inspectionPoint } from "./inspectionPoint";
|
||||||
|
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class inspectionPointResult {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "text" })
|
||||||
|
value: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspection)
|
||||||
|
inspection: inspection;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspectionPoint)
|
||||||
|
inspectionPoint: inspectionPoint;
|
||||||
|
}
|
35
src/entity/unit/inspection/inspectionVersionedPlan.ts
Normal file
35
src/entity/unit/inspection/inspectionVersionedPlan.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, Unique } from "typeorm";
|
||||||
|
import { Equipment } from "../equipment/equipment";
|
||||||
|
import { Vehicle } from "../vehicle/vehicle";
|
||||||
|
import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||||
|
import { inspectionPlan } from "./inspectionPlan";
|
||||||
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||||
|
import { inspectionPoint } from "./inspectionPoint";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
@Unique("unique_version", ["version", "inspectionPlanId"])
|
||||||
|
export class inspectionVersionedPlan {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
version: number;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
created: Date;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
inspectionPlanId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => inspectionPlan, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
inspectionPlan: inspectionPlan;
|
||||||
|
|
||||||
|
@OneToMany(() => inspectionPoint, (ip) => ip.versionedPlan, {
|
||||||
|
cascade: ["insert"],
|
||||||
|
})
|
||||||
|
inspectionPoints: inspectionPoint[];
|
||||||
|
}
|
5
src/enums/inspectionEnum.ts
Normal file
5
src/enums/inspectionEnum.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export enum InspectionPointEnum {
|
||||||
|
oknok = "oknok",
|
||||||
|
text = "text",
|
||||||
|
number = "number",
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import type { EquipmentViewModel } from "../equipment/equipment.models";
|
||||||
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
||||||
import type { WearableViewModel } from "../wearable/wearable.models";
|
import type { WearableViewModel } from "../wearable/wearable.models";
|
||||||
|
|
||||||
export interface DamageReportViewModel {
|
export type DamageReportViewModel = {
|
||||||
id: string;
|
id: string;
|
||||||
reported: Date;
|
reported: Date;
|
||||||
status: string;
|
status: string;
|
||||||
|
@ -10,9 +10,20 @@ export interface DamageReportViewModel {
|
||||||
description: string;
|
description: string;
|
||||||
providedImage: Array<string>;
|
providedImage: Array<string>;
|
||||||
relatedId: string;
|
relatedId: string;
|
||||||
related: EquipmentViewModel | VehicleViewModel | WearableViewModel;
|
} & (
|
||||||
affected: "equipment" | "vehicle" | "wearable";
|
| {
|
||||||
}
|
assigned: "equipment";
|
||||||
|
related: EquipmentViewModel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
assigned: "vehicle";
|
||||||
|
related: VehicleViewModel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
assigned: "wearable";
|
||||||
|
related: WearableViewModel;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export interface CreateDamageReportViewModel {
|
export interface CreateDamageReportViewModel {
|
||||||
description: string;
|
description: string;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
} from "../inspectionPlan/inspectionPlan.models";
|
} from "../inspectionPlan/inspectionPlan.models";
|
||||||
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
||||||
|
|
||||||
export interface InspectionViewModel {
|
export type InspectionViewModel = {
|
||||||
id: string;
|
id: string;
|
||||||
inspectionPlanId: string;
|
inspectionPlanId: string;
|
||||||
inspectionPlan: InspectionPlanViewModel;
|
inspectionPlan: InspectionPlanViewModel;
|
||||||
|
@ -18,16 +18,16 @@ export interface InspectionViewModel {
|
||||||
nextInspection?: Date;
|
nextInspection?: Date;
|
||||||
checks: Array<InspectionPointResultViewModel>;
|
checks: Array<InspectionPointResultViewModel>;
|
||||||
relatedId: string;
|
relatedId: string;
|
||||||
related: EquipmentViewModel | VehicleViewModel;
|
} & (
|
||||||
}
|
| {
|
||||||
|
assigned: "equipment";
|
||||||
export interface InspectionPointViewModel {
|
related: EquipmentViewModel;
|
||||||
id: string;
|
}
|
||||||
title: string;
|
| {
|
||||||
description: string;
|
assigned: "vehicle";
|
||||||
type: "iO-niO" | "text" | "number";
|
related: VehicleViewModel;
|
||||||
min?: number;
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
export interface InspectionPointResultViewModel {
|
export interface InspectionPointResultViewModel {
|
||||||
inspectionId: string;
|
inspectionId: string;
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
|
import { InspectionPointEnum } from "../../../../enums/inspectionEnum";
|
||||||
import type { EquipmentViewModel } from "../equipment/equipment.models";
|
import type { EquipmentViewModel } from "../equipment/equipment.models";
|
||||||
import type { EquipmentTypeViewModel } from "../equipmentType/equipmentType.models";
|
|
||||||
import type { InspectionPointViewModel } from "../inspection/inspection.models";
|
|
||||||
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
import type { VehicleViewModel } from "../vehicle/vehicle.models";
|
||||||
import type { VehicleTypeViewModel } from "../vehicleType/vehicleType.models";
|
|
||||||
|
|
||||||
export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`;
|
export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`;
|
||||||
|
|
||||||
export interface InspectionPlanViewModel {
|
export type InspectionPlanViewModel = {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
inspectionInterval: PlanTimeDefinition;
|
inspectionInterval: PlanTimeDefinition;
|
||||||
|
@ -15,8 +13,16 @@ export interface InspectionPlanViewModel {
|
||||||
created: Date;
|
created: Date;
|
||||||
inspectionPoints: InspectionPointViewModel[];
|
inspectionPoints: InspectionPointViewModel[];
|
||||||
relatedId: string;
|
relatedId: string;
|
||||||
related: EquipmentTypeViewModel | VehicleTypeViewModel;
|
} & (
|
||||||
}
|
| {
|
||||||
|
assigned: "equipment";
|
||||||
|
related: EquipmentViewModel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
assigned: "vehicle";
|
||||||
|
related: VehicleViewModel;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export interface InspectionVersionedPlanViewModel {
|
export interface InspectionVersionedPlanViewModel {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -25,6 +31,14 @@ export interface InspectionVersionedPlanViewModel {
|
||||||
inspectionPoints: InspectionPointViewModel[];
|
inspectionPoints: InspectionPointViewModel[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InspectionPointViewModel {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
type: InspectionPointEnum;
|
||||||
|
min?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreateInspectionPlanViewModel {
|
export interface CreateInspectionPlanViewModel {
|
||||||
title: string;
|
title: string;
|
||||||
inspectionInterval: PlanTimeDefinition;
|
inspectionInterval: PlanTimeDefinition;
|
||||||
|
|
Loading…
Add table
Reference in a new issue