using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.ProvinceStatistics
{
    /// <summary>
    /// 退回
    /// </summary>
    public class ProvinceSendBackListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 申请人
        /// </summary>
        public string? CreatorName { get; set; }

        /// <summary>
        /// 申请部门
        /// </summary>
        public string? CreatorOrgName { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 申请原因
        /// </summary>
        public string? Content { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string? AuditName { get; set; }

        /// <summary>
        /// 审核部门
        /// </summary>
        public string? AuditOrgName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditTime { get; set; }

        /// <summary>
        /// 审核意见
        /// </summary>
        public string? AuditOpinion { get; set; }

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

        /// <summary>
        ///  审核结果  0  待审核  1 审核通过  2 审核不通过
        /// </summary>
        public int State { get; set; }

        public string StateText => CalcRate(State);

        public string CalcRate(int state)
        {
            if (state == 1)
                return "同意";
            else if (state == 2)
                return "不同意";
            else
                return "申请中";
        }
    }

    /// <summary>
    /// 延期
    /// </summary>
    public class ProvinceOrderDelayListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 延期申请时间
        /// </summary>
        public DateTime ApplyDelayTime { get; set; }

        /// <summary>
        /// 申请部门Code
        /// </summary>
        public string ApplyOrgCode { get; set; }

        /// <summary>
        /// 申请部门名称
        /// </summary>
        public string ApplyOrgName { get; set; }

        /// <summary>
        /// 申请人
        /// </summary>
        public string EmployeeId { get; set; }

        /// <summary>
        /// 申请人名称
        /// </summary>
        public string? EmployeeName { get; set; }

        /// <summary>
        /// 延期申请时限
        /// </summary>
        public int DelayNum { get; set; }

        /// <summary>
        /// 延期申请单位
        /// </summary>
        public ETimeType DelayUnit { get; set; }
        public string? DelayUnitText => DelayUnit.GetDescription();

        /// <summary>
        /// 延期申请理由
        /// </summary>
        public string DelayReason { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string? AuditName { get; set; }

        /// <summary>
        /// 审核部门
        /// </summary>
        public string? AuditOrgName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditTime { get; set; }

        /// <summary>
        /// 审核意见
        /// </summary>
        public string? AuditOpinion { get; set; }

        /// <summary>
        /// 审批状态
        /// </summary>
        public EDelayState DelayState { get; set; }

        public string? DelayStateText => CalcRate();
        public string CalcRate()
        {
            if (DelayState == EDelayState.Pass)
                return "同意";
            else if (DelayState == EDelayState.NoPass)
                return "不同意";
            else
                return "申请中";
        }
    }

    /// <summary>
    /// 甄别
    /// </summary>
    public class ProvinceOrderScreenListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 申请人
        /// </summary>
        public string? CreatorName { get; set; }

        /// <summary>
        /// 申请部门
        /// </summary>
        public string? CreatorOrgName { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 甄别申请原因
        /// </summary>
        public string? Content { get; set; }


        /// <summary>
        /// 审核人
        /// </summary>
        public string? AuditName { get; set; }

        /// <summary>
        /// 审核部门
        /// </summary>
        public string? AuditOrgName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditTime { get; set; }

        /// <summary>
        /// 审核内容
        /// </summary>
        public string? ReplyContent { get; set; }

        /// <summary>
        /// 甄别申请状态
        /// </summary>
        public EScreenStatus Status { get; set; }

        public string? StatusText => CalcRate();

        public string CalcRate()
        {
            if (Status == EScreenStatus.End)
                return "同意";
            else if (Status == EScreenStatus.Refuse)
                return "不同意";
            else
                return "申请中";
        }

    }

    /// <summary>
    /// 撤单
    /// </summary>
    public class ProvinceOrderRevokeListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 撤单时间
        /// </summary>
        public DateTime? RevokeTime { get; set; }

        /// <summary>
        /// 撤单类型
        /// </summary>
        public string? RevokeType { get; set; }

        /// <summary>
        /// 撤单类型名称
        /// </summary>
        public string? RevokeTypeName { get; set; }

        /// <summary>
        /// 操作人员
        /// </summary>
        public string? RevokeName { get; set; }

        /// <summary>
        /// 撤单理由
        /// </summary>
        public string? RevokeReasion { get; set; }

        /// <summary>
        /// 材料标识
        /// </summary>
        public string? CliengGuid { get; set; }

    }

    /// <summary>
    /// 预警
    /// </summary>
    public class ProvinceOrderWarningListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 预警规则
        /// </summary>
        public string WarnRulename { get; set; }

        /// <summary>
        /// 规则明细
        /// </summary>
        public string WarnDescribe { get; set; }

        /// <summary>
        /// 预警应处理时间
        /// </summary>
        public DateTime? WarnTimebf { get; set; }

        /// <summary>
        /// 预警等级
        /// </summary>
        public string WarnDegree { get; set; }

        /// <summary>
        /// 预警类型
        /// </summary>
        public string WarnType { get; set; }

        /// <summary>
        /// 预警时间
        /// </summary>
        public DateTime? WarnDate { get; set; }

        /// <summary>
        /// 是否省预警
        /// </summary>
        public bool IsProWarn { get; set; }

    }

    /// <summary>
    /// 催办
    /// </summary>
    public class ProvinceOrderUrgeListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 催办人
        /// </summary>
        public string? CrUser { get; set; }

        /// <summary>
        /// 省催办时间
        /// </summary>
        public DateTime? RemindTime { get; set; }

        /// <summary>
        /// 催办申请内容
        /// </summary>
        public string? ApplyContent { get; set; }

    }

    /// <summary>
    /// 补充
    /// </summary>
    public class ProvinceOrderComplementListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 补充意见
        /// </summary>
        public string Opinion { get; set; }

        /// <summary>
        /// 补充人员
        /// </summary>
        public string? SupplyName { get; set; }

        /// <summary>
        /// 补充时间
        /// </summary>
        public string? SupplyTime { get; set; }

    }

    /// <summary>
    /// 督办
    /// </summary>
    public class ProvinceOrderSuperviseListDto
    {
        /// <summary>
        /// 业务Id
        /// </summary>
        public string Id { get; set; }

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

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

        /// <summary>
        /// 督办发起人
        /// </summary>
        public string? CrUser { get; set; }

        /// <summary>
        /// 督办发起时间
        /// </summary>
        public DateTime? SuperviseTime { get; set; }

        /// <summary>
        /// 督办回复人
        /// </summary>
        public string? ReUser { get; set; }

        /// <summary>
        /// 督办回复时间
        /// </summary>
        public DateTime? ReplyTime { get; set; }
    }
}
