using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;

namespace RB_MES_API.Models.Cloud
{
    public class PRD_PPBOMChange
    {
        /// <summary>
        /// 实体主键（无需填写，保存时自动添加）
        /// </summary>
        public int FID { get; set; }
        /// <summary>
        /// 单据编号    
        /// </summary>
        [StringLength(36)]
        public string FBillNo { get; set; }
        /// <summary>
        /// 单据类型  (必填项)
        /// </summary>
        public Dictionary<string, string> FBillType { get; set; } = new Dictionary<string, string>() { { "FNUMBER","SCYLQDBGD01_SYS"} };
        /// <summary>
        /// 日期  (必填项)
        /// </summary>
        [DataType(DataType.DateTime)]
        public string FDate { get; set; } = DateTime.Now.ToShortDateString();
        /// <summary>
        /// 产品编码  (必填项)
        /// </summary>
        public Dictionary<string, string> FMaterialID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 数量  (必填项)
        /// </summary>
        public decimal FQty { get; set; }
        /// <summary>
        /// BOM版本
        /// </summary>
        public Dictionary<string, string> FBOMID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 生产车间  (必填项)
        /// </summary>
        public Dictionary<string, string> FWorkshopID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 产品货主类型   
        /// </summary>
        [StringLength(36)]
        public string FParentOwnerTypeId { get; set; } = "BD_OwnerOrg";
        /// <summary>
        /// 产品货主
        /// </summary>
        public Dictionary<string, string> FParentOwnerId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
        /// <summary>
        /// 生产组织  (必填项)
        /// </summary>
        public Dictionary<string, string> FPrdOrgId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
        /// <summary>
        /// 变更原因
        /// </summary>
        public Dictionary<string,string> FChangeReason { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "BGYY02_SYS" } };
        /// <summary>
        /// 备注   
        /// </summary>
        [StringLength(36)]
        public string FDescription { get; set; } = "MES系统推送";
        /// <summary>
        /// 生产订单内码
        /// </summary>
        public int FMoId { get; set; }
        /// <summary>
        /// 生产订单行号
        /// </summary>
        public int FMOEntrySeq { get; set; }
        /// <summary>
        /// 生产订单分录内码
        /// </summary>
        public int FMOEntryID { get; set; }
        /// <summary>
        /// 生产订单编号
        /// </summary>
        public string FMOBillNO { get; set; }
        /// <summary>
        /// 产品基本单位数量
        /// </summary>
        public decimal FBASEQTY { get; set; }
        /// <summary>
        /// 生产订单类型
        /// </summary>
        public Dictionary<string, string> FMOType { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
        /// <summary>
        /// 产品基本单位
        /// </summary>
        public Dictionary<string,string> FBaseUnitID { get; set; } = new Dictionary<string, string>() { { "FNUMBER",""} };
        /// <summary>
        /// 单位  (必填项)
        /// </summary>
        public Dictionary<string, string> FUnitID { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
        public List<Entity> FEntity { get; set; } = new List<Entity>();
        public class Entity
        {
            public bool FISMinIssueQty { get; set; } = false;
            /// <summary>
            /// 父级行主键
            /// </summary>
            public string FParentRowId { get; set; }
            public int FSeq { get; set; }
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 变更类型
            /// 1.新增 2.变更前 3.变更后 4.取消
            /// </summary>
            public string FChangeType { get; set; }
            /// <summary>
            /// 子项物料编码   (必填项)
            /// </summary>
            public Dictionary<string, string> FMaterialID2 { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 分子
            /// </summary>
            public decimal FNumerator { get; set; } = 1;
            /// <summary>
            /// 分母
            /// </summary>
            public decimal FDenominator { get; set; } = 1;
            /// <summary>
            /// 子项单位   (必填项)
            /// </summary>
            public Dictionary<string, string> FUnitID2 { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 生产车间   (必填项)
            /// </summary>
            public Dictionary<string, string> FWorkshopID1 { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 产品生产数量
            /// </summary>
            public decimal FProduceQty { get; set; }
            /// <summary>
            /// 生产订单编号
            /// </summary>
            public string FMoBillNo1 { get; set; }
            /// <summary>
            /// 用量类型
            /// </summary>
            public int FDosageType { get; set; } = 2;
            /// <summary>
            /// 需求日期  (必填项)
            /// </summary>
            [DataType(DataType.DateTime)]
            public string FNeedDate2 { get; set; } = DateTime.Now.ToShortDateString();
            /// <summary>
            /// 子项类型(必填项)
            /// 1.标准件 2.返还件 3.替代件
            /// </summary>
            [StringLength(36)]
            public string FMaterialType { get; set; } = "1";
            /// <summary>
            /// 生产用料清单编号
            /// </summary>
            public string FPPBOMNo { get; set; }
            /// <summary>
            /// 生产订单行号
            /// </summary>
            public int FMoEntrySeq1 { get; set; }
            /// <summary>
            /// 生产用料清单行号
            /// </summary>
            public int FPPBOMEntrySeq { get; set; }
            /// <summary>
            /// 生产用料清单内码
            /// </summary>
            public int FPPBOMId { get; set; }
            /// <summary>
            /// 生产用料清单行内码
            /// </summary>
            public int FPPBOMEntryId { get; set; }
            /// <summary>
            /// 货主类型
            /// </summary>
            public string FOwnerTypeId { get; set; } = "BD_OwnerOrg";
            /// <summary>
            /// 供应类型
            /// </summary>
            public string FSupplyType { get; set; } = "C";
            /// <summary>
            /// 子项货主   (必填项)
            /// </summary>
            public Dictionary<string, string> FOwnerID { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            ///// <summary>
            ///// 源单编号
            ///// </summary>
            //public string FSrcBillNo { get; set; }
            //以下默认
            public int FIssueType { get; set; } = 1;
            /// <summary>
            /// 超发控制方式
            /// </summary>
            public int FOverControlMode { get; set; } 
            /// <summary>
            /// 发料组织   (必填项)
            /// </summary>
            public Dictionary<string, string> FSupplyOrg { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 替代策略
            /// </summary>
            public string FReplacePolicy { get; set; }
            /// <summary>
            /// 替代方式
            /// </summary>
            public string FReplaceType { get; set; }
            /// <summary>
            /// 替代优先级
            /// </summary>
            public int FReplacePriority { get; set; }
            /// <summary>
            /// 替代主料
            /// </summary>
            public int FIsKeyItem { get; set; }
            /// <summary>
            /// 使用比例
            /// </summary>
            public decimal FUseRate { get; set; }
            public int FRowExpandType { get; set; } = 16;
            ///// <summary>
            ///// 基本单位需求数量
            ///// </summary>
            //public decimal FBaseNeedQty { get; set; } //会自动重算，不需要赋值
            /// <summary>
            /// 需求数量
            /// </summary>
            public decimal FNeedQty2 { get; set; }
            /// <summary>
            /// 应发数量
            /// </summary>
            public decimal FMustQty { get; set; }
            ///// <summary>
            ///// 标准用量
            ///// </summary>
            //public decimal FSTDQTY { get ; set; }
            /// <summary>
            ///  MRP运算
            /// </summary>
            public bool FIsMrpRun { get; set; } = true;
            /// <summary>
            /// 位置号
            /// </summary>
            public string FPositionNO { get; set; } = string.Empty;
            /// <summary>
            /// 项次，替代主料的行号
            /// </summary>
            public int FReplaceGroup { get; set; }

            public List<Entity_Link> FEntity_Link { get; set; }
            public class Entity_Link
            {
                /// <summary>
                /// 实体主键，新建时为空，由系统自动填充
                /// </summary>
                public string FLinkId { get; set; } 
                public string FEntity_Link_FFlowId { get; set; } 
                public string FEntity_Link_FFlowLineId { get; set; }
                public string FEntity_Link_FRuleId { get; set; } ="PRD_PPBOM2PPBOMCHANGE";
                public int FEntity_Link_FSTableId { get; set; } 
                public string FEntity_Link_FSTableName { get; set; } = "T_PRD_PPBOMENTRY";
                /// <summary>
                /// 系统源单内码
                /// </summary>
                public int FEntity_Link_FSBillId { get; set; }  //要二次查询，或者由MES提供。一般二次查询...
                /// <summary>
                /// 系统源单分录内码
                /// </summary>
                public int FEntity_Link_FSId { get; set; }  //要二次查询，或者由MES提供。一般二次查询...
                public decimal FEntity_Link_FBaseStdQtyOld { get; set; }     //原始携带量
                public decimal FEntity_Link_FBaseStdQty { get; set; }    //修改携带量
            }
        }

    }
}
