using PowderCoating.Core.Enums;

namespace PowderCoating.Core.Entities;

public class OvenBatch : BaseEntity
{
    public string BatchNumber { get; set; } = string.Empty;
    public int? EquipmentId { get; set; }
    public int? OvenCostId { get; set; }
    public OvenBatchStatus Status { get; set; } = OvenBatchStatus.Planned;

    public DateTime ScheduledDate { get; set; }
    public DateTime? ScheduledStartTime { get; set; }
    public DateTime? EstimatedEndTime { get; set; }
    public DateTime? ActualStartTime { get; set; }
    public DateTime? ActualEndTime { get; set; }

    public decimal TotalSurfaceAreaSqFt { get; set; }
    public decimal? CureTemperatureF { get; set; }
    public int CycleMinutes { get; set; } = 45;

    public string? PrimaryColorName { get; set; }
    public string? PrimaryColorCode { get; set; }

    public bool AiSuggested { get; set; }
    public string? AiReasoningJson { get; set; }
    public string? Notes { get; set; }

    // Navigation
    public virtual Equipment? Equipment { get; set; }
    public virtual OvenCost? OvenCost { get; set; }
    public virtual ICollection<OvenBatchItem> Items { get; set; } = new List<OvenBatchItem>();
}

public class OvenBatchItem : BaseEntity
{
    public int OvenBatchId { get; set; }
    public int JobId { get; set; }
    public int JobItemId { get; set; }
    public int JobItemCoatId { get; set; }

    public decimal SurfaceAreaContribution { get; set; }
    public int CoatPassNumber { get; set; } = 1;
    public int SortOrder { get; set; }
    public OvenBatchItemStatus Status { get; set; } = OvenBatchItemStatus.Pending;
    public string? Notes { get; set; }

    // Navigation
    public virtual OvenBatch Batch { get; set; } = null!;
    public virtual Job Job { get; set; } = null!;
    public virtual JobItem JobItem { get; set; } = null!;
    public virtual JobItemCoat JobItemCoat { get; set; } = null!;
}
