using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DbCommon.Enties.DbModels
{
    [SugarTable("CallTask")]
    public class CallTask
    {
        [SugarColumn(IsPrimaryKey = true, Length = 50)]
        public string TaskID { get; set; }
        public int Route { get; set; }
        public int Priority { get; set; }
        public int Carrier { get; set; }

        public EnumTaskType TaskType { get; set; }
        public EnumTaskStatus TaskStatus { get; set; }

        public string AllWarehouse { get; set; }


        [SugarColumn(IsIgnore = true)]
        public string CurrentWarehouse
        {
            get
            {
                string[] posArray = AllWarehouse.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (posArray == null)
                {
                    return null;
                }

                if (WarehouseIndex >= posArray.Length)
                {
                    return null;
                }
                return posArray[WarehouseIndex];
            }
        }
        public int WarehouseIndex { get; set; }


        [SugarColumn(IsNullable = true, Length = 500)]
        public string Message { get; set; }


        public EnumStepStatus StepStatus { get; set; }
        public int StepMark { get; set; }
        public int StepRoute { get; set; }

        [SugarColumn(IsNullable = true, Length = 50)]
        public string StepLocation { get; set; }


        [SugarColumn(IsNullable = true, Length = 50)]
        public string LocationEx1 { get; set; }

        [SugarColumn(IsNullable = true, Length = 50)]
        public string LocationEx2 { get; set; }

        [SugarColumn(IsNullable = true, Length = 50)]
        public string LocationEx3 { get; set; }

        [SugarColumn(IsNullable = true, Length = 50)]
        public string LocationEx4 { get; set; }

        [SugarColumn(IsNullable = true, Length = 50)]
        public string MaterialId { get; set; }

        public DateTime CallTime { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }

        public CallTask()
        {
            TaskID = DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
        }
    }

    public enum EnumCallType
    {
        Pms = 0,
        Pad = 1,
    }

    public enum EnumTaskStatus
    {
        叫料 = 0,
        任务创建 = 1,
        任务启动 = 2,
        任务完成 = 3,

        任务手动删除处理 = 252,
        任务手动删除 = 253,
        任务添加异常 = 254,
        任务异常 = 255,
    }

    public enum EnumStepStatus
    {
        None = 0,
        正在发车 = 1,
        等待到达位置 = 2,
    }

    public enum EnumTaskType
    {
        None,
        普通叫料 = 1,
    }
}
