using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ChangKeTec.Wms.Models.Wms
{
    public partial class TM_CQBMPT_INJECTION_REPORT
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public int UID { get; set; }

        [Key]
        [Column(Order = 0)]
        [StringLength(50)]
        [DisplayName("机台编号")]
        public string MachineId { get; set; }

        [Key]
        [Column(Order = 1)]
        [StringLength(50)]
        [DisplayName("班次信息")]
        public string ShiftInfo { get; set; }

        [Key]
        [Column(Order = 2)]
        [StringLength(50)]
        [DisplayName("产品物料号")]
        public string PartCode { get; set; }

        [NotMapped]
        [DisplayName("产品物料描述")]
        public string PartDesc => WmsCache.GetPartDesc(PartCode);

        [StringLength(50)]
        [DisplayName("班组")]
        public string TeamName { get; set; }

        [DisplayName("计划数量")]
        public decimal PlanQty { get; set; }

        [DisplayName("完工数量")]
        public decimal FinishQty => GoodQty + ToMarketQty + ScrapQty;

        [DisplayName("合格数量")]
        public decimal GoodQty { get; set; }

        [DisplayName("市场件数量")]
        public decimal ToMarketQty { get; set; }

        [DisplayName("报废数量")]
        public decimal ScrapQty { get; set; }

        [DisplayName("报告日期")]
        public DateTime ReportTime { get; set; } = DateTime.Now;

        [NotMapped]
        public string 合格率 => $"{(FinishQty == 0 ? 0 : (GoodQty + ToMarketQty)/FinishQty):P}";
    }
}