using System;
using System.Collections.Generic;

namespace Haoliang.Models.System
{
    public class StatisticResult
    {
        public int Id { get; set; }
        public int RuleId { get; set; }
        public StatisticRule Rule { get; set; }
        public DateTime StatisticTime { get; set; }
        public Dictionary<string, object> GroupValues { get; set; }
        public decimal MetricValue { get; set; }
        public string MetricValueDisplay { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class StatisticSummary
    {
        public DateTime Date { get; set; }
        public int DeviceId { get; set; }
        public string DeviceName { get; set; }
        public int TotalQuantity { get; set; }
        public int ValidQuantity { get; set; }
        public int InvalidQuantity { get; set; }
        public decimal QualityRate { get; set; }
        public double RunningTime { get; set; }
        public double Efficiency { get; set; }
    }

    public class StatisticDimension
    {
        public string Name { get; set; }
        public string Label { get; set; }
        public List<string> Values { get; set; }
    }

    public class StatisticMetric
    {
        public string Name { get; set; }
        public string Label { get; set; }
        public string Formula { get; set; }
        public string Unit { get; set; }
        public string Format { get; set; }
        public decimal Value { get; set; }
        public decimal PreviousValue { get; set; }
        public decimal ChangeRate { get; set; }
    }

    public class StatisticViewModel
    {
        public int RuleId { get; set; }
        public string RuleName { get; set; }
        public string Description { get; set; }
        public List<StatisticDimension> Dimensions { get; set; }
        public List<StatisticMetric> Metrics { get; set; }
        public List<StatisticResult> Results { get; set; }
        public DateTime FromTime { get; set; }
        public DateTime ToTime { get; set; }
    }

    public class StatisticFilter
    {
        public List<int> DeviceIds { get; set; }
        public List<string> NCPrograms { get; set; }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; }
        public string GroupBy { get; set; } // device, program, date, hour
        public int? RuleId { get; set; }
        public int? TopCount { get; set; }
    }
}