using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;
namespace RB_MES_API.Models.Cloud
{
    /// <summary>
    /// 委外领料单
    /// </summary>
    public class SUB_PickMtrl
    {
        /// <summary>
        /// 实体主键（无需填写，保存时自动添加）
        /// </summary>
        public int FID { get; set; } 
        /// <summary>
        /// 单据类型，默认：普通   (必填项)
        /// </summary>
        public Dictionary<string, string> FBillType { get; set; } = new Dictionary<string, string>() {{ "FNUMBER","WWLLD01_SYS"} };
        /// <summary>
        /// 日期  (必填项)
        /// </summary>
        [DataType(DataType.DateTime)]
        public string FDate { get; set; } = DateTime.Now.ToShortDateString();
        /// <summary>
        /// 发料组织   (必填项)
        /// </summary>
        public Dictionary<string, string> FStockOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER",""} };
        /// <summary>
        /// 委外组织   (必填项)
        /// </summary>
        public Dictionary<string, string> FSubOrgId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""} };
        /// <summary>
        ///  供应商   (必填项)
        /// </summary>
        public Dictionary<string, string> FSupplierId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
        ///// <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 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; } = false;
        /// <summary>
        /// 库存刷新日期
        /// </summary>
        public DateTime FInventoryDate { get; set; } = DateTime.Now;
        /// <summary>
        /// MES唯一标识
        /// </summary>
        [StringLength(36)]
        public string F_SBMI_QUEUE_ID { get; set; }



        public List<Entity> FEntity { get; set; } = new List<Entity>();
        /// <summary>
        /// 明细  
        /// </summary>
        public class Entity
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FEntryID { get; set; }
            /// <summary>
            /// 物料编码   (必填项) 
            /// </summary>
            public Dictionary<string, string> FMaterialId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
            /// <summary>
            ///  辅助属性
            /// </summary>
            public AuxpropId FAuxPropId { get; set; }
            public class AuxpropId
            {
                public Dictionary<string, string> FAUXPROPID__FF100001 { get; set; } = new Dictionary<string, string>() {
                { "FNumber",""} };
            }
            /// <summary>
            /// 仓库     (必填项) 
            /// </summary>
            public Dictionary<string, string> FStockId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""} };
            public FStockLocId StockLocId { get; set; }
            /// <summary>
            /// 仓位  
            /// </summary>
            public class FStockLocId
            {
                public Dictionary<string, string> FSTOCKLOCID__FF100001 { get; set; } = new Dictionary<string, string>() { { "FNUMBER",""} };
                public Dictionary<string, string> FSTOCKLOCID__FF100002 { get; set; } = new Dictionary<string, string>() { { "FNUMBER",""}}; }
            /// <summary>
            /// 批号 
            /// </summary>
            public Dictionary<string, string> FLot { get; set; }=new Dictionary<string, string>() {{ "FNUMBER",""} };
            /// <summary>
            /// 系统源单类型
            /// </summary>
            public string FSrcBillType { get; set; } = "SUB_PPBOM";
            /// <summary>
            /// 系统源单编号
            /// </summary>
            public string FSrcBillNo { get; set; } = string.Empty;
            /// <summary>
            /// 系统源单行号
            /// </summary>
            public int FSrcEntrySeq { get; set; } = 0;
            /// <summary>
            /// 委外订单编号
            /// </summary>
            public string FSubReqBillNo { get; set; } = string.Empty;
            /// <summary>
            /// 业务源单行号
            /// </summary>
            public int FSRCBIZENTRYSEQ { get; set; }
            /// <summary>
            /// 业务源单类型 
            /// </summary>
            public Dictionary<string, string> FSRCBIZBILLTYPE { get; set; } = new Dictionary<string, string>() { { "FID",""}};
            /// <summary>
            /// 业务源单编号   
            /// </summary>
            [StringLength(36)]
            public string FSRCBIZBILLNO { get; set; }=String.Empty;
            /// <summary>
            /// 拣货状态
            /// </summary>
            public int FPickingStatus { get; set; } = 4;
            /// <summary>
            /// 产品编码     
            /// </summary>
            public Dictionary<string, string> FParentMaterialId { get; set; } = new Dictionary<string, string>() {{ "FNumber",""}};
            /// <summary>
            /// 系统源单内码
            /// </summary>
            public int FSrcInterId { get; set; } 
            /// <summary>
            /// 系统源单分录内码
            /// </summary>
            public int FSrcEntryId { get; set; }
            /// <summary>
            /// 业务源单内码
            /// </summary>
            public int FSRCBIZINTERID { get; set; }
            /// <summary>
            /// 消耗汇总   
            /// </summary>
            [StringLength(36)]
            public string FConsome { get; set; } = String.Empty;
            /// <summary>
            /// 委外订单内码
            /// </summary>
            public int FSubReqId { get; set; }
            /// <summary>
            /// 预留类型   
            /// </summary>
            [StringLength(36)]
            public string FReserveType { get; set; } = "1";
            /// <summary>
            /// 结算组织     
            /// </summary>
            public Dictionary<string, string> FSettleOrgId { get; set; } = new Dictionary<string, string>() {{ "FNumber",""} };
            /// <summary>
            /// 主库存基本单位实发数量
            /// </summary>
            public decimal FBaseStockActualQty { get; set; } 
            /// <summary>
            /// 业务源单分录内码
            /// </summary>
            public int FSRCBIZENTRYID { get; set; }
            /// <summary>
            /// 委外用料清单编号   
            /// </summary>
            [StringLength(36)]
            public string FPPbomBillNo { get; set; }
            /// <summary>
            /// 委外用料清单分录内码
            /// </summary>
            public int FPPbomEntryId { get; set; }
            /// <summary>
            /// 委外订单分录内码
            /// </summary>
            public int FSubReqEntryId { get; set; } 
            /// <summary>
            /// 委外订单分录行号
            /// </summary>
            public int FSubReqEntrySeq { 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 int FBaseSelPrcdReturnQty { get; set; } 
            /// <summary>
            /// 成本价
            /// </summary>
            public decimal FPrice { get; set; } 
            /// <summary>
            /// 总成本
            /// </summary>
            public decimal FAmount { get; set; } 
            /// <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 decimal FStockSelPrcdReturnQty { get; set; } 
            /// <summary>
            /// 辅助单位可超发数量
            /// </summary>
            public decimal FSecAllowOverQty { get; set; } 
            /// <summary>
            /// 辅助单位退料选单数量
            /// </summary>
            public decimal FSecSelPrcdReturnQty { get; set; } 
            /// <summary>
            /// VMI业务
            /// </summary>
            public bool FEntryVmiBusiness { get; set; } = false;
            /// <summary>
            /// 备料单编号   
            /// </summary>
            [StringLength(36)]
            public string FPMBillNo { get; set; } 
            /// <summary>
            /// 组别   
            /// </summary>
            [StringLength(36)]
            public string FGroupRow { get; set; } 
            /// <summary>
            /// 采购订单   
            /// </summary>
            [StringLength(36)]
            public string FPOOrderBillNo { get; set; } 
            /// <summary>
            /// 源领料单分录内码
            /// </summary>
            public int FSrcPickEntryId { get; set; } 
            /// <summary>
            /// 采购订单行号
            /// </summary>
            public int FPOOrderSeq { get; set; }
            /// <summary>
            /// 供应商    (必填项)     
            /// </summary>
            public Dictionary<string, string> FSupplierId0 { get; set; } = new Dictionary<string, string>() { { "FNUMBER",""} };
            /// <summary>
            /// 转出退料单标识   
            /// </summary>
            [StringLength(36)]
            public string FTransRetFormId { get; set; } 
            /// <summary>
            /// 转出退料单号   
            /// </summary>
            [StringLength(36)]
            public string FTransRetBillNo { get; set; }
            /// <summary>
            /// 保管者类型  (必填项)   
            /// </summary>
            [StringLength(36)]
            public string FKeeperTypeId { get; set; } = "BD_KeeperOrg";
            /// <summary>
            /// 转出退料单内码
            /// </summary>
            public int FTransRetId { get; set; } 
            /// <summary>
            /// 转出退料单分录内码
            /// </summary>
            public int FTransRetEntryId { get; set; }
            /// <summary>
            /// 工序号
            /// </summary>
            public int FOperID { get; set; } = 10;
            /// <summary>
            /// 保管者    (必填项)     
            /// </summary>
            public Dictionary<string, string> FKEEPERID { get; set; } = new Dictionary<string, string>() { { "FNUMBER",LocalStaticRequest.DefaultOrg} };
            /// <summary>
            /// 转出退料单行号
            /// </summary>
            public int FTransRetEntrySeq { get; set; } 
            /// <summary>
            /// 库存状态    (必填项)     
            /// </summary>
            public Dictionary<string, string> FStockStatusId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER","KCZT01_SYS"}};
            /// <summary>
            /// 生产日期
            /// </summary>
            [DataType(DataType.Date)]
            public string FProduceDate { get; set; } = string.Empty;
            /// <summary>
            /// 有效期至
            /// </summary>
            [DataType(DataType.Date)]
            public string FExpiryDate { get; set; }= string.Empty;
            /// <summary>
            /// 可超发数量
            /// </summary>
            public decimal FAllowOverQty { get; set; } 
            /// <summary>
            /// 货主类型  (必填项)   
            /// </summary>
            [StringLength(36)]
            public string FOwnerTypeId { get; set; } = "BD_OwnerOrg";
            /// <summary>
            /// 货主    (必填项)     
            /// </summary>
            public Dictionary<string, string> FOwnerId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
            /// <summary>
            /// 产品货主类型  (必填项)   
            /// </summary>
            [StringLength(36)]
            public string FParentOwnerTypeId { get; set; } 
            /// <summary>
            /// 产品货主    (必填项)     
            /// </summary>
            public Dictionary<string, string> FParentOwnerId { 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>
            /// 关联关系表
            /// </summary>
            public List<Entity_Link> FEntity_Link { get; set; } = new List<Entity_Link>();
            public class Entity_Link
            {
                /// <summary>
                /// 实体主键，新建时为空，由系统自动填充
                /// </summary>
                public string FLinkId { get; set; }
                /// <summary>
                /// 业务流程图
                /// </summary>
                public string FEntity_Link_FFlowId { get; set; }
                /// <summary>
                /// 推进路线
                /// </summary>
                public string FEntity_Link_FFlowLineId { get; set; }
                /// <summary>
                /// 转换规则
                /// </summary>
                public string FEntity_Link_FRuleId { get; set; } = "SUB_PPBOM_Pick";  // "SUB_PPBOM2PICKMTRL_PREPAREMTRL";
                /// <summary>
                ///  源单表内码
                /// </summary>
                public int FEntity_Link_FSTableId { get; set; }
                /// <summary>
                /// 源单表
                /// </summary>
                public string FEntity_Link_FSTableName { get; set; } = "T_SUB_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; }    //修改携带量

            }
        }
      
        /// <summary>
        /// 序列号子单据体      
        /// </summary>
        public class FSerialSubEntity
        {
            /// <summary>
            /// 实体主键（无需填写，保存时自动添加）
            /// </summary>
            public int FDetailID { get; set; }
            /// <summary>
            /// 序列号
            /// </summary>
            [StringLength(36)]
            public string FSerialNo { get; set; } 
            /// <summary>
            /// 序列号        
            /// </summary>
            public Dictionary<string, string> FSerialId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER",""}};
            /// <summary>
            /// 备注
            /// </summary>
            [StringLength(36)]
            public string FSerialNote { get; set; }
        }
    }
}
