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; }
        /// 
        /// 1物理隔板;2单支计数;3管控药盒;4储物箱;5智能显示;6称重计数;63称重计数药盒;653称重计数药盒智能显示;
        /// 
        [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 drugManuNoList { get; set; }=new List();
        [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 OrderList { get; set; }
        //药盒中药品对应的选中的处方信息
        [Column(IsColumn =false)]
        public IList 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 DrawerChanneStockList { get; set; }
        //药盒中未绑套餐的药所在抽屉库位
        [Column(IsColumn = false)]
        public ChannelStock ReturnDrawerChanneStock { get; set; }
        //调拨出、入库时药品单位是否与药品表中的小单位相同(库存中存小单位的数量,单位不一致需要转换)
        public bool UnitEquals{get; set;  }=true;
    }
}