using OASystem.Domain.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace OASystem.Domain.Entities.Groups
{
    /// 
    /// 团组流程管控
    /// 
    [SugarTable("Grp_Schedule")]
    public class Grp_ScheduleInfo : EntityBase
    {
        /// 
        /// 团组Id
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int DiId { get; set; }
        /// 
        /// 当前主流程
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public GrpSchedulePrimaryStepEnum PrimaryStep { get; set; }
        /// 
        /// 当前子流程
        /// 
        //[SugarColumn(IsNullable = true, ColumnDataType = "int")]
        //public int DetailStep { get; set; }
        /// 
        /// 预计开始时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime ExpectBeginDt { get; set; }
        /// 
        /// 预计结束时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime ExpectEndDt { get; set; }
        /// 
        /// 实际开始时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime RealBeginDt { get; set; }
        /// 
        /// 实际结束时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime RealEndDt { get; set; }
        /// 
        /// 总负责人(SysUser.Id)
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int Leader { get; set; }
        /// 
        /// 异常状态0:正常,1:异常
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int Exception { get; set; }
    }
    /// 
    /// 团组流程管控详细进度
    /// 因为要实现DeepClone 字段必须在同一类下所以不能继承EntityBase
    /// 
    [SugarTable("Grp_ScheduleDetail")]
    [Serializable]
    public class Grp_ScheduleDetailInfo : ICloneable
    {
        /// 
        /// 编号
        /// 
        [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = true, IsNullable = false)]
        public int Id { get; set; }
        /// 
        /// 创建者Id
        /// 
        [SugarColumn(ColumnDescription = "创建者Id", IsNullable = true, ColumnDataType = "int")]
        public int CreateUserId { get; set; }
        /// 
        /// 创建时间
        /// 
        [SugarColumn(ColumnDescription = "创建时间", IsNullable = true, ColumnDataType = "DateTime")]
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// 
        /// 删除者Id
        /// 
        [SugarColumn(ColumnDescription = "删除者Id", IsNullable = true, ColumnDataType = "int")]
        public int? DeleteUserId { get; set; }
        /// 
        /// 删除时间
        /// 
        [SugarColumn(ColumnDescription = "删除时间", IsNullable = true, ColumnDataType = "varchar(30)")]
        public string DeleteTime { get; set; }
        /// 
        /// 备注
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
        public string Remark { get; set; }
        /// 
        /// 是否删除
        /// 
        [SugarColumn(ColumnDescription = "是否删除", IsNullable = true, ColumnDataType = "int")]
        public int IsDel { get; set; }
        /// 
        /// 团组流程Id
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int ScheduleId { get; set; }
        /// 
        /// 等级
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int SLevel { get; set; }
        /// 
        /// 流程
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int Step { get; set; }
        /// 
        /// 父级流程
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int ParentStep { get; set; }
        /// 
        /// 流程状态
        /// 
        /// - 0:待分配(未开始)///
- 1:进行中///
- 2:已完成///
/// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int StepStatus { get; set; }
        /// 
        /// 负责人员(SysUser.Id)
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int Duty { get; set; }
        /// 
        /// 工作内容
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
        public string JobContent { get; set; }
        /// 
        /// 预计开始时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime ExpectBeginDt { get; set; }
        /// 
        /// 预计结束时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime ExpectEndDt { get; set; }
        /// 
        /// 实际开始时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime RealBeginDt { get; set; }
        /// 
        /// 实际结束时间
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "datetime")]
        public DateTime RealEndDt { get; set; }
        /// 
        /// 异常状态0:正常,1:异常
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int Exception { get; set; }
        
        public object Clone()
        {
            return this.MemberwiseClone();
        }
        public Grp_ScheduleDetailInfo DeepClone()
        {
            using (Stream objectStream = new MemoryStream())
            {
                IFormatter formatter = new BinaryFormatter();
                formatter.Serialize(objectStream, this);
                objectStream.Seek(0, SeekOrigin.Begin);
                return formatter.Deserialize(objectStream) as Grp_ScheduleDetailInfo;
            }
        }
    }
    /// 
    /// 团组流程管控人员配置
    /// 
    [SugarTable("Grp_SchedulePerson")]
    public class Grp_SchedulePersonInfo : EntityBase
    {
        /// 
        /// 流程Id
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int ScheduleId { get; set; }
        /// 
        /// 人员编号(SysUser.Id)
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
        public int SysUserId { get; set; }
        /// 
        /// 人员姓名
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
        public string SysUserName { get; set; }
        /// 
        /// 负责工作
        /// 
        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
        public string JobStr { get; set; }
    }
}