using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareDataCore.ORM; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace iWareDataCore.BASE.Entity { public class MaterialEntity : ICommonEntity { /// /// 1物料主键 /// public int Id { get; set; } /// /// 2物料名称 /// public string Name { get; set; } /// /// 2物料规格号 /// public string MaterialNo { get; set; } /// /// 3物料号 /// public string Code { get; set; } /// /// 4版本(用于保存在SAP中的物料类型) /// public string Version { get; set; } /// /// 5物料状态(启用、禁用) /// public int Status { get; set; } /// /// 6外键物料类型id /// public int TypeId { get; set; } /// /// 7保质期 /// public string GuaranteePeriod { get; set; } /// /// 8计数单位 /// public string Unit { get; set; } /// /// 9备注(用于保存SAP中的物料组) /// public string Remark { get; set; } /// /// 10描述 /// public string Description { get; set; } /// /// 11成本 /// public decimal Cost { get; set; } /// /// 12船级社 /// public string ClassificationSociety { get; set; } /// /// 13分段号 /// public string SerialNo { get; set; } /// /// 14垂直位置 /// public string VerticalPosition { get; set; } /// /// 15重量 /// public string Weight { get; set; } /// /// 16发放工程号 /// public string IssueProjectNo { get; set; } /// /// 17采购工程号 /// public string ProcurementProjectNo { get; set; } /// /// 18切割类型 /// public string CuttingType { get; set; } /// /// 19页码 /// public string PageNo { get; set; } /// /// 20厚 /// public string Thick { get; set; } /// /// 21宽 /// public string Wide { get; set; } /// /// 22长 /// public string Length { get; set; } /// /// 23记号笔 /// public string MarkingPen { get; set; } /// /// 24分道 /// public string LaneSeparation { get; set; } /// /// 无参构造 /// public MaterialEntity() { } /// /// 有参构造 /// /// orm映射的类 public MaterialEntity(BASEMaterial material) { EntityPropHelper.CopyProp(material, this, GetColumnMap()); } /// /// 转换视图的方法 /// /// public MaterialEntity(MaterialViewEntity material) { var keys = GetColumnMap().Keys.ToList(); var columnMap = new Dictionary(); keys.ForEach(x => columnMap.Add(x, x)); EntityPropHelper.CopyProp(material, this, columnMap); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的BASEMaterial类型 public BASEMaterial ToOrm() { BASEMaterial material = new BASEMaterial(); EntityPropHelper.CopyProp(this, material, GetColumnMap()); return material; } /// /// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { { "Id", "id"}, { "Name", "name"}, { "Code", "code"}, { "MaterialNo", "materialno"}, { "Version", "version"}, { "Status", "status"}, { "TypeId","typeid"}, { "GuaranteePeriod", "guaranteeperiod"}, { "Unit", "unit"}, { "Remark", "remark"}, { "Description", "description"}, { "Cost", "cost"}, { "ClassificationSociety", "classificationsociety"}, { "SerialNo", "serialno"}, { "VerticalPosition", "verticalposition"}, { "Weight", "weight"}, { "IssueProjectNo", "issueprojectno"}, { "ProcurementProjectNo", "procurementprojectno"}, { "CuttingType", "cuttingtype"}, { "PageNo", "pageno"}, { "Thick", "thick"}, { "Wide", "wide"}, { "Length", "length"}, { "MarkingPen", "markingpen"}, { "LaneSeparation", "laneseparation"} }; } /// /// 根据MaterialEntity的字段转BASEMaterial的字段 /// /// MaterialEntity的字段 /// BASEMaterial public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取MaterialEntity对应的表名 /// /// 表名 public static string GetTableName() { return "[dbo].[BASEMaterial]"; } } }