using CMS.Plugin.HIAWms.Domain; using CMS.Plugin.HIAWms.Domain.WmsPlaces; using CMS.Plugin.HIAWms.Domain.Shared.WmsPlaces; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; namespace CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions; /// /// EfCore扩展 /// public static partial class CMSPluginEfCoreExtensions { /// /// Includes the details. /// /// The queryable. /// if set to true [include]. /// public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) { if (!include) { return queryable; } return queryable; } /// /// Configures the wmsplace. /// /// The builder. public static void ConfigureWmsPlace(this ModelBuilder builder) { Check.NotNull(builder, nameof(builder)); builder.Entity(b => { // Configure table & schema name b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_WmsPlaces").ToLower(), CMSPluginDbProperties.DbSchema).HasComment("库位表"); b.ConfigureByConvention(); // Properties b.Property(x => x.PlaceNo).HasMaxLength(WmsPlaceConsts.MaxPlaceNoLength).IsRequired().HasComment("编号"); b.Property(x => x.StorageTypeNo).HasComment("货位类型"); b.Property(x => x.PlaceStatus).HasComment("货位状态"); b.Property(x => x.AreaCode).HasMaxLength(WmsPlaceConsts.MaxAreaCodeLength).IsRequired().HasComment("所在库区"); b.Property(x => x.Aisle).HasComment("巷道"); b.Property(x => x.RowNo).HasComment("排"); b.Property(x => x.ColumnNo).HasComment("列"); b.Property(x => x.LayerNo).HasComment("层"); b.Property(x => x.Islock).HasComment("是否锁定"); b.Property(x => x.EmptyContainer).HasComment("是否空托"); b.Property(x => x.RedundantField1).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段1 - 预留扩展用途"); b.Property(x => x.RedundantField2).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段2 - 预留扩展用途"); b.Property(x => x.RedundantField3).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段3 - 预留扩展用途"); b.Property(x => x.Sort).HasComment("排序"); b.Property(x => x.Remark).HasMaxLength(WmsPlaceConsts.MaxRemarkLength).IsRequired(false).HasComment("备注"); b.Property(x => x.IsDisabled).IsRequired(false).HasComment("是否禁用"); // Indexes b.HasIndex(u => u.PlaceNo).IsUnique(); // 编号字段添加唯一索引 b.HasIndex(u => u.AreaCode); // 所在库区字段添加普通索引 b.HasIndex(u => u.StorageTypeNo); // 货位类型字段添加普通索引 b.HasIndex(u => u.PlaceStatus); // 货位类型字段添加普通索引 // Apply object extension mappings b.ApplyObjectExtensionMappings(); }); } }