using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MDL.DTOs;

namespace BLL.Interfaces
{
    /// <summary>
    /// 指标计算服务接口
    /// </summary>
    public interface IMetricsCalculationService
    {
        /// <summary>
        /// 时间转换辅助方法：UTC 转 UTC-5
        /// </summary>
        DateTime ConvertUtcToUtc5(DateTime utcTime);

        /// <summary>
        /// 时间转换辅助方法：UTC-5 转 UTC
        /// </summary>
        DateTime ConvertUtc5ToUtc(DateTime utc5Time);

        /// <summary>
        /// 获取 UTC-5 时区的今天日期
        /// </summary>
        DateTime GetUtc5Today();

        /// <summary>
        /// 获取 UTC-5 日期的开始时间（UTC 表示）
        /// </summary>
        DateTime GetUtc5DateStart(DateTime utc5Date);

        /// <summary>
        /// 获取 UTC-5 日期的结束时间（UTC 表示）
        /// </summary>
        DateTime GetUtc5DateEnd(DateTime utc5Date);

        /// <summary>
        /// 获取指定交接单的标签率
        /// </summary>
        Task<LabelRateMetricsDto> GetLabelRateAsync(string handoverNumber);

        /// <summary>
        /// 获取指定订单的考核时间和完成状态
        /// </summary>
        Task<MetricsCalculationDto> GetOrderMetricsAsync(string neutralWaybillNumber);

        /// <summary>
        /// 获取当天新增换单数
        /// </summary>
        Task<int> GetDailyNewReplaceCountAsync(DateTime date);

        /// <summary>
        /// 获取累计要换的总单数
        /// </summary>
        Task<int> GetCumulativeTotalReplaceCountAsync(DateTime date);

        /// <summary>
        /// 获取当日换单完成数
        /// </summary>
        Task<int> GetDailyCompletionCountAsync(DateTime date);

        /// <summary>
        /// 获取当日STOP数
        /// </summary>
        Task<int> GetDailyStopCountAsync(DateTime date);

        /// <summary>
        /// 获取当日标签推送数
        /// </summary>
        Task<int> GetDailyLabelPushCountAsync(DateTime date);

        /// <summary>
        /// 获取当日未完结失败订单数
        /// </summary>
        Task<int> GetDailyUnfinishedFailureCountAsync();

        /// <summary>
        /// 获取当日换单失败数
        /// </summary>
        Task<int> GetDailyFailureCountAsync(DateTime date);

        /// <summary>
        /// 获取当日换单成功数
        /// </summary>
        Task<int> GetDailySuccessCountAsync(DateTime date);

        /// <summary>
        /// 获取当天应该换单数
        /// </summary>
        Task<int> GetDailyShouldReplaceCountAsync(DateTime date);

        /// <summary>
        /// 获取16点前到仓包裹数
        /// </summary>
        Task<int> GetBeforeNoonArrivedCountAsync(DateTime date);

        /// <summary>
        /// 获取16点后到仓包裹数
        /// </summary>
        Task<int> GetAfternoonArrivedCountAsync(DateTime date);

        /// <summary>
        /// 获取16点前考核通过包裹数
        /// </summary>
        Task<int> GetBeforeNoonPassedCountAsync(DateTime date);

        /// <summary>
        /// 获取16点后考核通过包裹数
        /// </summary>
        Task<int> GetAfternoonPassedCountAsync(DateTime date);

        /// <summary>
        /// 获取当日扫描数
        /// </summary>
        Task<int> GetDailyScanCountAsync(DateTime date);

        /// <summary>
        /// 计算24小时完成率
        /// </summary>
        Task<double> Calculate24HCompletionRateAsync(DateTime date);

        /// <summary>
        /// 计算当天换单完成率
        /// </summary>
        Task<double> CalculateDailyCompletionRateAsync(DateTime date);

        /// <summary>
        /// 获取完整的每日统计数据汇总
        /// </summary>
        Task<Daily24HCompletionRateDto> GetDailySummaryAsync(DateTime date);

        /// <summary>
        /// 批量计算多个订单的指标
        /// </summary>
        Task<List<MetricsCalculationDto>> GetBatchOrderMetricsAsync(List<string> neutralWaybillNumbers);

        /// <summary>
        /// 获取指定日期范围的每日统计
        /// </summary>
        Task<List<Daily24HCompletionRateDto>> GetDailySummariesAsync(DateTime startDate, DateTime endDate);

        /// <summary>
        /// 重新计算并缓存某个交接单的标签率
        /// </summary>
        Task<bool> RecalculateAndCacheLabelRateAsync(string handoverNumber);
    }
}
