- 移除station表的hasDock、dockCode字段及相关代码 - 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台 - 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式 - 新增SQL注释固化脚本,完善MES表注释
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
)
|
|
|
|
// InventoryLock 库存锁定(工单锁库存,防超卖)
|
|
type InventoryLock struct {
|
|
ent.Schema
|
|
}
|
|
|
|
func (InventoryLock) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{entsql.Table("inventory_locks"), entsql.WithComments(true), schema.Comment("InventoryLock 库存锁定(工单锁库存,防超卖)")}
|
|
}
|
|
func (InventoryLock) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
// 锁定对象:批次或 SN
|
|
field.String("target_type").Comment("BATCH/SN"),
|
|
field.String("target_id").Comment("批次号或 SN"),
|
|
field.String("material_code").Comment("物料编码"),
|
|
field.Int("locked_qty").Default(1).Comment("锁定数量"),
|
|
field.String("order_no").Comment("关联工单号"),
|
|
field.String("status").Default("ACTIVE").Comment("ACTIVE/RELEASED/CONSUMED"),
|
|
field.Int64("expired_at").Optional().Comment("过期时间戳"),
|
|
field.String("remark").Optional().Comment("备注"),
|
|
field.Int64("created_at").DefaultFunc(nowUnix),
|
|
field.Int64("updated_at").DefaultFunc(nowUnix),
|
|
}
|
|
}
|
|
|
|
func (InventoryLock) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("order_no"),
|
|
index.Fields("status"),
|
|
index.Fields("target_id"),
|
|
}
|
|
}
|