71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum InspectionVisitStatus {
|
|
DRAFT = 'DRAFT',
|
|
PLANNED = 'PLANNED',
|
|
IN_PROGRESS = 'IN_PROGRESS',
|
|
CLOSED = 'CLOSED',
|
|
CANCELLED = 'CANCELLED',
|
|
}
|
|
|
|
@Entity({ name: 'inspection_visits' })
|
|
@Index('uq_inspection_visits_code', ['code'], { unique: true })
|
|
@Index('idx_inspection_visits_status', ['status'])
|
|
@Index('idx_inspection_visits_scope_asset_id', ['scopeAssetId'])
|
|
@Index('idx_inspection_visits_lead_inspector_user_id', ['leadInspectorUserId'])
|
|
@Index('idx_inspection_visits_planned_start_at', ['plannedStartAt'])
|
|
@Index('idx_inspection_visits_operational_context', ['operationalAreaId', 'operatorCompanyId'])
|
|
export class InspectionVisit extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ type: 'varchar', length: 80 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
objective!: string | null;
|
|
|
|
@Column({ type: 'varchar', length: 24, default: InspectionVisitStatus.DRAFT })
|
|
status!: InspectionVisitStatus;
|
|
|
|
@Column({ name: 'scope_asset_id', type: 'uuid', nullable: true })
|
|
scopeAssetId!: string | null;
|
|
|
|
@Column({ name: 'operational_area_id', type: 'uuid', nullable: true })
|
|
operationalAreaId!: string | null;
|
|
|
|
@Column({ name: 'operator_company_id', type: 'uuid', nullable: true })
|
|
operatorCompanyId!: string | null;
|
|
|
|
@Column({ name: 'lead_inspector_user_id', type: 'uuid', nullable: true })
|
|
leadInspectorUserId!: string | null;
|
|
|
|
@Column({ name: 'planned_start_at', type: 'timestamptz', nullable: true })
|
|
plannedStartAt!: Date | null;
|
|
|
|
@Column({ name: 'actual_started_at', type: 'timestamptz', nullable: true })
|
|
actualStartedAt!: Date | null;
|
|
|
|
@Column({ name: 'actual_closed_at', type: 'timestamptz', nullable: true })
|
|
actualClosedAt!: Date | null;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
instructions!: string | null;
|
|
|
|
@Column({ name: 'cancellation_reason', type: 'text', nullable: true })
|
|
cancellationReason!: string | null;
|
|
|
|
@Column({ name: 'checklist_generation', type: 'integer', default: 0 })
|
|
checklistGeneration!: number;
|
|
|
|
@Column({ name: 'checklist_generated_at', type: 'timestamptz', nullable: true })
|
|
checklistGeneratedAt!: Date | null;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|