using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.FlowEngine.Workflows;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.File;
using Hotline.Share.Dtos.FlowEngine;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.FlowEngine;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using SqlSugar;
using XF.Domain.Repository;

namespace Hotline.Orders
{
	/// <summary>
	/// 特提
	/// </summary>
	[Description("工单特提")]
	public class OrderSpecial : FullStateEntity
	{
        public string OrderId { get; set; }
        public string WorkflowId { get; set; }

        /// <summary>
        /// 下一节点code(defineStep.code)
        /// </summary>
        public string NextStepCode { get; set; } = string.Empty;
        public string NextStepName { get; set; } = string.Empty;

        public EFlowDirection? FlowDirection { get; set; }

        /// <summary>
        /// 办理对象类型
        /// </summary>
        public EHandlerType? HandlerType { get; set; }
        /// <summary>
        /// 模板配置节点业务类型
        /// </summary>
        public EBusinessType? BusinessType { get; set; }

		public string? StepCode { get; set; } = string.Empty;
        public string? StepName { get; set; } = string.Empty;

		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		public List<FlowStepHandler> NextHandlers { get; set; }

		/// <summary>
		/// 特提原因
		/// </summary>
		[SugarColumn(ColumnDescription = "特提原因")]
        public string? Cause { get; set; }

		/// <summary>
		/// 特提理由
		/// </summary>
		[SugarColumn(ColumnDescription = "特提理由", ColumnDataType = "varchar(2000)")]
        public string? Reason { get; set; }

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

        public ETimeType? TimeLimitUnit { get; set; } = ETimeType.WorkDay;

        /// <summary>
        /// 是否修改期满时间
        /// </summary>
        public bool AlterTime { get; set; }

		/// <summary>
		/// 特提意见
		/// </summary>
		[SugarColumn(ColumnDescription = "特提意见", ColumnDataType = "varchar(2000)")]
        public string? Opinion { get; set; }

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

		[SugarColumn(ColumnDescription = "组织Id")]
		public string? OrgId { get; set; }

		public string? OrgName { get; set; }

        /// <summary>
        /// 工单
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(OrderId))]
        public Order Order { get; set; }

        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public List<FileJson>? FileJson { get; set; }

        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public List<FileJson>? ReplyFileJson { get; set; }

        /// <summary>
        /// 特提类型
        /// </summary>
        public ESpecialType? ESpecialType { get; set; }

		/// <summary>
		/// 错件类型
		/// </summary>
		//[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		[Navigate(NavigateType.OneToMany, nameof(OrderSpecialDetail.SpecialId))]
		public List<OrderSpecialDetail> ReTransactError { get; set; }


	}

    //public class ReTransactError { 
    
    //    public string OrgId { get; set; }

    //    public string OrgName { get; set; }

    //    public string ErrorId { get; set; }

    //    public string ErrorName { get; set; }
    //}
}
