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

namespace RB_MES_API.Models.Cloud
{
    public class SUB_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", "WWYLQDBGD01_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> FSupplierId { 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> FSubOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        /// <summary>
        /// 变更原因
        /// </summary>
        public Dictionary<string, string> FChangeReason { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
        ///// <summary>
        ///// 备注   
        ///// </summary>
        //[StringLength(36)]
        //public string FDescription { get; set; } = "MES系统推送";
        /// <summary>
        /// 委外订单内码
        /// </summary>
        public int FSubReqId { get; set; }
        /// <summary>
        /// 委外订单行号
        /// </summary>
        public int FSubReqEntrySeq { get; set; }
        /// <summary>
        /// 委外订单分录内码
        /// </summary>
        public int FSubReqEntryId { get; set; }
        /// <summary>
        /// 委外订单编号
        /// </summary>
        public string FSubReqBillNO { get; set; }
        /// <summary>
        /// 产品基本单位数量
        /// </summary>
        public decimal FBASEQTY { get; set; }
        /// <summary>
        /// 委外订单类型
        /// </summary>
        public Dictionary<string, string> FSubReqType { 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 FReplaceGroup { get; set; }
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 变更类型
            /// </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 decimal FProduceQty { get; set; }
            /// <summary>
            /// 用量类型
            /// </summary>
            public int FDosageType { get; set; } = 2;
            /// <summary>
            /// 需求日期  (必填项)
            /// </summary>
            [DataType(DataType.DateTime)]
            public string FNeedDate2 { get; set; } = DateTime.Now.ToShortDateString();
            /// <summary>
            /// 子项类型  (必填项)   
            /// </summary>
            [StringLength(36)]
            public string FMaterialType { get; set; } = "1";
            /// <summary>
            /// 委外订单编号
            /// </summary>
            public string FSubReqBillNO1 { get; set; }
            /// <summary>
            /// 委外订单分录行号
            /// </summary>
            public int FSubReqEntrySeq1 { get; set; }
            /// <summary>
            /// 委外订单内码
            /// </summary>
            public int FSubReqId1 { get; set; }
            /// <summary>
            /// 委外订单分录内码
            /// </summary>
            public int FSubReqEntryId1 { get; set; }
            /// <summary>
            /// 委外用料清单内码
            /// </summary>
            public int FSUBPPBOMId { get; set; }
            /// <summary>
            /// 委外用料清单分录内码
            /// </summary>
            public int FSUBPPBOMEntryId { get; set; }
            /// <summary>
            /// 委外用料清单行号
            /// </summary>
            public int FSUBPPBOMEntrySeq { get; set; }
            /// <summary>
            /// 委外用料清单单编号
            /// </summary>
            public string FSUBPPBOMNo { 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; }
            //以下默认
            /// <summary>
            /// 发料方式
            /// </summary>
            public int FIssueType { get; set; } = 1;
            /// <summary>
            /// 超发控制方式
            /// </summary>
            public int FOverControlMode { get; set; } = 1;
            /// <summary>
            /// 发料组织   (必填项)
            /// </summary>
            public Dictionary<string, string> FSupplyOrg { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            /// <summary>
            /// 替代策略
            /// </summary>
            public string FReplacePolicy { get; set; }
            /// <summary>
            /// 替代方式
            /// </summary>
            public string FReplaceType { get; set; }
            /// <summary>
            /// 替代优先级
            /// </summary>
            public int FReplacePriority { get; set; }
            /// <summary>
            /// 位置号
            /// </summary>
            public string FPositionNO { 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 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 int FInsertRow { 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; } = "SUB_PPBOM2PPBOMCHANGE";
                public int FEntity_Link_FSTableId { get; set; }
                public string FEntity_Link_FSTableName { get; set; } = "T_SUB_PPBOMENTRY";
                /// <summary>
                /// 系统源单内码
                /// </summary>
                public int FEntity_Link_FSBillId { get; set; }  //委外用料清单内码...
                /// <summary>
                /// 系统源单分录内码
                /// </summary>
                public int FEntity_Link_FSId { get; set; }  //委外用料清单分录内码...
                public decimal FEntity_Link_FBaseStdQtyOld { get; set; }     //原始携带量
                public decimal FEntity_Link_FBaseStdQty { get; set; }    //修改携带量
            }
        }
    }
}
