RobotCacheLocationConfiguration.cs
3.16 KB
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
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Rcs.Domain.Entities;
namespace Rcs.Infrastructure.DB.Configuration.Domain
{
/// <summary>
/// RobotCacheLocation实体的EF Core配置
/// </summary>
public class RobotCacheLocationConfiguration : IEntityTypeConfiguration<RobotCacheLocation>
{
public void Configure(EntityTypeBuilder<RobotCacheLocation> builder)
{
// 配置表名
builder.ToTable("robot_cache_locations");
// 配置主键
builder.HasKey(e => e.CacheLocationId);
// 配置属性
builder.Property(e => e.CacheLocationId)
.HasColumnName("id")
.ValueGeneratedNever();
builder.Property(e => e.RobotId)
.HasColumnName("robot_id")
.IsRequired();
builder.Property(e => e.LocationCode)
.HasColumnName("location_code")
.HasMaxLength(100)
.IsRequired();
builder.Property(e => e.Row)
.HasColumnName("row")
.IsRequired();
builder.Property(e => e.Column)
.HasColumnName("column")
.IsRequired();
builder.Property(e => e.Level)
.HasColumnName("level")
.IsRequired();
builder.Property(e => e.ContainerId)
.HasColumnName("container_id")
.HasMaxLength(100);
builder.Property(e => e.MaterialCode)
.HasColumnName("material_code")
.HasMaxLength(100);
builder.Property(e => e.MaterialName)
.HasColumnName("material_name")
.HasMaxLength(200);
builder.Property(e => e.Quantity)
.HasColumnName("quantity");
builder.Property(e => e.Weight)
.HasColumnName("weight");
builder.Property(e => e.Remark)
.HasColumnName("remark")
.HasMaxLength(500);
builder.Property(e => e.CreatedAt)
.HasColumnName("created_at")
.HasColumnType("timestamp without time zone");
builder.Property(e => e.UpdatedAt)
.HasColumnName("updated_at")
.HasColumnType("timestamp without time zone");
// 配置索引
builder.HasIndex(e => e.RobotId)
.HasDatabaseName("idx_robot_cache_location_robot_id");
builder.HasIndex(e => e.LocationCode)
.HasDatabaseName("idx_robot_cache_location_code");
builder.HasIndex(e => e.Row)
.HasDatabaseName("idx_robot_cache_location_row");
builder.HasIndex(e => e.Column)
.HasDatabaseName("idx_robot_cache_location_column");
builder.HasIndex(e => e.Level)
.HasDatabaseName("idx_robot_cache_location_level");
// 配置复合索引(排-列-层)用于快速查询
builder.HasIndex(e => new { e.Row, e.Column, e.Level })
.HasDatabaseName("idx_robot_cache_location_position");
}
}
}