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

namespace YBEE.EQM.Core;

/// <summary>
/// 监测计划
/// </summary>
[Comment("监测计划")]
public partial class ExamPlan : DEntityBase
{
    /// <summary>
    /// 学段
    /// </summary>
    [Comment("学段")]
    [Required, Column(TypeName = "smallint")]
    public EducationStage EducationStage { get; set; }
    /// <summary>
    /// 学制
    /// </summary>
    [Comment("学制")]
    [Required]
    public short EducationYears { get; set; }
    /// <summary>
    /// 学期ID
    /// </summary>
    [Comment("学期ID")]
    [Required]
    public short SemesterId { 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 = "json")]
    public string Config { get; set; } = new { }.ToJson();

    /// <summary>
    /// 是否已固定监测抽样方案
    /// </summary>
    [Comment("是否已固定监测抽样方案")]
    [Required]
    public bool IsFixedExamSample { get; set; } = false;

    /// <summary>
    /// 状态
    /// </summary>
    [Comment("状态")]
    [Required]
    public ExamStatus Status { get; set; } = ExamStatus.READY;
    /// <summary>
    /// 开始时间
    /// </summary>
    [Comment("开始时间")]
    public DateTime? BeginTime { get; set; }
    /// <summary>
    /// 结束时间
    /// </summary>
    [Comment("结束时间")]
    public DateTime? EndTime { get; set; }

    /// <summary>
    /// 一对一引用（学期）
    /// </summary>
    public virtual Semester Semester { get; set; }
    /// <summary>
    /// 一对多引用（监测机构）
    /// </summary>
    public ICollection<ExamOrg> ExamOrgs { get; } = new List<ExamOrg>();
    /// <summary>
    /// 一对多引用（监测年级）
    /// </summary>
    public ICollection<ExamGrade> ExamGrades { get; } = new List<ExamGrade>();
    /// <summary>
    /// 一对多引用（监测上报类型）
    /// </summary>
    public ICollection<ExamDataReport> ExamDataReports { get; } = new List<ExamDataReport>();
}
