using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using Hotline.Share.Requests;

namespace Hotline.Share.Dtos.Settings
{
    public record AddTimeLimitDto
    {
        /// <summary>
        /// 配置名称
        /// </summary>
        public string TimeLimitName { get; set; }

        /// <summary>
        /// 业务名称
        /// </summary>
        public string WorkflowName { get; set; }

        /// <summary>
        /// 业务编码
        /// </summary>
        public string WorkflowCode { get; set; }

        /// <summary>
        /// 已配置参数
        /// </summary>
        public List<ParamValueModel>? ParamArr { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public List<PriorityModel>? Priority { get; set; }

        /// <summary>
        /// 组合
        /// </summary>
        public List<CombinationModel>? Combination { get; set; }
    }

    #region Model

    /// <summary>
    /// 组合对象
    /// </summary>
    public class CombinationModel
    {
        /// <summary>
        /// 组合ID
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 组合名称
        /// </summary>
        public string CombinationName { get; set; }


        /// <summary>
        /// 组合参数
        /// </summary>
        public List<CombinationParamModel> CombinationParam { get; set; }

        /// <summary>
        /// 组合参数拼接
        /// </summary>
        public string CombinationDisplayParam { get; set; }

        /// <summary>
        /// 时限
        /// </summary>
        public int TimeLimitValue { get; set; }
        /// <summary>
        /// 时限类型
        /// </summary>
        public ETimeType TimeLimit { get; set; }

        /// <summary>
        /// 时限类型名称
        /// </summary>
        public string TimeLimitName { get; set; }

        /// <summary>
        /// 换算小时
        /// </summary>
        public int Hour { get; set; }
    }

    /// <summary>
    /// 组合对象子对象
    /// </summary>
    public class CombinationParamModel
    {
        /// <summary>
        /// 参数类型Code
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 组合参数名称
        /// </summary>
        public string ParamName { get; set; }

        /// <summary>
        /// 组合参数值
        /// </summary>
        public string ParamValue { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public string ParamType { get; set; }

        /// <summary>
        /// 热点分级ID
        /// </summary>
        public string HotParamParent { get; set; }


    }


    /// <summary>
    /// 排序对象
    /// </summary>
    public class PriorityModel
    {
        public string Code { get; set; }

        public string ParamTypeName { get; set; }

        public string ParamTypeValue { get; set; }

        public string ParamType { get; set; }

        public int Sort { get; set; }
    }

    /// <summary>
    /// 已配置参数对象
    /// </summary>
    public class ParamValueModel
    {
        public string Id { get; set; }

        /// <summary>
        /// 参数类型
        /// </summary>
        public string ParamType { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string ParamTypeName { get; set; }

        public string ParamTypeValue { get; set; }

        public string HotParamParent { get; set; }


        /// <summary>
        /// 时限
        /// </summary>
        public int TimeLimitValue { get; set; }
        /// <summary>
        /// 时限类型
        /// </summary>
        public ETimeType TimeLimitType { get; set; }

        /// <summary>
        /// 时限类型名称
        /// </summary>
        public string TimeLimitTypeName { get; set; }


        /// <summary>
        /// 换算小时
        /// </summary>
        public int Hour { get; set; }
    }

    #endregion

    public record UpdateTimeLimitDto : AddTimeLimitDto
    {
        public string Id { get; set; }
    }

    public record QueryPagedTimeLimitPagedDto : PagedKeywordRequest
    {

    }


    #region 时间计算返回参数

    public record TimeResult
    {
        public string RuleId { get; set; }

        public DateTime EndTime { get; set; }

        public string RuleStr { get; set; }

        /// <summary>
        /// 即将超期时间
        /// </summary>
        public DateTime NearlyExpiredTime { get; set; }

        /// <summary>
        /// 即将超期第一级
        /// </summary>
        public DateTime NearlyExpiredTimeOne { get; set; }
    }

    #endregion



    #region 工作日计算时间常量配置

    public record CalcTimeSetting
    {
        /// <summary>
        /// 业务Code
        /// </summary>
        public string BusCode { get; set; }

        /// <summary>
        /// 时间类型
        /// </summary>
        public ETimeType TimeType { get; set; }

        /// <summary>
        /// 时间值
        /// </summary>
        public int TimeValue { get; set; }

        /// <summary>
        /// 业务名称
        /// </summary>
        public string BusName { get; set; }

        /// <summary>
        /// 超期时限百分比
        /// </summary>
        public int Percentage { get; set; }

        /// <summary>
        /// 超期时间百分比（第一级）
        /// </summary>
        public int PercentageOne { get; set; }
    }

    #endregion
}
