49 lines
2.1 KiB
Go
49 lines
2.1 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"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// DeliveryOrder 配送单(2026-11-05 拍板:叫料与送料彻底拆开)。
|
|||
|
|
// 一个叫料包(package_no)可拆多张配送单;一张配送单 = 一次托盘配送(一接驳台一托盘)。
|
|||
|
|
// 状态机:PENDING 待配送 → DISPATCHED 配送中(AGV 已派车) → DONE 已送达;分支 CANCELLED 已取消。
|
|||
|
|
// 配送单必有配送详情(物料、各多少、工位、工艺、日排产)——见 DeliveryOrderItem。
|
|||
|
|
type DeliveryOrder struct {
|
|||
|
|
ent.Schema
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (DeliveryOrder) Annotations() []schema.Annotation {
|
|||
|
|
return []schema.Annotation{entsql.Annotation{Table: "delivery_order"}, entsql.WithComments(true), schema.Comment("DeliveryOrder 配送单:WMS 按叫料包创建,一包可拆多张;一单=一次托盘配送")}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (DeliveryOrder) Fields() []ent.Field {
|
|||
|
|
return []ent.Field{
|
|||
|
|
field.Int("id").Positive(),
|
|||
|
|
field.String("deliveryNo").MaxLen(64).Comment("配送单号"),
|
|||
|
|
field.String("packageNo").Default("").MaxLen(64).Comment("关联叫料包号(material_request.packageNo)"),
|
|||
|
|
field.Int("stationNo").Default(0).Comment("目标工位号"),
|
|||
|
|
field.String("targetDock").Default("").MaxLen(20).Comment("配送接驳台(左右手必选,仅可选空台:传感器+在途任务)"),
|
|||
|
|
// 状态:PENDING 待配送 / DISPATCHED 配送中 / DONE 已送达 / CANCELLED 已取消
|
|||
|
|
field.String("status").Default("PENDING").MaxLen(20),
|
|||
|
|
field.String("operator").Default("").MaxLen(64).Comment("创建人(库管)"),
|
|||
|
|
field.String("remark").Default("").MaxLen(255).Comment("备注"),
|
|||
|
|
field.String("agvTaskNo").Default("").MaxLen(64).Comment("AGV 任务号(派车成功后回写)"),
|
|||
|
|
field.Time("createdAt").Default(time.Now).Immutable(),
|
|||
|
|
field.Time("updatedAt").Default(time.Now).UpdateDefault(time.Now).Optional().Nillable(),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (DeliveryOrder) Indexes() []ent.Index {
|
|||
|
|
return []ent.Index{
|
|||
|
|
index.Fields("packageNo"),
|
|||
|
|
index.Fields("status"),
|
|||
|
|
index.Fields("stationNo"),
|
|||
|
|
}
|
|||
|
|
}
|