using Hotline.Share.Dtos.FlowEngine.Definition;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Dtos.Users;
using Hotline.Share.Enums.FlowEngine;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.FlowEngine.Workflow
{
    public class WorkflowDto
    {
        public string Id { get; set; }

        public string DefinitionId { get; set; }

        public string Title { get; set; }

        /// <summary>
        /// 业务模块名称
        /// </summary>
        public string? ModuleName { get; set; }

        public string? ModuleCode { get; set; }

        /// <summary>
        /// 到期时间
        /// </summary>
        public DateTime ExpiredTime { get; set; }

        public DateTime? CompleteTime { get; set; }

        /// <summary>
        /// 当前节点名称（会签状态此字段保存最外层会签办理节点名称）
        /// </summary>
        public string CurrentStepName { get; set; }

        /// <summary>
        /// 到达当前节点时间
        /// </summary>
        public DateTime? CurrentStepTime { get; set; }

        public EWorkflowStatus Status { get; set; }
        public string StatusText => Status.ToString();

        /// <summary>
        /// 中心直办件
        /// </summary>
        public bool IsStraight { get; set; } = true;

        /// <summary>
        /// 交办时间
        /// </summary>
        public DateTime AssignTime { get; set; }

        /// <summary>
        /// 办理时间限制(如：24小时、7个工作日)
        /// </summary>
        public string TimeLimit { get; set; }

        /// <summary>
        /// 办理意见（冗余，办理中...or 最终办理意见）
        /// </summary>
        public string Opinion { get; set; }

        /// <summary>
        /// 接办部门
        /// </summary>
        public string AssignOrgs { get; set; }

        /// <summary>
        /// 是否可办理
        /// </summary>
        public bool CanHandle { get; set; }

        public DefinitionDto Definition { get; set; }

        /// <summary>
        /// 主节点，依据流转进度动态生成
        /// </summary>
        public List<WorkflowStepDto> StepBoxes { get; set; }

        public List<WorkflowTraceDto> Traces { get; set; }

        public List<WorkflowSupplementDto> Supplements { get; set; }

        public List<WorkflowAssignDto> Assigns { get; set; }

        public DateTime CreationTime { get; set; }
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 实际办理人名称
        /// </summary>
        public string? ActualHandlerName { get; set; }

        /// <summary>
        /// 实际办理部门名称
        /// </summary>
        public string? ActualHandleOrgName { get; set; }

        /// <summary>
        /// 交办时间(中心交部门办理时间)
        /// </summary>
		public DateTime? CenterToOrgTime { get; set; }

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

        /// <summary>
        /// 实际办理节点名称（会签状态此字段保存最外层会签发起节点名称）
        /// </summary>
        public string? ActualHandleStepName { get; set; }

	}

    public class WorkflowAssignDto
    {
        public string WorkflowId { get; set; }

        public string OrgCode { get; set; }

        public string OrgName { get; set; }
    }

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

        /// <summary>
        /// 附件
        /// </summary>
        public List<string> Additions { get; set; } = new();

        public DateTime CreationTime { get; set; }

        public UserDto Creator { get; set; }
    }

    public class WorkflowOrderDto : WorkflowDto 
    {
        public OrderDto Order { get; set; }
    }
}
