using LinqToDB.Mapping;
using MasaBlazorApp3.Pojo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace MasaBlazorApp3.Pojo
{
    [Table("dm_machine_record")]
    public class MachineRecord
    {
        /// 
        /// 主键 
        ///
        [Column("id", IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        /// 
        /// 设备id 
        ///
        [Column("machine_id")]
        public string MachineId { get; set; }
        /// 
        /// 药品id 
        ///
        [Column("drug_id")]
        public string DrugId { get; set; }
        [Association(ThisKey = nameof(DrugId), OtherKey = nameof(DrugInfo.DrugId))]
        public DrugInfo Drug { get; set; }
        /// 
        /// 数量 
        ///
        [Column("quantity")]
        public int Quantity { get; set; }
        
        /// 
        /// 批号 
        ///
        [Column("manu_no")]
        public string ManuNo { get; set; }
        /// 
        /// 操作人id 
        ///
        [Column("operator")]
        public int? Operator { get; set; }
        [Association(ThisKey = nameof(Operator), OtherKey = nameof(User.Id))]
        public User OperatorUser { get; set; }
        /// 
        /// 审核人id 
        ///
        [Column("reviewer")]
        public int? Reviewer { get; set; }
        [Association(ThisKey = nameof(Reviewer), OtherKey = nameof(User.Id))]
        public User ReviewerUser { get; set; }
        /// 
        /// 操作时间 
        /// 默认值: CURRENT_TIMESTAMP
        ///
        [Column("operation_time")]
        public DateTime OperationTime { get; set; }
        /// 
        /// 效期 
        ///
        [Column("eff_date")]
        public DateTime? EffDate { get; set; }
        /// 
        /// 出库入库类型(1入库2出库31还药32还空瓶) 
        ///
        [Column("type")]
        public int Type { get; set; }
        /// 
        /// 出入库调拨单id 
        ///
        [Column("invoice_id")]
        public string InvoiceId { get; set; }
        /// 
        /// 列号 
        ///
        [Column("col_no")]
        public int ColNo { get; set; }
        /// 
        /// 抽屉号 
        ///
        [Column("drawer_no")]
        public int DrawerNo { get; set; }
        /// 
        /// 取药科室 
        ///
        [Column("department_id")]
        public string DepartmentId { get; set; }
        /// 
        /// 是否已经退药(0:没有1:还了部分2:完成) 
        /// 默认值: 0
        ///
        [Column("status")]
        public int Status { get; set; }
        /// 
        /// 退药量 
        /// 默认值: 0
        ///
        [Column("return_quantity1")]
        public int ReturnQuantity1 { get; set; }
        /// 
        /// 退空瓶量 
        /// 默认值: 0
        ///
        [Column("return_quantity2")]
        public int ReturnQuantity2 { get; set; }
        [Column(IsColumn = false)]
        public int CurrentReturnQuantity { get; set; }
        /// 
        /// 取药记录id 
        ///
        [Column("get_id")]
        public int? GetId { get; set; }
        /// 
        /// 是否已经销毁 
        /// 默认值: 0
        ///
        [Column("is_destroy")]
        public int? IsDestroy { get; set; }
        [Column(IsColumn = false)]
        public int CanReturnQuantity
        {
            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
        }
        //是否选中
        [Column(IsColumn = false)]
        public bool IsSelected { get; set; }
        [Column(IsColumn =false)]
        public string Location
        {
            get => DrawerNo + "-" + ColNo;
        }
    }
}