using Hotline.Share.Dtos.File;
using Hotline.Share.Dtos.FlowEngine.Workflow;
using Hotline.Share.Enums.FlowEngine;
using Hotline.Share.Enums.Order;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Order.Detail;

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

    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 节点名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 交班人名称
    /// </summary>
    public string? AssignerName { get; set; }

    /// <summary>
    /// 交班人部门
    /// </summary>
    public string AssignerOrgName { get; set; }

    /// <summary>
    /// 受理人
    /// </summary>
    public string? AcceptorName { get; set; }

    public string? AcceptorOrgName { get; set; }

    /// <summary>
    /// 受理时间
    /// </summary>
    public DateTime? AcceptTime { get; set; }

    /// <summary>
    /// 办理人
    /// </summary>

    public string? HandlerName { get; set; }

    /// <summary>
    /// 办理人部门
    /// </summary>
    public string? HandlerOrgName { get; set; }

    /// <summary>
    /// 办理时间
    /// </summary>
    public DateTime? HandleTime { get; set; }

    /// <summary>
    /// 节点期满时间
    /// </summary>
    public DateTime? StepExpiredTime { get; set; }

    /// <summary>
    /// 超期状态
    /// </summary>
    public EExpiredStatus? ExpiredStatus { get; set; }

    public string? ExpiredStatusText => ExpiredStatus.HasValue ? ExpiredStatus.GetDescription() : "";

    /// <summary>
    /// 办理方式
    /// </summary>
    public EHandleMode? HandleMode { get; set; }

    public string HandleModeText => HandleMode.HasValue ? HandleMode.GetDescription() : "";

    /// <summary>
    /// 节点类型
    /// </summary>
    public ETraceStyle TraceStyle { get; set; }

    public EWorkflowStepStatus Status { get; set; }
    public string StatusText => Status.GetDescription();

    /// <summary>
    /// 会签流转记录
    /// </summary>
    public List<OrderFlowTraceDto> Traces { get; set; }

    #region 流程节点展开

    /// <summary>
    /// 办理意见
    /// </summary>
    public string? Opinion { get; set; }

    /// <summary>
    /// 附件
    /// </summary>
    public List<FileJson>? FileJson { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }

    #endregion

    #region 发布节点展开


    /// <summary>
    /// 发布范围
    /// </summary>
    public bool? PublishState { get; set; }

    /// <summary>
    /// 整理结果
    /// </summary>
    public string ArrangeOpinion { get; set; }

    #endregion

    #region 回访节点展开


    /// <summary>
    /// 语音评价（话务评价）
    /// </summary>
    public EVoiceEvaluate? VoiceEvaluate { get; set; }

    public string? VoiceEvaluateText => VoiceEvaluate.HasValue ? VoiceEvaluate.GetDescription() : "";

    /// <summary>
    /// 话务员评价（话务评价）
    /// </summary>
    public ESeatEvaluate? SeatEvaluate { get; set; }
    public string? SeatEvaluateText => SeatEvaluate.HasValue ? SeatEvaluate.GetDescription() : "";

    /// <summary>
    /// 回访内容
    /// </summary>
    public string? VisitContent { get; set; }

    public IReadOnlyList<OrderFlowVisitDetail> OrderFlowVisitDetails { get; set; }

    #endregion

    /// <summary>
    /// 发布状态、回访结果
    /// </summary>
    public string? OpinionResult {  get; set; }
}

/// <summary>
/// 工单办理流程明细回访明细项
/// </summary>
public class OrderFlowVisitDetail
{
    /// <summary>
    /// 回访部门名称
    /// </summary>
    public string VisitOrgName { get; set; }

    /// <summary>
    /// 部门办件结果
    /// </summary>
    public string? OrgProcessingResults { get; set; }

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

    /// <summary>
    /// 部门办件态度
    /// </summary>
    public string? OrgHandledAttitude { get; set; }

    /// <summary>
    /// 回访内容
    /// </summary>
    public string? VisitContent { get; set; }
}