2026-11-03 10:17:49 +08:00
|
|
|
|
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"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// AgvPoint AGV 点位(硬件级别真源)。
|
|
|
|
|
|
// 点位编码(position_code)与接驳台的一一对应关系为硬件内置:软件层只能“启用/停用”与改显示名(name),
|
|
|
|
|
|
// 绝对不能修改核心物理编码和绑定关系(dock_id)。
|
|
|
|
|
|
// 纯 AGV 点位(无接驳台)用 is_dock=false 表示;派车时无传感器,仅做二次确认“请确保现场安全”。
|
|
|
|
|
|
type AgvPoint struct {
|
|
|
|
|
|
ent.Schema
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (AgvPoint) Annotations() []schema.Annotation {
|
|
|
|
|
|
return []schema.Annotation{entsql.Annotation{Table: "agv_point"}, entsql.WithComments(true),
|
|
|
|
|
|
schema.Comment("AgvPoint AGV 点位(硬件级别真源):点位编码与接驳台一一对应,软件仅可启用/停用与改显示名。")}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (AgvPoint) Fields() []ent.Field {
|
|
|
|
|
|
return []ent.Field{
|
|
|
|
|
|
field.String("position_code").Unique().MaxLen(32).Comment("AGV 点位编码(硬件映射=送往 RCS 的目标坐标,软件不可改)"),
|
|
|
|
|
|
field.String("name").Default("").MaxLen(64).Comment("点位显示名称(可编辑)"),
|
|
|
|
|
|
field.Bool("is_dock").Default(false).Comment("是否接驳台点位(true=绑定接驳台,false=纯待命/充电点位)"),
|
|
|
|
|
|
// 硬件内置绑定:该点位对应的接驳台 ID(is_dock=true 时强绑定,软件不可改)
|
|
|
|
|
|
field.Int("dock_id").Optional().Nillable().Comment("绑定的接驳台 ID(is_dock=true 时硬件内置强绑定)"),
|
|
|
|
|
|
field.Bool("enabled").Default(true).Comment("是否启用(可编辑)"),
|
2026-11-07 15:06:00 +08:00
|
|
|
|
// 派车锁(2026-11-06 拍板):点位级占用锁,防两个任务同时抢同一点位。
|
|
|
|
|
|
// system 锁=派车成功自动置、任务终态自动释放(JBT21 例外:卸货后保持锁定,库管手动解锁);
|
|
|
|
|
|
// manual 锁=库管在「点位管理」手动锁定,仅手动解锁。锁与 PLC 传感器比对不一致落预警不拦车。
|
|
|
|
|
|
field.Bool("locked").Default(false).Comment("派车锁:true=被任务占用/人工锁定,派车前查锁拒绝"),
|
|
|
|
|
|
field.String("locked_by").Default("").MaxLen(10).Comment("锁来源:system=派车自动 / manual=人工"),
|
|
|
|
|
|
field.String("locked_reason").Default("").MaxLen(64).Comment("锁定原因(system=任务号 / manual=人工原因)"),
|
|
|
|
|
|
field.Int64("locked_at").Default(0).Comment("锁定时间 unix秒"),
|
|
|
|
|
|
// 强提风险标记(2026-11-06 拍板):PLC 离线强行提交叫料时在目标点位打标 + 推预警;
|
|
|
|
|
|
// 后续该点位派车要求人工二次确认(确认后下发并在任务备注留痕),卸货放行自动清除。
|
|
|
|
|
|
field.Bool("force_pick").Default(false).Comment("强提风险标记:true=该点位曾因 PLC 离线强提,派车需人工二次确认"),
|
|
|
|
|
|
field.Int64("force_pick_at").Default(0).Comment("强提标记时间 unix秒"),
|
2026-11-03 10:17:49 +08:00
|
|
|
|
field.Time("created_at").Default(time.Now).Immutable(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (AgvPoint) Indexes() []ent.Index {
|
|
|
|
|
|
return []ent.Index{
|
|
|
|
|
|
index.Fields("position_code").Unique(),
|
|
|
|
|
|
index.Fields("is_dock"),
|
|
|
|
|
|
index.Fields("enabled"),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|