Files
bj_power/bj_power_mes/schema/workpiece_bind.go
T
SunYF 1f7a42fc38 refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据
- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
2026-10-08 13:09:53 +08:00

54 lines
2.2 KiB
Go

package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)
// 绑定到工件,构成"这台机实际用了哪些料"的单件追溯。绑定动作在工位扫码/手录产生。
type WorkpieceBind struct {
ent.Schema
}
func (WorkpieceBind) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_bind"}, entsql.WithComments(true), schema.Comment("WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 电气件=SN)")}
}
func (WorkpieceBind) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").MaxLen(64).Comment("工件SN"),
field.String("orderNo").Default("").MaxLen(64).Comment("工单号"),
field.Int("flowId").Comment("装配工艺ID"),
field.String("stationNo").Default("").MaxLen(32).Comment("绑定工位"),
field.String("materialCode").MaxLen(64).Comment("物料编码"),
field.String("materialName").Default("").MaxLen(128).Comment("物料名称"),
field.String("spec").Default("").MaxLen(128).Comment("规格"),
field.String("unit").Default("").MaxLen(16).Comment("单位"),
// 是否逐件SN管理(冗余自物料档案 sn_mode,追溯展示/绑定口径依据):1 序列号件(SN) / 2 批次件
field.Int("snMode").Default(2),
// 结构件=批次号;电气件=SN 码
field.String("bindValue").MaxLen(128).Comment("绑定值:批次号 或 SN"),
// BATCH(批次绑定) / SN(序列号绑定),冗余自 snMode 便于直接展示
field.String("bindType").Default("SN").MaxLen(10),
field.String("operator").Default("").MaxLen(64).Comment("操作人"),
field.Time("createdAt").Default(time.Now).Immutable().Comment("绑定时间"),
}
}
func (WorkpieceBind) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn"),
index.Fields("sn", "flowId"),
index.Fields("sn", "materialCode"),
index.Fields("orderNo"),
index.Fields("materialCode", "bindValue"),
}
}