using System;
using System.Collections.Generic;

namespace NPP.SmartSchedue.Api.Contracts.Services.Time.Output;

/// <summary>
/// 批量操作结果输出模型
/// 用于返回批量操作的执行结果和统计信息
/// </summary>
public class BatchOperationResult
{
    /// <summary>
    /// 操作是否成功
    /// </summary>
    public bool IsSuccess { get; set; }

    /// <summary>
    /// 操作消息
    /// </summary>
    public string Message { get; set; }

    /// <summary>
    /// 总记录数
    /// </summary>
    public int TotalCount { get; set; }

    /// <summary>
    /// 成功处理的记录数量
    /// </summary>
    public int ProcessedCount { get; set; }

    /// <summary>
    /// 成功操作数量
    /// </summary>
    public int SuccessCount { get; set; }

    /// <summary>
    /// 跳过的记录数量（通常是已存在且不覆盖的记录）
    /// </summary>
    public int SkippedCount { get; set; }

    /// <summary>
    /// 失败的记录数量
    /// </summary>
    public int FailedCount { get; set; }

    /// <summary>
    /// 错误消息列表
    /// </summary>
    public List<string> ErrorMessages { get; set; } = new();

    /// <summary>
    /// 警告消息列表
    /// </summary>
    public List<string> WarningMessages { get; set; } = new();

    /// <summary>
    /// 操作详细信息
    /// </summary>
    public string OperationDetails { get; set; }

    /// <summary>
    /// 操作耗时（毫秒）
    /// </summary>
    public long ElapsedMilliseconds { get; set; }

    /// <summary>
    /// 操作开始时间
    /// </summary>
    public DateTime StartTime { get; set; }

    /// <summary>
    /// 操作结束时间
    /// </summary>
    public DateTime EndTime { get; set; }

    /// <summary>
    /// 失败项目详细信息列表
    /// </summary>
    public List<BatchOperationFailedItem> FailedItems { get; set; } = new();

    /// <summary>
    /// 批量操作的统计摘要
    /// </summary>
    public BatchOperationSummary Summary { get; set; } = new();
}

/// <summary>
/// 批量操作统计摘要
/// </summary>
public class BatchOperationSummary
{
    /// <summary>
    /// 总记录数
    /// </summary>
    public int TotalRecords { get; set; }

    /// <summary>
    /// 成功率（百分比）
    /// </summary>
    public decimal SuccessRate { get; set; }

    /// <summary>
    /// 涉及的员工数量
    /// </summary>
    public int AffectedPersonnelCount { get; set; }

    /// <summary>
    /// 涉及的日期范围
    /// </summary>
    public string DateRange { get; set; }

    /// <summary>
    /// 涉及的班次数量
    /// </summary>
    public int AffectedShiftCount { get; set; }

    /// <summary>
    /// 操作类型描述
    /// </summary>
    public string OperationType { get; set; }
}

/// <summary>
/// 批量操作失败项目详细信息
/// 记录单个失败项目的具体信息
/// </summary>
public class BatchOperationFailedItem
{
    /// <summary>
    /// 日期
    /// </summary>
    public DateTime Date { get; set; }

    /// <summary>
    /// 班次ID
    /// </summary>
    public long ShiftId { get; set; }

    /// <summary>
    /// 班次名称
    /// </summary>
    public string ShiftName { get; set; }

    /// <summary>
    /// 员工ID
    /// </summary>
    public long? PersonnelId { get; set; }

    /// <summary>
    /// 员工姓名
    /// </summary>
    public string PersonnelName { get; set; }

    /// <summary>
    /// 失败原因
    /// </summary>
    public string Reason { get; set; }

    /// <summary>
    /// 错误代码
    /// </summary>
    public string ErrorCode { get; set; }
}