64 lines
2.6 KiB
Go
64 lines
2.6 KiB
Go
package schema
|
||||
|
|
|
|||
|
|
import (
|
|||
|
|
"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"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// RecipeStep å·¥åº�定义,工艺路线ä¸çš„å�•ä¸ªåŠ å·¥æ¥éª¤ã€?
|
|||
|
|
//
|
|||
|
|
// 设计原则:æ¥éª¤çš„èµ°å�‘ç”?Scheduler 层实时决ç–,ä¸�通过 JSON å—æ®µé…�置分支逻辑ã€?
|
|||
|
|
// nextStepDefault æ��供默认下一跳,Scheduler çš?Generator/Filter å�¯åœ¨è¿�è¡Œæ—¶æ ¹æ�®ç³»ç»Ÿçжæ€�覆盖ã€?
|
|||
|
|
type RecipeStep struct {
|
|||
|
|
ent.Schema
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (RecipeStep) Annotations() []schema.Annotation {
|
|||
|
|
return []schema.Annotation{
|
|||
|
|
entsql.Annotation{
|
|||
|
|
Table: "recipe_step",
|
|||
|
|
Options: "COMMENT='å·¥åº�定义表,工艺路线ä¸çš„å�•ä¸ªåŠ å·¥æ¥éª¤'",
|
|||
|
|
},
|
|||
|
|
entsql.WithComments(true),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (RecipeStep) Fields() []ent.Field {
|
|||
|
|
return []ent.Field{
|
|||
|
|
field.Int("id").Positive().Comment("主键ID"),
|
|||
|
|
field.Int("recipeId").Comment("所属工艺路线ID"),
|
|||
|
|
field.String("stepId").MaxLen(20).Default("").Comment("业务æ¥éª¤ID,如 OP10/OP20"),
|
|||
|
|
field.String("stepName").MaxLen(50).Comment("工��称"),
|
|||
|
|
field.Int("stepIndex").Comment("工���"),
|
|||
|
|
field.Enum("stepType").
|
|||
|
|
GoType(constants.StepType("")).
|
|||
|
|
Comment("工�类型:OPERATION/BUFFER_STAGE/AIR_BLOW/LOAD_DOCK/UNLOAD_DOCK"),
|
|||
|
|
field.String("resourceType").Default("").Comment("ç›®æ ‡è®¾å¤‡ç±»åž‹ç¼–ç �,如 GRINDER/FULL_CHECK,手æŒ�æ“�作时å�¯ä¸ºç©?),
|
|||
|
|
field.String("nextStepDefault").Default("").Comment("默认下一æ¥stepId,æ£å¸¸æµ�è½¬æ—¶çš„ç›®æ ‡æ¥éª?),
|
|||
|
|
field.Int("priority").Default(2).Comment("调度优先级,数值越å°�越优先(磨床å�–æ–™ç‰é«˜ä¼˜å…ˆï¼‰ï¼ŒtrySchedule 按当å‰�æ¥éª¤ä¼˜å…ˆçº§æŽ’åº�"),
|
|||
|
|
field.Int("timeoutSeconds").Default(-1).Comment("超时秒数�1=一致监�轮询兜底(�超时),0=�超时,>0=超时秒数"),
|
|||
|
|
field.Bool("holdUntilHandover").Default(false).Comment("本æ¥éª¤å®Œæˆ�å�Žæ˜¯å�¦æŒ‚èµ·ç‰å¾…交接(æ�¢æ–™åœºæ™¯ï¼šç£¨å®Œçš„工件ç‰ä¸‹ä¸€ä»¶æ�¥æ�¢æ–™äº¤æŽ¥ï¼Œçжæ€�è¿›å…?holding,ä¸�自动推进ï¼?),
|
|||
|
|
field.String("fallbackNextStep").MaxLen(20).Default("").Comment("holding æŒ‚èµ·æ—¶è‹¥æ— å�Žç»§å·¥ä»¶äº¤æŽ¥ï¼Œèµ°æ¤æ¥éª¤æ”¶å°¾ï¼ˆå¦‚最å�Žä¸€ä»¶è‡ªè¡Œå�–料)"),
|
|||
|
|
field.String("desc").Default("").Comment("工��述"),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (RecipeStep) Edges() []ent.Edge {
|
|||
|
|
return []ent.Edge{
|
|||
|
|
edge.From("recipe", Recipe.Type).Ref("steps").Field("recipeId").Unique().Required().Comment("所属工艺路�),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (RecipeStep) Indexes() []ent.Index {
|
|||
|
|
return []ent.Index{
|
|||
|
|
index.Fields("recipeId", "stepIndex").Unique(),
|
|||
|
|
index.Fields("recipeId", "stepId").Unique(),
|
|||
|
|
}
|
|||
|
|
}
|