zs
2025-05-09 14f9c8378bde7d9a8d8f1fcc393e0e8d49eced82
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using CMS.Plugin.HIAWms.Domain;
using CMS.Plugin.HIAWms.Domain.WmsMaterialStocks;
using CMS.Plugin.HIAWms.Domain.Shared.WmsMaterialStocks;
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<WmsMaterialStock> IncludeDetails(this IQueryable<WmsMaterialStock> queryable, bool include = true)
    {
        if (!include)
        {
            return queryable;
        }
 
        return queryable;
    }
 
    /// <summary>
    /// Configures the wmsmaterialstock.
    /// </summary>
    /// <param name="builder">The builder.</param>
    public static void ConfigureWmsMaterialStock(this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));
 
        builder.Entity<WmsMaterialStock>(b =>
        {
            // 配置表和架构名称
            b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_WmsMaterialStocks").ToLower(),
                      CMSPluginDbProperties.DbSchema)
             .HasComment("WMS物料库存表");
 
            b.ConfigureByConvention();
 
            // 主键配置
            b.HasKey(x => x.Id);
 
            // 属性配置
            b.Property(x => x.MaterialId)
                .HasMaxLength(64)
                .IsRequired()
                .HasComment("物料ID");
 
            b.Property(x => x.MaterialName)
                .HasMaxLength(128)
                .IsRequired()
                .HasComment("物料名称");
 
            b.Property(x => x.ContainerNo)
                .HasMaxLength(64)
                .HasComment("容器编号");
 
            b.Property(x => x.ContainerStatus)
                .HasComment("容器状态");
 
            b.Property(x => x.ContainerType)
                .HasComment("容器类型");
 
            b.Property(x => x.MaterialNo)
                .HasMaxLength(64)
                .IsRequired()
                .HasComment("物料编号");
 
            b.Property(x => x.StockNumber)
                .HasComment("库存数量");
 
            b.Property(x => x.MaterialBatch)
                .HasMaxLength(64)
                .HasComment("物料批次");
 
            b.Property(x => x.SupplierCode)
                .HasMaxLength(64)
                .HasComment("供应商编号");
 
            b.Property(x => x.MaterialModel)
                .HasMaxLength(128)
                .HasComment("机型/规格");
 
            b.Property(x => x.PlaceNo)
                .HasMaxLength(64)
                .HasComment("库位编号");
 
            b.Property(x => x.PlaceStatus)
                .HasComment("库位状态;");
 
            b.Property(x => x.StorageTypeNo)
                .HasComment("库位类型");
 
            b.Property(x => x.AreaCode)
                .HasMaxLength(64)
                .HasComment("区域编号");
 
            b.Property(x => x.AreaName)
                .HasMaxLength(128)
                .HasComment("库区名称");
 
            b.Property(x => x.IsLock)
                .HasComment("是否锁定(2:未锁定,1:已锁定)");
            b.Property(x => x.EmptyContainer)
                .HasComment("是否空托(2:否,1:是)");
 
            b.Property(x => x.InStockTime)
                .HasComment("入库时间");
 
            b.Property(x => x.Sort)
                .HasDefaultValue(0)
                .HasComment("排序");
 
            b.Property(x => x.Remark)
                .HasMaxLength(500)
                .HasComment("备注");
 
            b.Property(x => x.CheckStatus)
                .HasComment("检验状态(1:未检验,2:检验通过,3:检验不通过)");
 
            // 冗余字段配置
            b.Property(x => x.RedundantField1)
                .HasMaxLength(256)
                .IsRequired(false)
                .HasComment("冗余字段1 - 预留扩展用途");
 
            b.Property(x => x.RedundantField2)
                .HasMaxLength(256)
                .IsRequired(false)
                .HasComment("冗余字段2 - 预留扩展用途");
 
            b.Property(x => x.RedundantField3)
                .HasMaxLength(256)
                .IsRequired(false)
                .HasComment("冗余字段3 - 预留扩展用途");
 
            b.Property(x => x.IsDisabled)
                .HasComment("是否禁用");
 
            // 索引配置
            b.HasIndex(x => x.MaterialNo);
            b.HasIndex(x => x.MaterialName);
            b.HasIndex(x => x.ContainerNo);
            b.HasIndex(x => x.PlaceNo);
            b.HasIndex(x => x.AreaCode);
            b.HasIndex(x => new { x.MaterialBatch, x.SupplierCode });
 
            // 扩展属性配置
            b.ApplyObjectExtensionMappings();
        });
    }
}