using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
    [SugarTable("dm_machine_record")]
    public class MachineRecord
    {
        /// 
        /// 主键 
        ///
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        /// 
        /// 设备id 
        ///
        [SugarColumn(ColumnName = "machine_id")]
        public string MachineId { get; set; }
        /// 
        /// 药品id 
        ///
        [SugarColumn(ColumnName = "drug_id")]
        public string DrugId { get; set; }
        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
        public DrugInfo DrugInfo { get; set; }
        /// 
        /// 数量 
        ///
        [SugarColumn(ColumnName = "quantity")]
        public int Quantity { get; set; }
        [SugarColumn(ColumnName = "stock_quantity")]
        public int? StockQuantity { get; set; }
        [SugarColumn(ColumnName = "check_quantity")]
        public int? CheckQuantity { get; set; }
        
        /// 
        /// 批号 
        ///
        [SugarColumn(ColumnName = "manu_no")]
        public string ManuNo { get; set; }
        /// 
        /// 操作人id 
        ///
        [SugarColumn(ColumnName = "operator")]
        public int? Operator { get; set; }
        [Navigate(NavigateType.ManyToOne, nameof(Operator))]
        public UserList User { get; set; }
        /// 
        /// 审核人id 
        ///
        [SugarColumn(ColumnName = "reviewer")]
        public int? Reviewer { get; set; }
        /// 
        /// 操作时间 
        /// 默认值: CURRENT_TIMESTAMP
        ///
        [SugarColumn(ColumnName = "operation_time")]
        public DateTime OperationTime { get; set; }
        /// 
        /// 效期 
        ///
        [SugarColumn(ColumnName = "eff_date")]
        public DateTime? EffDate { get; set; }
        /// 
        /// 出库入库类型(1入库2出库31还药32还空瓶) 
        ///
        [SugarColumn(ColumnName = "type")]
        public int Type { get; set; }
        /// 
        /// 出入库调拨单id 
        ///
        [SugarColumn(ColumnName = "invoice_id")]
        public string InvoiceId { get; set; }
        /// 
        /// 列号 
        ///
        [SugarColumn(ColumnName = "col_no")]
        public int ColNo { get; set; }
        /// 
        /// 抽屉号 
        ///
        [SugarColumn(ColumnName = "drawer_no")]
        public int DrawerNo { get; set; }
        /// 
        /// 取药科室 
        ///
        [SugarColumn(ColumnName = "department_id")]
        public string DepartmentId { get; set; }
        /// 
        /// 是否已经退药(0:没有1:还了部分2:完成) 
        /// 默认值: 0
        ///
        [SugarColumn(ColumnName = "status", IsOnlyIgnoreInsert = true)]
        public int Status { get; set; }
        /// 
        /// 退药量 
        /// 默认值: 0
        ///
        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
        public int ReturnQuantity1 { get; set; }
        /// 
        /// 退空瓶量 
        /// 默认值: 0
        ///
        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
        public int ReturnQuantity2 { get; set; }
        /// 
        /// 取药记录id 
        ///
        [SugarColumn(ColumnName = "get_id")]
        public int? GetId { get; set; }
        /// 
        /// 是否已经销毁 
        /// 默认值: 0
        ///
        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
        public int? IsDestroy { get; set; }
        [SugarColumn(IsIgnore = true)]
        public int CanReturnQuantity
        {
            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
            
        }
        [SugarColumn(IsIgnore = true)]
        public bool IsSelected { get; set; }
        /// 
        /// 药品对应批号库存
        /// 
        [SugarColumn(ColumnName = "manunoQuantity")]
        public int? ManunoQuantity { get; set; }
    }
}