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

namespace MadRunFabric.Model
{
    /// <summary>
    /// 计划工单 - 省三院
    /// </summary>
    [BsonIgnoreExtraElements]
    public class Distri_Workorder_PlanTask : IBaseModel<string>
    {
        /// <summary>
        /// 自增id
        /// </summary>
        [Key]
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string id { get; set; }
        /// <summary>
        /// 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信
        /// </summary>
        public int channel { get; set; } = 1;
        /// <summary>
        /// 计划工单状态:0创建计划任务，1开始，2已完成
        /// </summary>
        public int planwostate { get; set; } = 0;
        /// <summary>
        /// 项目名称id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string projectid { get; set; }
        /// <summary>
        /// 计划ID -----------------------------
        /// </summary>
        public string planid { get; set; }

        /// <summary>
        /// 计划工单编号 -------------------------------------------
        /// </summary>
        public string wocode { get; set; }
        /// <summary>
        /// 计划工单名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 计划工单内容
        /// </summary>
        public string content { get; set; }
        /// <summary>
        /// 计划工单参与人
        /// </summary>
        public List<string> joinuserlist { get; set; } = new List<string>();

        /// <summary>
        /// 配送物品 ------------------------------------------- 物品种类、物品数量（非必填）、收货地址（非必填）
        /// </summary>
        public List<DistributionGoodsListByTask> goodslist { get; set; } = new List<DistributionGoodsListByTask>();
        /// <summary>
        /// 收件（地址，科室，联系） ------------------------------------------- 把收/发地址信息保存起来，保证地址的独立性
        /// </summary>
        public List<DistributionDddressModel> receiverlist { get; set; } = new List<DistributionDddressModel>();
        /// <summary>
        /// 发货（地址，科室，联系）
        /// </summary>
        public List<DistributionDddressModel> deliverylist { get; set; } = new List<DistributionDddressModel>();
        /// <summary>
        /// 发货人
        /// </summary>
        public string deliveryname { get; set; } = "";
        /// <summary>
        /// 发货电话
        /// </summary>
        public string deliverytel { get; set; } = "";

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? statetime { get; set; }
        /// <summary>
        /// 处理人 -------------------------------------------------
        /// </summary>
        public string dealby { get; set; }
        /// <summary>
        /// 处理时间
        /// </summary>
        public DateTime dealtime { get; set; }


        /// <summary>
        /// 开始时间 - 计划工单 生成时间） -------------------------------------------------需要开始时间和结束时间，是为了定时添加参与人
        /// </summary>
        public DateTime starttime { get; set; }
        /// <summary>
        /// 结束时间 - 计划工单 生成时间
        /// </summary>
        public DateTime endtime { get; set; }

        ///// <summary>
        ///// 排序 --------------------------------------------------
        ///// </summary>
        //public int sortnum { get; set; } = 0;
        /// <summary>
        /// 添加人工号 --------------------------------------------------
        /// </summary>
        public string createtby { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime createtime { get; set; } = DateTime.Now;
        /// <summary>
        /// 是否删除(0正常 1删除)
        /// </summary>
        public int isdelete { get; set; } = 0;
        /// <summary>
        /// 删除人
        /// </summary>
        public string deleteby { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime deletetime { get; set; }
        
    }

    /// <summary>
    /// 配送计划状态:0创建计划，1开始，2已完成
    /// </summary>
    public enum EnumDistriWorkOrderPlanWOstate
    {
        create = 0,     //0创建计划
        start = 1,     //1开始
        finish = 2     //2已完成
    }

    /// <summary>
    /// 配送物品 - 计划工单
    /// </summary>
    public class DistributionGoodsListByTask
    {
        /// <summary>
        /// 物品id
        /// </summary>
        public string goodsid { get; set; }
        /// <summary>
        /// 物品名称
        /// </summary>
        public string goodsname { get; set; }
        /// <summary>
        /// 紧急程度 - 1一般 2紧急
        /// </summary>
        public int typeid { get; set; }
        /// <summary>
        /// 是否提醒 - 提醒（关联工单，即将提醒内填写的内容展示在该物品下单成功后的物品种类后面）
        /// </summary>
        public bool isremind { get; set; }
        /// <summary>
        /// 提醒备注
        /// </summary>
        public string remark { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public int num { get; set; }
        /// <summary>
        /// 已使用数量
        /// </summary>
        public int usednum { get; set; }
    }
}
