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

namespace Hotline.Orders
{
	[Description("退回审批")]
	public class OrderSendBackAudit: FullStateEntity
	{
		/// <summary>
		/// 工单ID
		/// </summary>
		[SugarColumn(ColumnDescription = "工单ID")]
		public string OrderId { get; set; }


		/// <summary>
		/// 根据办理者类型不同，此字段为不同内容
		/// <example>
		/// 部门等级/分类为：depCodes, 角色为：userIds
		/// </example>
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true)]
		public List<FlowStepHandler>? NextHandlers { get; set; } = new();

		/// <summary>
		/// 流程快照ID
		/// </summary>
		[SugarColumn(ColumnDescription = "流程快照ID")]
		public string? TraceId { get; set; }

		/// <summary>
		/// 状态
		/// </summary>
		[SugarColumn(ColumnDescription = "状态")]
		public ESendBackAuditState? State { get; set; }

		/// <summary>
		/// 工单状态
		/// </summary>
		public EOrderStatus? Status { get; set; }

		/// <summary>
		/// 退回原因
		/// </summary>
		[SugarColumn(ColumnDescription = "退回原因", ColumnDataType = "text")]
		public string? Content { get; set; }

		/// <summary>
		/// 审批意见
		/// </summary>
		[SugarColumn(ColumnDescription = "审批意见", ColumnDataType = "text")]
		public string? AuditContent { get; set; }

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

		/// <summary>
		/// 退回数据
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		public PreviousWorkflowDto SendBackData { get; set; }

		/// <summary>
		/// 审批人ID
		/// </summary>
		[SugarColumn(ColumnDescription = "审批人ID")]
		public string? AuditId { get; set; }

		[SugarColumn(ColumnDescription = "审批人")]
		public string? AuditUser { get; set; }

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

		/// <summary>
		/// 申请部门ID
		/// </summary>
		[SugarColumn(ColumnDescription = "申请部门ID")]
		public string? ApplyOrgId { get; set; }

		/// <summary>
		/// 申请部门名称
		/// </summary>
		[SugarColumn(ColumnDescription = "申请部门名称")]
		public string? ApplyOrgName { get; set; }

		/// <summary>
		/// 退回部门ID
		/// </summary>
		[SugarColumn(ColumnDescription = "退回部门ID")]
		public string SendBackOrgId { get; set; }

		/// <summary>
		/// 退回部门名称
		/// </summary>
		[SugarColumn(ColumnDescription = "退回部门名称")]
		public string SendBackOrgName { get; set; }

		/// <summary>
		/// 退回节点名称
		/// </summary>
		[SugarColumn(ColumnDescription = "退回节点名称")]
		public string? SendBackStepName { get; set; }

		/// <summary>
		/// 退回节点创建时间
		/// </summary>
		[SugarColumn(ColumnDescription = "退回节点创建时间")]
		public DateTime? WorkflowStepSendBackCrTime { get; set; }

		/// <summary>
		/// 流程退回发起部门ID
		/// </summary>
		[SugarColumn(ColumnDescription = "流程退回发起部门ID")]
		public string WorkflowOrgId { get; set; }

		/// <summary>
		/// 流程退回发起用户ID
		/// </summary>
		[SugarColumn(ColumnDescription = "流程退回发起用户ID")]
		public string WorkflowUserId { get; set; }

		/// <summary>
		/// 是否允许再次退回
		/// </summary>
		[SugarColumn(ColumnDescription = "是否允许再次退回",DefaultValue = "f")]
		public bool? IsReturnAgain { get; set; }

		/// <summary>
		/// 流程退回发起用户角色ID
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true, ColumnDescription = "流程退回发起用户角色ID")]
		public List<string> WorkflowRoleIds { get; set; }

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

        /// <summary>
        ///退回后最新节点Id
        /// </summary>
        [SugarColumn(ColumnDescription = "退回后最新节点Id")]
        public string? NewCurrentStepId { get; set; }

		/// <summary>
		/// 工单超期时间
		/// </summary>
		[SugarColumn(ColumnDescription = "工单超期时间")]
		public DateTime? OrderExpiredTime { get; set; }


		/// <summary>
		/// 指定节点Id
		/// </summary>
		[SugarColumn(ColumnDescription = "指定节点Id")]
		public string? AssignStepId { get; set; }

		/// <summary>
		/// 是否指定节点
		/// </summary>
		[SugarColumn(ColumnDescription = "是否指定节点")]
		public bool? IsAssign { get; set; }

	}
}
