- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集) - 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList - 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损) - 新增 AGV 车辆状态表 agv_vehicle_state 及查询 - 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
472 lines
15 KiB
Go
472 lines
15 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/agvvehiclestate"
|
|
"bj_power_mes/ent/predicate"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// AgvVehicleStateUpdate is the builder for updating AgvVehicleState entities.
|
|
type AgvVehicleStateUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *AgvVehicleStateMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the AgvVehicleStateUpdate builder.
|
|
func (_u *AgvVehicleStateUpdate) Where(ps ...predicate.AgvVehicleState) *AgvVehicleStateUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetAgvCode sets the "agv_code" field.
|
|
func (_u *AgvVehicleStateUpdate) SetAgvCode(v string) *AgvVehicleStateUpdate {
|
|
_u.mutation.SetAgvCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAgvCode sets the "agv_code" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableAgvCode(v *string) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetAgvCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (_u *AgvVehicleStateUpdate) SetHasPallet(v bool) *AgvVehicleStateUpdate {
|
|
_u.mutation.SetHasPallet(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHasPallet sets the "has_pallet" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableHasPallet(v *bool) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetHasPallet(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSource sets the "source" field.
|
|
func (_u *AgvVehicleStateUpdate) SetSource(v string) *AgvVehicleStateUpdate {
|
|
_u.mutation.SetSource(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSource sets the "source" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableSource(v *string) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetSource(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedBy sets the "updated_by" field.
|
|
func (_u *AgvVehicleStateUpdate) SetUpdatedBy(v string) *AgvVehicleStateUpdate {
|
|
_u.mutation.SetUpdatedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableUpdatedBy(v *string) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetUpdatedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *AgvVehicleStateUpdate) SetUpdatedAt(v int64) *AgvVehicleStateUpdate {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableUpdatedAt(v *int64) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *AgvVehicleStateUpdate) AddUpdatedAt(v int64) *AgvVehicleStateUpdate {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *AgvVehicleStateUpdate) SetRemark(v string) *AgvVehicleStateUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdate) SetNillableRemark(v *string) *AgvVehicleStateUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the AgvVehicleStateMutation object of the builder.
|
|
func (_u *AgvVehicleStateUpdate) Mutation() *AgvVehicleStateMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *AgvVehicleStateUpdate) 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 *AgvVehicleStateUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *AgvVehicleStateUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgvVehicleStateUpdate) 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 *AgvVehicleStateUpdate) check() error {
|
|
if v, ok := _u.mutation.AgvCode(); ok {
|
|
if err := agvvehiclestate.AgvCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "agv_code", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.agv_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Source(); ok {
|
|
if err := agvvehiclestate.SourceValidator(v); err != nil {
|
|
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.source": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.UpdatedBy(); ok {
|
|
if err := agvvehiclestate.UpdatedByValidator(v); err != nil {
|
|
return &ValidationError{Name: "updated_by", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.updated_by": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := agvvehiclestate.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgvVehicleStateUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvVehicleStateUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgvVehicleStateUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agvvehiclestate.Table, agvvehiclestate.Columns, sqlgraph.NewFieldSpec(agvvehiclestate.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.AgvCode(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldAgvCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HasPallet(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldHasPallet, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Source(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldSource, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedBy(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldUpdatedBy, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(agvvehiclestate.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldRemark, 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{agvvehiclestate.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// AgvVehicleStateUpdateOne is the builder for updating a single AgvVehicleState entity.
|
|
type AgvVehicleStateUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *AgvVehicleStateMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetAgvCode sets the "agv_code" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetAgvCode(v string) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.SetAgvCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAgvCode sets the "agv_code" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableAgvCode(v *string) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetAgvCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHasPallet sets the "has_pallet" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetHasPallet(v bool) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.SetHasPallet(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHasPallet sets the "has_pallet" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableHasPallet(v *bool) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetHasPallet(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSource sets the "source" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetSource(v string) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.SetSource(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSource sets the "source" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableSource(v *string) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetSource(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedBy sets the "updated_by" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetUpdatedBy(v string) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.SetUpdatedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableUpdatedBy(v *string) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdatedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetUpdatedAt(v int64) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.ResetUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableUpdatedAt(v *int64) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddUpdatedAt adds value to the "updated_at" field.
|
|
func (_u *AgvVehicleStateUpdateOne) AddUpdatedAt(v int64) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.AddUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *AgvVehicleStateUpdateOne) SetRemark(v string) *AgvVehicleStateUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *AgvVehicleStateUpdateOne) SetNillableRemark(v *string) *AgvVehicleStateUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the AgvVehicleStateMutation object of the builder.
|
|
func (_u *AgvVehicleStateUpdateOne) Mutation() *AgvVehicleStateMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the AgvVehicleStateUpdate builder.
|
|
func (_u *AgvVehicleStateUpdateOne) Where(ps ...predicate.AgvVehicleState) *AgvVehicleStateUpdateOne {
|
|
_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 *AgvVehicleStateUpdateOne) Select(field string, fields ...string) *AgvVehicleStateUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated AgvVehicleState entity.
|
|
func (_u *AgvVehicleStateUpdateOne) Save(ctx context.Context) (*AgvVehicleState, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *AgvVehicleStateUpdateOne) SaveX(ctx context.Context) *AgvVehicleState {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *AgvVehicleStateUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgvVehicleStateUpdateOne) 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 *AgvVehicleStateUpdateOne) check() error {
|
|
if v, ok := _u.mutation.AgvCode(); ok {
|
|
if err := agvvehiclestate.AgvCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "agv_code", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.agv_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Source(); ok {
|
|
if err := agvvehiclestate.SourceValidator(v); err != nil {
|
|
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.source": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.UpdatedBy(); ok {
|
|
if err := agvvehiclestate.UpdatedByValidator(v); err != nil {
|
|
return &ValidationError{Name: "updated_by", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.updated_by": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := agvvehiclestate.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "AgvVehicleState.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgvVehicleStateUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvVehicleStateUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgvVehicleStateUpdateOne) sqlSave(ctx context.Context) (_node *AgvVehicleState, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agvvehiclestate.Table, agvvehiclestate.Columns, sqlgraph.NewFieldSpec(agvvehiclestate.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AgvVehicleState.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, agvvehiclestate.FieldID)
|
|
for _, f := range fields {
|
|
if !agvvehiclestate.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != agvvehiclestate.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.AgvCode(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldAgvCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HasPallet(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldHasPallet, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Source(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldSource, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedBy(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldUpdatedBy, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedUpdatedAt(); ok {
|
|
_spec.AddField(agvvehiclestate.FieldUpdatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(agvvehiclestate.FieldRemark, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &AgvVehicleState{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{agvvehiclestate.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|