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 PlaceEntity : ICommonEntity { /// /// 库位ID /// public int Id { get; set; } /// /// 库位编码 /// public string Code { get; set; } /// /// 库位类型id /// public int TypeId { get; set; } /// /// 排 /// public int Row { get; set; } /// /// 列 /// public int Col { get; set; } /// /// 层 /// public int Layer { get; set; } /// /// 长 /// public decimal Length { get; set; } /// /// 宽 /// public decimal Width { get; set; } /// /// 高 /// public decimal Height { get; set; } /// /// 最大承重 /// public decimal MaxWeight { get; set; } /// /// 档位 /// public int HeightLevel { get; set; } /// /// X /// public int Posx { get; set; } /// /// Y /// public int Posy { get; set; } /// /// Z /// public int Posz { get; set; } /// /// 库位状态 /// public int Status { get; set; } /// /// 库位锁 /// public int IsLock { get; set; } /// /// 是否执行 /// public int IsExecute { get; set; } /// /// 无参构造 /// public PlaceEntity() { } /// /// 有参构造 /// /// orm映射的类 public PlaceEntity(BASEPlace place) { EntityPropHelper.CopyProp(place, this, GetColumnMap()); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的BASEPlace类型 public BASEPlace ToOrm() { var place = new BASEPlace(); EntityPropHelper.CopyProp(this, place, GetColumnMap()); return place; } /// /// 转换视图的方法 /// /// public PlaceEntity(PlaceViewEntity place) { var keys = GetColumnMap().Keys.ToList(); var columnMap = new Dictionary(); keys.ForEach(x => columnMap.Add(x, x)); EntityPropHelper.CopyProp(place, this, columnMap); } /// /// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"Code", "code"}, {"TypeId", "typeid"}, {"Row", "row"}, {"Col", "col"}, {"Layer", "layer"}, {"Width", "width"}, {"Length", "length"}, {"Height", "height"}, {"MaxWeight", "maxweight"}, {"HeightLevel", "heightlevel"}, {"Posx", "posx"}, {"Posy", "posy"}, {"Posz", "posz"}, {"Status", "status"}, {"IsLock", "islock"}, {"IsExecute", "isexecute"} }; } /// /// 根据WareHouseAreaTypeEntity的字段转BASEPlace的字段 /// /// WareHouseAreaTypeEntity的字段 /// BASEPlace public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取WareHouseAreaTypeEntity对应的表名 /// /// 表名 public static string GetTableName() { return "[dbo].[BASEPlace]"; } } }