F3.1: asociar Inventario con familia técnica
This commit is contained in:
@@ -1,42 +1,25 @@
|
|||||||
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm';
|
||||||
import { TimestampedEntity } from './timestamped.entity';
|
import { TimestampedEntity } from './timestamped.entity';
|
||||||
|
import {
|
||||||
export enum AssetInformationStatus {
|
AssetDataOrigin,
|
||||||
DRAFT = 'DRAFT',
|
AssetInformationStatus,
|
||||||
PENDING_SURVEY = 'PENDING_SURVEY',
|
AssetOperationalStatus,
|
||||||
SURVEYED = 'SURVEYED',
|
} from './enums';
|
||||||
VALIDATED = 'VALIDATED',
|
|
||||||
OBSERVED = 'OBSERVED',
|
|
||||||
OUTDATED = 'OUTDATED',
|
|
||||||
INACTIVE = 'INACTIVE',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum AssetOperationalStatus {
|
|
||||||
UNKNOWN = 'UNKNOWN',
|
|
||||||
IN_SERVICE = 'IN_SERVICE',
|
|
||||||
TEMPORARILY_OUT_OF_SERVICE = 'TEMPORARILY_OUT_OF_SERVICE',
|
|
||||||
OUT_OF_SERVICE = 'OUT_OF_SERVICE',
|
|
||||||
DECOMMISSIONED = 'DECOMMISSIONED',
|
|
||||||
ABANDONED = 'ABANDONED',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum AssetDataOrigin {
|
|
||||||
MANUAL = 'MANUAL',
|
|
||||||
FIELD_SURVEY = 'FIELD_SURVEY',
|
|
||||||
PROVIDED_DOCUMENT = 'PROVIDED_DOCUMENT',
|
|
||||||
IMPORT = 'IMPORT',
|
|
||||||
SYSTEM = 'SYSTEM',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity({ name: 'assets' })
|
@Entity({ name: 'assets' })
|
||||||
@Index('idx_assets_type_id', ['assetTypeId'])
|
@Index('uq_assets_code', ['code'], { unique: true })
|
||||||
@Index('idx_assets_parent_id', ['parentId'])
|
@Index('idx_assets_parent', ['parentId'])
|
||||||
@Index('idx_assets_operational_area_id', ['operationalAreaId'])
|
@Index('idx_assets_type', ['assetTypeId'])
|
||||||
@Index('idx_assets_operator_company_id', ['operatorCompanyId'])
|
@Index('idx_assets_status', ['informationStatus'])
|
||||||
@Index('idx_assets_information_status', ['informationStatus'])
|
|
||||||
@Index('idx_assets_operational_status', ['operationalStatus'])
|
@Index('idx_assets_operational_status', ['operationalStatus'])
|
||||||
@Index('idx_assets_data_origin', ['dataOrigin'])
|
@Index('idx_assets_operational_area', ['operationalAreaId'])
|
||||||
@Index('idx_assets_provenance_verified_at', ['provenanceVerifiedAt'])
|
@Index('idx_assets_operator_company', ['operatorCompanyId'])
|
||||||
|
@Index('idx_assets_inventory_family', ['inventoryFamilyId'])
|
||||||
export class Asset extends TimestampedEntity {
|
export class Asset extends TimestampedEntity {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id!: string;
|
id!: string;
|
||||||
@@ -53,13 +36,16 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ name: 'operator_company_id', type: 'uuid', nullable: true })
|
@Column({ name: 'operator_company_id', type: 'uuid', nullable: true })
|
||||||
operatorCompanyId!: string | null;
|
operatorCompanyId!: string | null;
|
||||||
|
|
||||||
|
@Column({ name: 'inventory_family_id', type: 'uuid', nullable: true })
|
||||||
|
inventoryFamilyId!: string | null;
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 120 })
|
@Column({ type: 'varchar', length: 120 })
|
||||||
code!: string;
|
code!: string;
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 200 })
|
@Column({ type: 'varchar', length: 240 })
|
||||||
name!: string;
|
name!: string;
|
||||||
|
|
||||||
@Column({ name: 'common_name', type: 'varchar', length: 200, nullable: true })
|
@Column({ name: 'common_name', type: 'varchar', length: 240, nullable: true })
|
||||||
commonName!: string | null;
|
commonName!: string | null;
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
@Column({ type: 'text', nullable: true })
|
||||||
@@ -67,14 +53,18 @@ export class Asset extends TimestampedEntity {
|
|||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
name: 'information_status',
|
name: 'information_status',
|
||||||
type: 'enum',
|
type: 'varchar',
|
||||||
enum: AssetInformationStatus,
|
length: 20,
|
||||||
enumName: 'asset_information_status',
|
|
||||||
default: AssetInformationStatus.DRAFT,
|
default: AssetInformationStatus.DRAFT,
|
||||||
})
|
})
|
||||||
informationStatus!: AssetInformationStatus;
|
informationStatus!: AssetInformationStatus;
|
||||||
|
|
||||||
@Column({ name: 'operational_status', type: 'enum', enum: AssetOperationalStatus, enumName: 'asset_operational_status', default: AssetOperationalStatus.UNKNOWN })
|
@Column({
|
||||||
|
name: 'operational_status',
|
||||||
|
type: 'varchar',
|
||||||
|
length: 24,
|
||||||
|
default: AssetOperationalStatus.IN_SERVICE,
|
||||||
|
})
|
||||||
operationalStatus!: AssetOperationalStatus;
|
operationalStatus!: AssetOperationalStatus;
|
||||||
|
|
||||||
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
||||||
@@ -83,16 +73,18 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
||||||
updatedBy!: string | null;
|
updatedBy!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
@Column({
|
||||||
currentVersion!: number;
|
name: 'data_origin',
|
||||||
|
type: 'varchar',
|
||||||
@Column({ name: 'data_origin', type: 'varchar', length: 32, default: AssetDataOrigin.MANUAL })
|
length: 20,
|
||||||
|
default: AssetDataOrigin.MANUAL,
|
||||||
|
})
|
||||||
dataOrigin!: AssetDataOrigin;
|
dataOrigin!: AssetDataOrigin;
|
||||||
|
|
||||||
@Column({ name: 'source_name', type: 'varchar', length: 160, nullable: true })
|
@Column({ name: 'source_name', type: 'varchar', length: 240, nullable: true })
|
||||||
sourceName!: string | null;
|
sourceName!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'source_reference', type: 'varchar', length: 255, nullable: true })
|
@Column({ name: 'source_reference', type: 'varchar', length: 500, nullable: true })
|
||||||
sourceReference!: string | null;
|
sourceReference!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'source_observed_at', type: 'timestamptz', nullable: true })
|
@Column({ name: 'source_observed_at', type: 'timestamptz', nullable: true })
|
||||||
@@ -107,9 +99,9 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ name: 'provenance_verified_by', type: 'uuid', nullable: true })
|
@Column({ name: 'provenance_verified_by', type: 'uuid', nullable: true })
|
||||||
provenanceVerifiedBy!: string | null;
|
provenanceVerifiedBy!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'provenance_updated_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
||||||
provenanceUpdatedAt!: Date;
|
|
||||||
|
|
||||||
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
||||||
provenanceUpdatedBy!: string | null;
|
provenanceUpdatedBy!: string | null;
|
||||||
|
|
||||||
|
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
||||||
|
currentVersion!: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user