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 : IBaseModel<string>
    {
        /// <summary>
        /// 自增id
        /// </summary>
        [Key]
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string id { get; set; }
        /// <summary>
        /// 工单分类(1随机工单,2计划分送工单)
        /// </summary>
        public int wosorts { get; set; } = 1;
        /// <summary>
        /// 渠道来源 1表示PC 2表示安卓 3表示IOS 4表示微信
        /// </summary>
        public int channel { get; set; } = 1;
        /// <summary>
        /// 紧急程度 - 1一般 2紧急
        /// </summary>
        public int emergencyid { get; set; }
        /// <summary>
        /// 计划Id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string planid { get; set; }
        /// <summary>
        /// 计划任务Id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string plantaskid { get; set; }
        /// <summary>
        /// 项目名称id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string projectid { get; set; }
        /// <summary>
        /// 工单编号 -------------------------------------------
        /// </summary>
        public string wocode { get; set; } = "";
        /// <summary>
        /// 配送工单状态:0创建工单，1转派或者抢单（待取货）,2已取货（配送中）,3货物异常（异常），4已完结/待评价，5已取消，6挂起，7取货异常退单 ，9已评价 
        /// </summary>
        public int wostate { get; set; } = 0;
        /// <summary>
        /// 电梯岗 - 工单状态(0创建工单，1已接单（待取货），2已取货（待配送）) -------------------------------------------
        /// </summary>
        public int wostate_elevator { get; set; } = 0;
        /// <summary>
        /// 电梯岗 - 接单人 1个人
        /// </summary>
        public string touser_elevator { get; set; }
        /// <summary>
        /// 备注内容 - 备用
        /// </summary>
        public string detail { get; set; } = "";      
        ///// <summary>
        ///// 当前记录的状态 0进行中，1已结束
        ///// </summary>
        //public int itemstate { get; set; } = 0;

        /// <summary>
        /// 配送物品 -------------------------------------------
        /// </summary>
        public List<DistributionGoodsList> goodslist { get; set; } = new List<DistributionGoodsList>();

        /// <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 List<string> touser { get; set; } = new List<string>();
        /// <summary>
        /// 类型(1派单2抢单3强制分配)
        /// </summary>
        public int totype { get; set; } = 0;
        /// <summary>
        /// 接单时间 - 配送岗
        /// </summary>
        public DateTime assigtime { get; set; }
        /// <summary>
        /// 接单时间 - 电梯岗
        /// </summary>
        public DateTime assigtime_elevator { get; set; }
        /// <summary>
        /// 挂起时间
        /// </summary>
        public DateTime hanguptime { get; set; }
        /// <summary>
        /// 取消时间
        /// </summary>
        public DateTime canceltime { get; set; }
        // <summary>
        /// 星级 服务满意度打分☆☆☆☆☆ 注：其中默认都是5星，最低只能打1星，每一星对应20分，合计100分
        /// </summary>
        public int starnum { get; set; } = 0;
        /// <summary>
        /// 评价时间
        /// </summary>
        public DateTime evaluatetime { get; set; }
        /// <summary>
        /// 处理人
        /// </summary>
        public List<string> dealby { get; set; } = new List<string>();
        /// <summary>
        /// 处理时间
        /// </summary>
        public DateTime dealtime { get; set; }
        /// <summary>
        /// 是否最后一步 0否 1是
        /// </summary>
        public int islast { get; set; } = 0;
        /// <summary>
        /// 是否违规 0否 1是
        /// </summary>
        public int isoffence { get; set; } = 0;

        /// <summary>
        /// 收货人签字 - 随记工单 -------------------------------------------
        /// </summary>
        public List<FileBaseModel> signbypic { get; set; } = new List<FileBaseModel>();
        /// <summary>
        /// 收货人拍照 - 分送工单
        /// </summary>
        public List<FileBaseModel> planwopic { get; set; } = new List<FileBaseModel>();
        /// <summary>
        /// 是否异常（0否1是） - 主管异常
        /// </summary>
        public int isexceptions { get; set; }
        ///// <summary>
        ///// 是否送达（0否1是） - 异常上报 完结
        ///// </summary>
        //public int sended { get; set; }
        ///// <summary>
        ///// 异常说明
        ///// </summary>
        //public string exceptions { get; set; }

        /// <summary>
        /// 添加人工号 -------------------------------------------
        /// </summary>
        public string createtby { get; set; }
        /// <summary>
        /// 添加人姓名
        /// </summary>
        public string createname { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime createtime { get; set; } = DateTime.Now;
        /// <summary>
        /// 是否删除(0正常 1删除)
        /// </summary>
        public int isdelete { get; set; }
        /// <summary>
        /// 删除人
        /// </summary>
        public string deleteby { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime deletetime { get; set; }
        /// <summary>
        /// 应用分类（0pc 1android 2ios）
        /// </summary>
        public int apptype { get; set; } = 0;
    }

    #region 字段 model
    /// <summary>
    /// 配送物品
    /// </summary>
    public class DistributionGoodsList
    {
        /// <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 class DistributionDddressModel
    {
        /// <summary>
        /// 楼宇名称id ---------------------------------------------关联科室
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string buildingid { get; set; }
        /// <summary>
        /// 楼宇
        /// </summary>
        public string building_name { get; set; }
        /// <summary>
        /// 层数id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string floorid { get; set; }
        /// <summary>
        /// 层数
        /// </summary>
        public string floor_name { get; set; }
        /// <summary>
        /// 科室(例如：内科|消化科[一级|二级|三级]) - 原因：科室可能是一级二级三级...不确定，所以用"|"隔开
        /// </summary>
        public string department_name { get; set; }
        ///// <summary>
        ///// 姓名
        ///// </summary>
        //public string fullname { get; set; }
        ///// <summary>
        ///// 电话
        ///// </summary>
        //public string mobile { get; set; }
    }
    #endregion

    /// <summary>
    /// 配送工单状态:0创建工单，1转派或者抢单（待取货）,2已取货（配送中）,3货物异常（异常），4已完结/待评价，5已取消，6挂起，7取货异常退单 ，9已评价 
    /// </summary>
    public enum EnumDistributionState
    {
        create = 0,     //0创建工单
        assign = 1,     //1转派或者抢单（待取货）
        delivery = 2,   //2已取货
        exceptions = 3, //3货物异常（异常）
        finish = 4,     //4已完结/待评价
        canceled = 5,   //5已取消
        //hangup = 6,     //6挂起//
        backed = 7,     //7取货异常退单
        evaluated = 9   //9已评价
    }

    /// <summary>
    /// 电梯岗 - 工单状态(0创建工单，1已接单（待取货），2已取货（待配送）)
    /// </summary>
    public enum EnumDistributionState_elevator
    {
        create = 0,     //0创建工单
        accept = 1,     //1已接单（待取货）
        delivery = 2    //2已取货（待配送）
    }

    /// <summary>
    /// 类型(1派单 2抢单)
    /// </summary>
    public enum EnumDistributionTotype
    {
        create = 0,   //0创建
        send = 1,   //1派单
        robbery = 2, //2抢单
        assign = 3 //3强制分配
    }

    /// <summary>
    /// 工单分类(1随机工单,2计划分送工单)
    /// </summary>
    public enum EnumDistributionWoSorts
    {
        random = 1,     //1随机工单
        plan = 2,        //2分送工单
        plantask = 3        //2计划工单
    }
}
