using CMS.Plugin.HIAWms.Domain; using CMS.Plugin.HIAWms.Domain.WmsInOutStockOrder; using CMS.Plugin.HIAWms.Domain.WmsInOutStockOrderDetail; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; namespace CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions { 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; } /// /// Configure WmsInOutStockOrderDetail /// /// public static void ConfigureWmsInOutStockOrderDetail(this ModelBuilder builder) { Check.NotNull(builder, nameof(builder)); builder.Entity(b => { b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_WmsInOutStockOrderDetail").ToLower(), CMSPluginDbProperties.DbSchema) .HasComment("出入库单据明细表"); // 主键配置 b.HasKey(x => x.Id); //// 复合主键配置(根据业务需求调整) //b.HasKey(x => new { x.OrderNo, x.MaterialId }); // 字段配置 b.Property(x => x.OrderNo) .HasMaxLength(50) .IsRequired() .HasComment("单据编号"); b.Property(x => x.OrderType) .IsRequired() .HasComment("单据类型(枚举值)"); b.Property(x => x.MaterialNo) .HasMaxLength(50) .IsRequired() .HasComment("物料件号"); b.Property(x => x.MaterialName) .HasMaxLength(100) .HasComment("物料名称"); b.Property(x => x.MaterialId) .HasMaxLength(64) .IsRequired() .HasComment("物料唯一码"); b.Property(x => x.ContainerNo) .HasMaxLength(50) .HasComment("容器编号"); b.Property(x => x.MaterialModel) .HasMaxLength(50) .HasComment("机型"); b.Property(x => x.MaterialBatch) .HasMaxLength (50) .HasComment("物料批次"); b.Property(x => x.Remark) .HasMaxLength(500) .HasComment("备注"); b.Property(x => x.Sort) .HasDefaultValue(0) .HasComment("排序"); b.Property(x => x.IsDisabled) .HasDefaultValue(false) .HasComment("是否禁用"); // 索引配置(根据查询需求优化) b.HasIndex(x => x.OrderNo); // 单据查询 b.HasIndex(x => x.MaterialNo); // 物料查询 b.HasIndex(x => x.MaterialId); // 唯一码查询 b.HasIndex(x => x.ContainerNo); // 容器查询 b.HasIndex(x => new { x.OrderNo, x.OrderType }); // 联合查询 // ABP框架配置 b.ConfigureByConvention(); b.ApplyObjectExtensionMappings(); }); } } }