Files
bj_power/bj_power_mes/schema/recipe_step.go
T

64 lines
2.6 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 (
"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(),
}
}