using Hotline.Share.Tools;

namespace Hotline.Share.Dtos.CallCenter;

/// <summary>
/// 坐席话务量统计
/// </summary>
public class BiSeatCallsDto
{
    /// <summary>
    /// 坐席姓名
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 用户ID
    /// </summary>
    public string UserId { get; set; }

    /// <summary>
    /// 工号
    /// </summary>
    public string StaffNo { get; set; }

    /// <summary>
    /// 分机号
    /// </summary>
    public string TelNo { get; set; }

    /// <summary>
    /// 呼入总量
    /// </summary>
    public int InTotal { get; set; }

    /// <summary>
    /// 呼出总量
    /// </summary>
    public int OutTotal { get; set; }

    /// <summary>
    /// 呼入接通量
    /// </summary>
    public int InAnswered { get; set; }

    /// <summary>
    /// 呼出接通量
    /// </summary>
    public int OutAnswered { get; set; }

    /// <summary>
    /// 呼入秒挂
    /// </summary>
    public int InHangupImmediate { get; set; }

    /// <summary>
    /// 呼入未接
    /// </summary>
    public int InHanguped { get; set; }

    /// <summary>
    /// 呼入平均时长
    /// </summary>
    public double InDurationAvg { get; set; }

    /// <summary>
    /// 呼出平均时长
    /// </summary>
    public double OutDurationAvg { get; set; }

    /// <summary>
    /// 有效接通量
    /// </summary>
    public int InAvailableAnswer { get; set; }

    /// <summary>
    /// 呼入接通秒挂
    /// </summary>
    public int InHangupImmediateWhenAnswered { get; set; }

    /// <summary>
    /// 登录时长（秒)
    /// </summary>
    public double? LoginDuration { get; set; }

    /// <summary>
    /// 登录时长(显示)
    /// </summary>
    public string LoginDurationString => this.LoginDuration.SecondsToString();

    /// <summary>
    /// 小休+摘机时长 (秒)
    /// </summary>
    public double RestDuration { get; set; }

    /// <summary>
    /// 小休+摘机时长(显示)
    /// </summary>
    public string RestDurationString => this.RestDuration.SecondsToString();

    /// <summary>
    /// 呼入接通率
    /// </summary>
    public double InAnsweredRate => InTotal > 0 ? Math.Round(((double)InAnswered / (double)InTotal) * 100, digits: 4) : 0;

    /// <summary>
    /// 呼入接通率(显示)
    /// </summary>
    public string InAnsweredRateString => this.InAnsweredRate + "%";

    /// <summary>
    /// 呼出接通率
    /// </summary>
    public double OutAnsweredRate => OutTotal > 0 ? Math.Round(((double)OutAnswered / (double)OutTotal) * 100, digits: 4) : 0;

    /// <summary>
    /// 呼出接通率(显示)
    /// </summary>
    public string OutAnsweredRateString => this.OutAnsweredRate + "%";

    /// <summary>
    /// 呼入有效接通率
    /// </summary>
    public double AvailableAnswerRate => InTotal > 0 ? Math.Round(((double)InAvailableAnswer / (double)InTotal) * 100, digits: 4) : 0;

    /// <summary>
    /// 呼入有效接通率(显示)
    /// </summary>
    public string AvailableAnswerRateString => this.AvailableAnswerRate + "%";

    /// <summary>
    /// 工作效率
    /// </summary>
    public double WorkRate => LoginDuration > 0 ? Math.Round((1 - (double)RestDuration / (double)LoginDuration) * 100, digits: 4) : 0;

    /// <summary>
    /// 工作效率(显示)
    /// </summary>
    public string WorkRateString => this.WorkRate + "%";
}


public class BiSeatRestDto
{
    public string UserId { get; set; }
    public string? StaffNo { get; set; }

    public string UserName { get; set; }

    public int RestCount { get; set; }

    public double RestDuration { get; set; }

    public string RestDurationTxt => RestDuration.ToString("f2");

    /// <summary>
    /// 小休累计时长 (单元: 分)
    /// </summary>
    public double CumulativeDuration { get; set; }
    public string CumulativeDurationTxt => CumulativeDuration.ToString("f2");
}


public class BiSeatSwitchDto
{
    public string Id { get; set; }

    public string? UserId { get; set; }

    public string? UserName { get; set; }

    public string? CPN { get; set; }

    /// <summary>
    /// 外线号码
    /// </summary>
    public string? CDPN { get; set; }

    /// <summary>
    /// 分机号
    /// </summary>
    public string? TelNo { get; set; }

    /// <summary>
    /// 转接外线时间
    /// </summary>
    public DateTime CreatedTime { get; set; }
}


public class BiVisitNoSatisfiedDto
{
    public int Count { get; set; }
    public string Key { get; set; }
    
    
    public Dictionary<string,string> Org { get; set; }
    public string OrgName { get; set; }

    public string OrgCode { get; set; }
}