AGV 调度: - 任务重构为 GO_LOAD/TRANSPORT/EMPTY_RETURN/FREE 三段链,到位即停(ARRIVED)需人工确认装卸 - 自由调度单点步进,每段强制弹"请确保路径畅通无杂物";托盘回收独立工作台 - 接驳台 PLC 传感器检测到托盘即自动卸货放行,传感器故障由人工按钮兜底(无轮询) - 车辆状态只读展示(海康3.1.7 queryAgvStatus),调度仍由 RCS 负责 物料闭环: - 补料管理(SHORTAGE):工位申请 + 主管审批调增叫料池额度,与借料/差异补发三轨并行 - 损耗台账(loss_ledger):退料实际 < 理论必填原因、后审核,工单不记损耗 - 退料强制指定左/右接驳台,WMS 库管可代工位退料 下班闭环: - 工位终端自检接驳台剩余物料后下班;库管收货 + 托盘拉走后事件驱动自动结班 - 退出登录未下班仅作安全提示(不强制拦截、不新增责任审批) 接驳台左右按操作员朝向建模(dock.side 字段),废除"奇左偶右"隐式约定; 看板标签 / seed / 迁移补丁 / 布局文档统一为中文左/右。 产线布局说明:C1 前线头 AGV 点、C15 后线尾 AGV 点、外部 O1/O2/O3 散点, 清理修订痕迹为最终态描述。
418 lines
12 KiB
Go
418 lines
12 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/dock"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// DockCreate is the builder for creating a Dock entity.
|
|
type DockCreate struct {
|
|
config
|
|
mutation *DockMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetDockCode sets the "dockCode" field.
|
|
func (_c *DockCreate) SetDockCode(v string) *DockCreate {
|
|
_c.mutation.SetDockCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *DockCreate) SetName(v string) *DockCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableName(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetName(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDockType sets the "dockType" field.
|
|
func (_c *DockCreate) SetDockType(v string) *DockCreate {
|
|
_c.mutation.SetDockType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDockType sets the "dockType" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableDockType(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetDockType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStationNo sets the "stationNo" field.
|
|
func (_c *DockCreate) SetStationNo(v int) *DockCreate {
|
|
_c.mutation.SetStationNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableStationNo(v *int) *DockCreate {
|
|
if v != nil {
|
|
_c.SetStationNo(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSide sets the "side" field.
|
|
func (_c *DockCreate) SetSide(v string) *DockCreate {
|
|
_c.mutation.SetSide(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSide sets the "side" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableSide(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetSide(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetHasPallet sets the "hasPallet" field.
|
|
func (_c *DockCreate) SetHasPallet(v bool) *DockCreate {
|
|
_c.mutation.SetHasPallet(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableHasPallet sets the "hasPallet" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableHasPallet(v *bool) *DockCreate {
|
|
if v != nil {
|
|
_c.SetHasPallet(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPalletRef sets the "palletRef" field.
|
|
func (_c *DockCreate) SetPalletRef(v string) *DockCreate {
|
|
_c.mutation.SetPalletRef(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePalletRef sets the "palletRef" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillablePalletRef(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetPalletRef(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *DockCreate) SetStatus(v string) *DockCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableStatus(v *string) *DockCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "createdAt" field.
|
|
func (_c *DockCreate) SetCreatedAt(v time.Time) *DockCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
|
|
func (_c *DockCreate) SetNillableCreatedAt(v *time.Time) *DockCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the DockMutation object of the builder.
|
|
func (_c *DockCreate) Mutation() *DockMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the Dock in the database.
|
|
func (_c *DockCreate) Save(ctx context.Context) (*Dock, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *DockCreate) SaveX(ctx context.Context) *Dock {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *DockCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *DockCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *DockCreate) defaults() {
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
v := dock.DefaultName
|
|
_c.mutation.SetName(v)
|
|
}
|
|
if _, ok := _c.mutation.DockType(); !ok {
|
|
v := dock.DefaultDockType
|
|
_c.mutation.SetDockType(v)
|
|
}
|
|
if _, ok := _c.mutation.StationNo(); !ok {
|
|
v := dock.DefaultStationNo
|
|
_c.mutation.SetStationNo(v)
|
|
}
|
|
if _, ok := _c.mutation.Side(); !ok {
|
|
v := dock.DefaultSide
|
|
_c.mutation.SetSide(v)
|
|
}
|
|
if _, ok := _c.mutation.HasPallet(); !ok {
|
|
v := dock.DefaultHasPallet
|
|
_c.mutation.SetHasPallet(v)
|
|
}
|
|
if _, ok := _c.mutation.PalletRef(); !ok {
|
|
v := dock.DefaultPalletRef
|
|
_c.mutation.SetPalletRef(v)
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := dock.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := dock.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *DockCreate) check() error {
|
|
if _, ok := _c.mutation.DockCode(); !ok {
|
|
return &ValidationError{Name: "dockCode", err: errors.New(`ent: missing required field "Dock.dockCode"`)}
|
|
}
|
|
if v, ok := _c.mutation.DockCode(); ok {
|
|
if err := dock.DockCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "dockCode", err: fmt.Errorf(`ent: validator failed for field "Dock.dockCode": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Dock.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := dock.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Dock.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.DockType(); !ok {
|
|
return &ValidationError{Name: "dockType", err: errors.New(`ent: missing required field "Dock.dockType"`)}
|
|
}
|
|
if v, ok := _c.mutation.DockType(); ok {
|
|
if err := dock.DockTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "dockType", err: fmt.Errorf(`ent: validator failed for field "Dock.dockType": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.StationNo(); !ok {
|
|
return &ValidationError{Name: "stationNo", err: errors.New(`ent: missing required field "Dock.stationNo"`)}
|
|
}
|
|
if _, ok := _c.mutation.Side(); !ok {
|
|
return &ValidationError{Name: "side", err: errors.New(`ent: missing required field "Dock.side"`)}
|
|
}
|
|
if v, ok := _c.mutation.Side(); ok {
|
|
if err := dock.SideValidator(v); err != nil {
|
|
return &ValidationError{Name: "side", err: fmt.Errorf(`ent: validator failed for field "Dock.side": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.HasPallet(); !ok {
|
|
return &ValidationError{Name: "hasPallet", err: errors.New(`ent: missing required field "Dock.hasPallet"`)}
|
|
}
|
|
if v, ok := _c.mutation.PalletRef(); ok {
|
|
if err := dock.PalletRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "palletRef", err: fmt.Errorf(`ent: validator failed for field "Dock.palletRef": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Dock.status"`)}
|
|
}
|
|
if v, ok := _c.mutation.Status(); ok {
|
|
if err := dock.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Dock.status": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "Dock.createdAt"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *DockCreate) sqlSave(ctx context.Context) (*Dock, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *DockCreate) createSpec() (*Dock, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Dock{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(dock.Table, sqlgraph.NewFieldSpec(dock.FieldID, field.TypeInt))
|
|
)
|
|
if value, ok := _c.mutation.DockCode(); ok {
|
|
_spec.SetField(dock.FieldDockCode, field.TypeString, value)
|
|
_node.DockCode = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(dock.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.DockType(); ok {
|
|
_spec.SetField(dock.FieldDockType, field.TypeString, value)
|
|
_node.DockType = value
|
|
}
|
|
if value, ok := _c.mutation.StationNo(); ok {
|
|
_spec.SetField(dock.FieldStationNo, field.TypeInt, value)
|
|
_node.StationNo = value
|
|
}
|
|
if value, ok := _c.mutation.Side(); ok {
|
|
_spec.SetField(dock.FieldSide, field.TypeString, value)
|
|
_node.Side = value
|
|
}
|
|
if value, ok := _c.mutation.HasPallet(); ok {
|
|
_spec.SetField(dock.FieldHasPallet, field.TypeBool, value)
|
|
_node.HasPallet = value
|
|
}
|
|
if value, ok := _c.mutation.PalletRef(); ok {
|
|
_spec.SetField(dock.FieldPalletRef, field.TypeString, value)
|
|
_node.PalletRef = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(dock.FieldStatus, field.TypeString, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(dock.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// DockCreateBulk is the builder for creating many Dock entities in bulk.
|
|
type DockCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*DockCreate
|
|
}
|
|
|
|
// Save creates the Dock entities in the database.
|
|
func (_c *DockCreateBulk) Save(ctx context.Context) ([]*Dock, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*Dock, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*DockMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *DockCreateBulk) SaveX(ctx context.Context) []*Dock {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *DockCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *DockCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|