using System;
using System.Collections.Generic;
using Haoliang.Models.Common;

namespace Haoliang.Models.Models.System
{
    /// <summary>
    /// Production target configuration
    /// </summary>
    public class ProductionTargetConfig
    {
        public int DeviceId { get; set; }
        public string DeviceName { get; set; }
        public string ProgramName { get; set; }
        public decimal DailyTarget { get; set; }
        public decimal MonthlyTarget { get; set; }
        public decimal YearlyTarget { get; set; }
        public bool IsActive { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
        public string CreatedBy { get; set; }
        public string UpdatedBy { get; set; }
    }

    /// <summary>
    /// Working hours configuration
    /// </summary>
    public class WorkingHoursConfig
    {
        public List<DayOfWeek> WorkingDays { get; set; }
        public TimeSpan WorkingHours { get; set; }
        public int StartHour { get; set; }
        public int EndHour { get; set; }
        public List<TimeSpan> BreakIntervals { get; set; }
        public bool IncludeWeekendProduction { get; set; }
        public decimal WeekendOvertimeRate { get; set; }
        public decimal NightShiftRate { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Alert configuration
    /// </summary>
    public class AlertConfiguration
    {
        public bool EnableAlerts { get; set; }
        public List<string> AlertTypes { get; set; }
        public Dictionary<string, decimal> AlertThresholds { get; set; }
        public List<string> NotificationChannels { get; set; }
        public EmailSettings EmailSettings { get; set; }
        public SMSSettings SMSSettings { get; set; }
        public WebhookSettings WebhookSettings { get; set; }
        public bool EnableAlertHistory { get; set; }
        public int AlertRetentionDays { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Business rule configuration
    /// </summary>
    public class BusinessRuleConfig
    {
        public int RuleId { get; set; }
        public string RuleName { get; set; }
        public string Description { get; set; }
        public string RuleExpression { get; set; }
        public Dictionary<string, object> Parameters { get; set; }
        public bool Enabled { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
        public string CreatedBy { get; set; }
        public string UpdatedBy { get; set; }
        public List<string> Tags { get; set; }
    }

    /// <summary>
    /// Statistics rule configuration
    /// </summary>
    public class StatisticsRuleConfig
    {
        public int RuleId { get; set; }
        public string RuleName { get; set; }
        public string Description { get; set; }
        public string CalculationExpression { get; set; }
        public List<string> InputFields { get; set; }
        public string OutputField { get; set; }
        public CalculationMethod CalculationMethod { get; set; }
        public bool Enabled { get; set; }
        public int Priority { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Data retention configuration
    /// </summary>
    public class DataRetentionConfig
    {
        public int BusinessDataRetentionDays { get; set; }
        public int LogDataRetentionDays { get; set; }
        public int StatisticsDataRetentionDays { get; set; }
        public int AlertDataRetentionDays { get; set; }
        public bool AutoCleanupEnabled { get; set; }
        public string CleanupSchedule { get; set; }
        public bool CompressOldData { get; set; }
        public bool ArchiveDataBeforeDeletion { get; set; }
        public string ArchivePath { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Dashboard configuration
    /// </summary>
    public class DashboardConfig
    {
        public int RefreshInterval { get; set; }
        public bool EnableRealTimeUpdates { get; set; }
        public string DefaultTimeRange { get; set; }
        public List<string> AvailableTimeRanges { get; set; }
        public List<string> AvailableWidgets { get; set; }
        public List<WidgetConfig> DefaultWidgets { get; set; }
        public bool EnableExport { get; set; }
        public List<string> ExportFormats { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Export configuration
    /// </summary>
    public class ExportConfig
    {
        public List<string> AvailableFormats { get; set; }
        public List<string> AvailableFields { get; set; }
        public int MaxRecords { get; set; }
        public bool IncludeHeaders { get; set; }
        public string DateFormat { get; set; }
        public bool CompressFiles { get; set; }
        public string DefaultFormat { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Data collection configuration
    /// </summary>
    public class CollectionConfig
    {
        public int DefaultCollectionInterval { get; set; }
        public int MaxCollectionInterval { get; set; }
        public int MinCollectionInterval { get; set; }
        public bool EnableRetry { get; set; }
        public int MaxRetries { get; set; }
        public int RetryDelayMs { get; set; }
        public bool EnableDataValidation { get; set; }
        public bool EnableAutoRecovery { get; set; }
        public List<string> RequiredFields { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Notification configuration
    /// </summary>
    public class NotificationConfig
    {
        public bool EnableNotifications { get; set; }
        public List<string> NotificationTypes { get; set; }
        public EmailSettings EmailSettings { get; set; }
        public SMSSettings SMSSettings { get; set; }
        public WebhookSettings WebhookSettings { get; set; }
        bool PushNotificationSettings { get; set; }
        public int NotificationQueueSize { get; set; }
        public bool EnableNotificationHistory { get; set; }
        public int NotificationRetentionDays { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// Email settings
    /// </summary>
    public class EmailSettings
    {
        public bool EnableEmail { get; set; }
        public string SmtpServer { get; set; }
        public int SmtpPort { get; set; }
        public string SmtpUsername { get; set; }
        public string SmtpPassword { get; set; }
        public bool EnableSsl { get; set; }
        public List<string> Recipients { get; set; }
        public string SenderEmail { get; set; }
        public string SenderName { get; set; }
        public bool EnableHtmlFormat { get; set; }
    }

    /// <summary>
    /// SMS settings
    /// </summary>
    public class SMSSettings
    {
        public bool EnableSMS { get; set; }
        public string Provider { get; set; }
        public string ApiKey { get; set; }
        public string ApiSecret { get; set; }
        public string PhoneNumber { get; set; }
        public List<string> RecipientPhoneNumbers { get; set; }
        public bool EnableTestMode { get; set; }
    }

    /// <summary>
    /// Webhook settings
    /// </summary>
    public class WebhookSettings
    {
        public bool EnableWebhook { get; set; }
        public string WebhookUrl { get; set; }
        public string HttpMethod { get; set; }
        public Dictionary<string, string> Headers { get; set; }
        public string PayloadFormat { get; set; }
        public bool EnableRetry { get; set; }
        public int MaxRetries { get; set; }
        public int RetryDelayMs { get; set; }
        public bool EnableSignature { get; set; }
        public string SignatureKey { get; set; }
    }

    /// <summary>
    /// Widget configuration
    /// </summary>
    public class WidgetConfig
    {
        public string WidgetType { get; set; }
        public string WidgetId { get; set; }
        public string Title { get; set; }
        public int PositionX { get; set; }
        public int PositionY { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public Dictionary<string, object> Settings { get; set; }
        public bool IsVisible { get; set; }
        public int RefreshInterval { get; set; }
    }

    /// <summary>
    /// Configuration change tracking
    /// </summary>
    public class ConfigurationChange
    {
        public int ChangeId { get; set; }
        public string ConfigurationType { get; set; }
        public string ChangeType { get; set; }
        public string ChangedBy { get; set; }
        public DateTime ChangedAt { get; set; }
        public string OldValue { get; set; }
        public string NewValue { get; set; }
        public string Reason { get; set; }
        public string IPAddress { get; set; }
    }

    /// <summary>
    /// Calculation methods for statistics
    /// </summary>
    public enum CalculationMethod
    {
        Sum,
        Average,
        Minimum,
        Maximum,
        Count,
        Median,
        StandardDeviation,
        Percentage,
        Custom
    }
}