namespace QMSDAL.DTO { // ── TPCSCARDSTAGE — one row per routing stage per card ─────────────────── public class PcsCardStageDTO { public int PcsCardStaeId { get; set; } // note: "STAE" matches DB column public int PcsCardId { get; set; } // Routing stage snapshot (immutable after card creation) public int RoutingDetailId { get; set; } public short StageNo { get; set; } public string StageCode { get; set; } = string.Empty; public string StageName { get; set; } = string.Empty; public string StageGroup { get; set; } = string.Empty; // PCS control flags (snapshot from MROUTINGDETAIL) // RequiresSupervisor: 0=OperatorOnly 1=SupervisorSignOff public byte RequiresSupervisor { get; set; } // RequiresMaterialLog: 0=No 1=MaterialBatchEntryRequired public byte RequiresMaterialLog { get; set; } // AllowQuantity: 0=NoQtyDisposition 1=EnterGood/Rework/Reject/Other public byte AllowQuantity { get; set; } // ChecklistId: FK to MCHECKLIST (-1 = no checklist for this stage) public int ChecklistId { get; set; } = -1; // Timing public DateTime? PlannedStart { get; set; } public DateTime? PlannedEnd { get; set; } public DateTime? ActualStart { get; set; } public DateTime? ActualEnd { get; set; } // Personnel public int OperatorId { get; set; } = -1; public int SupervisorId { get; set; } = -1; public DateTime? Supervisedon { get; set; } // Quantity disposition (only when AllowQuantity=1) public decimal GoodQuantity { get; set; } public decimal ReworkQuantity { get; set; } public decimal RejectedQuantity { get; set; } public decimal OtherQuantity { get; set; } // Checklist log link // ChecklistLogId: FK to TCHECKLISTLOG (-1 until OpenStageAsync creates the log) public int ChecklistLogId { get; set; } = -1; // Status / result // StageStatus: 0=Pending 1=InProgress 2=Complete 3=OnHold 4=NcrRaised 5=Skipped public byte StageStatus { get; set; } // StageResult: 0=Pending 1=Pass 2=Fail 3=ReworkRequired public byte StageResult { get; set; } public string? Remarks { get; set; } // ── Joined / computed — not persisted ──────────────────────────────── public string? OperatorName { get; set; } public string? SupervisorName { get; set; } } // ── PCS stage action DTOs ──────────────────────────────────────────────── public class PcsOpenStageDTO { public int PcsCardStaeId { get; set; } public int OperatorId { get; set; } = -1; } public class PcsStageCompleteDTO { public int PcsCardStaeId { get; set; } public int SupervisorId { get; set; } public string? Remarks { get; set; } } public class PcsNcrDTO { public int PcsCardStaeId { get; set; } public string Description { get; set; } = string.Empty; } public class PcsSkipStageDTO { public int PcsCardStaeId { get; set; } public int SupervisorId { get; set; } public string Reason { get; set; } = string.Empty; } // ── Stage save (stage fields + materials) ──────────────────────────────── public class PcsStageSaveDTO { public PcsCardStageDTO Stage { get; set; } = new(); public IEnumerable Materials { get; set; } = []; } // ── Routing detail row used when creating PCS card stages ──────────────── // VARIANTS is a JSON string (e.g. '["VARIM","RTM"]'); empty array = all variants public class RoutingDetailForPcsDTO { public int RoutingDetailId { get; set; } public short StageNo { get; set; } public string StageCode { get; set; } = string.Empty; public string StageName { get; set; } = string.Empty; public string StageGroup { get; set; } = string.Empty; public byte RequiresSupervisor { get; set; } public byte RequiresMaterialLog { get; set; } public byte AllowQuantity { get; set; } public int ChecklistId { get; set; } = -1; public string? Variants { get; set; } } }