using RB_MES_API.Context;
using System.ComponentModel.DataAnnotations;
namespace RB_MES_API.Models.Cloud
{
    /// <summary>
    /// 生产订单变更单
    /// </summary>
    public class PRD_MOCHANGE
    {
        /// <summary>
        /// 实体主键（无需填写，保存时自动添加）
        /// </summary>
        [Required]
        public int FID { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string FDescription { get; set; } = "MES系统推送...";
        /// <summary>
        /// 生产组织  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FPrdOrgId { get; set; } = new Dictionary<string, string>() {{ "FNUMBER", LocalStaticRequest.DefaultOrg } };
        /// <summary>
        /// 单据类型  (必填项)
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FBillType { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "SCDDBGD01_SYS" } };
        /// <summary>
        /// 生产车间
        /// </summary>
        [StringLength(36)]
        public Dictionary<string, string> FWorkShopID { 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>
        [DataType(DataType.Date)]
        public string FDate { get; set; } = DateTime.Now.ToShortDateString();
        public List<Entity> FEntity { get; set; }= new List<Entity>();
        public class Entity
        {
            public int FEntryID { get; set; }
            /// <summary>
            /// 变更类型:1新增；2变更前；3变更后
            /// </summary>
            public string FChangeType { get; set; }
            /// <summary>
            /// 子项物料编码   (必填项)
            /// </summary>
            public Dictionary<string, string> FMaterialId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 生产车间
            /// </summary>
            [StringLength(36)]
            public Dictionary<string, string> FWorkShopId1 { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 源单类型  (必填项)
            /// </summary>
            public string FSrcBillType { get; set; }= "PRD_MO";
            /// <summary>
            /// 源单编号
            /// </summary>
            public string FSrcBillNo { get; set; } =string.Empty;
            /// <summary>
            /// 源单内码
            /// </summary>
            public int FSrcBillId { get; set; }
            /// <summary>
            /// 源单分录内码
            /// </summary>
            public int FSrcBillEntryId { get; set; }
            /// <summary>
            /// 源单行号
            /// </summary>
            public int FSrcBillEntrySeq { get; set; }
            /// <summary>
            /// 生产订单编号
            /// </summary>
            public string FMoNo { get; set; } = string.Empty;
            /// <summary>
            /// 生产订单内码
            /// </summary>
            public int FMoId { get; set; }
            /// <summary>
            ///生产订单分录内码
            /// </summary>
            public int FMoEntryId { get; set; }
            /// <summary>
            /// 生产订单行号
            /// </summary>
            public int FMoEntrySeq { get; set; }
            /// <summary>
            /// 单位   (必填项)
            /// </summary>
            public Dictionary<string, string> FUnitId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 产品基本单位
            /// </summary>
            public Dictionary<string, string> FBaseUnitId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 数量
            /// </summary>
            public decimal FQty { get; set; }
            /// <summary>
            /// 基本单位数量
            /// </summary>
            public decimal FBaseQty { get; set; }
            /// <summary>
            /// 业务状态   (必填项)
            /// </summary>
            public string FStatus { get; set; } = string.Empty;
            /// <summary>
            /// 计划开工时间   (必填项)
            /// </summary>
            [DataType(DataType.Date)]
            public string FPlanStartDate { get; set; }
            /// <summary>
            /// 计划完工时间   (必填项)
            /// </summary>
            [DataType(DataType.Date)]
            public string FPlanFinishDate { get; set; }
            /// <summary>
            /// BOM版本
            /// </summary>
            public Dictionary<string, string> FBomId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 需求组织
            /// </summary>
            public Dictionary<string, string> FRequestOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            /// <summary>
            /// 批号
            /// </summary>
            public Dictionary<string, string> FLot { get; set; } = new Dictionary<string, string>() { { "FNUMBER", "" } };
            /// <summary>
            /// 产品类型   (必填项)
            /// </summary>
            public string FProductType { get; set; } = "1";
            ///// <summary>
            ///// 辅助属性
            ///// </summary>
            //public AuxPropId FAuxPropId { get; set; } = new AuxPropId();
            ///// <summary>
            ///// 20230719打了6月补丁之后，这个字段不能再默认了
            ///// </summary>
            //public class AuxPropId
            //{
            //    public Dictionary<string, string> FAUXPROPID__FF100001;
            //}
            /// <summary>
            /// 入库组织
            /// </summary>
            public Dictionary<string, string> FStockInOrgId { get; set; } = new Dictionary<string, string>() { { "FNUMBER", LocalStaticRequest.DefaultOrg } };
            /// <summary>
            /// 备注
            /// </summary>
            public string FMemoItem { get; set; } = "1";
            /// <summary>
            /// 需求类型
            /// </summary>
            public string FReqType { get; set; } = "1";

            ///// <summary>
            ///// 需求发起人#
            ///// </summary>
            //public string F_PNDR_Remarks_uky2 { get; set; }

            ///// <summary>
            ///// OA试制编号#
            ///// </summary>
            //public string F_PNDR_Remarks_dvn2 { get; set; }

            ///// <summary>
            ///// 工艺#
            ///// </summary>
            //public string F_PNDR_Remarks_w5c2 { 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_MO2MOCHANGE";
                public int FEntity_Link_FSTableId { get; set; }
                public string FEntity_Link_FSTableName { get; set; } = "T_PRD_MOENTRY";
                /// <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; }    //修改携带量
            }
        }
    }
}
