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 散点, 清理修订痕迹为最终态描述。
1118 lines
34 KiB
Go
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
|
|
}
|
|
|
|
// SetHikTaskCode sets the "hik_task_code" field.
|
|
func (_u *AgvTaskUpdate) SetHikTaskCode(v string) *AgvTaskUpdate {
|
|
_u.mutation.SetHikTaskCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHikTaskCode sets the "hik_task_code" field if the given value is not nil.
|
|
func (_u *AgvTaskUpdate) SetNillableHikTaskCode(v *string) *AgvTaskUpdate {
|
|
if v != nil {
|
|
_u.SetHikTaskCode(*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
|
|
}
|
|
|
|
// 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.HikTaskCode(); ok {
|
|
if err := agvtask.HikTaskCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "hik_task_code", err: fmt.Errorf(`ent: validator failed for field "AgvTask.hik_task_code": %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.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.HikTaskCode(); ok {
|
|
_spec.SetField(agvtask.FieldHikTaskCode, 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.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
|
|
}
|
|
|
|
// SetHikTaskCode sets the "hik_task_code" field.
|
|
func (_u *AgvTaskUpdateOne) SetHikTaskCode(v string) *AgvTaskUpdateOne {
|
|
_u.mutation.SetHikTaskCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHikTaskCode sets the "hik_task_code" field if the given value is not nil.
|
|
func (_u *AgvTaskUpdateOne) SetNillableHikTaskCode(v *string) *AgvTaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetHikTaskCode(*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
|
|
}
|
|
|
|
// 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.HikTaskCode(); ok {
|
|
if err := agvtask.HikTaskCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "hik_task_code", err: fmt.Errorf(`ent: validator failed for field "AgvTask.hik_task_code": %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.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.HikTaskCode(); ok {
|
|
_spec.SetField(agvtask.FieldHikTaskCode, 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.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
|
|
}
|