using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.DAL.DbModels;

namespace WCS.BLL.DbModels
{
    /// <summary>
    /// 出库物料明细（库存数据加锁后缓存对应的数据并记录状态）
    /// </summary>
    [SugarTable("wcs_out_order_mat_detail")]
    public class OutOrderMatDetail
    {
        /// <summary>
        /// 主键 自增Id
        /// </summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 出库单据的主键ID
        /// </summary>
        [SugarColumn(ColumnName = "order_id", IsNullable = false)]
        public int OrderId { get; set; }

        /// <summary>
        /// 出库单据号
        /// </summary>           
        [SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = false, ColumnDescription = "出库单据号")]
        public string OrderNumber { get; set; }

        /// <summary>
        /// 出库单据明细的ID
        /// </summary>
        [SugarColumn(ColumnName = "out_order_detail_id", IsNullable = true)]
        public int OutOrderDetailId { get; set; }

        /// <summary>
        /// 库存数据的ID
        /// </summary>
        [SugarColumn(ColumnName = "inventory_detail_id", IsNullable = true)]
        public int InventoryDetailId { get; set; }

        #region 库位属性
        /// <summary>
        /// 入库的库位表ID
        /// </summary>
        [SugarColumn(ColumnName = "store_id", IsNullable = false, ColumnDescription = "库位ID")]
        public int StoreId { get; set; }

        /// <summary>
        /// 入库的库位编码
        /// </summary>
        [SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
        public string StoreCode { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(StoreId))]
        public StoreInfo StoreInfo { get; set; }
        #endregion

        #region 物料属性
        /// <summary>
        /// 物料编码（SN）
        /// </summary>
        [SugarColumn(ColumnName = "mat_sn", Length = 200, IsNullable = false, ColumnDescription = "物料SN")]
        public string MatSN { get; set; }
        /// <summary>
        /// 物料编码
        /// </summary>
        [SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
        public string MatCode { get; set; }
        /// <summary>
        /// 物料名称
        /// </summary>           
        [SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")]
        public string MatName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>           
        [SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")]
        public string MatSpec { get; set; }

        /// <summary>
        /// 物料批次
        /// </summary>           
        [SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")]
        public string MatBatch { get; set; }

        /// <summary>
        /// 物料数量 
        /// </summary>
        [SugarColumn(ColumnName = "mat_qty", IsNullable = false, ColumnDescription = "物料数量")]
        public int MatQty { get; set; }

        /// <summary>
        /// 物料供应商
        /// </summary>           
        [SugarColumn(ColumnName = "mat_supplier", Length = 150, IsNullable = true, ColumnDescription = "物料供应商")]
        public string? MatSupplier { get; set; }

        /// <summary>
        /// 物料客户
        /// </summary>           
        [SugarColumn(ColumnName = "mat_customer", Length = 150, IsNullable = true, ColumnDescription = "物料客户")]
        public string? MatCustomer { get; set; }
        #endregion

        /// <summary>
        /// 该物料是否已出库
        /// </summary>
        [SugarColumn(ColumnName = "is_sended", IsNullable = false, ColumnDescription = "该物料是否已出库")]
        public bool IsSended { get; set; } = false;

        /// <summary>
        /// 创建时间
        /// </summary>           
        [SugarColumn(ColumnName = "create_time", IsNullable = false, ColumnDescription = "入库时间")]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建人
        /// </summary>           
        [SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
        public string CreateUser { get; set; }

        /// <summary>
        /// 是否是盟讯公司盘点生成的出库单
        /// </summary>
        [SugarColumn(ColumnName = "is_MXPD", IsNullable = true, ColumnDescription = "是否是盟讯公司盘点生成的出库单")]
        public bool? IsMXPD { get; set; } = false;

        /// <summary>
        /// 用于绑定中显示序号
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public int RowNumber { get; set; }
    }
}
