using MadRunFabric.Common;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;

namespace MadRunFabric.Model
{
    /// <summary>
    /// 保养工单基础表
    /// </summary>
    [BsonIgnoreExtraElements]
    public class Wo_Maintain_Base : IBaseModel<string>
    {
        /// <summary>
        /// id
        /// </summary>
        [Key]
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string id { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string wocode { get; set; } = "";
        /// <summary>
        /// 保养计划Id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string planid { get; set; } = "";
        public string wodate { get; set; } = "";
        /// <summary>
        /// 项目名称
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string projectid { get; set; } = "";

        /// <summary>
        /// 检查事项
        /// </summary>
        public string[] matterids { get; set; }
        ///// <summary>
        ///// 系统名称
        ///// </summary>
        //[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string systemid { get; set; } = "";

        ///// <summary>
        ///// 设备名称
        ///// </summary>
        ////[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string[] equipmentid { get; set; }
        /// <summary>
        /// 工单开始时间
        /// </summary>
        public DateTime starttime { get; set; }
        /// <summary>
        /// 工单结束时间
        /// </summary>
        public DateTime endtime { get; set; }
        /// <summary>
        /// 上次保养时间
        /// </summary>
        public DateTime lastmaintaintime { get; set; }

        /// <summary>
        /// 上次保养结果
        /// </summary>
        public int lastmaintainresult { get; set; } = 0;
        /// <summary>
        /// 上次保养类别
        /// </summary>
        public List<string> lastmaintaintype { get; set; }

        /// <summary>
        /// 本次保养时间
        /// </summary>
        public DateTime maintaintime { get; set; }
        /// <summary>
        /// 工单名称
        /// </summary>
        public string woname { get; set; } = "";
        /// <summary>
        /// 保养内容
        /// </summary>
        public string maintaincontent { get; set; } = "";
        /// <summary>
        /// 保养要求
        /// </summary>
        public string maintainclim { get; set; } = "";
        /// <summary>
        /// 本次保养类别
        /// </summary>
        public List<string> timemaintaintype { get; set; }
        #region 处理信息
        /// <summary>
        /// 保养单位
        /// </summary>
        public string maintainunit { get; set; } = "";

        ///// <summary>
        ///// 保养人
        ///// </summary>
        //public string maintainman { get; set; } = "";
        /// <summary>
        /// 保养人
        /// </summary>
        public List<string> maintainuser { get; set; }

        /// <summary>
        /// 保养人姓名
        /// </summary>
        public List<string> maintainusername { get; set; }

        /// <summary>
        /// 保养类别
        /// </summary>
        public List<string> maintaintype { get; set; } = null;

        /// <summary>
        /// 更换说明
        /// </summary>
        public string replacedes { get; set; } = "";

        /// <summary>
        /// 保养图片
        /// </summary>
        public List<FileBaseModel> maintainpic { get; set; } = null;
        /// <summary>
        /// 扩展字段 - 自定义
        /// </summary>
        public List<ExtensionFileModel> extensionlist { get; set; } = null;
        /// <summary>
        /// 设备状态 0正常，1异常
        /// </summary>
        public int equipstate { get; set; } = 0;

        /// <summary>
        /// 异常说明
        /// </summary>
        public string exceptiondes { get; set; } = "";

        /// <summary>
        /// 任务状态:0创建工单，1已转派，3已处理，6挂起 
        /// </summary>
        public int wostate { get; set; } = 0;

        /// <summary>
        /// 处理提交时间
        /// </summary>
        public DateTime dealtime { get; set; }
        /// <summary>
        /// 处理人 usercode
        /// </summary>
        //public string dealby { get; set; } = "";
        /// <summary>
        /// 处理人
        /// </summary>
        public List<string> dealuser { get; set; }

        /// <summary>
        /// 处理人姓名
        /// </summary>
        public List<string> dealusername { get; set; }
        #endregion
        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime createtime { get; set; }

        /// <summary>
        /// 提交人
        /// </summary>
        public string createby { get; set; } = "";
        /// <summary>
        /// 是否删除
        /// </summary>
        public bool isdelete { get; set; } = false;
        public string deleteby { get; set; } = "";
        public DateTime deletetime { get; set; }
        #region
        ///// <summary>
        ///// 保养计划Id
        ///// </summary>
        //[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string plan { get; set; } = "";

        ///// <summary>
        ///// 项目名称
        ///// </summary>
        //[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string proname { get; set; } = "";

        ///// <summary>
        ///// 系统名称
        ///// </summary>
        //[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string sysname { get; set; } = "";

        ///// <summary>
        ///// 设备名称
        ///// </summary>
        //[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        //public string equipname { get; set; } = "";
        ///// <summary>
        ///// 到期时间
        ///// 计算超时需要使用
        ///// </summary>
        //public DateTime expirytime { get; set; }
        ///// <summary>
        ///// 提前展示时长（分钟）
        ///// </summary>
        //public int advancelong { get; set; } = 0;
        ///// <summary>
        ///// 提前展示时间
        ///// </summary>
        //public DateTime advancetime { get; set; }
        ///// <summary>
        ///// 上次保养时间
        ///// </summary>
        //public DateTime lastmaintaintime { get; set; }

        ///// <summary>
        ///// 上次保养结果
        ///// </summary>
        //public int lastmaintainresult { get; set; } = 0;
        ///// <summary>
        ///// 上次保养类别
        ///// </summary>
        //public List<string> lastmaintaintype { get; set; }

        ///// <summary>
        ///// 本次保养时间
        ///// </summary>
        //public DateTime maintaintime { get; set; }

        ///// <summary>
        ///// 本次保养内容
        ///// </summary>
        //public string maintaincontent { get; set; } = "";
        ///// <summary>
        ///// 本次保养类别
        ///// </summary>
        //public List<string> timemaintaintype { get; set; }
        //#region 处理信息
        ///// <summary>
        ///// 保养单位
        ///// </summary>
        //public string maintainunit { get; set; } = "";

        ///// <summary>
        ///// 保养人
        ///// </summary>
        //public string maintainman { get; set; } = "";

        ///// <summary>
        ///// 保养类别
        ///// </summary>
        //public List<string> maintaintype { get; set; } = null;

        ///// <summary>
        ///// 更换说明
        ///// </summary>
        //public string replacedes { get; set; } = "";

        ///// <summary>
        ///// 保养图片
        ///// </summary>
        //public List<FileBaseModel> maintainpic { get; set; } = null;

        ///// <summary>
        ///// 设备状态 0正常，1异常
        ///// </summary>
        //public int equipstate { get; set; } = 0;

        ///// <summary>
        ///// 异常说明
        ///// </summary>
        //public string exceptiondes { get; set; } = "";

        ///// <summary>
        ///// 任务状态:0创建工单，1已转派，3已处理，6挂起 
        ///// </summary>
        //public int wostate { get; set; } = 0;

        ///// <summary>
        ///// 处理提交时间
        ///// </summary>
        //public DateTime dealtime { get; set; }
        ///// <summary>
        ///// 处理人 usercode
        ///// </summary>
        //public string dealby { get; set; } = "";
        //#endregion
        ///// <summary>
        ///// 提交时间
        ///// </summary>
        //public DateTime createtime { get; set; }

        ///// <summary>
        ///// 提交人
        ///// </summary>
        //public string createby { get; set; } = "";
        ///// <summary>
        ///// 是否删除
        ///// </summary>
        //public bool isdelete { get; set; } = false;
        #endregion
    }

    /// <summary>
    /// 任务状态:0创建工单，1已转派，2已抢单，3已处理，6挂起 
    /// </summary>
    public enum EnumWoMaintainState
    {
        create = 0,
        assign = 1,
        grab = 2,
        deal = 3,
        hangup = 6
    }

    /// <summary>
    /// 保养工单设备状态：0正常，1异常
    /// </summary>
    public enum EnumWoMEquipmentState
    {
        normal = 0,//正常
        abnormal = 1//异常
    }
}