schangxiang@126.com
2025-05-07 7eb4eb64a854eae4f3f62f0dfc4e63427d7231b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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;
 
/// <summary>
/// EfCore扩展
/// </summary>
public  static partial class CMSPluginEfCoreExtensions
{
    /// <summary>
    /// Includes the details.
    /// </summary>
    /// <param name="queryable">The queryable.</param>
    /// <param name="include">if set to <c>true</c> [include].</param>
    /// <returns></returns>
    public static IQueryable<WmsPlace> IncludeDetails(this IQueryable<WmsPlace> queryable, bool include = true)
    {
        if (!include)
        {
            return queryable;
        }
 
        return queryable;
    }
 
    /// <summary>
    /// Configures the wmsplace.
    /// </summary>
    /// <param name="builder">The builder.</param>
    public static void ConfigureWmsPlace(this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));
 
        builder.Entity<WmsPlace>(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();
        });
    }
}