Files
SunYF 1cc93795ce feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段
- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统
- 为BomItem实体添加relatedStandard字段及相关CRUD方法
- 为InspectionRecord实体添加reportNo、materialCode、materialName等字段
- 更新ent schema确保新字段的验证和默认值设置
- 添加必要的数据库迁移和字段映射逻辑
2026-09-17 12:49:07 +08:00

50 lines
1.5 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"
)
// WorkpieceProcess 工件-工序实绩(某工件在某工位完成某道工序的一次记录,构成工序时间线)
type WorkpieceProcess struct {
ent.Schema
}
func (WorkpieceProcess) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "workpiece_process"}}
}
func (WorkpieceProcess) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("sn").MaxLen(64).Comment("工件SN"),
field.Int("processCode").Comment("工序代码"),
field.String("stationNo").Default("").MaxLen(32).Comment("工位号"),
field.String("orderNo").Default("").MaxLen(64),
field.String("processName").Default("").MaxLen(64),
// PENDING / DOING / DONE / NG / REPAIRED
field.String("status").Default("DONE").MaxLen(20),
field.String("operator").Default("").MaxLen(64),
field.String("result").Default("OK").MaxLen(10).Comment("总判定 OK/NG"),
field.Time("startedAt").Optional().Nillable(),
field.Time("endedAt").Optional().Nillable(),
field.Int("durationSec").Default(0).Comment("作业时长(秒)=endedAt-startedAt"),
field.String("remark").Default("").MaxLen(255),
field.Time("createdAt").Default(time.Now).Immutable(),
}
}
func (WorkpieceProcess) Indexes() []ent.Index {
return []ent.Index{
index.Fields("sn"),
index.Fields("sn", "processCode"),
index.Fields("orderNo"),
index.Fields("stationNo"),
}
}