Files
bj_power/bj_power_mes/ent/dock_update.go
T
SunYF 42bcf395d2 feat: AGV三段链安全机制、补料/损耗/下班闭环、接驳台左右互换
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 散点,
清理修订痕迹为最终态描述。
2026-11-03 18:29:31 +08:00

578 lines
16 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/dock"
"bj_power_mes/ent/predicate"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// DockUpdate is the builder for updating Dock entities.
type DockUpdate struct {
config
hooks []Hook
mutation *DockMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the DockUpdate builder.
func (_u *DockUpdate) Where(ps ...predicate.Dock) *DockUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetDockCode sets the "dockCode" field.
func (_u *DockUpdate) SetDockCode(v string) *DockUpdate {
_u.mutation.SetDockCode(v)
return _u
}
// SetNillableDockCode sets the "dockCode" field if the given value is not nil.
func (_u *DockUpdate) SetNillableDockCode(v *string) *DockUpdate {
if v != nil {
_u.SetDockCode(*v)
}
return _u
}
// SetName sets the "name" field.
func (_u *DockUpdate) SetName(v string) *DockUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *DockUpdate) SetNillableName(v *string) *DockUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDockType sets the "dockType" field.
func (_u *DockUpdate) SetDockType(v string) *DockUpdate {
_u.mutation.SetDockType(v)
return _u
}
// SetNillableDockType sets the "dockType" field if the given value is not nil.
func (_u *DockUpdate) SetNillableDockType(v *string) *DockUpdate {
if v != nil {
_u.SetDockType(*v)
}
return _u
}
// SetStationNo sets the "stationNo" field.
func (_u *DockUpdate) SetStationNo(v int) *DockUpdate {
_u.mutation.ResetStationNo()
_u.mutation.SetStationNo(v)
return _u
}
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
func (_u *DockUpdate) SetNillableStationNo(v *int) *DockUpdate {
if v != nil {
_u.SetStationNo(*v)
}
return _u
}
// AddStationNo adds value to the "stationNo" field.
func (_u *DockUpdate) AddStationNo(v int) *DockUpdate {
_u.mutation.AddStationNo(v)
return _u
}
// SetSide sets the "side" field.
func (_u *DockUpdate) SetSide(v string) *DockUpdate {
_u.mutation.SetSide(v)
return _u
}
// SetNillableSide sets the "side" field if the given value is not nil.
func (_u *DockUpdate) SetNillableSide(v *string) *DockUpdate {
if v != nil {
_u.SetSide(*v)
}
return _u
}
// SetHasPallet sets the "hasPallet" field.
func (_u *DockUpdate) SetHasPallet(v bool) *DockUpdate {
_u.mutation.SetHasPallet(v)
return _u
}
// SetNillableHasPallet sets the "hasPallet" field if the given value is not nil.
func (_u *DockUpdate) SetNillableHasPallet(v *bool) *DockUpdate {
if v != nil {
_u.SetHasPallet(*v)
}
return _u
}
// SetPalletRef sets the "palletRef" field.
func (_u *DockUpdate) SetPalletRef(v string) *DockUpdate {
_u.mutation.SetPalletRef(v)
return _u
}
// SetNillablePalletRef sets the "palletRef" field if the given value is not nil.
func (_u *DockUpdate) SetNillablePalletRef(v *string) *DockUpdate {
if v != nil {
_u.SetPalletRef(*v)
}
return _u
}
// ClearPalletRef clears the value of the "palletRef" field.
func (_u *DockUpdate) ClearPalletRef() *DockUpdate {
_u.mutation.ClearPalletRef()
return _u
}
// SetStatus sets the "status" field.
func (_u *DockUpdate) SetStatus(v string) *DockUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *DockUpdate) SetNillableStatus(v *string) *DockUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// Mutation returns the DockMutation object of the builder.
func (_u *DockUpdate) Mutation() *DockMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *DockUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *DockUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *DockUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *DockUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *DockUpdate) check() error {
if v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *DockUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DockUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *DockUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(dock.Table, dock.Columns, sqlgraph.NewFieldSpec(dock.FieldID, field.TypeInt))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.DockCode(); ok {
_spec.SetField(dock.FieldDockCode, field.TypeString, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(dock.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.DockType(); ok {
_spec.SetField(dock.FieldDockType, field.TypeString, value)
}
if value, ok := _u.mutation.StationNo(); ok {
_spec.SetField(dock.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedStationNo(); ok {
_spec.AddField(dock.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.Side(); ok {
_spec.SetField(dock.FieldSide, field.TypeString, value)
}
if value, ok := _u.mutation.HasPallet(); ok {
_spec.SetField(dock.FieldHasPallet, field.TypeBool, value)
}
if value, ok := _u.mutation.PalletRef(); ok {
_spec.SetField(dock.FieldPalletRef, field.TypeString, value)
}
if _u.mutation.PalletRefCleared() {
_spec.ClearField(dock.FieldPalletRef, field.TypeString)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(dock.FieldStatus, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{dock.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// DockUpdateOne is the builder for updating a single Dock entity.
type DockUpdateOne struct {
config
fields []string
hooks []Hook
mutation *DockMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetDockCode sets the "dockCode" field.
func (_u *DockUpdateOne) SetDockCode(v string) *DockUpdateOne {
_u.mutation.SetDockCode(v)
return _u
}
// SetNillableDockCode sets the "dockCode" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableDockCode(v *string) *DockUpdateOne {
if v != nil {
_u.SetDockCode(*v)
}
return _u
}
// SetName sets the "name" field.
func (_u *DockUpdateOne) SetName(v string) *DockUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableName(v *string) *DockUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDockType sets the "dockType" field.
func (_u *DockUpdateOne) SetDockType(v string) *DockUpdateOne {
_u.mutation.SetDockType(v)
return _u
}
// SetNillableDockType sets the "dockType" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableDockType(v *string) *DockUpdateOne {
if v != nil {
_u.SetDockType(*v)
}
return _u
}
// SetStationNo sets the "stationNo" field.
func (_u *DockUpdateOne) SetStationNo(v int) *DockUpdateOne {
_u.mutation.ResetStationNo()
_u.mutation.SetStationNo(v)
return _u
}
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableStationNo(v *int) *DockUpdateOne {
if v != nil {
_u.SetStationNo(*v)
}
return _u
}
// AddStationNo adds value to the "stationNo" field.
func (_u *DockUpdateOne) AddStationNo(v int) *DockUpdateOne {
_u.mutation.AddStationNo(v)
return _u
}
// SetSide sets the "side" field.
func (_u *DockUpdateOne) SetSide(v string) *DockUpdateOne {
_u.mutation.SetSide(v)
return _u
}
// SetNillableSide sets the "side" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableSide(v *string) *DockUpdateOne {
if v != nil {
_u.SetSide(*v)
}
return _u
}
// SetHasPallet sets the "hasPallet" field.
func (_u *DockUpdateOne) SetHasPallet(v bool) *DockUpdateOne {
_u.mutation.SetHasPallet(v)
return _u
}
// SetNillableHasPallet sets the "hasPallet" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableHasPallet(v *bool) *DockUpdateOne {
if v != nil {
_u.SetHasPallet(*v)
}
return _u
}
// SetPalletRef sets the "palletRef" field.
func (_u *DockUpdateOne) SetPalletRef(v string) *DockUpdateOne {
_u.mutation.SetPalletRef(v)
return _u
}
// SetNillablePalletRef sets the "palletRef" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillablePalletRef(v *string) *DockUpdateOne {
if v != nil {
_u.SetPalletRef(*v)
}
return _u
}
// ClearPalletRef clears the value of the "palletRef" field.
func (_u *DockUpdateOne) ClearPalletRef() *DockUpdateOne {
_u.mutation.ClearPalletRef()
return _u
}
// SetStatus sets the "status" field.
func (_u *DockUpdateOne) SetStatus(v string) *DockUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *DockUpdateOne) SetNillableStatus(v *string) *DockUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// Mutation returns the DockMutation object of the builder.
func (_u *DockUpdateOne) Mutation() *DockMutation {
return _u.mutation
}
// Where appends a list predicates to the DockUpdate builder.
func (_u *DockUpdateOne) Where(ps ...predicate.Dock) *DockUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *DockUpdateOne) Select(field string, fields ...string) *DockUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated Dock entity.
func (_u *DockUpdateOne) Save(ctx context.Context) (*Dock, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *DockUpdateOne) SaveX(ctx context.Context) *Dock {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *DockUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *DockUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *DockUpdateOne) check() error {
if v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *DockUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DockUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *DockUpdateOne) sqlSave(ctx context.Context) (_node *Dock, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(dock.Table, dock.Columns, sqlgraph.NewFieldSpec(dock.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Dock.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, dock.FieldID)
for _, f := range fields {
if !dock.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != dock.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.DockCode(); ok {
_spec.SetField(dock.FieldDockCode, field.TypeString, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(dock.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.DockType(); ok {
_spec.SetField(dock.FieldDockType, field.TypeString, value)
}
if value, ok := _u.mutation.StationNo(); ok {
_spec.SetField(dock.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedStationNo(); ok {
_spec.AddField(dock.FieldStationNo, field.TypeInt, value)
}
if value, ok := _u.mutation.Side(); ok {
_spec.SetField(dock.FieldSide, field.TypeString, value)
}
if value, ok := _u.mutation.HasPallet(); ok {
_spec.SetField(dock.FieldHasPallet, field.TypeBool, value)
}
if value, ok := _u.mutation.PalletRef(); ok {
_spec.SetField(dock.FieldPalletRef, field.TypeString, value)
}
if _u.mutation.PalletRefCleared() {
_spec.ClearField(dock.FieldPalletRef, field.TypeString)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(dock.FieldStatus, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &Dock{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{dock.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}