using LinqToDB.Mapping;
using Mysqlx.Crud;

namespace MasaBlazorApp3.Pojo
{
    [Table("channel_stock")]
    public class ChannelStock
    {
        [PrimaryKey]
        [Column("chsguid")]
        public string Id { get; set; }

        [Column("chnguid")]
        public string ListId { get; set; }

        [Column("machine_id")]
        public string MachineId { get; set; }

        [Column("row_no")]
        public int DrawerNo { get; set; }

        [Column("col_no")]
        public int ColNo { get; set; }

        [Column("drug_id")]
        public string DrugId { get; set; }

        [Column("quantity")]
        public int Quantity { get; set; }
        
        [Column(IsColumn =false)]
        public int TotalQuantity { get; set; }

        //药盒DrawerType为非1时表示不在库
        [Column("drawer_type")]
        public int DrawerType { get; set; }

        /// <summary>
        /// 1物理隔板;2单支计数;3管控药盒;4储物箱;5智能显示;6称重计数;63称重计数药盒;653称重计数药盒智能显示;
        /// </summary>
        [Column("board_type")]
        public int BoardType { get; set; }

        [Column("manu_no")]
        public string ManuNo { get; set; }

        [Column("eff_date")]
        public string EffDate { get; set; }

        [LinqToDB.Mapping.Association(ThisKey = nameof(DrugId), OtherKey = nameof(DrugInfo.DrugId))]
        public DrugInfo? Drug { get; set; }


        [Column(IsColumn = false)]
        public int TakeQuantity { get; set; } = 0;
        [Column(IsColumn = false)]
        public int AddQuantity { get; set; } = 0;

        [Column(IsColumn = false)]
        public int ReturnQuantity { get; set; } = 0;

        [Column("dmnguid")]
        public string Dmnguid { get; set; }

        [LinqToDB.Mapping.Association(ThisKey = nameof(Dmnguid), OtherKey = nameof(DrugManuNo.Id))]
        public DrugManuNo? drugManuNo { get; set; }

        [Association(ThisKey = nameof(DrugId), OtherKey = nameof(DrugManuNo.DrugId))]
        public List<DrugManuNo> drugManuNoList { get; set; }=new List<DrugManuNo>();

        [Column(IsColumn = false)]
        public string Location
        { get => DrawerNo + "-" + ColNo; }

        [Column(IsColumn = false)]
        public int CanReturnQuantity { get; set; }
        [Column(IsColumn = false)]
        public int CheckQuantity
        {
            get;
            set;
        }
        [Column("Pos_No")]
        public int BiaoDingStatus { get; set; }

        //手术室药盒中的药品基数
        [Column("Check_Quantity")]
        public int BaseQuantity { get; set; }
        //手术室药盒中某药品全部批次的需要加药数
        [Column("col_no2")]
        public int NeedQuantity { get; set; }
        //手术室药盒中某药品全部批次的已取药待入库数
        [Column("col_no1")]
        public int AddToQuantity { get; set; }
        //手术室药盒中药品补药状态(1需补药2已补药待入库0满库状态)
        [Column("state")]
        public int BoxState { get; set; }
        [Column("fill_time")]
        public DateTime FillTime { get; set; }
        //药盒中药品对应的处方信息
        [Column(IsColumn =false)]
        public List<OrderInfo> OrderList { get; set; }
        //药盒中药品对应的选中的处方信息
        [Column(IsColumn =false)]
        public IList<OrderInfo> SelectedOrderList { get; set; }
        //还空瓶库位
        [Column(IsColumn = false)]
        public ChannelStock EmptyStock { get; set; }
        //还空瓶数
        [Column(IsColumn = false)]
        public int EmptyQuantity { get; set; } = 0;
        //用药数
        [Column(IsColumn =false)]
        public int UseQuantity { get; set; }
        //处方数
        [Column(IsColumn =false)]
        public int OrderQuantity { get; set; }
        //药盒中未绑套餐的药所在抽屉库位
        [Column(IsColumn =false)]
        public List<ChannelStock> DrawerChanneStockList { get; set; }
        //药盒中未绑套餐的药所在抽屉库位
        [Column(IsColumn = false)]
        public ChannelStock ReturnDrawerChanneStock { get; set; }
    }
}
