Files
bj_power/bj_power_mes/schema/work_order.go
T

67 lines
2.4 KiB
Go
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package schema
import (
"time"
"bj_power_mes/constants"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// WorkOrder å·¥å•,一次生产任务的下达指令
type WorkOrder struct {
ent.Schema
}
func (WorkOrder) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{
Table: "work_order",
Options: "COMMENT='å·¥å•è¡¨ï¼Œè®°å½•æ¯æ¬¡ç”Ÿäº§ä»»åŠ¡çš„ä¸‹è¾¾æŒ‡ä»¤ï¼šäº§å“ã€æ•°é‡ã€çжæ€ã€æ¥æºåŠå®Œå·¥ç»Ÿè®¡'",
},
entsql.WithComments(true),
}
}
func (WorkOrder) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive().Comment("主键ID"),
field.Int("productTypeId").Comment("产å“类型ID,决定生产的工件ç§ç±»"),
field.Int("quantity").Default(1).Comment("工件计划数é‡ï¼Œè¯¥å·¥å•需è¦ç”Ÿäº§çš„æ€»ä»¶æ•?),
field.Int("finishedNum").Default(0).Comment("已完æˆè‰¯åæ•°é‡?),
field.Int("failNum").Default(0).Comment("检测NGæ•°é‡ï¼ŒåŠ å·¥æˆ–æ£€æµ‹ä¸åˆæ ¼çš„ä»¶æ•?),
field.Enum("status").
GoType(constants.WorkOrderStatus("")).
Default(string(constants.WorkOrderStatus_Created)).
Comment("å·¥åçŠæï¼šCreated/InProgress/Paused/Completed/Cancelled/Error/Reported"),
field.Time("createdAt").Default(time.Now).Immutable().Comment("åˆå»ºæ—¶é—´"),
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable().Comment("æ›´æ–°æ—¶é—´"),
field.Time("completedAt").Optional().Nillable().Comment("完工时间,所æœå·¥ä»¶åŠ å·¥å®Œæ¯•çšæ—¶åˆ»"),
field.Enum("source").
GoType(constants.WorkOrderSource("")).
Default(string(constants.WorkOrderSource_Manual)).
Comment("工忥æºï¼šManual/MOM,æ è¯†å·¥åçšåˆå»ºæ¸ é"),
field.String("workOrderNo").Default("").Comment("å·¥åå·ï¼Œå¤–部系统(MOM/ERP)传入çšä¸šåŠ¡ç¼–å·"),
field.Bool("isDel").Default(false).Comment("软删除æ è®°ï¼šTRUE=å·²åˆ é™¤ï¼ˆåˆ é™¤å·¥åæ—¶è½¯åˆ ï¼Œä¿ç•™å®¡è®¡æ•°æ®ï¼‰ï¼›æŸ¥è¯¢éœè¿‡æ»¤ is_del = FALSE"),
}
}
func (WorkOrder) Edges() []ent.Edge {
return []ent.Edge{
edge.From("productType", ProductType.Type).Ref("workOrders").Field("productTypeId").Unique().Required().Comment("产åç±»åž"),
edge.To("jobs", Job.Type).Comment("å·¥å下çšå·¥ä»¶åˆè¡¨"),
}
}
func (WorkOrder) Indexes() []ent.Index {
return []ent.Index{
index.Fields("status"),
index.Fields("productTypeId"),
}
}