Files
SunYF 5e2640c13a feat: AGV点位锁与缓存迁移 + 工位终端去离线队列 + WMS出入库增强
【MES】
- AGV点位/线路点位/AGV任务/工单 ent schema 重构(全量重生成 ent 代码)
- 新增派车锁 agv_point_lock.go:目标点位占用即拒车,JBT21 库房接驳台卸货后保持锁定待库管手动解锁
- 新增进程内 TTL 缓存 cache.go,由 Redis 看板缓存迁移至内存(singleflight 防击穿,去除外部依赖)
- AGV 三段链安全机制、车辆状态/接驳台左右互换、补料损耗闭环完善
- 来料检/工序卡/工单/质检/日排产/AGV 前端与帮助文档更新
- 新增 migrations/、sql/ 目录

【WMS】
- 出库、Excel 导出、物料、路由处理增强
- 配置与 DB 初始化调整;基础数据/成品入库/入库前端调整

【工位终端】
- 移除离线同步队列(syncer 包、sync.go、SyncQueueDialog.vue),改为实时直连上报 MES(断网即失败报错),以本人身份操作
- 本地 SQLite 仅保留操作日志 + 内置账号 + 登录态;保留空闲自动登出

【文档】
- 删除 AGV海康litev1.5.md;案例.md 更新
2026-11-07 15:06:00 +08:00

1118 lines
34 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/agvtask"
"bj_power_mes/ent/predicate"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// AgvTaskUpdate is the builder for updating AgvTask entities.
type AgvTaskUpdate struct {
config
hooks []Hook
mutation *AgvTaskMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the AgvTaskUpdate builder.
func (_u *AgvTaskUpdate) Where(ps ...predicate.AgvTask) *AgvTaskUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetTaskNo sets the "task_no" field.
func (_u *AgvTaskUpdate) SetTaskNo(v string) *AgvTaskUpdate {
_u.mutation.SetTaskNo(v)
return _u
}
// SetNillableTaskNo sets the "task_no" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableTaskNo(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetTaskNo(*v)
}
return _u
}
// SetSourceDock sets the "source_dock" field.
func (_u *AgvTaskUpdate) SetSourceDock(v string) *AgvTaskUpdate {
_u.mutation.SetSourceDock(v)
return _u
}
// SetNillableSourceDock sets the "source_dock" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableSourceDock(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetSourceDock(*v)
}
return _u
}
// SetTargetDock sets the "target_dock" field.
func (_u *AgvTaskUpdate) SetTargetDock(v string) *AgvTaskUpdate {
_u.mutation.SetTargetDock(v)
return _u
}
// SetNillableTargetDock sets the "target_dock" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableTargetDock(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetTargetDock(*v)
}
return _u
}
// SetMaterialsJSON sets the "materials_json" field.
func (_u *AgvTaskUpdate) SetMaterialsJSON(v string) *AgvTaskUpdate {
_u.mutation.SetMaterialsJSON(v)
return _u
}
// SetNillableMaterialsJSON sets the "materials_json" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableMaterialsJSON(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetMaterialsJSON(*v)
}
return _u
}
// SetRelatedRequestNo sets the "related_request_no" field.
func (_u *AgvTaskUpdate) SetRelatedRequestNo(v string) *AgvTaskUpdate {
_u.mutation.SetRelatedRequestNo(v)
return _u
}
// SetNillableRelatedRequestNo sets the "related_request_no" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableRelatedRequestNo(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetRelatedRequestNo(*v)
}
return _u
}
// ClearRelatedRequestNo clears the value of the "related_request_no" field.
func (_u *AgvTaskUpdate) ClearRelatedRequestNo() *AgvTaskUpdate {
_u.mutation.ClearRelatedRequestNo()
return _u
}
// SetRelatedOutboundNo sets the "related_outbound_no" field.
func (_u *AgvTaskUpdate) SetRelatedOutboundNo(v string) *AgvTaskUpdate {
_u.mutation.SetRelatedOutboundNo(v)
return _u
}
// SetNillableRelatedOutboundNo sets the "related_outbound_no" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableRelatedOutboundNo(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetRelatedOutboundNo(*v)
}
return _u
}
// ClearRelatedOutboundNo clears the value of the "related_outbound_no" field.
func (_u *AgvTaskUpdate) ClearRelatedOutboundNo() *AgvTaskUpdate {
_u.mutation.ClearRelatedOutboundNo()
return _u
}
// SetStatus sets the "status" field.
func (_u *AgvTaskUpdate) SetStatus(v string) *AgvTaskUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableStatus(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetKind sets the "kind" field.
func (_u *AgvTaskUpdate) SetKind(v string) *AgvTaskUpdate {
_u.mutation.SetKind(v)
return _u
}
// SetNillableKind sets the "kind" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableKind(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetKind(*v)
}
return _u
}
// SetBizType sets the "biz_type" field.
func (_u *AgvTaskUpdate) SetBizType(v string) *AgvTaskUpdate {
_u.mutation.SetBizType(v)
return _u
}
// SetNillableBizType sets the "biz_type" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableBizType(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetBizType(*v)
}
return _u
}
// SetBizNo sets the "biz_no" field.
func (_u *AgvTaskUpdate) SetBizNo(v string) *AgvTaskUpdate {
_u.mutation.SetBizNo(v)
return _u
}
// SetNillableBizNo sets the "biz_no" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableBizNo(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetBizNo(*v)
}
return _u
}
// SetTemplateType sets the "template_type" field.
func (_u *AgvTaskUpdate) SetTemplateType(v string) *AgvTaskUpdate {
_u.mutation.SetTemplateType(v)
return _u
}
// SetNillableTemplateType sets the "template_type" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableTemplateType(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetTemplateType(*v)
}
return _u
}
// SetChainNo sets the "chain_no" field.
func (_u *AgvTaskUpdate) SetChainNo(v string) *AgvTaskUpdate {
_u.mutation.SetChainNo(v)
return _u
}
// SetNillableChainNo sets the "chain_no" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableChainNo(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetChainNo(*v)
}
return _u
}
// SetAutoEnd sets the "auto_end" field.
func (_u *AgvTaskUpdate) SetAutoEnd(v bool) *AgvTaskUpdate {
_u.mutation.SetAutoEnd(v)
return _u
}
// SetNillableAutoEnd sets the "auto_end" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableAutoEnd(v *bool) *AgvTaskUpdate {
if v != nil {
_u.SetAutoEnd(*v)
}
return _u
}
// SetAgvCode sets the "agv_code" field.
func (_u *AgvTaskUpdate) SetAgvCode(v string) *AgvTaskUpdate {
_u.mutation.SetAgvCode(v)
return _u
}
// SetNillableAgvCode sets the "agv_code" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableAgvCode(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetAgvCode(*v)
}
return _u
}
// SetOperator sets the "operator" field.
func (_u *AgvTaskUpdate) SetOperator(v string) *AgvTaskUpdate {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableOperator(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// SetDispatchedAt sets the "dispatched_at" field.
func (_u *AgvTaskUpdate) SetDispatchedAt(v int64) *AgvTaskUpdate {
_u.mutation.ResetDispatchedAt()
_u.mutation.SetDispatchedAt(v)
return _u
}
// SetNillableDispatchedAt sets the "dispatched_at" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableDispatchedAt(v *int64) *AgvTaskUpdate {
if v != nil {
_u.SetDispatchedAt(*v)
}
return _u
}
// AddDispatchedAt adds value to the "dispatched_at" field.
func (_u *AgvTaskUpdate) AddDispatchedAt(v int64) *AgvTaskUpdate {
_u.mutation.AddDispatchedAt(v)
return _u
}
// SetArrivedAt sets the "arrived_at" field.
func (_u *AgvTaskUpdate) SetArrivedAt(v int64) *AgvTaskUpdate {
_u.mutation.ResetArrivedAt()
_u.mutation.SetArrivedAt(v)
return _u
}
// SetNillableArrivedAt sets the "arrived_at" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableArrivedAt(v *int64) *AgvTaskUpdate {
if v != nil {
_u.SetArrivedAt(*v)
}
return _u
}
// AddArrivedAt adds value to the "arrived_at" field.
func (_u *AgvTaskUpdate) AddArrivedAt(v int64) *AgvTaskUpdate {
_u.mutation.AddArrivedAt(v)
return _u
}
// SetRemark sets the "remark" field.
func (_u *AgvTaskUpdate) SetRemark(v string) *AgvTaskUpdate {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableRemark(v *string) *AgvTaskUpdate {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *AgvTaskUpdate) ClearRemark() *AgvTaskUpdate {
_u.mutation.ClearRemark()
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *AgvTaskUpdate) SetCreatedAt(v int64) *AgvTaskUpdate {
_u.mutation.ResetCreatedAt()
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *AgvTaskUpdate) SetNillableCreatedAt(v *int64) *AgvTaskUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// AddCreatedAt adds value to the "created_at" field.
func (_u *AgvTaskUpdate) AddCreatedAt(v int64) *AgvTaskUpdate {
_u.mutation.AddCreatedAt(v)
return _u
}
// Mutation returns the AgvTaskMutation object of the builder.
func (_u *AgvTaskUpdate) Mutation() *AgvTaskMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AgvTaskUpdate) 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 *AgvTaskUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AgvTaskUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AgvTaskUpdate) 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 *AgvTaskUpdate) check() error {
if v, ok := _u.mutation.TaskNo(); ok {
if err := agvtask.TaskNoValidator(v); err != nil {
return &ValidationError{Name: "task_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.task_no": %w`, err)}
}
}
if v, ok := _u.mutation.SourceDock(); ok {
if err := agvtask.SourceDockValidator(v); err != nil {
return &ValidationError{Name: "source_dock", err: fmt.Errorf(`ent: validator failed for field "AgvTask.source_dock": %w`, err)}
}
}
if v, ok := _u.mutation.TargetDock(); ok {
if err := agvtask.TargetDockValidator(v); err != nil {
return &ValidationError{Name: "target_dock", err: fmt.Errorf(`ent: validator failed for field "AgvTask.target_dock": %w`, err)}
}
}
if v, ok := _u.mutation.MaterialsJSON(); ok {
if err := agvtask.MaterialsJSONValidator(v); err != nil {
return &ValidationError{Name: "materials_json", err: fmt.Errorf(`ent: validator failed for field "AgvTask.materials_json": %w`, err)}
}
}
if v, ok := _u.mutation.RelatedRequestNo(); ok {
if err := agvtask.RelatedRequestNoValidator(v); err != nil {
return &ValidationError{Name: "related_request_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.related_request_no": %w`, err)}
}
}
if v, ok := _u.mutation.RelatedOutboundNo(); ok {
if err := agvtask.RelatedOutboundNoValidator(v); err != nil {
return &ValidationError{Name: "related_outbound_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.related_outbound_no": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := agvtask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "AgvTask.status": %w`, err)}
}
}
if v, ok := _u.mutation.Kind(); ok {
if err := agvtask.KindValidator(v); err != nil {
return &ValidationError{Name: "kind", err: fmt.Errorf(`ent: validator failed for field "AgvTask.kind": %w`, err)}
}
}
if v, ok := _u.mutation.BizType(); ok {
if err := agvtask.BizTypeValidator(v); err != nil {
return &ValidationError{Name: "biz_type", err: fmt.Errorf(`ent: validator failed for field "AgvTask.biz_type": %w`, err)}
}
}
if v, ok := _u.mutation.BizNo(); ok {
if err := agvtask.BizNoValidator(v); err != nil {
return &ValidationError{Name: "biz_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.biz_no": %w`, err)}
}
}
if v, ok := _u.mutation.TemplateType(); ok {
if err := agvtask.TemplateTypeValidator(v); err != nil {
return &ValidationError{Name: "template_type", err: fmt.Errorf(`ent: validator failed for field "AgvTask.template_type": %w`, err)}
}
}
if v, ok := _u.mutation.ChainNo(); ok {
if err := agvtask.ChainNoValidator(v); err != nil {
return &ValidationError{Name: "chain_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.chain_no": %w`, err)}
}
}
if v, ok := _u.mutation.AgvCode(); ok {
if err := agvtask.AgvCodeValidator(v); err != nil {
return &ValidationError{Name: "agv_code", err: fmt.Errorf(`ent: validator failed for field "AgvTask.agv_code": %w`, err)}
}
}
if v, ok := _u.mutation.Operator(); ok {
if err := agvtask.OperatorValidator(v); err != nil {
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "AgvTask.operator": %w`, err)}
}
}
if v, ok := _u.mutation.Remark(); ok {
if err := agvtask.RemarkValidator(v); err != nil {
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "AgvTask.remark": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *AgvTaskUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvTaskUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *AgvTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(agvtask.Table, agvtask.Columns, sqlgraph.NewFieldSpec(agvtask.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.TaskNo(); ok {
_spec.SetField(agvtask.FieldTaskNo, field.TypeString, value)
}
if value, ok := _u.mutation.SourceDock(); ok {
_spec.SetField(agvtask.FieldSourceDock, field.TypeString, value)
}
if value, ok := _u.mutation.TargetDock(); ok {
_spec.SetField(agvtask.FieldTargetDock, field.TypeString, value)
}
if value, ok := _u.mutation.MaterialsJSON(); ok {
_spec.SetField(agvtask.FieldMaterialsJSON, field.TypeString, value)
}
if value, ok := _u.mutation.RelatedRequestNo(); ok {
_spec.SetField(agvtask.FieldRelatedRequestNo, field.TypeString, value)
}
if _u.mutation.RelatedRequestNoCleared() {
_spec.ClearField(agvtask.FieldRelatedRequestNo, field.TypeString)
}
if value, ok := _u.mutation.RelatedOutboundNo(); ok {
_spec.SetField(agvtask.FieldRelatedOutboundNo, field.TypeString, value)
}
if _u.mutation.RelatedOutboundNoCleared() {
_spec.ClearField(agvtask.FieldRelatedOutboundNo, field.TypeString)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(agvtask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Kind(); ok {
_spec.SetField(agvtask.FieldKind, field.TypeString, value)
}
if value, ok := _u.mutation.BizType(); ok {
_spec.SetField(agvtask.FieldBizType, field.TypeString, value)
}
if value, ok := _u.mutation.BizNo(); ok {
_spec.SetField(agvtask.FieldBizNo, field.TypeString, value)
}
if value, ok := _u.mutation.TemplateType(); ok {
_spec.SetField(agvtask.FieldTemplateType, field.TypeString, value)
}
if value, ok := _u.mutation.ChainNo(); ok {
_spec.SetField(agvtask.FieldChainNo, field.TypeString, value)
}
if value, ok := _u.mutation.AutoEnd(); ok {
_spec.SetField(agvtask.FieldAutoEnd, field.TypeBool, value)
}
if value, ok := _u.mutation.AgvCode(); ok {
_spec.SetField(agvtask.FieldAgvCode, field.TypeString, value)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(agvtask.FieldOperator, field.TypeString, value)
}
if value, ok := _u.mutation.DispatchedAt(); ok {
_spec.SetField(agvtask.FieldDispatchedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedDispatchedAt(); ok {
_spec.AddField(agvtask.FieldDispatchedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.ArrivedAt(); ok {
_spec.SetField(agvtask.FieldArrivedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedArrivedAt(); ok {
_spec.AddField(agvtask.FieldArrivedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(agvtask.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(agvtask.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(agvtask.FieldCreatedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedCreatedAt(); ok {
_spec.AddField(agvtask.FieldCreatedAt, field.TypeInt64, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{agvtask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AgvTaskUpdateOne is the builder for updating a single AgvTask entity.
type AgvTaskUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AgvTaskMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetTaskNo sets the "task_no" field.
func (_u *AgvTaskUpdateOne) SetTaskNo(v string) *AgvTaskUpdateOne {
_u.mutation.SetTaskNo(v)
return _u
}
// SetNillableTaskNo sets the "task_no" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableTaskNo(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetTaskNo(*v)
}
return _u
}
// SetSourceDock sets the "source_dock" field.
func (_u *AgvTaskUpdateOne) SetSourceDock(v string) *AgvTaskUpdateOne {
_u.mutation.SetSourceDock(v)
return _u
}
// SetNillableSourceDock sets the "source_dock" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableSourceDock(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetSourceDock(*v)
}
return _u
}
// SetTargetDock sets the "target_dock" field.
func (_u *AgvTaskUpdateOne) SetTargetDock(v string) *AgvTaskUpdateOne {
_u.mutation.SetTargetDock(v)
return _u
}
// SetNillableTargetDock sets the "target_dock" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableTargetDock(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetTargetDock(*v)
}
return _u
}
// SetMaterialsJSON sets the "materials_json" field.
func (_u *AgvTaskUpdateOne) SetMaterialsJSON(v string) *AgvTaskUpdateOne {
_u.mutation.SetMaterialsJSON(v)
return _u
}
// SetNillableMaterialsJSON sets the "materials_json" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableMaterialsJSON(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetMaterialsJSON(*v)
}
return _u
}
// SetRelatedRequestNo sets the "related_request_no" field.
func (_u *AgvTaskUpdateOne) SetRelatedRequestNo(v string) *AgvTaskUpdateOne {
_u.mutation.SetRelatedRequestNo(v)
return _u
}
// SetNillableRelatedRequestNo sets the "related_request_no" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableRelatedRequestNo(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetRelatedRequestNo(*v)
}
return _u
}
// ClearRelatedRequestNo clears the value of the "related_request_no" field.
func (_u *AgvTaskUpdateOne) ClearRelatedRequestNo() *AgvTaskUpdateOne {
_u.mutation.ClearRelatedRequestNo()
return _u
}
// SetRelatedOutboundNo sets the "related_outbound_no" field.
func (_u *AgvTaskUpdateOne) SetRelatedOutboundNo(v string) *AgvTaskUpdateOne {
_u.mutation.SetRelatedOutboundNo(v)
return _u
}
// SetNillableRelatedOutboundNo sets the "related_outbound_no" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableRelatedOutboundNo(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetRelatedOutboundNo(*v)
}
return _u
}
// ClearRelatedOutboundNo clears the value of the "related_outbound_no" field.
func (_u *AgvTaskUpdateOne) ClearRelatedOutboundNo() *AgvTaskUpdateOne {
_u.mutation.ClearRelatedOutboundNo()
return _u
}
// SetStatus sets the "status" field.
func (_u *AgvTaskUpdateOne) SetStatus(v string) *AgvTaskUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableStatus(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetKind sets the "kind" field.
func (_u *AgvTaskUpdateOne) SetKind(v string) *AgvTaskUpdateOne {
_u.mutation.SetKind(v)
return _u
}
// SetNillableKind sets the "kind" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableKind(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetKind(*v)
}
return _u
}
// SetBizType sets the "biz_type" field.
func (_u *AgvTaskUpdateOne) SetBizType(v string) *AgvTaskUpdateOne {
_u.mutation.SetBizType(v)
return _u
}
// SetNillableBizType sets the "biz_type" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableBizType(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetBizType(*v)
}
return _u
}
// SetBizNo sets the "biz_no" field.
func (_u *AgvTaskUpdateOne) SetBizNo(v string) *AgvTaskUpdateOne {
_u.mutation.SetBizNo(v)
return _u
}
// SetNillableBizNo sets the "biz_no" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableBizNo(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetBizNo(*v)
}
return _u
}
// SetTemplateType sets the "template_type" field.
func (_u *AgvTaskUpdateOne) SetTemplateType(v string) *AgvTaskUpdateOne {
_u.mutation.SetTemplateType(v)
return _u
}
// SetNillableTemplateType sets the "template_type" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableTemplateType(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetTemplateType(*v)
}
return _u
}
// SetChainNo sets the "chain_no" field.
func (_u *AgvTaskUpdateOne) SetChainNo(v string) *AgvTaskUpdateOne {
_u.mutation.SetChainNo(v)
return _u
}
// SetNillableChainNo sets the "chain_no" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableChainNo(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetChainNo(*v)
}
return _u
}
// SetAutoEnd sets the "auto_end" field.
func (_u *AgvTaskUpdateOne) SetAutoEnd(v bool) *AgvTaskUpdateOne {
_u.mutation.SetAutoEnd(v)
return _u
}
// SetNillableAutoEnd sets the "auto_end" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableAutoEnd(v *bool) *AgvTaskUpdateOne {
if v != nil {
_u.SetAutoEnd(*v)
}
return _u
}
// SetAgvCode sets the "agv_code" field.
func (_u *AgvTaskUpdateOne) SetAgvCode(v string) *AgvTaskUpdateOne {
_u.mutation.SetAgvCode(v)
return _u
}
// SetNillableAgvCode sets the "agv_code" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableAgvCode(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetAgvCode(*v)
}
return _u
}
// SetOperator sets the "operator" field.
func (_u *AgvTaskUpdateOne) SetOperator(v string) *AgvTaskUpdateOne {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableOperator(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// SetDispatchedAt sets the "dispatched_at" field.
func (_u *AgvTaskUpdateOne) SetDispatchedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.ResetDispatchedAt()
_u.mutation.SetDispatchedAt(v)
return _u
}
// SetNillableDispatchedAt sets the "dispatched_at" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableDispatchedAt(v *int64) *AgvTaskUpdateOne {
if v != nil {
_u.SetDispatchedAt(*v)
}
return _u
}
// AddDispatchedAt adds value to the "dispatched_at" field.
func (_u *AgvTaskUpdateOne) AddDispatchedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.AddDispatchedAt(v)
return _u
}
// SetArrivedAt sets the "arrived_at" field.
func (_u *AgvTaskUpdateOne) SetArrivedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.ResetArrivedAt()
_u.mutation.SetArrivedAt(v)
return _u
}
// SetNillableArrivedAt sets the "arrived_at" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableArrivedAt(v *int64) *AgvTaskUpdateOne {
if v != nil {
_u.SetArrivedAt(*v)
}
return _u
}
// AddArrivedAt adds value to the "arrived_at" field.
func (_u *AgvTaskUpdateOne) AddArrivedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.AddArrivedAt(v)
return _u
}
// SetRemark sets the "remark" field.
func (_u *AgvTaskUpdateOne) SetRemark(v string) *AgvTaskUpdateOne {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableRemark(v *string) *AgvTaskUpdateOne {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *AgvTaskUpdateOne) ClearRemark() *AgvTaskUpdateOne {
_u.mutation.ClearRemark()
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *AgvTaskUpdateOne) SetCreatedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.ResetCreatedAt()
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *AgvTaskUpdateOne) SetNillableCreatedAt(v *int64) *AgvTaskUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// AddCreatedAt adds value to the "created_at" field.
func (_u *AgvTaskUpdateOne) AddCreatedAt(v int64) *AgvTaskUpdateOne {
_u.mutation.AddCreatedAt(v)
return _u
}
// Mutation returns the AgvTaskMutation object of the builder.
func (_u *AgvTaskUpdateOne) Mutation() *AgvTaskMutation {
return _u.mutation
}
// Where appends a list predicates to the AgvTaskUpdate builder.
func (_u *AgvTaskUpdateOne) Where(ps ...predicate.AgvTask) *AgvTaskUpdateOne {
_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 *AgvTaskUpdateOne) Select(field string, fields ...string) *AgvTaskUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AgvTask entity.
func (_u *AgvTaskUpdateOne) Save(ctx context.Context) (*AgvTask, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AgvTaskUpdateOne) SaveX(ctx context.Context) *AgvTask {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AgvTaskUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AgvTaskUpdateOne) 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 *AgvTaskUpdateOne) check() error {
if v, ok := _u.mutation.TaskNo(); ok {
if err := agvtask.TaskNoValidator(v); err != nil {
return &ValidationError{Name: "task_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.task_no": %w`, err)}
}
}
if v, ok := _u.mutation.SourceDock(); ok {
if err := agvtask.SourceDockValidator(v); err != nil {
return &ValidationError{Name: "source_dock", err: fmt.Errorf(`ent: validator failed for field "AgvTask.source_dock": %w`, err)}
}
}
if v, ok := _u.mutation.TargetDock(); ok {
if err := agvtask.TargetDockValidator(v); err != nil {
return &ValidationError{Name: "target_dock", err: fmt.Errorf(`ent: validator failed for field "AgvTask.target_dock": %w`, err)}
}
}
if v, ok := _u.mutation.MaterialsJSON(); ok {
if err := agvtask.MaterialsJSONValidator(v); err != nil {
return &ValidationError{Name: "materials_json", err: fmt.Errorf(`ent: validator failed for field "AgvTask.materials_json": %w`, err)}
}
}
if v, ok := _u.mutation.RelatedRequestNo(); ok {
if err := agvtask.RelatedRequestNoValidator(v); err != nil {
return &ValidationError{Name: "related_request_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.related_request_no": %w`, err)}
}
}
if v, ok := _u.mutation.RelatedOutboundNo(); ok {
if err := agvtask.RelatedOutboundNoValidator(v); err != nil {
return &ValidationError{Name: "related_outbound_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.related_outbound_no": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := agvtask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "AgvTask.status": %w`, err)}
}
}
if v, ok := _u.mutation.Kind(); ok {
if err := agvtask.KindValidator(v); err != nil {
return &ValidationError{Name: "kind", err: fmt.Errorf(`ent: validator failed for field "AgvTask.kind": %w`, err)}
}
}
if v, ok := _u.mutation.BizType(); ok {
if err := agvtask.BizTypeValidator(v); err != nil {
return &ValidationError{Name: "biz_type", err: fmt.Errorf(`ent: validator failed for field "AgvTask.biz_type": %w`, err)}
}
}
if v, ok := _u.mutation.BizNo(); ok {
if err := agvtask.BizNoValidator(v); err != nil {
return &ValidationError{Name: "biz_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.biz_no": %w`, err)}
}
}
if v, ok := _u.mutation.TemplateType(); ok {
if err := agvtask.TemplateTypeValidator(v); err != nil {
return &ValidationError{Name: "template_type", err: fmt.Errorf(`ent: validator failed for field "AgvTask.template_type": %w`, err)}
}
}
if v, ok := _u.mutation.ChainNo(); ok {
if err := agvtask.ChainNoValidator(v); err != nil {
return &ValidationError{Name: "chain_no", err: fmt.Errorf(`ent: validator failed for field "AgvTask.chain_no": %w`, err)}
}
}
if v, ok := _u.mutation.AgvCode(); ok {
if err := agvtask.AgvCodeValidator(v); err != nil {
return &ValidationError{Name: "agv_code", err: fmt.Errorf(`ent: validator failed for field "AgvTask.agv_code": %w`, err)}
}
}
if v, ok := _u.mutation.Operator(); ok {
if err := agvtask.OperatorValidator(v); err != nil {
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "AgvTask.operator": %w`, err)}
}
}
if v, ok := _u.mutation.Remark(); ok {
if err := agvtask.RemarkValidator(v); err != nil {
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "AgvTask.remark": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *AgvTaskUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgvTaskUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *AgvTaskUpdateOne) sqlSave(ctx context.Context) (_node *AgvTask, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(agvtask.Table, agvtask.Columns, sqlgraph.NewFieldSpec(agvtask.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AgvTask.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, agvtask.FieldID)
for _, f := range fields {
if !agvtask.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != agvtask.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.TaskNo(); ok {
_spec.SetField(agvtask.FieldTaskNo, field.TypeString, value)
}
if value, ok := _u.mutation.SourceDock(); ok {
_spec.SetField(agvtask.FieldSourceDock, field.TypeString, value)
}
if value, ok := _u.mutation.TargetDock(); ok {
_spec.SetField(agvtask.FieldTargetDock, field.TypeString, value)
}
if value, ok := _u.mutation.MaterialsJSON(); ok {
_spec.SetField(agvtask.FieldMaterialsJSON, field.TypeString, value)
}
if value, ok := _u.mutation.RelatedRequestNo(); ok {
_spec.SetField(agvtask.FieldRelatedRequestNo, field.TypeString, value)
}
if _u.mutation.RelatedRequestNoCleared() {
_spec.ClearField(agvtask.FieldRelatedRequestNo, field.TypeString)
}
if value, ok := _u.mutation.RelatedOutboundNo(); ok {
_spec.SetField(agvtask.FieldRelatedOutboundNo, field.TypeString, value)
}
if _u.mutation.RelatedOutboundNoCleared() {
_spec.ClearField(agvtask.FieldRelatedOutboundNo, field.TypeString)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(agvtask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Kind(); ok {
_spec.SetField(agvtask.FieldKind, field.TypeString, value)
}
if value, ok := _u.mutation.BizType(); ok {
_spec.SetField(agvtask.FieldBizType, field.TypeString, value)
}
if value, ok := _u.mutation.BizNo(); ok {
_spec.SetField(agvtask.FieldBizNo, field.TypeString, value)
}
if value, ok := _u.mutation.TemplateType(); ok {
_spec.SetField(agvtask.FieldTemplateType, field.TypeString, value)
}
if value, ok := _u.mutation.ChainNo(); ok {
_spec.SetField(agvtask.FieldChainNo, field.TypeString, value)
}
if value, ok := _u.mutation.AutoEnd(); ok {
_spec.SetField(agvtask.FieldAutoEnd, field.TypeBool, value)
}
if value, ok := _u.mutation.AgvCode(); ok {
_spec.SetField(agvtask.FieldAgvCode, field.TypeString, value)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(agvtask.FieldOperator, field.TypeString, value)
}
if value, ok := _u.mutation.DispatchedAt(); ok {
_spec.SetField(agvtask.FieldDispatchedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedDispatchedAt(); ok {
_spec.AddField(agvtask.FieldDispatchedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.ArrivedAt(); ok {
_spec.SetField(agvtask.FieldArrivedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedArrivedAt(); ok {
_spec.AddField(agvtask.FieldArrivedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(agvtask.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(agvtask.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(agvtask.FieldCreatedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedCreatedAt(); ok {
_spec.AddField(agvtask.FieldCreatedAt, field.TypeInt64, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &AgvTask{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{agvtask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}