Add complete dispatch module for incident assignment: Entities (7): - DispatchBoard: Board configuration - UnitStatus: Real-time unit state - TechnicianSkill: Skills and certifications - TechnicianShift: Shift schedules - DispatchRule: Assignment rules - EscalationRule: Escalation rules - DispatchLog: Audit trail Services (4): - DispatchService: Unit management, assignments, suggestions - SkillService: Skill CRUD, validation, matrix - ShiftService: Shift management, availability - RuleService: Dispatch and escalation rules Controllers (4): - DispatchController: /api/v1/dispatch - SkillController: /api/v1/dispatch/skills - ShiftController: /api/v1/dispatch/shifts - RuleController: /api/v1/dispatch/rules Integrated in main.ts with routes and documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
/**
|
|
* DispatchRule Entity
|
|
* Mecanicas Diesel - ERP Suite
|
|
*
|
|
* Rules for automatic assignment suggestions.
|
|
* Module: MMD-011 Dispatch Center
|
|
*/
|
|
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Index,
|
|
} from 'typeorm';
|
|
|
|
export interface DispatchConditions {
|
|
requiresSkills?: string[];
|
|
requiresAssetCategories?: string[];
|
|
minUnitCapacity?: 'light' | 'medium' | 'heavy';
|
|
maxDistanceKm?: number;
|
|
zoneCodes?: string[];
|
|
minSkillLevel?: 'basic' | 'intermediate' | 'advanced' | 'expert';
|
|
excludeOnCall?: boolean;
|
|
}
|
|
|
|
@Entity({ name: 'dispatch_rules', schema: 'dispatch' })
|
|
@Index('idx_dispatch_rules_tenant', ['tenantId'])
|
|
@Index('idx_dispatch_rules_priority', ['tenantId', 'priority'])
|
|
export class DispatchRule {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
name: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description?: string;
|
|
|
|
@Column({ type: 'integer', default: 0 })
|
|
priority: number;
|
|
|
|
// Applicability
|
|
@Column({ name: 'service_type_code', type: 'varchar', length: 50, nullable: true })
|
|
serviceTypeCode?: string;
|
|
|
|
@Column({ name: 'incident_category', type: 'varchar', length: 50, nullable: true })
|
|
incidentCategory?: string;
|
|
|
|
// Conditions
|
|
@Column({ type: 'jsonb', default: {} })
|
|
conditions: DispatchConditions;
|
|
|
|
// Action
|
|
@Column({ name: 'auto_assign', type: 'boolean', default: false })
|
|
autoAssign: boolean;
|
|
|
|
@Column({ name: 'assignment_weight', type: 'integer', default: 100 })
|
|
assignmentWeight: number;
|
|
|
|
@Column({ name: 'is_active', type: 'boolean', default: true })
|
|
isActive: boolean;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy?: string;
|
|
}
|