using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;
namespace RB_MES_API.Models.Cloud
{
    /// <summary>
    /// 生产领料单
    /// </summary>
    public class PRD_PickMtrl
    {
        /// <summary>
        /// 实体主键（无需填写，保存时自动添加）
        /// </summary>
        public int FID { get; set; } 
        /// <summary>
        /// 单据类型   (必填项)
        /// </summary>
        public Dictionary<string, string> FBillType { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""} 
        };
        /// <summary>
        /// 日期  (必填项)
        /// </summary>
        public string FDate { get; set; }
        /// <summary>
        /// 发料组织   (必填项)
        /// </summary>
        public Dictionary<string, string> FStockOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",LocalStaticRequest.DefaultOrg}        
        };
        /// <summary>
        /// 仓库
        /// </summary>
        public Dictionary<string, string> FStockId0 { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",""}
        };
        /// <summary>
        /// 生产组织   (必填项)
        /// </summary>
        public Dictionary<string, string> FPrdOrgId { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",LocalStaticRequest.DefaultOrg}        
        };
        /// <summary>
        /// 生产车间
        /// </summary>
        public Dictionary<string, string> FWorkShopId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
        /// <summary>
        /// 货主类型   
        /// </summary>
        [StringLength(36)]
        public string FOwnerTypeId0 { get; set; } = "BD_OwnerOrg";
        /// <summary>
        /// 货主
        /// </summary>
        public Dictionary<string, string> FOwnerId0 { get; set; } = new Dictionary<string, string>() {
            { "FNUMBER",LocalStaticRequest.DefaultOrg}
        };
        /// <summary>
        /// 领料人
        /// </summary>
        public Dictionary<string, string> FPickerId { get; set; } = new Dictionary<string, string>() {
            { "FNAME",""}
        };
        /// <summary>
        /// 仓管员
        /// </summary>
        public Dictionary<string, string> FSTOCKERID { get; set; } = new Dictionary<string, string>() {
            { "FNAME",""}
        };
        /// <summary>
        /// 备注   
        /// </summary>
        [StringLength(36)]
        public string FDescription { get; set; } 
        /// <summary>
        /// 本位币
        /// </summary>
        public Dictionary<string, string> FCurrId { get; set; } = new Dictionary<string, string>() {
            { "FNumber","PRE001"}
        };
        /// <summary>
        /// 跨法人交易
        /// </summary>
        public bool FIsCrossTrade { get; set; } = false;
        /// <summary>
        /// VMI业务
        /// </summary>
        public bool FVmiBusiness { get; set; } = false;
        /// <summary>
        /// 序列号上传   
        /// </summary>
        [StringLength(36)]
        public string FScanBox { get; set; } 
        /// <summary>
        /// 倒冲来源   
        /// </summary>
        [StringLength(36)]
        public string FSourceType { get; set; }
        /// <summary>
        /// 货主含组织
        /// </summary>
        public bool FIsOwnerTInclOrg { get; set; } = true;
        /// <summary>
        /// MES唯一标识
        /// </summary>
        [StringLength(36)]
        public string F_SBMI_QUEUE_ID { get; set; }

        public List<BillEntry> FEntity { get; set; } = new List<BillEntry>();
        /// <summary>
        /// 明细信息
        /// </summary>
        public class BillEntry
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 拣货规则标识位    
            /// </summary>
            public int FPickingStatus { get; set; } = 3;
            /// <summary>
            /// 产品编码    
            /// </summary>
            public Dictionary<string, string> FParentMaterialId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            
            /// <summary>
            ///  生产备料单据编号，源单为生产用料清单，此字段可忽略...
            /// </summary>
            [StringLength(36)]
            public string FFPMBillNo { get; set; } 
            /// <summary>
            ///  工序序列   
            /// </summary>
            [StringLength(36)]
            public int FOptQueue { get; set; }
            /// <summary>
            ///  预留类型   
            /// </summary>
            [StringLength(36)]
            public int FReserveType { get; set; } = 1;
            /// <summary>
            /// 物料编码  (必填项)    
            /// </summary>
            public Dictionary<string, string> FMaterialId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 单位    (必填项) 
            /// </summary>
            public Dictionary<string, string> FUnitID { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 申请数量
            /// </summary>
            public decimal FAppQty { get; set; } 
            /// <summary>
            /// 实发数量
            /// </summary>
            public decimal FActualQty { get; set; }
            /// <summary>
            /// 主库存基本单位实发数量，必须大于0
            /// </summary>
            public decimal FBaseStockActualQty { get; set; }
            /// <summary>
            ///  VMI业务
            /// </summary>
            public bool FEntryVmiBusiness { get; set; } = false;
            /// <summary>
            ///  工序计划单编号   
            /// </summary>
            [StringLength(36)]
            public string FOptPlanBillNo { get; set; } 
            /// <summary>
            /// 发料仓库    (必填项) 
            /// </summary>
            public Dictionary<string, string> FStockId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 工序计划单内码
            /// </summary>
            public int FOptPlanBillId { get; set; } 
            /// <summary>
            /// 仓位信息
            /// </summary>
            public StockLocId FStockLocId { get; set; } = new StockLocId() { 
                FSTOCKLOCID__FF100001=new Dictionary<string, string>(),
                FSTOCKLOCID__FF100002=new Dictionary<string, string>()
            };
            /// <summary>
            /// 仓位信息 
            /// </summary>
            public class StockLocId 
            {
                /// <summary>
                /// 货架
                /// </summary>
                public Dictionary<string, string> FSTOCKLOCID__FF100001 { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
                /// <summary>
                /// 货架的位置号
                /// </summary>
                public Dictionary<string, string> FSTOCKLOCID__FF100002 { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            }
            /// <summary>
            /// 工作中心
            /// </summary>
            public Dictionary<string, string> FWorkCenterId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            ///  工序计划工序内码
            /// </summary>
            public int FOptDetailId { get; set; } 
            /// <summary>
            ///  联副产品BOM分录内码
            /// </summary>
            public int FCobyBomEntryID { get; set; } 
            /// <summary>
            /// 作业
            /// </summary>
            public Dictionary<string, string> FProcessId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// BOM版本
            /// </summary>
            public Dictionary<string, string> FBomId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };

            /// <summary>
            ///  源领料单分录内码
            /// </summary>
            public int FSrcPickEntryId { get; set; } 
            /// <summary>
            ///  业务来源类型   
            /// </summary>
            public string FSrcBusinessType { get; set; }
            /// <summary>
            ///  库存查询标识   
            /// </summary>
            public string FQueryStockUpdate { get; set; }
            /// <summary>
            /// 库存状态   (必填项)
            /// </summary>
            public Dictionary<string, string> FStockStatusId { get; set; } = new Dictionary<string, string>() {
            { "FNumber","KCZT01_SYS"}};
            /// <summary>
            /// 生产日期
            /// </summary>
            public string FProduceDate { get; set; }
            /// <summary>
            /// 转出退料单标识   
            /// </summary>
            [StringLength(36)]
            public string FTransRetFormId { get; set; } 
            /// <summary>
            /// 转出退料单号   
            /// </summary>
            [StringLength(36)]
            public string FTransRetBillNo { get; set; } 
            /// <summary>
            /// 转出退料单内码
            /// </summary>
            public int FTransRetId { get; set; } 
            /// <summary>
            /// 转出退料单分录内码
            /// </summary>
            public int FTransRetEntryId { get; set; } 
            /// <summary>
            /// 直送标识   
            /// </summary>
            [StringLength(36)]
            public string FSendRowId { get; set; }
            /// <summary>
            /// 转出退料单行号
            /// </summary>
            public int FTransRetEntrySeq { get; set; } 
            /// <summary>
            ///  生产退料检验
            /// </summary>
            public bool FCheckReturnMtrl { get; set; } = false;
            /// <summary>
            /// 行备注   
            /// </summary>
            [StringLength(36)]
            public string FEntrtyMemo { get; set; }
            /// <summary>
            /// 计划跟踪号   
            /// </summary>
            [StringLength(36)]
            public string FMtoNo { get; set; }
            /// <summary>
            /// 项目编号   
            /// </summary>
            [StringLength(36)]
            public string FProjectNo { get; set; }
            /// <summary>
            /// 生产订单编号    (必填项)   
            /// </summary>
            public string FMoBillNo { get; set; } 
            /// <summary>
            /// 生产订单分录内码
            /// </summary>
            public int FMoEntryId { get; set; } 
            /// <summary>
            /// 用料清单分录内码
            /// </summary>
            public int FPPBomEntryId { get; set; }
            /// <summary>
            /// 工序号
            /// </summary>
            public int FOperId { get; set; } = 10;
            /// <summary>
            /// 货主类型    (必填项)   
            /// </summary>
            public string FOwnerTypeId { get; set; } = "BD_OwnerOrg";
            /// <summary>
            /// 主库存单位   (必填项)
            /// </summary>
            public Dictionary<string, string> FStockUnitId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 主库存单位申请数量
            /// </summary>
            public decimal FStockAppQty { get; set; } 
            /// <summary>
            /// 主库存单位实发数量
            /// </summary>
            public decimal FStockActualQty { get; set; } 
            /// <summary>
            /// 主库存单位可超发数量
            /// </summary>
            public decimal FStockAllowOverQty { get; set; } 
            /// <summary>
            /// 辅助库存单位，未启用辅助单位时不填
            /// </summary>
            public Dictionary<string, string> FSecUnitId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 辅库存单位实发数量
            /// </summary>
            public int FSecActualQty { get; set; } 
            /// <summary>
            /// 辅库存单位可超发数量
            /// </summary>
            public int FSecAllowOverQty { get; set; } 
            /// <summary>
            /// 生产订单内码
            /// </summary>
            public int FMoId { get; set; } 
            /// <summary>
            /// 生产订单行号
            /// </summary>
            public int FMoEntrySeq { get; set; } 
            /// <summary>
            /// 可超发数量
            /// </summary>
            public decimal FAllowOverQty { get; set; } 
            /// <summary>
            /// 用料清单编号  
            /// </summary>
            public string FPPBomBillNo { get; set; } 
            /// <summary>
            /// 基本单位   (必填项)
            /// </summary>
            public Dictionary<string, string> FBaseUnitId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 基本单位申请数量
            /// </summary>
            public decimal FBaseAppQty { get; set; } 
            /// <summary>
            /// 基本单位实发数量
            /// </summary>
            public decimal FBaseActualQty { get; set; } 
            /// <summary>
            /// 基本单位可超发数量
            /// </summary>
            public decimal FBaseAllowOverQty { get; set; } 
            /// <summary>
            /// 车间   (必填项)  
            /// </summary>
            public Dictionary<string, string> FEntryWorkShopId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 保管者类型   (必填项)  
            /// </summary>
            public string FKeeperTypeId { get; set; } = "BD_KeeperOrg";
            /// <summary>
            /// 保管者   (必填项) 
            /// </summary>
            public Dictionary<string, string> FKeeperId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",LocalStaticRequest.DefaultOrg}        //生产环境必须修改
        };
            /// <summary>
            /// 货主    (必填项) 
            /// </summary>
            public Dictionary<string, string> FOwnerId { get; set; } = new Dictionary<string, string>() {
            { "FNumber",LocalStaticRequest.DefaultOrg}        //生产环境必须修改
        };
            /// <summary>
            /// 有效期至
            /// </summary>
            [DataType(DataType.Date)]
            public string FExpiryDate { get; set; }
            /// <summary>
            /// 系统源单类型  
            /// </summary>
            public string FSrcBillType { get; set; } //= "PRD_PPBOM";
            /// <summary>
            /// 系统源单编号  
            /// </summary>
            public string FSrcBillNo { get; set; } 
            /// <summary>
            /// 成本价
            /// </summary>
            public int FPrice { get; set; } 
            /// <summary>
            /// 系统源单内码
            /// </summary>
            public int FEntrySrcInterId { get; set; } 
            /// <summary>
            /// 总成本
            /// </summary>
            public int FAmount { get; set; }
            /// <summary>
            /// 系统源单分录内码：（分录主键）
            /// </summary>
            public int FEntrySrcEnteryId { get; set; } 
            /// <summary>
            /// 系统源单行号
            /// </summary>
            public int FEntrySrcEntrySeq { get; set; }
            /// <summary>
            /// 产品货主类型   (必填项)  
            /// </summary>
            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> FSRCBIZBILLTYPE { get; set; } = new Dictionary<string, string>() {
            { "FNAME",""}
        };
            /// <summary>
            /// 业务源单编号   
            /// </summary>
            public string FSRCBIZBILLNO { get; set; } 
            /// <summary>
            /// 业务源单内码
            /// </summary>
            public int FSRCBIZINTERID { get; set; } 
            /// <summary>
            /// 业务源单分录内码    
            /// </summary>
            public int FSRCBIZENTRYID { get; set; } 
            /// <summary>
            /// 业务源单行号    
            /// </summary>
            public int FSRCBIZENTRYSEQ { get; set; }
            /// <summary>
            /// 批号
            /// </summary>
            public Dictionary<string, string> FLot { get; set; } = new Dictionary<string, string>() {
            { "FNumber",""}
        };
            /// <summary>
            /// 主库存单位申请数量
            /// </summary>
            public decimal FSTOCKAPPQTY { get; set; }
            /// <summary>
            /// 主库存单位实发数量
            /// </summary>
            public decimal FSTOCKACTUALQTY { get; set; }
            ///// <summary>
            ///// 更新库存标志
            ///// </summary>
            //public string FStockFlag { get; set; } = "false";
            ///// <summary>
            ///// 级别
            ///// </summary>
            //public string FGroupRow { get; set; } = "00155da1-c302-9080-11ed-e4af22c69293";

            /// <summary>
            /// 辅助属性
            /// </summary>
            public AuxPropId FAuxPropId { get; set; } = new AuxPropId();

            public class AuxPropId
            {
                public Dictionary<string, string> FAUXPROPID__FF100001 = new Dictionary<string, string>() {{ "FNumber",""}};
            }
            public List<SerialSubEntity> FSerialSubEntity = new List<SerialSubEntity>();
            /// <summary>
            /// 序列号子单据体    
            /// </summary>
            public class SerialSubEntity
            {
                /// <summary>
                /// 实体主键    
                /// </summary>
                public int FDetailID { get; set; } 
                /// <summary>
                /// 序列号   
                /// </summary>
                public string FSerialNo { get; set; } 
                /// <summary>
                /// 序列号
                /// </summary>
                public Dictionary<string, string> FSerialId { get; set; } = new Dictionary<string, string>() {
            { "FNAME",""}
        };
                /// <summary>
                /// 序号号备注   
                /// </summary>
                [StringLength(36)]
                public string FSerialNote { get; set; } 
                /// <summary>
                /// 请检关联标志    (必填项)   
                /// </summary>
                public string FIsAppInspect { 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; } //= "3c1a4345-38c0-4530-bbd9-5c3ccc53be88";
                public string FEntity_Link_FFlowLineId { get; set; }
                public string FEntity_Link_FRuleId { get; set; } = "PRD_PPBOM2PICKMTRL_NORMAL";
                public int FEntity_Link_FSTableId { get; set; } = 0;
                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_FBaseActualQtyOld { get; set; }     //应发数量
                public decimal FEntity_Link_FBaseActualQty { get; set; }    //实发数量
            }

        }
    }
}
