一、AGV 挂起动作引擎(弃显式任务队列、弃并发硬拒) - 新增 internal/logic/agv_pending.go:待发动作直接挂任务(pending_action + pending_since), CONTINUE_LIFT(举升完成→continueTask#1)/ WAIT_DROP_CONFIRM(人工确认放下→continueTask#2) / FREE_ROBOT(末组完成→freeRobot);系统动作超 60s 未触发转预警人工重试,绝不自动重发 - Client 新增 ContinueTask(RCS 2.1.2) / FreeRobot(3.1.2),仅点名释放指定车,禁止释放全部 - agv_task 增 pending_action/pending_since 字段,ent 重生成 + db.go 幂等迁移补丁 + migrateonce - 回调按 B01/B02/C01 模板编排:业务流转到位即自动放行放下、回调自动放车; 仅人工派车(MANUAL)挂 WAIT_DROP_CONFIRM;新增 /agv/confirm-drop、/agv/pending/retry - 前端 AgvManual/Agv 确认放下、挂起重试按钮与等待提示联动 二、智能跟车 + 动态目标截断流转引擎 - 新增 internal/logic/flow_engine.go:事件驱动(报工/扫码),读 48 位物理快照,从下游往上游算, 前方占用则动态截断到最近空闲缓存位;IN_TRANSIT 在途闭锁防重复下发,MW=0 才确认到位落台账; 主线占用=台账 OR 传感器,工位 G 位只认台账;在途超 5s 落预警 - workpiece 增 flow_transit_mw/target/at 字段,ent 重生成 + 迁移补丁 三、PLC 读取优化与诊断 - 新增 internal/plc/snapshot_cache.go:2s TTL + singleflight + 写失效,合并 SSE/PLC监控/流转引擎 的重复点位读取;tcp.go 读块重构、localip.go 多网卡、plcdiag 诊断工具、plc_monitor/logging 配套 四、文档与前端 - help.js 重写「工位下发」帮助:明确报工自动驱动流转 vs 下发路线码的定位、缺料/握手/撤回边界 - 案例.md 补充定稿说明;public/index.html 构建指纹更新
1013 lines
31 KiB
Go
1013 lines
31 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/predicate"
|
|
"bj_power_mes/ent/workpiece"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// WorkpieceUpdate is the builder for updating Workpiece entities.
|
|
type WorkpieceUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *WorkpieceMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the WorkpieceUpdate builder.
|
|
func (_u *WorkpieceUpdate) Where(ps ...predicate.Workpiece) *WorkpieceUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetSn sets the "sn" field.
|
|
func (_u *WorkpieceUpdate) SetSn(v string) *WorkpieceUpdate {
|
|
_u.mutation.SetSn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSn sets the "sn" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableSn(v *string) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetSn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOrderNo sets the "orderNo" field.
|
|
func (_u *WorkpieceUpdate) SetOrderNo(v string) *WorkpieceUpdate {
|
|
_u.mutation.SetOrderNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableOrderNo(v *string) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetOrderNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWorkOrderId sets the "workOrderId" field.
|
|
func (_u *WorkpieceUpdate) SetWorkOrderId(v int) *WorkpieceUpdate {
|
|
_u.mutation.ResetWorkOrderId()
|
|
_u.mutation.SetWorkOrderId(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWorkOrderId sets the "workOrderId" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableWorkOrderId(v *int) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetWorkOrderId(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddWorkOrderId adds value to the "workOrderId" field.
|
|
func (_u *WorkpieceUpdate) AddWorkOrderId(v int) *WorkpieceUpdate {
|
|
_u.mutation.AddWorkOrderId(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearWorkOrderId clears the value of the "workOrderId" field.
|
|
func (_u *WorkpieceUpdate) ClearWorkOrderId() *WorkpieceUpdate {
|
|
_u.mutation.ClearWorkOrderId()
|
|
return _u
|
|
}
|
|
|
|
// SetCurrentStationNo sets the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdate) SetCurrentStationNo(v int) *WorkpieceUpdate {
|
|
_u.mutation.ResetCurrentStationNo()
|
|
_u.mutation.SetCurrentStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCurrentStationNo sets the "currentStationNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableCurrentStationNo(v *int) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetCurrentStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCurrentStationNo adds value to the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdate) AddCurrentStationNo(v int) *WorkpieceUpdate {
|
|
_u.mutation.AddCurrentStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCurrentStationNo clears the value of the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdate) ClearCurrentStationNo() *WorkpieceUpdate {
|
|
_u.mutation.ClearCurrentStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetAtStationNo sets the "atStationNo" field.
|
|
func (_u *WorkpieceUpdate) SetAtStationNo(v int) *WorkpieceUpdate {
|
|
_u.mutation.ResetAtStationNo()
|
|
_u.mutation.SetAtStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAtStationNo sets the "atStationNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableAtStationNo(v *int) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetAtStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAtStationNo adds value to the "atStationNo" field.
|
|
func (_u *WorkpieceUpdate) AddAtStationNo(v int) *WorkpieceUpdate {
|
|
_u.mutation.AddAtStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAtStationNo clears the value of the "atStationNo" field.
|
|
func (_u *WorkpieceUpdate) ClearAtStationNo() *WorkpieceUpdate {
|
|
_u.mutation.ClearAtStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *WorkpieceUpdate) SetStatus(v string) *WorkpieceUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableStatus(v *string) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOnlineAt sets the "onlineAt" field.
|
|
func (_u *WorkpieceUpdate) SetOnlineAt(v time.Time) *WorkpieceUpdate {
|
|
_u.mutation.SetOnlineAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOnlineAt sets the "onlineAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableOnlineAt(v *time.Time) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetOnlineAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOnlineAt clears the value of the "onlineAt" field.
|
|
func (_u *WorkpieceUpdate) ClearOnlineAt() *WorkpieceUpdate {
|
|
_u.mutation.ClearOnlineAt()
|
|
return _u
|
|
}
|
|
|
|
// SetDoneAt sets the "doneAt" field.
|
|
func (_u *WorkpieceUpdate) SetDoneAt(v time.Time) *WorkpieceUpdate {
|
|
_u.mutation.SetDoneAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDoneAt sets the "doneAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableDoneAt(v *time.Time) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetDoneAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDoneAt clears the value of the "doneAt" field.
|
|
func (_u *WorkpieceUpdate) ClearDoneAt() *WorkpieceUpdate {
|
|
_u.mutation.ClearDoneAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updatedAt" field.
|
|
func (_u *WorkpieceUpdate) SetUpdatedAt(v time.Time) *WorkpieceUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
|
func (_u *WorkpieceUpdate) ClearUpdatedAt() *WorkpieceUpdate {
|
|
_u.mutation.ClearUpdatedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgPending sets the "torque_ng_pending" field.
|
|
func (_u *WorkpieceUpdate) SetTorqueNgPending(v bool) *WorkpieceUpdate {
|
|
_u.mutation.SetTorqueNgPending(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgPending sets the "torque_ng_pending" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableTorqueNgPending(v *bool) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetTorqueNgPending(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgAt sets the "torque_ng_at" field.
|
|
func (_u *WorkpieceUpdate) SetTorqueNgAt(v time.Time) *WorkpieceUpdate {
|
|
_u.mutation.SetTorqueNgAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgAt sets the "torque_ng_at" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableTorqueNgAt(v *time.Time) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetTorqueNgAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTorqueNgAt clears the value of the "torque_ng_at" field.
|
|
func (_u *WorkpieceUpdate) ClearTorqueNgAt() *WorkpieceUpdate {
|
|
_u.mutation.ClearTorqueNgAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgBy sets the "torque_ng_by" field.
|
|
func (_u *WorkpieceUpdate) SetTorqueNgBy(v string) *WorkpieceUpdate {
|
|
_u.mutation.SetTorqueNgBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgBy sets the "torque_ng_by" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableTorqueNgBy(v *string) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetTorqueNgBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTorqueNgBy clears the value of the "torque_ng_by" field.
|
|
func (_u *WorkpieceUpdate) ClearTorqueNgBy() *WorkpieceUpdate {
|
|
_u.mutation.ClearTorqueNgBy()
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitMW sets the "flowTransitMW" field.
|
|
func (_u *WorkpieceUpdate) SetFlowTransitMW(v int) *WorkpieceUpdate {
|
|
_u.mutation.ResetFlowTransitMW()
|
|
_u.mutation.SetFlowTransitMW(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitMW sets the "flowTransitMW" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableFlowTransitMW(v *int) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetFlowTransitMW(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFlowTransitMW adds value to the "flowTransitMW" field.
|
|
func (_u *WorkpieceUpdate) AddFlowTransitMW(v int) *WorkpieceUpdate {
|
|
_u.mutation.AddFlowTransitMW(v)
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitTarget sets the "flowTransitTarget" field.
|
|
func (_u *WorkpieceUpdate) SetFlowTransitTarget(v string) *WorkpieceUpdate {
|
|
_u.mutation.SetFlowTransitTarget(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitTarget sets the "flowTransitTarget" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableFlowTransitTarget(v *string) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetFlowTransitTarget(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitAt sets the "flowTransitAt" field.
|
|
func (_u *WorkpieceUpdate) SetFlowTransitAt(v time.Time) *WorkpieceUpdate {
|
|
_u.mutation.SetFlowTransitAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitAt sets the "flowTransitAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdate) SetNillableFlowTransitAt(v *time.Time) *WorkpieceUpdate {
|
|
if v != nil {
|
|
_u.SetFlowTransitAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearFlowTransitAt clears the value of the "flowTransitAt" field.
|
|
func (_u *WorkpieceUpdate) ClearFlowTransitAt() *WorkpieceUpdate {
|
|
_u.mutation.ClearFlowTransitAt()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the WorkpieceMutation object of the builder.
|
|
func (_u *WorkpieceUpdate) Mutation() *WorkpieceMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *WorkpieceUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *WorkpieceUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *WorkpieceUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *WorkpieceUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *WorkpieceUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
|
v := workpiece.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *WorkpieceUpdate) check() error {
|
|
if v, ok := _u.mutation.Sn(); ok {
|
|
if err := workpiece.SnValidator(v); err != nil {
|
|
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "Workpiece.sn": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.OrderNo(); ok {
|
|
if err := workpiece.OrderNoValidator(v); err != nil {
|
|
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "Workpiece.orderNo": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := workpiece.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Workpiece.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.TorqueNgBy(); ok {
|
|
if err := workpiece.TorqueNgByValidator(v); err != nil {
|
|
return &ValidationError{Name: "torque_ng_by", err: fmt.Errorf(`ent: validator failed for field "Workpiece.torque_ng_by": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.FlowTransitTarget(); ok {
|
|
if err := workpiece.FlowTransitTargetValidator(v); err != nil {
|
|
return &ValidationError{Name: "flowTransitTarget", err: fmt.Errorf(`ent: validator failed for field "Workpiece.flowTransitTarget": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *WorkpieceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *WorkpieceUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(workpiece.Table, workpiece.Columns, sqlgraph.NewFieldSpec(workpiece.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.Sn(); ok {
|
|
_spec.SetField(workpiece.FieldSn, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.OrderNo(); ok {
|
|
_spec.SetField(workpiece.FieldOrderNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.WorkOrderId(); ok {
|
|
_spec.SetField(workpiece.FieldWorkOrderId, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedWorkOrderId(); ok {
|
|
_spec.AddField(workpiece.FieldWorkOrderId, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.WorkOrderIdCleared() {
|
|
_spec.ClearField(workpiece.FieldWorkOrderId, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.CurrentStationNo(); ok {
|
|
_spec.SetField(workpiece.FieldCurrentStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCurrentStationNo(); ok {
|
|
_spec.AddField(workpiece.FieldCurrentStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.CurrentStationNoCleared() {
|
|
_spec.ClearField(workpiece.FieldCurrentStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.AtStationNo(); ok {
|
|
_spec.SetField(workpiece.FieldAtStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAtStationNo(); ok {
|
|
_spec.AddField(workpiece.FieldAtStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.AtStationNoCleared() {
|
|
_spec.ClearField(workpiece.FieldAtStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(workpiece.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.OnlineAt(); ok {
|
|
_spec.SetField(workpiece.FieldOnlineAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.OnlineAtCleared() {
|
|
_spec.ClearField(workpiece.FieldOnlineAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.DoneAt(); ok {
|
|
_spec.SetField(workpiece.FieldDoneAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DoneAtCleared() {
|
|
_spec.ClearField(workpiece.FieldDoneAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(workpiece.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdatedAtCleared() {
|
|
_spec.ClearField(workpiece.FieldUpdatedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgPending(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgPending, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgAt(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.TorqueNgAtCleared() {
|
|
_spec.ClearField(workpiece.FieldTorqueNgAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgBy(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgBy, field.TypeString, value)
|
|
}
|
|
if _u.mutation.TorqueNgByCleared() {
|
|
_spec.ClearField(workpiece.FieldTorqueNgBy, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitMW(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFlowTransitMW(); ok {
|
|
_spec.AddField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitTarget(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitTarget, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitAt(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.FlowTransitAtCleared() {
|
|
_spec.ClearField(workpiece.FieldFlowTransitAt, field.TypeTime)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{workpiece.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// WorkpieceUpdateOne is the builder for updating a single Workpiece entity.
|
|
type WorkpieceUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *WorkpieceMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetSn sets the "sn" field.
|
|
func (_u *WorkpieceUpdateOne) SetSn(v string) *WorkpieceUpdateOne {
|
|
_u.mutation.SetSn(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSn sets the "sn" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableSn(v *string) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetSn(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOrderNo sets the "orderNo" field.
|
|
func (_u *WorkpieceUpdateOne) SetOrderNo(v string) *WorkpieceUpdateOne {
|
|
_u.mutation.SetOrderNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderNo sets the "orderNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableOrderNo(v *string) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetOrderNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWorkOrderId sets the "workOrderId" field.
|
|
func (_u *WorkpieceUpdateOne) SetWorkOrderId(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.ResetWorkOrderId()
|
|
_u.mutation.SetWorkOrderId(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWorkOrderId sets the "workOrderId" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableWorkOrderId(v *int) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetWorkOrderId(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddWorkOrderId adds value to the "workOrderId" field.
|
|
func (_u *WorkpieceUpdateOne) AddWorkOrderId(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.AddWorkOrderId(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearWorkOrderId clears the value of the "workOrderId" field.
|
|
func (_u *WorkpieceUpdateOne) ClearWorkOrderId() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearWorkOrderId()
|
|
return _u
|
|
}
|
|
|
|
// SetCurrentStationNo sets the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) SetCurrentStationNo(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.ResetCurrentStationNo()
|
|
_u.mutation.SetCurrentStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCurrentStationNo sets the "currentStationNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableCurrentStationNo(v *int) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetCurrentStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCurrentStationNo adds value to the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) AddCurrentStationNo(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.AddCurrentStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCurrentStationNo clears the value of the "currentStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) ClearCurrentStationNo() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearCurrentStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetAtStationNo sets the "atStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) SetAtStationNo(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.ResetAtStationNo()
|
|
_u.mutation.SetAtStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAtStationNo sets the "atStationNo" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableAtStationNo(v *int) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetAtStationNo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAtStationNo adds value to the "atStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) AddAtStationNo(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.AddAtStationNo(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAtStationNo clears the value of the "atStationNo" field.
|
|
func (_u *WorkpieceUpdateOne) ClearAtStationNo() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearAtStationNo()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *WorkpieceUpdateOne) SetStatus(v string) *WorkpieceUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableStatus(v *string) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetOnlineAt sets the "onlineAt" field.
|
|
func (_u *WorkpieceUpdateOne) SetOnlineAt(v time.Time) *WorkpieceUpdateOne {
|
|
_u.mutation.SetOnlineAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOnlineAt sets the "onlineAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableOnlineAt(v *time.Time) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetOnlineAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOnlineAt clears the value of the "onlineAt" field.
|
|
func (_u *WorkpieceUpdateOne) ClearOnlineAt() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearOnlineAt()
|
|
return _u
|
|
}
|
|
|
|
// SetDoneAt sets the "doneAt" field.
|
|
func (_u *WorkpieceUpdateOne) SetDoneAt(v time.Time) *WorkpieceUpdateOne {
|
|
_u.mutation.SetDoneAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDoneAt sets the "doneAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableDoneAt(v *time.Time) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetDoneAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDoneAt clears the value of the "doneAt" field.
|
|
func (_u *WorkpieceUpdateOne) ClearDoneAt() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearDoneAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updatedAt" field.
|
|
func (_u *WorkpieceUpdateOne) SetUpdatedAt(v time.Time) *WorkpieceUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
|
func (_u *WorkpieceUpdateOne) ClearUpdatedAt() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearUpdatedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgPending sets the "torque_ng_pending" field.
|
|
func (_u *WorkpieceUpdateOne) SetTorqueNgPending(v bool) *WorkpieceUpdateOne {
|
|
_u.mutation.SetTorqueNgPending(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgPending sets the "torque_ng_pending" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableTorqueNgPending(v *bool) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetTorqueNgPending(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgAt sets the "torque_ng_at" field.
|
|
func (_u *WorkpieceUpdateOne) SetTorqueNgAt(v time.Time) *WorkpieceUpdateOne {
|
|
_u.mutation.SetTorqueNgAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgAt sets the "torque_ng_at" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableTorqueNgAt(v *time.Time) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetTorqueNgAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTorqueNgAt clears the value of the "torque_ng_at" field.
|
|
func (_u *WorkpieceUpdateOne) ClearTorqueNgAt() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearTorqueNgAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTorqueNgBy sets the "torque_ng_by" field.
|
|
func (_u *WorkpieceUpdateOne) SetTorqueNgBy(v string) *WorkpieceUpdateOne {
|
|
_u.mutation.SetTorqueNgBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTorqueNgBy sets the "torque_ng_by" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableTorqueNgBy(v *string) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetTorqueNgBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTorqueNgBy clears the value of the "torque_ng_by" field.
|
|
func (_u *WorkpieceUpdateOne) ClearTorqueNgBy() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearTorqueNgBy()
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitMW sets the "flowTransitMW" field.
|
|
func (_u *WorkpieceUpdateOne) SetFlowTransitMW(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.ResetFlowTransitMW()
|
|
_u.mutation.SetFlowTransitMW(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitMW sets the "flowTransitMW" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitMW(v *int) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetFlowTransitMW(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFlowTransitMW adds value to the "flowTransitMW" field.
|
|
func (_u *WorkpieceUpdateOne) AddFlowTransitMW(v int) *WorkpieceUpdateOne {
|
|
_u.mutation.AddFlowTransitMW(v)
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitTarget sets the "flowTransitTarget" field.
|
|
func (_u *WorkpieceUpdateOne) SetFlowTransitTarget(v string) *WorkpieceUpdateOne {
|
|
_u.mutation.SetFlowTransitTarget(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitTarget sets the "flowTransitTarget" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitTarget(v *string) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetFlowTransitTarget(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetFlowTransitAt sets the "flowTransitAt" field.
|
|
func (_u *WorkpieceUpdateOne) SetFlowTransitAt(v time.Time) *WorkpieceUpdateOne {
|
|
_u.mutation.SetFlowTransitAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFlowTransitAt sets the "flowTransitAt" field if the given value is not nil.
|
|
func (_u *WorkpieceUpdateOne) SetNillableFlowTransitAt(v *time.Time) *WorkpieceUpdateOne {
|
|
if v != nil {
|
|
_u.SetFlowTransitAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearFlowTransitAt clears the value of the "flowTransitAt" field.
|
|
func (_u *WorkpieceUpdateOne) ClearFlowTransitAt() *WorkpieceUpdateOne {
|
|
_u.mutation.ClearFlowTransitAt()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the WorkpieceMutation object of the builder.
|
|
func (_u *WorkpieceUpdateOne) Mutation() *WorkpieceMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the WorkpieceUpdate builder.
|
|
func (_u *WorkpieceUpdateOne) Where(ps ...predicate.Workpiece) *WorkpieceUpdateOne {
|
|
_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 *WorkpieceUpdateOne) Select(field string, fields ...string) *WorkpieceUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Workpiece entity.
|
|
func (_u *WorkpieceUpdateOne) Save(ctx context.Context) (*Workpiece, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *WorkpieceUpdateOne) SaveX(ctx context.Context) *Workpiece {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *WorkpieceUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *WorkpieceUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *WorkpieceUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
|
v := workpiece.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *WorkpieceUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Sn(); ok {
|
|
if err := workpiece.SnValidator(v); err != nil {
|
|
return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "Workpiece.sn": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.OrderNo(); ok {
|
|
if err := workpiece.OrderNoValidator(v); err != nil {
|
|
return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "Workpiece.orderNo": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := workpiece.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Workpiece.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.TorqueNgBy(); ok {
|
|
if err := workpiece.TorqueNgByValidator(v); err != nil {
|
|
return &ValidationError{Name: "torque_ng_by", err: fmt.Errorf(`ent: validator failed for field "Workpiece.torque_ng_by": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.FlowTransitTarget(); ok {
|
|
if err := workpiece.FlowTransitTargetValidator(v); err != nil {
|
|
return &ValidationError{Name: "flowTransitTarget", err: fmt.Errorf(`ent: validator failed for field "Workpiece.flowTransitTarget": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *WorkpieceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *WorkpieceUpdateOne) sqlSave(ctx context.Context) (_node *Workpiece, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(workpiece.Table, workpiece.Columns, sqlgraph.NewFieldSpec(workpiece.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Workpiece.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, workpiece.FieldID)
|
|
for _, f := range fields {
|
|
if !workpiece.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != workpiece.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.Sn(); ok {
|
|
_spec.SetField(workpiece.FieldSn, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.OrderNo(); ok {
|
|
_spec.SetField(workpiece.FieldOrderNo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.WorkOrderId(); ok {
|
|
_spec.SetField(workpiece.FieldWorkOrderId, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedWorkOrderId(); ok {
|
|
_spec.AddField(workpiece.FieldWorkOrderId, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.WorkOrderIdCleared() {
|
|
_spec.ClearField(workpiece.FieldWorkOrderId, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.CurrentStationNo(); ok {
|
|
_spec.SetField(workpiece.FieldCurrentStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCurrentStationNo(); ok {
|
|
_spec.AddField(workpiece.FieldCurrentStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.CurrentStationNoCleared() {
|
|
_spec.ClearField(workpiece.FieldCurrentStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.AtStationNo(); ok {
|
|
_spec.SetField(workpiece.FieldAtStationNo, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAtStationNo(); ok {
|
|
_spec.AddField(workpiece.FieldAtStationNo, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.AtStationNoCleared() {
|
|
_spec.ClearField(workpiece.FieldAtStationNo, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(workpiece.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.OnlineAt(); ok {
|
|
_spec.SetField(workpiece.FieldOnlineAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.OnlineAtCleared() {
|
|
_spec.ClearField(workpiece.FieldOnlineAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.DoneAt(); ok {
|
|
_spec.SetField(workpiece.FieldDoneAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DoneAtCleared() {
|
|
_spec.ClearField(workpiece.FieldDoneAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(workpiece.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdatedAtCleared() {
|
|
_spec.ClearField(workpiece.FieldUpdatedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgPending(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgPending, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgAt(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.TorqueNgAtCleared() {
|
|
_spec.ClearField(workpiece.FieldTorqueNgAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TorqueNgBy(); ok {
|
|
_spec.SetField(workpiece.FieldTorqueNgBy, field.TypeString, value)
|
|
}
|
|
if _u.mutation.TorqueNgByCleared() {
|
|
_spec.ClearField(workpiece.FieldTorqueNgBy, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitMW(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFlowTransitMW(); ok {
|
|
_spec.AddField(workpiece.FieldFlowTransitMW, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitTarget(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitTarget, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.FlowTransitAt(); ok {
|
|
_spec.SetField(workpiece.FieldFlowTransitAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.FlowTransitAtCleared() {
|
|
_spec.ClearField(workpiece.FieldFlowTransitAt, field.TypeTime)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &Workpiece{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{workpiece.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|