Files
bj_power/bj_power_mes/schema/micrometer_measurement.go
T

51 lines
1.9 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"
)
// MicrometerMeasurement 千分尺测量数据,记录千分尺客户端上传的测量结果
type MicrometerMeasurement struct {
ent.Schema
}
func (MicrometerMeasurement) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{
Table: "micrometer_measurement",
Options: "COMMENT='千分尺测量数据表,记录千分尺客户端上传的工件测量结果'",
},
entsql.WithComments(true),
}
}
func (MicrometerMeasurement) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive().Comment("主键ID"),
field.String("work_order_no").Comment("工单号,关联生产工单"),
field.String("workpiece_no").Comment("工件号,手动录入的唯一编码,同一工件号可多次录入测量数据"),
field.String("category").Default("").Comment("分类,如A类/B类"),
field.String("workpiece_type").Comment("工件类型:square=方形 / circle=圆形"),
field.Float("value_a").Comment("千分尺测量值A:方形=弧面半径B / 圆形=球面直径A"),
field.Float("value_b").Optional().Comment("千分尺测量值B:圆形=球面轮廓度B,方形不传"),
field.Float("value_c").Optional().Comment("千分尺测量值C:圆形=球面位置C,方形不传"),
field.String("unit").Default("mm").Comment("单位:mm/inch"),
field.String("serial").Default("").Comment("串口号,如COM7"),
field.Time("measure_time").Optional().Comment("测量时间戳,千分尺客户端上报的测量时刻"),
field.Time("created_at").Default(time.Now).Immutable().Comment("记录创建时间"),
}
}
func (MicrometerMeasurement) Indexes() []ent.Index {
return []ent.Index{
index.Fields("work_order_no"),
index.Fields("workpiece_no"),
index.Fields("created_at"),
}
}