using SqlSugar;
using System;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace WCS.Entity
{
    /// <summary>
    /// AGV任务中间表
    /// </summary>
    [SugarTable(nameof(WCS_AgvTaskInfo) + "_{year}{month}{day}", "AGV任务中间表")]
    [SplitTable(SplitType.Month)]//按年分表 （自带分表支持 年、季、月、周、日）
    [DataContract]
    public class WCS_AgvTaskInfo
    {
        /// <summary>
        /// ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, ColumnDescription = "ID"), DataMember(Order = 0)]
        public int ID { get; set; }

        /// <summary>
        /// AGVID
        /// </summary>
        [SugarColumn(ColumnDescription = "AGVID", Length = 50, IsNullable = true), DataMember(Order = 1)]
        public string AgvID { get; set; }

        /// <summary>
        ///  wcsTaskId
        /// </summary>
        [SugarColumn(ColumnDescription = "wcsTaskId", IsNullable = true), DataMember(Order = 2)]
        public int TaskId { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(TaskId))]
        public WCS_TaskInfo Task { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        [SugarColumn(ColumnDescription = "任务类型")]
        [DataMember(Order = 2)]
        public AGVTaskType TaskType { get; set; }

        /// <summary>
        /// WCS AGV任务状态
        /// </summary>
        [SugarColumn(ColumnDescription = "WCS AGV任务状态")]
        [DataMember(Order = 3)]
        public AGVTaskStatus Status { get; set; }

        /// <summary>
        /// AGV自身状态
        /// </summary>
        [SugarColumn(ColumnDescription = "AGV自身状态")]
        [DataMember(Order = 4)]
        public AGVTaskStatus AgvStatus { get; set; }

        /// <summary>
        /// 车间
        /// </summary>
        [SugarColumn(ColumnDescription = "车间")]
        [DataMember(Order = 5)]
        public int WorkShop { get; set; }

        /// <summary>
        /// 站台
        /// </summary>
        [SugarColumn(ColumnDescription = "站台", Length = 20, IsNullable = true)]
        [DataMember(Order = 6)]
        public string Station { get; set; }

        /// <summary>
        /// 位置
        /// </summary>
        [SugarColumn(ColumnDescription = "位置", Length = 20, IsNullable = true)]
        [DataMember(Order = 7)]
        public string Position { get; set; }

        /// <summary>
        /// 货物数量(1.两个位置放1个货物，2.两个位置放2个货物）
        /// </summary>

        [SugarColumn(ColumnDescription = "货物数量(1.两个位置放1个货物，2.两个位置放2个货物）")]
        [DataMember(Order = 11)]
        public int GoodsSum { get; set; }

        /// <summary>
        /// 创建用户
        /// 仅记录用户ID
        /// </summary>
        [SugarColumn(ColumnDescription = "创建用户", Length = 50)]
        public string AddWho { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(ColumnDescription = "创建时间", InsertServerTime = true)]
        public DateTime AddTime { get; set; }

        /// <summary>
        /// AGV更新时间
        /// </summary>
        [SugarColumn(ColumnDescription = "AGV更新时间", UpdateServerTime = true, IsNullable = true)]
        [DataMember(Order = 10)]
        public DateTime AgvUpdateTime { get; set; }

        /// <summary>
        /// 更新用户
        /// 仅记录用户ID
        /// </summary>
        [SugarColumn(ColumnDescription = "更新用户", Length = 50, IsNullable = true)]
        public string EditWho { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(ColumnDescription = "更新时间", IsNullable = true, UpdateServerTime = true)]
        public DateTime EditTime { get; set; }
    }

    /// <summary>
    /// AGV任务状态
    /// </summary>
    public enum AGVTaskStatus
    {
        /// <summary>
        /// 新建
        /// </summary>
        [Description("新建")]
        NewBuild = 0,

        /// <summary>
        /// 确认
        /// </summary>
        [Description("确认")]
        Confirm = 5,

        /// <summary>
        /// 执行
        /// </summary>
        [Description("执行")]
        Execution = 10,

        /// <summary>
        ///  走出储位
        /// </summary>
        ExitStorage = 11,

        /// <summary>
        ///  走入储位
        /// </summary>
        WalkIntoStorage = 12,

        /// <summary>
        ///  巷道/工位分配申请
        /// </summary>
        [Description("巷道/工位分配申请")]
        RequestOrPermission1 = 20,

        /// <summary>
        /// 完成巷道/工位分配申请
        /// </summary>
        [Description("完成巷道/工位分配申请")]
        Complete1 = 21,

        #region 安全交互

        /// <summary>
        ///  取站台前安全交互申请
        /// </summary>
        [Description("取放站台前安全交互申请")]
        RequestOrPermission2 = 30,

        /// <summary>
        ///  完成交互
        ///  完成交互
        /// </summary>
        [Description("取放站台前安全交互申请")]
        Complete = 31,

        /// <summary>
        ///  放站台前安全交互申请
        /// </summary>
        [Description("取放站台前安全交互申请")]
        PutRequestOrPermission = 40,

        #endregion 安全交互

        /// <summary>
        ///  小车离开取货位
        /// </summary>
        [Description("小车离开取货位")]
        LeaveGet = 32,

        /// <summary>
        ///  小车离开放货位
        /// </summary>
        [Description("小车离开放货位")]
        LeavePut = 33,

        /// <summary>
        /// 任务完成
        /// </summary>
        [Description("任务完成")]
        MissionCompleted = 99,

        /// <summary>
        /// 完成扫码
        /// </summary>
        [Description("完成扫码")]
        CompleteScanCode = 100,

        /// <summary>
        ///  取消
        /// </summary>
        [Description("取消")]
        Cancel = 106
    }

    /// <summary>
    /// AGV任务类型
    /// </summary>
    public enum AGVTaskType
    {
        /// <summary>
        /// 入库
        /// </summary>
        [Description("入库")]
        EnterDepot = 1,

        /// <summary>
        /// 背负式补空
        /// </summary>
        [Description("背负式补空")]
        CallForMaterial = 2,

        /// <summary>
        ///  叉车机台补空任务
        /// </summary>
        [Description("叉车机台补空任务")]
        ForkliftFilling = 3,

        /// <summary>
        /// 叫料
        /// </summary>
        [Description("叫料")]
        CallMaterial = 4,

        /// <summary>
        ///  搬运/运输
        /// </summary>
        [Description("搬运/运输")]
        Transport = 5,
    }
}
