using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.HardWare;

namespace WCS.DAL.DbModels
{
    [SugarTable("wcs_location_info")]
    public class LocationInfo
    {
        /// <summary>
        /// 主键 自增Id
        /// </summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 位置编码
        /// </summary>       
        [SugarColumn(ColumnName = "location_code", Length = 64, IsNullable = false, ColumnDescription = "位置编码")]
        public string LocationCode { get; set; }

        /// <summary>
        /// 库位区域
        /// </summary>
        [SugarColumn(ColumnName = "location_area_id", IsNullable = true, ColumnDescription = "库位区域Id")]
        public int LocationAreaId { get; set; }
        /// <summary>
        /// 库位区域
        /// </summary>       
        [SugarColumn(ColumnName = "location_area", Length = 64, IsNullable = false, ColumnDescription = "库位区域名称")]
        public string LocationArea { get; set; }

        /// <summary>
        /// RCS库位编号
        /// </summary>
        [SugarColumn(ColumnName = "rcs_store_code", Length = 64, IsNullable = true, ColumnDescription = "RCS库位编号")]
        public string RcsStoreCode { get; set; }


        /// <summary>
        /// X坐标
        /// </summary>
        [SugarColumn(ColumnName = "X", IsNullable = true, DefaultValue = "0", ColumnDescription = "X坐标")]
        public decimal X { get; set; }

        /// <summary>
        /// Y坐标
        /// </summary>
        [SugarColumn(ColumnName = "Y", IsNullable = true, DefaultValue = "0", ColumnDescription = "Y坐标")]
        public decimal Y { get; set; }

        /// <summary>
        /// 可放置货架类型
        /// </summary>
        [SugarColumn(ColumnName = "allow_shelf_types", Length = 256, IsNullable = true, ColumnDescription = "可放置货架类型", IsJson = true)]
        public List<int> AllowShelfTypes { get; set; }

        /// <summary>
        /// 作为起点时 允许的目的地类型
        /// </summary>
        [SugarColumn(ColumnName = "allow_destination_location_area", Length = 512, IsNullable = true, ColumnDescription = "可放置货架类型", IsJson = true)]
        public List<int> AllowDestinationLocationArea { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>           
        [SugarColumn(ColumnName = "modify_user", Length = 128, IsNullable = true, ColumnDescription = "更新人")]
        public string ModifyUser { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>           
        [SugarColumn(ColumnName = "modify_time", IsNullable = false, ColumnDescription = "更新时间")]
        public DateTime ModifyTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 当前位置的状态
        /// </summary>
        [SugarColumn(ColumnName = "location_status", IsNullable = false, DefaultValue = "0", ColumnDescription = "当前位置的状态")]
        public LocationStatusEnum LocationStatus { get; set; } = LocationStatusEnum.空闲;

        /// <summary>
        /// 是否启用
        /// </summary>
        [SugarColumn(ColumnName = "is_enable", IsNullable = false, ColumnDescription = "是否启用")]
        public bool IsEnable { get; set; } = true;

        [SugarColumn(IsIgnore = true)]
        public string IsEnableStr
        {
            get
            {
                if (IsEnable)
                    return "启用";
                else
                    return "禁用";
            }
        }

        /// <summary>
        /// 序号
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public int RowNumber { get; set; }

        [SugarColumn(IsIgnore = true)]
        public List<string> AllowShelfTypesName { get; set; } = new List<string>();

        [SugarColumn(IsIgnore = true)]
        public string AllowShelfTypesNameStr { get { return string.Join(",", AllowShelfTypesName); } }
        /// <summary>
        /// 是否已经选择
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public bool IsSelected { get; set; }
    }


    /// <summary>
    /// 货架运输状态
    /// </summary>
    public enum LocationStatusEnum
    {
        空闲 = 0,//位置上既没有货架 也没有送货架过来的任务
        待占用 = 1,//位置上无货架 但是有送货架过来的任务
        占用 = 2,//位置上有货架
        待空闲 = 3,//位置上有货架 但是此货架已有送走的任务
    }
}
