using Hotline.Orders;
using Hotline.Share.Dtos;
using Hotline.Share.Enums.Quality;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Repository;

namespace Hotline.Quality
{
	[Description("质检")]
	[SugarIndex("index_quality_creationtime", nameof(Quality.CreationTime), OrderByType.Desc)]
	[SugarIndex("index_quality_orderId", nameof(OrderScreen.OrderId), OrderByType.Asc)]
	[SugarIndex("index_quality_visitId", nameof(OrderScreen.VisitId), OrderByType.Asc)]
	public class Quality : FullStateEntity
	{
		/// <summary>
		/// 工单ID
		/// </summary>
		[SugarColumn(ColumnDescription = "工单ID")]
		public string OrderId { get; set; }

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

		/// <summary>
		/// 质检方式
		/// </summary>
		[SugarColumn(ColumnDescription = "质检方式")]
		public string? Mode { get; set; }

		/// <summary>
		/// 质检分数
		/// </summary>
		[SugarColumn(ColumnDescription = "质检分数")]
		public int? Grade { get; set; }

		/// <summary>
		/// 质检评价
		/// </summary>
		[SugarColumn(ColumnDescription = "质检评价", ColumnDataType = "text")]
		public string? Content { get; set; }

		/// <summary>
		/// 质检状态
		/// </summary>
		[SugarColumn(ColumnDescription = "质检状态   0 待质检  1 已质检")]
		public EQualityState? State { get; set; }

		/// <summary>
		/// 质检来源
		/// </summary>
		[SugarColumn(ColumnDescription = "质检来源")]
		public EQualitySource? Source { get; set; }

		/// <summary>
		/// 质检人
		/// </summary>
		[SugarColumn(ColumnDescription = "质检人")]
		public string? UserName { get; set; }

		/// <summary>
		/// 质检时间
		/// </summary>
		[SugarColumn(ColumnDescription = "质检时间")]
		public DateTime? QualityTime { get; set; }

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

		/// <summary>
		/// 质检明细
		/// </summary>
		[Navigate(NavigateType.OneToMany, nameof(QualityDetail.QualityId))]
		public List<QualityDetail> QualityDetails { get; set; }

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

		/// <summary>
		/// 智能质检
		/// </summary>
		public bool? AiQuality { get; set; } = false;

		/// <summary>
		/// 转写状态
		/// </summary>
		[SugarColumn(ColumnDescription = "转写状态", DefaultValue = "0")]
		public EQualityTransferState? TransferState { get; set; }

		/// <summary>
		/// 转写内容
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		public List<Transfer>? Transfer { get; set; }

	}

}
