2026-08-28 15:06:01 +08:00
|
|
|
package schema
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
2026-09-04 14:18:53 +08:00
|
|
|
"entgo.io/ent/dialect"
|
2026-08-28 15:06:01 +08:00
|
|
|
"entgo.io/ent/dialect/entsql"
|
|
|
|
|
"entgo.io/ent/schema"
|
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
|
"entgo.io/ent/schema/index"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// DailyPlan 日排产:仅预告,不触发出库/领料
|
|
|
|
|
type DailyPlan struct {
|
|
|
|
|
ent.Schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (DailyPlan) Annotations() []schema.Annotation {
|
|
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "daily_plan"}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (DailyPlan) Fields() []ent.Field {
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
field.Int("id").Positive(),
|
|
|
|
|
field.String("orderNo").MaxLen(64).Comment("工单号"),
|
|
|
|
|
field.String("planDate").MaxLen(10).Comment("排产日期 yyyy-MM-dd"),
|
|
|
|
|
field.Int("planQty").Default(0).Comment("计划数量"),
|
|
|
|
|
field.Int("completedQty").Default(0).Comment("已完成数量"),
|
2026-09-19 07:50:21 +08:00
|
|
|
// 各工位产量分配:stationNo(字符串键) → 该工位分配到的总计划产量。
|
|
|
|
|
// 备料算料时,按「工位↔工序」派工(station_process) + 本分配,把 BOM 物料拆到工位级。
|
|
|
|
|
field.JSON("stationPlanQty", map[string]int{}).Optional().SchemaType(map[string]string{
|
2026-09-04 14:18:53 +08:00
|
|
|
dialect.Postgres: "jsonb",
|
2026-09-19 07:50:21 +08:00
|
|
|
}).Comment("各工位产量分配 stationNo→计划产量"),
|
2026-08-28 15:06:01 +08:00
|
|
|
// PENDING / PROCESSING / DONE
|
|
|
|
|
field.String("status").Default("PENDING").MaxLen(20),
|
|
|
|
|
field.String("operator").Default("").MaxLen(64),
|
|
|
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|
|
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (DailyPlan) Indexes() []ent.Index {
|
|
|
|
|
return []ent.Index{
|
|
|
|
|
index.Fields("orderNo"),
|
|
|
|
|
index.Fields("planDate"),
|
|
|
|
|
index.Fields("planDate", "orderNo").Unique(),
|
|
|
|
|
}
|
|
|
|
|
}
|