
using Hotline.Share.Dtos.Caselibrary;
using Hotline.Share.Dtos.FlowEngine.Workflow;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.CallCenter;
using Hotline.Share.Requests;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.TrCallCenter
{
    #region 分机
    public class TrTelDto
    {
        public string Id { get; set; }

        public string Name { get; set; }

        public string TelNo { get; set; }

        public string Description { get; set; }

        public string QueueId { get; set; }

        /// <summary>
        /// 外呼分机组（由内部系统提供）
        /// </summary>
        public string? CallOutQueue { get; set; }
    }


    public class TrTelStateDto
    {
        /// <summary>
        /// ID
        /// </summary>
        public string? Id { get; set; }

        /// <summary>
        /// 分机号
        /// </summary>
        public string? TelNo { get; set; }
        /// <summary>
        /// 通道流水
        /// </summary>
        public string? ChannelUUid { get; set; }
        /// <summary>
        /// 鉴权用户名
        /// </summary>
        public string? TelName { get; set; }
        /// <summary>
        /// 分机状态机类型
        /// </summary>
        public string? Type { get; set; }
        /// <summary>
        /// 权重
        /// </summary>
        public string? Weight { get; set; }

        /// <summary>
        /// 所在呼叫组
        /// </summary>
        public string? Queue { get; set; }

        /// <summary>
        /// 分机状态
        /// </summary>
        public string? State { get; set; }

        /// <summary>
        /// 前一状态
        /// </summary>
        public string? OldState { get; set; }

        /// <summary>
        /// 注册设备
        /// </summary>
        public string? Device { get; set; }

        /// <summary>
        /// 注册IP
        /// </summary>
        public string? SipIp { get; set; }

        /// <summary>
        /// 二级状态
        /// </summary>
        public string? PrivateData { get; set; }

        /// <summary>
        /// 是否注册
        /// </summary>
        public string? SipState { get; set; }

        /// <summary>
        /// 签入时间
        /// </summary>
        public string? CreatedAt { get; set; }

        /// <summary>
        /// 状态变更时间
        /// </summary>
        public string? UpdatedAt { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public string? CallDirection { get; set; }

        /// <summary>
        /// 呼叫号码
        /// </summary>
        public string? OtherNumber { get; set; }

        /// <summary>
        /// 使用线路
        /// </summary>
        public string? GateWay { get; set; }

        /// <summary>
        /// 接听时间
        /// </summary>
        public string? AnsweredAt { get; set; }

        /// <summary>
        /// 分机用户名
        /// </summary>
        public string? WorkUserName { get; set; }

        /// <summary>
        /// 分机用户ID
        /// </summary>
        public string? WorkUserId { get; set; }

        /// <summary>
        /// 今日接听量
        /// </summary>
        public int OnStateCount { get; set; } = 0;
    }



    #endregion

    #region 黑白名单
    public class TrAddBlacklistDto
    {
        public string Phone { get; set; }

        public int SpecialFlag { get; set; }
    }

    public class TrDelBlacklistDto
    {
        public string Phone { get; set; }

        public int? SpecialFlag { get; set; }
    }

    public class TrQueryBlacklistDto
    {
        public string? Phone { get; set; }

        /// <summary>
        /// 1:白名单;2:呼入黑名单;3:呼出黑名单;4:呼入呼出黑名单;
        /// </summary>
        public int? SpecialFlag { get; set; }
    }

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

        public string UserId { get; set; }

        public DateTime CreationTime { get; set; }

        public string Phone { get; set; }

        public int SpecialFlag { get; set; }

        public int? Priority { get; set; }
    }
    #endregion

    #region 登录

    public class TrOnDutyDto
    {
        public string? TelNo { get; set; }

        public int TelModelState { get; set; }
    }

    public class ChangeTelModelDto
    {
        public bool isCallOut { get; set; }
    }

    public class TelOutDto
    {
        public string TelNo { get; set; }
        public string TelPwd { get; set; }
        public string Queue { get; set; }
    }

    public class TrOnDutyResponseDto
    {
        public string? TelNo { get; set; }

        public string? TelPwd { get; set; }

        public string? Description { get; set; }
        public string? QueueId { get; set; }

        public string? QueueCallOut { get; set; }

        public DateTime StartTime { get; set; }

        public bool? IsRest { get; set; }

        public bool? IsCallHold { get; set; }

        public bool? IsCallEndArrange { get; set; }

        public bool? IsTelMute { get; set; }

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

        public int Second => CalcSecond();

        public ETelModel? TelModel { get; set; }
        public int CalcSecond()
        {
            return (int)(DateTime.Now - StartTime).TotalSeconds;
        }
    }


    #endregion

    #region 小休

    public class TrRestDto
    {
        public string Reason { get; set; }
    }

    #endregion

    #region 通话记录（对外）

    public class ReceiveCallRecordDto
    {
        /// <summary>
        /// IPPBX用户名
        /// </summary>
        public string user { get; set; }

        /// <summary>
        /// 可直接访问的通话录音地址
        /// </summary>
        public string? recording_file_url { get; set; }

        /// <summary>
        /// 呼叫方向：呼入 in / 呼出 out
        /// </summary>
        public string call_direction { get; set; }

        /// <summary>
        /// 挂断方：主叫挂断 caller / 被叫挂断 callee / 其他未知情况
        /// </summary>
        public string hangup_side { get; set; }

        /// <summary>
        /// 转接分机号
        /// </summary>
        public string? agent_transfer_number { get; set; }

        /// <summary>
        /// 坐席侧通话流水，无坐席参与则为手机侧通话流水
        /// </summary>
        public string call_accept { get; set; }

        /// <summary>
        /// 主叫号码
        /// </summary>
        public string caller_id_name { get; set; }

        /// <summary>
        /// 主叫号码
        /// </summary>
        public string caller_id_number { get; set; }

        /// <summary>
        /// 被叫号码
        /// </summary>
        public string destination_number { get; set; }

        /// <summary>
        /// 通话录音绝对路径
        /// </summary>
        public string? recording_file_name { get; set; }

        /// <summary>
        /// 通话创建时间
        /// </summary>
        public string created_time { get; set; }

        /// <summary>
        /// 接通时间
        /// </summary>
        public string? answered_time { get; set; }

        /// <summary>
        /// 挂机时间
        /// </summary>
        public string over_time { get; set; }

        /// <summary>
        /// 线路号
        /// </summary>
        public string gateway { get; set; }

        /// <summary>
        /// 呼出时自定义的内容
        /// </summary>
        public string? other_str { get; set; }

        /// <summary>
        /// 手机侧通话流水，无坐席参与则为空
        /// </summary>
        public string? other_accept { get; set; }

        /// <summary>
        /// 状态码，语音信箱：999/其他：16
        /// </summary>
        public string status { get; set; }

        /// <summary>
        /// IVR开始时间
        /// </summary>
        public string? beginIvrTime { get; set; }

        /// <summary>
        /// IVR结束时间
        /// </summary>
        public string? endIvrTime { get; set; }

        /// <summary>
        /// 开始等待时间
        /// </summary>
        public string? beginQueueTime { get; set; }

        /// <summary>
        /// 结束等待时间
        /// </summary>
        public string? endQueueTime { get; set; }

        /// <summary>
        /// 开始振铃时间
        /// </summary>
        public string? beginRingTime { get; set; }

        /// <summary>
        /// 结束振铃时间
        /// </summary>
        public string? endRingTime { get; set; }

        /// <summary>
        /// 队列ID
        /// </summary>
        public string? ola_queue { get; set; }

        /// <summary>
        /// 批量外呼流水
        /// </summary>
        public string? batch_accept { get; set; }

        /// <summary>
        /// IVR按键信息
        /// </summary>
        public string? ivr_dtmf { get; set; }

        /// <summary>
        /// IVR按键对应动作，需解码
        /// </summary>
        public string? dtmf_type { get; set; }

        public string? phoneTypes { get; set; }
    }


    public class ReceiveCallEvaluateDto
    {
        public string dtmf { get; set; }

        public string call_accept { get; set; }
        public int type { get; set; }
    }

    public class PublishCallRecrodDto
    {
        public OrderDto? Order { get; set; }

        /// <summary>
        /// 办理节点信息
        /// </summary>
        public WorkflowTraceDto WorkflowTrace { get; set; }

        public TrCallDto? TrCallRecordDto { get; set; }
    }

    #endregion

    #region 通话记录（对内）

    public record class GetCallListDto : PagedRequest
    {
        /// <summary>
        /// 主叫
        /// </summary>
        public string? CPN { get; set; }
        /// <summary>
        /// 被叫
        /// </summary>
        public string? CDPN { get; set; }

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

        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 电话方向
        /// </summary>
        public ECallDirection? CallDirection { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        public EOnState? OnState { get; set; }

        /// <summary>
        /// 挂断方
        /// </summary>
        public EEndBy? EndBy { get; set; }

        /// <summary>
        /// IVR开始开始时间
        /// </summary>
        public DateTime? BeginIvrTimeStart { get; set; }

        /// <summary>
        /// IVR开始结束时间
        /// </summary>
        public DateTime? BeginIvrTimeEnd { get; set; }

        /// <summary>
        /// IVR结束开始时间
        /// </summary>
        public DateTime? EndIvrTimeStart { get; set; }

        /// <summary>
        /// IVR结束结束时间
        /// </summary>
        public DateTime? EndIvrTimeEnd { get; set; }

        /// <summary>
        /// 开始等待开始时间(队列开始时间)
        /// </summary>
        public DateTime? BeginQueueTimeStart { get; set; }

        /// <summary>
        /// 开始等待结束时间（队列开始时间）
        /// </summary>
        public DateTime? BeginQueueTimeEnd { get; set; }

        /// <summary>
        /// 结束等待开始时间（队列结束时间）
        /// </summary>
        public DateTime? EndQueueTimeStart { get; set; }

        /// <summary>
        /// 结束等待结束时间（队列结束时间）
        /// </summary>
        public DateTime? EndQueueTimeEnd { get; set; }

        /// <summary>
        /// 应答开始时间
        /// </summary>
        public DateTime? AnsweredTimeStart { get; set; }

        /// <summary>
        /// 应答结束时间
        /// </summary>
        public DateTime? AnsweredTimeEnd { get; set; }

        /// <summary>
        /// 通话结束开始时间
        /// </summary>
        public DateTime? OverTimeStart { get; set; }

        /// <summary>
        /// 通话结束结束时间
        /// </summary>
        public DateTime? OverTimeEnd { get; set; }

        /// <summary>
        /// 振铃开始开始时间
        /// </summary>
        public DateTime? BeginRingTimeStart { get; set; }

        /// <summary>
        /// 振铃开始结束时间
        /// </summary>
        public DateTime? BeginRingTimeEnd { get; set; }

        /// <summary>
        /// 振铃结束开始时间
        /// </summary>
        public DateTime? EndRingTimeStart { get; set; }

        /// <summary>
        /// 振铃结束结束时间
        /// </summary>
        public DateTime? EndRingTimeEnd { get; set; }

        /// <summary>
        /// 通话开始时间开始
        /// </summary>
        public DateTime? CallTimeStart { get; set; }

        /// <summary>
        /// 通话开始时间结束
        /// </summary>
        public DateTime? CallTimeEnd { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string? OrderNo { get; set; }

        /// <summary>
        /// 工单标题
        /// </summary>
        public string? Title { get; set; }

        /// <summary>
        /// 中继号
        /// </summary>
        public string? Gateway { get; set; }

        /// <summary>
        /// 是否智能应答（需要OnState条件传 接通）
        /// </summary>
        public bool IsAiAnswered { get; set; }

        /// <summary>
        /// 电话类型
        /// </summary>
        public EPhoneTypes? PhoneTypes { get; set; }

        /// <summary>
        /// 是否敏感词
        /// </summary>
        public bool? IsSensitiveWord { get; set; }

        /// <summary>
        /// 敏感词
        /// </summary>
        public string? SensitiveWord { get; set; }

        /// <summary>
        /// 是否自己的通话记录
        /// </summary>
        public string? QuerySelf { get; set; }
    }


    public class TrCallDto
    {
        public string Id { get; set; }
        /// <summary>
        /// 可直接访问的通话录音地址
        /// </summary>
        public string? RecordingFileUrl { get; set; }
        public string? RecordingBaseAddress { get; set; }
        public string? RecordingAbsolutePath { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public ECallDirection? CallDirection { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public string CallDirectionText => CallDirection?.GetDescription();

        /// <summary>
        /// 挂断方
        /// </summary>
        public EEndBy? EndBy { get; set; }

        /// <summary>
        /// 挂断方
        /// </summary>
        public string EndByText => EndBy.GetDescription();


        /// <summary>
        /// 坐席侧通话流水，无坐席参与则为手机侧通话流水
        /// </summary>
        public string CallAccept { get; set; }
        /// <summary>
        /// 主叫
        /// </summary>
        public string CPN { get; set; }
        /// <summary>
        /// 主叫名称
        /// </summary>
        public string CPNName { get; set; }
        /// <summary>
        /// 被叫
        /// </summary>
        public string CDPN { get; set; }
        /// <summary>
        /// 分机号
        /// </summary>
        public string TelNo { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 通话录音绝对路径
        /// </summary>
        public string? RecordingFileName { get; set; }
        /// <summary>
        /// 通话创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }
        /// <summary>
        /// 接通时间
        /// </summary>
        public DateTime? AnsweredTime { get; set; }
        /// <summary>
        /// 挂机时间
        /// </summary>
        public DateTime OverTime { get; set; }
        /// <summary>
        /// 线路号
        /// </summary>
        public string Gateway { get; set; }
        /// <summary>
        /// 呼出时自定义的内容
        /// </summary>
        public string? OtherStr { get; set; }
        /// <summary>
        /// 手机侧通话流水，无坐席参与则为空
        /// </summary>
        public string? OtherAccept { get; set; }
        /// <summary>
        /// 状态码，语音信箱：999/其他：16
        /// </summary>
        public string Status { get; set; }
        /// <summary>
        /// IVR开始时间
        /// </summary>
        public DateTime? BeginIvrTime { get; set; }
        /// <summary>
        /// IVR结束时间
        /// </summary>
        public DateTime? EndIvrTime { get; set; }
        /// <summary>
        /// 开始等待时间
        /// </summary>
        public DateTime? BeginQueueTime { get; set; }
        /// <summary>
        /// 结束等待时间
        /// </summary>
        public DateTime? EndQueueTime { get; set; }
        /// <summary>
        /// 开始振铃时间
        /// </summary>
        public DateTime? BeginRingTime { get; set; }
        /// <summary>
        /// 结束振铃时间
        /// </summary>
        public DateTime? EndRingTimg { get; set; }
        /// <summary>
        /// 队列ID
        /// </summary>
        public string? OlaQueue { get; set; }
        /// <summary>
        /// 批量外呼流水
        /// </summary>
        public string? BatchAccept { get; set; }
        /// <summary>
        /// IVR按键信息
        /// </summary>
        public string? IvrDtmf { get; set; }
        /// <summary>
        /// IVR按键对应动作，需解码
        /// </summary>
        public string? DtmfType { get; set; }

        /// <summary>
        /// 允许关联工单
        /// </summary>
        public bool? IsBindOrder { get; set; }

        #region 自定义字段
        /// <summary>
        /// 通话时长（挂机时间-接通时间）
        /// </summary>
        public int Duration { get; set; }

        /// <summary>
        /// 振铃时长（振铃结束时间-振铃开始时间）
        /// </summary>
        public int RingTimes { get; set; }

        /// <summary>
        /// 排队时长（排队结束时间-排队开始时间）
        /// </summary>
        public int QueueTims { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        public EOnState OnState { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        public string OnStateText => OnState.GetDescription();


        public ECallOrderType? CallOrderType { get; set; }

        /// <summary>
        /// 外部ID
        /// </summary>
        public string? ExternalId { get; set; }

        /// <summary>
        /// 工单
        /// </summary>
        public OrderDto? Order { get; set; }

        /// <summary>
        /// 归属地
        /// </summary>
        public string? MobileAreaName { get; set; }

        /// <summary>
        /// 运营商
        /// </summary>
        public string? OFlag { get; set; }

        /// <summary>
        /// 卡类型
        /// </summary>
        public string? OperatorName { get; set; }


        /// <summary>
        /// 转写内容
        /// </summary>
        public string? TransliterationContent { get; set; }

        /// <summary>
        /// 转写状态
        /// </summary>
        public ECallTransliterationState TransliterationState { get; set; }

        public string TransliterationStateText => TransliterationState.GetDescription();

        /// <summary>
        /// 转写id  涉及转写失败后再次推送  id需要更换
        /// </summary>
        public string? TransliterationId { get; set; }

        /// <summary>
        /// 敏感标签
        /// </summary>
        public List<string>? Sensitive { get; set; }

        public string? SensitiveText => (Sensitive != null && Sensitive.Any()) ? string.Join(',', Sensitive) : "";

        #endregion
    }

    public class CallRecordOutDto
    {
        /// <summary>
        /// 可直接访问的通话录音地址
        /// </summary>
        public string? RecordingFileUrl { get; set; }
        /// <summary>
        /// 通话录音绝对路径
        /// </summary>
        public string? RecordingFileName { get; set; }
        public string? RecordingBaseAddress { get; set; }
        public string? RecordingAbsolutePath { get; set; }

        #region 业务字段
        /// <summary>
        /// 主叫
        /// </summary>
        public string FromNo { get; set; }

        /// <summary>
        /// 被叫
        /// </summary>
        public string ToNo { get; set; }

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

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public ECallDirection Direction { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public string DirectionText => Direction.GetDescription();

        /// <summary>
        /// 挂断方
        /// </summary>
        public EEndBy? EndBy { get; set; }

        /// <summary>
        /// 挂断方
        /// </summary>
        public string EndByText => EndBy.GetDescription();

        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? CreatedTime { get; set; }

        /// <summary>
        /// 开始等待时间
        /// </summary>
        public DateTime? BeginQueueTime { get; set; }

        /// <summary>
        /// 接通时间
        /// </summary>
        public DateTime? AnsweredTime { get; set; }

        /// <summary>
        /// 挂机时间
        /// </summary>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 通话时长（挂机时间-接通时间）
        /// </summary>
        public int Duration { get; set; }
        #endregion

        #region 第三方系统字段(兼容前端)
        /// <summary>
        /// 坐席侧通话流水，无坐席参与则为手机侧通话流水
        /// </summary>
        public string OtherAccept { get; set; }

        /// <summary>
        /// 主叫
        /// </summary>
        public string Cpn { get; set; }

        /// <summary>
        /// 被叫
        /// </summary>
        public string Cdpn { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public ECallDirection CallDirection { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public string CallDirectionText => CallDirection.GetDescription();
        /// <summary>
        /// 挂机时间
        /// </summary>
        public DateTime OverTime { get; set; }
        #endregion

        /// <summary>
        /// 工单Id
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 工单标题
        /// </summary>
        public string OrderTitle { get; set; }
        public string Id { get; set; }
    }

    public class TrCallDtoNew
    {
        /// <summary>
        /// 可直接访问的通话录音地址
        /// </summary>
        public string? RecordingFileUrl { get; set; }
        public string? RecordingBaseAddress { get; set; }
        public string? RecordingAbsolutePath { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public ECallDirection CallDirection { get; set; }

        /// <summary>
        /// 呼叫方向
        /// </summary>
        public string CallDirectionText => CallDirection.GetDescription();

        /// <summary>
        /// 挂断方
        /// </summary>
        public EEndBy? EndBy { get; set; }

        /// <summary>
        /// 挂断方
        /// </summary>
        public string EndByText => EndBy.GetDescription();

        /// <summary>
        /// 坐席侧通话流水，无坐席参与则为手机侧通话流水
        /// </summary>
        public string CallAccept { get; set; }
        /// <summary>
        /// 主叫
        /// </summary>
        public string Cpn { get; set; }
        /// <summary>
        /// 主叫名称
        /// </summary>
        public string CPNName { get; set; }
        /// <summary>
        /// 被叫
        /// </summary>
        public string Cdpn { get; set; }
        /// <summary>
        /// 分机号
        /// </summary>
        public string TelNo { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 通话录音绝对路径
        /// </summary>
        public string? RecordingFileName { get; set; }
        /// <summary>
        /// 通话创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }
        /// <summary>
        /// 接通时间
        /// </summary>
        public DateTime? AnsweredTime { get; set; }
        /// <summary>
        /// 挂机时间
        /// </summary>
        public DateTime OverTime { get; set; }
        /// <summary>
        /// 线路号
        /// </summary>
        public string Gateway { get; set; }
        /// <summary>
        /// 呼出时自定义的内容
        /// </summary>
        public string? OtherStr { get; set; }
        /// <summary>
        /// 手机侧通话流水，无坐席参与则为空
        /// </summary>
        public string? OtherAccept { get; set; }
        /// <summary>
        /// 状态码，语音信箱：999/其他：16
        /// </summary>
        public string Status { get; set; }
        /// <summary>
        /// IVR开始时间
        /// </summary>
        public DateTime? BeginIvrTime { get; set; }
        /// <summary>
        /// IVR结束时间
        /// </summary>
        public DateTime? EndIvrTime { get; set; }
        /// <summary>
        /// 开始等待时间
        /// </summary>
        public DateTime? BeginQueueTime { get; set; }
        /// <summary>
        /// 结束等待时间
        /// </summary>
        public DateTime? EndQueueTime { get; set; }
        /// <summary>
        /// 开始振铃时间
        /// </summary>
        public DateTime? BeginRingTime { get; set; }
        /// <summary>
        /// 结束振铃时间
        /// </summary>
        public DateTime? EndRingTimg { get; set; }
        /// <summary>
        /// 队列ID
        /// </summary>
        public string? OlaQueue { get; set; }
        /// <summary>
        /// 批量外呼流水
        /// </summary>
        public string? BatchAccept { get; set; }
        /// <summary>
        /// IVR按键信息
        /// </summary>
        public string? IvrDtmf { get; set; }
        /// <summary>
        /// IVR按键对应动作，需解码
        /// </summary>
        public string? DtmfType { get; set; }

        #region 自定义字段
        /// <summary>
        /// 通话时长（挂机时间-接通时间）
        /// </summary>
        public int Duration { get; set; }

        /// <summary>
        /// 振铃时长（振铃结束时间-振铃开始时间）
        /// </summary>
        public int RingTimes { get; set; }

        /// <summary>
        /// 排队时长（排队结束时间-排队开始时间）
        /// </summary>
        public int QueueTims { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        public EOnState OnState { get; set; }

        /// <summary>
        /// 通话状态
        /// </summary>
        public string OnStateText => OnState.GetDescription();


        public ECallOrderType? CallOrderType { get; set; }

        /// <summary>
        /// 外部ID
        /// </summary>
        public string? ExternalId { get; set; }

        /// <summary>
        /// 归属地
        /// </summary>
        public string? MobileAreaName { get; set; }

        /// <summary>
        /// 运营商
        /// </summary>
        public string? OFlag { get; set; }

        /// <summary>
        /// 卡类型
        /// </summary>
        public string? OperatorName { get; set; }

        /// <summary>
        /// 工单Id
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 工单标题
        /// </summary>
        public string OrderTitle { get; set; }
        #endregion
    }


    public record class CallTransliteration
    {
        /// <summary>
        /// 主叫
        /// </summary>
        public List<string> Ids { get; set; }
    }
    #endregion

    #region 关联

    public class LinkCallRecordDto
    {
        public bool IsOrder { get; set; }

        public string Id { get; set; }

        public string CallId { get; set; }
    }

    #endregion

    #region 坐席动作类型

    public record TelActionListDto : PagedRequest
    {
        public string TelNo { get; set; }

        public EActionType? ActionTtype { get; set; }

        public string? UserName { get; set; }

        public DateTime? StartTime { get; set; }

        public DateTime? EndTime { get; set; }
    }

    public record TelActionXthxDto : PagedRequest
    {
        public string TelNo { get; set; }

        public EOperationStatus? OperationStatus { get; set; }

        public string? UserName { get; set; }

        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
    }

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

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

        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }

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

        /// <summary>
        /// 分机组
        /// </summary>
        public string QueueId { get; set; }

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

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

        /// <summary>
        /// 动作类型
        /// </summary>
        public EActionType ActionType { get; set; }

        public string ActionTypeText => ActionType.GetDescription();

        /// <summary>
        /// 用时
        /// </summary>
        public double Duration { get; private set; }

    }

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

        /// <summary>
        /// 分机id
        /// </summary>
        public string? TelId { get; set; }

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

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

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

        /// <summary>
        /// 用户名称
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        public string? UserGroup { get; set; }

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

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

        /// <summary>
        /// 时长（单位：秒）
        /// </summary>
        public decimal RestDuration { get; set; }

        /// <summary>
        /// 案例分类名称
        /// </summary>
        public decimal RestDuration2 => GetRestDuration(RestDuration);

        /// <summary>
        /// 获取案例分类名称
        /// </summary>
        /// <returns></returns>
        public decimal GetRestDuration(decimal value)
        {
            if (value != 0)
            {
                return Math.Round(value, 2);
            }
            return 0;
        }

        /// <summary>
        /// 备注（冗余）
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 分机状态
        /// </summary>
        public EOperationStatus OperationStatus { get; set; }

    }

    #endregion
}
