using Hotline.Share.Dtos.Settings;
using Hotline.Share.Enums.FlowEngine;
using Hotline.Share.Enums.Settings;

namespace Hotline.Settings.TimeLimits
{
    public interface ITimeLimitDomainService
    {

        /// <summary>
        /// 获取工单办理时限配置
        /// </summary>
        TimeConfig GetOrderTimeLimitConfig(string? code = null);

        /// <summary>
        /// 计算期满时间
        /// </summary>
        ExpiredTimeWithConfig CalcEndTime(DateTime beginTime, TimeConfig timeConfig, string busCode);

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        Task<string> AddAsync(TimeLimit model, CancellationToken cancellationToken);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task UpdateAsync(TimeLimit model, CancellationToken cancellationToken);


        /// <summary>
        /// 
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="timeType"></param>
        /// <param name="timeValue"></param>
        /// <returns></returns>
        TimeResult CalcEndTime(DateTime beginTime, ETimeType timeType, int timeValue, int Percentage);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="busCode"></param>
        /// <returns></returns>
        ExpiredTimeWithConfig? CalcEndTime(DateTime beginTime, string busCode);

        /// <summary>
        /// 计算期满时间
        /// </summary>
        ExpiredTimeWithConfig CalcExpiredTime(DateTime beginTime, EFlowDirection flowDirection, string? acceptTypeCode);

        TimeResult CalcEndTime(DateTime beginTime, ETimeType timeType, int timeValue, string busCode);


        /// <summary>
        /// 
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="isCenter"></param>
        /// <returns></returns>
        decimal CalcWorkTimeToDecimal(DateTime beginTime, DateTime endTime, bool isCenter);


        /// <summary>
        /// 
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        int CalcWorkTime(DateTime beginTime, DateTime endTime, bool isCenter);

        /// <summary>
        /// 计算时间间隔
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="isCenter"></param>
        /// <returns></returns>
        string CalcTimeInterval(DateTime beginTime, DateTime endTime, bool isCenter);

        /// <summary>
        /// 时间间隔 小时
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="isCenter"></param>
        /// <returns></returns>
        decimal CalcWorkTimeToHour(DateTime beginTime, DateTime endTime, bool isCenter);

		/// <summary>
		/// 判断是否工作日
		/// </summary>
		/// <param name="date"></param>
		/// <returns></returns>
		bool IsWorkDay(DateTime date);

        /// <summary>
        /// 获取工作日
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
		DateTime WorkDay(DateTime date);

        /// <summary>
        /// 倒推工作日
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        DateTime CalcWorkTimeReduce(DateTime date, int timeValue);


    }
}
