using Hotline.Orders;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.Ai;
using Hotline.Share.Enums.Ai;
using Hotline.Share.Enums.Order;
using Oracle.ManagedDataAccess.Types;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Repository;

namespace Hotline.Ai.Visit
{
    public class AiOrderVisitDetail : CreationEntity
    {
        /// <summary>
        /// 主表ID
        /// </summary>
        public string AiOrderVisitId { get; set; }
        /// <summary>
        /// 工单ID
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 工单
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(OrderId))]
        public Order Order { get; set; }
        /// <summary>
        /// 工单回访主表ID
        /// </summary>
        public string OrderVisitId { get; set; }
        /// <summary>
        /// 工单
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(OrderVisitId))]
        public OrderVisit OrderVisit { get; set; }
        /// <summary>
        /// 外呼电话
        /// </summary>
        public string OuterNo { get; set; }

        public EAiOrderVisitState AiOrderVisitState { get; set; }

        /// <summary>
        /// 智能回访时间
        /// </summary>
        public DateTime? AiVisitTime { get; set; }

        /// <summary>
        /// 最新外呼时间
        /// </summary>
        public DateTime? CallTime { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool? IsSuccess { get; set; }


        /// <summary>
        /// 批此上传成功后任务ID
        /// </summary>
        public string? TaskUid { get; set; }

        /// <summary>
        /// 话务员评价（话务评价）
        /// </summary>
        public ESeatEvaluate? AiSeatEvaluate { get; set; }

        /// <summary>
        /// 话务员不满意原因
        /// </summary>
        public string? AiSeatNoSatisfiedReason { get; set; }

        /// <summary>
        /// 是否联系
        /// </summary>
        public bool? AiIsContact { get; set; }

        /// <summary>
        /// 处理结果
        /// </summary>
        public bool? AiVolved { get; set; }

        /// <summary>
        /// 未处理内容
        /// </summary>
        public string? AiVolveConent { get; set; }

        /// <summary>
        /// 部门办件结果
        /// </summary>
        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public Kv? AiOrgProcessingResults { get; set; }

        /// <summary>
        /// 不满意原因
        /// </summary>
        public string? AiOrgNoSatisfiedReason { get; set; }

        /// <summary>
        /// 重呼次数
        /// </summary>
        [SugarColumn(DefaultValue = "0")]
        public int CallTimes { get; set; }

        /// <summary>
        /// 语音段列表信息
        /// </summary>
        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public List<SentenceList>? SentenceList { get; set; }
    }

    public class SentenceList
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int Index { get; set; }
        /// <summary>
        /// 开始时间（毫秒）
        /// </summary>
        public int StartTime { get; set; }

        /// <summary>
        /// 结束时间（毫秒）
        /// </summary>
        public int EndTime { get; set; }

        /// <summary>
        /// 角色（机器人:agent，用户:user，未知:unknown）
        /// </summary>
        public string Role { get; set; }

        /// <summary>
        /// 性别（未知:unknow，男:male，女:female）
        /// </summary>
        public string Gender { get; set; }

        /// <summary>
        /// 文本
        /// </summary>
        public string Text { get; set; }

        /// <summary>
        /// 人工编译后文本
        /// </summary>
        public string CorrectText { get; set; }

        /// <summary>
        /// 置信分数（本词条的可信度[0-65535], 分值越高，越可信）
        /// </summary>
        public string Score { get; set; }

        /// <summary>
        /// 语速
        /// </summary>
        public string Speed { get; set; }

        /// <summary>
        /// 最大音量
        /// </summary>
        public string MaxVolume { get; set; }

        /// <summary>
        /// 平均音量
        /// </summary>
        public string AvgVolume { get; set; }
    }
}
