using Hotline.File;
using Hotline.FlowEngine.Workflows;
using Hotline.Share.Enums.Order;
using SqlSugar;
using System.ComponentModel;
using Hotline.Share.Dtos.File;
using Hotline.Share.Dtos.Order;
using XF.Domain.Repository;

namespace Hotline.Orders
{
    [Description("工单甄别")]
    [SugarIndex("index_screen_orderId", nameof(OrderScreen.OrderId), OrderByType.Asc)]
	[SugarIndex("index_screen_visitDetailId", nameof(OrderScreen.VisitDetailId), OrderByType.Desc)]
	[SugarIndex("index_screen_visitId", nameof(OrderScreen.VisitId), OrderByType.Desc)]
	public class OrderScreen : WorkflowEntity
    {
        /// <summary>
        /// 工单编号
        /// </summary>
        [SugarColumn(ColumnDescription = "工单编号")]
        public string No { get; set; }

        /// <summary>
        /// 回访id
        /// </summary>
        [SugarColumn(ColumnDescription = "回访id")]
        public string VisitId { get; set; }

        /// <summary>
        /// 回访明细id
        /// </summary>
        [SugarColumn(ColumnDescription = "回访明细id")]
        public string VisitDetailId { get; set; }

        /// <summary>
        /// 工单id
        /// </summary>
        [SugarColumn(ColumnDescription = "工单id")]
        public string OrderId { get; set; }

        /// <summary>
        /// 回访
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(VisitDetailId))]
        public OrderVisitDetail VisitDetail { get; set; }

        /// <summary>
        /// 回访
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(VisitId))]
        public OrderVisit Visit { get; set; }

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

        /// <summary>
        /// 回访
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(OrderScreenDetail.ScreenId), nameof(Id))]
        public List<OrderScreenDetail> ScreenDetails { get; set; }

		/// <summary>
		/// 甄别申请类型id
		/// </summary>
		[SugarColumn(ColumnDescription = "甄别申请类型id")]
        public string? TypeDicId { get; set; }

        /// <summary>
        /// 甄别申请类型名称
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别申请类型名称")]
        public string? TypeDicName { get; set; }


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

        /// <summary>
        /// 甄别申请回复
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别申请回复", ColumnDataType = "text")]
        public string? ReplyContent { get; set; }

        #region 用于省平台查询
        /// <summary>
        /// 审核人
        /// </summary>
        public string? AuditName { get; set; }

        /// <summary>
        /// 审核部门
        /// </summary>
        public string? AuditOrgName { get; set; }

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

        /// <summary>
        /// 是否省甄别
        /// </summary>
        [SugarColumn(DefaultValue = "f")]
        public bool IsProScreen { get; set; }

        #endregion


        /// <summary>
        /// 甄别截至申请时间
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别截至申请时间")]
        public DateTime? ApplyEndTime { get; set; }

        /// <summary>
        /// 甄别申请状态
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别申请状态")]
        public EScreenStatus? Status { get; set; }

		/// <summary>
		/// 业务流程ID
		/// </summary>
		[SugarColumn(ColumnDescription = "业务流程ID")]
        public string? WorkflowId { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(WorkflowId))]
        public Workflow? Workflow { get; set; }

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

		/// <summary>
		/// 上传省平台附件
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		public List<FileJson>? ProvinceFileJson { get; set; }

		/// <summary>
		/// 甄别耗时
		/// </summary>
		[SugarColumn(ColumnDescription = "甄别耗时")]
		public decimal? TimeConsuming { get; set; }

        /// <summary>
        /// 甄别退回次数
        /// </summary>
		[SugarColumn(DefaultValue = "0")]
		public int SendBackNum { get; set; }

        /// <summary>
        /// 甄别退回到申请人
        /// </summary>
		[SugarColumn(DefaultValue = "f")]
		public bool SendBackApply { get; set; }

        /// <summary>
        /// 甄别重提申请次数
        /// </summary>
		[SugarColumn(DefaultValue = "0")]
		public int SendBackApplyNum { get; set; }

        /// <summary>
        /// 甄别退回时间
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别退回时间")]
        public DateTime? SendBackTime { get; set; }

        /// <summary>
        /// 甄别审批时间
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别审批时间")]
        public DateTime? NewestAuditTime { get; set; }

        /// <summary>
        /// 甄别类型
        /// </summary>
        [SugarColumn(ColumnDescription = "甄别类型",DefaultValue ="0")]
		public EOrderScreenType?  ScreenType { get; set; }
	}
}
