using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace YBEE.EQM.Core;

/// <summary>
/// 抽样方案
/// </summary>
[Comment("抽样方案")]
public partial class ExamSample : DEntityBase
{
    /// <summary>
    /// 监测计划ID
    /// </summary>
    [Comment("监测计划ID")]
    [Required]
    public int ExamPlanId { get; set; }
    /// <summary>
    /// 序，同一监测从1开始计数
    /// </summary>
    [Comment("序，同一监测从1开始计数")]
    [Required]
    public short Sequence { get; set; } = 1;
    /// <summary>
    /// 名称
    /// </summary>
    [Comment("名称")]
    [Required, StringLength(100)]
    public string Name { get; set; }
    /// <summary>
    /// 全称
    /// </summary>
    [Comment("全称")]
    [Required, StringLength(200)]
    public string FullName { get; set; }
    /// <summary>
    /// 简称
    /// </summary>
    [Comment("简称")]
    [Required, StringLength(50)]
    public string ShortName { get; set; }
    /// <summary>
    /// 备注
    /// </summary>
    [Comment("备注")]
    [StringLength(200)]
    public string Remark { get; set; } = "";

    /// <summary>
    /// 状态
    /// </summary>
    [Comment("状态")]
    [Required, Column(TypeName = "smallint")]
    public ExamSampleStatus Status { get; set; } = ExamSampleStatus.INITIAL;


    /// <summary>
    /// 抽样配置
    /// {
    ///     percent: 40,
    ///     onlyOneClassStudentMin: 40,
    ///     gradeNoSampleStudentMin: 20,
    ///     classStudentMin: 25,
    ///     startPosition： 1,
    ///     interval: 2,
    ///     isExcludeSpecialStudent: true,
    ///     isGradeSeatNumberRandom: true,
    /// }
    /// </summary>
    [Comment("抽样配置")]
    [Required, Column(TypeName = "json")]
    public string Config { get; set; } = "{}";

    /// <summary>
    /// 成绩引用监测计划ID
    /// </summary>
    [Comment("成绩引用监测计划ID")]
    public int? ExamScoreRefExamPlanId { get; set; }

    /// <summary>
    /// 是否选中使用的方案
    /// </summary>
    [Comment("是否选中使用的方案")]
    public bool IsSelected { get; set; } = false;
    /// <summary>
    /// 选中使用时间
    /// </summary>
    [Comment("选中使用时间")]
    public DateTime? SelectedTime { get; set; }
    /// <summary>
    /// 选中使用操作用户ID
    /// </summary>
    [Comment("选中使用操作用户ID")]
    public int? SelectedSysUserId { get; set; }


    /// <summary>
    /// 一对一引用（监测信息）
    /// </summary>
    public virtual ExamPlan ExamPlan { get; set; }
    /// <summary>
    /// 一对一引用（选中使用操作用户）
    /// </summary>
    public virtual SysUser SelectedSysUser { get; set; }
    /// <summary>
    /// 一对一引用（成绩引用监测计划）
    /// </summary>
    public virtual ExamPlan ExamScoreRefExamPlan { get; set; }
}
