Files
bj_power/bj_power_wms/ent/inspectiondisposalitem_update.go
T
SunYF d92ca803d5 feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志
- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端
- MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流
- 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志
- MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整
- 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整
- 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
2026-11-16 16:42:44 +08:00

484 lines
15 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/predicate"
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// InspectionDisposalItemUpdate is the builder for updating InspectionDisposalItem entities.
type InspectionDisposalItemUpdate struct {
config
hooks []Hook
mutation *InspectionDisposalItemMutation
}
// Where appends a list predicates to the InspectionDisposalItemUpdate builder.
func (_u *InspectionDisposalItemUpdate) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetRecordID sets the "record_id" field.
func (_u *InspectionDisposalItemUpdate) SetRecordID(v int64) *InspectionDisposalItemUpdate {
_u.mutation.ResetRecordID()
_u.mutation.SetRecordID(v)
return _u
}
// SetNillableRecordID sets the "record_id" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableRecordID(v *int64) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetRecordID(*v)
}
return _u
}
// AddRecordID adds value to the "record_id" field.
func (_u *InspectionDisposalItemUpdate) AddRecordID(v int64) *InspectionDisposalItemUpdate {
_u.mutation.AddRecordID(v)
return _u
}
// SetDisposeType sets the "dispose_type" field.
func (_u *InspectionDisposalItemUpdate) SetDisposeType(v string) *InspectionDisposalItemUpdate {
_u.mutation.SetDisposeType(v)
return _u
}
// SetNillableDisposeType sets the "dispose_type" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableDisposeType(v *string) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetDisposeType(*v)
}
return _u
}
// SetQty sets the "qty" field.
func (_u *InspectionDisposalItemUpdate) SetQty(v int) *InspectionDisposalItemUpdate {
_u.mutation.ResetQty()
_u.mutation.SetQty(v)
return _u
}
// SetNillableQty sets the "qty" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableQty(v *int) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetQty(*v)
}
return _u
}
// AddQty adds value to the "qty" field.
func (_u *InspectionDisposalItemUpdate) AddQty(v int) *InspectionDisposalItemUpdate {
_u.mutation.AddQty(v)
return _u
}
// SetRemark sets the "remark" field.
func (_u *InspectionDisposalItemUpdate) SetRemark(v string) *InspectionDisposalItemUpdate {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableRemark(v *string) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *InspectionDisposalItemUpdate) ClearRemark() *InspectionDisposalItemUpdate {
_u.mutation.ClearRemark()
return _u
}
// SetOperator sets the "operator" field.
func (_u *InspectionDisposalItemUpdate) SetOperator(v string) *InspectionDisposalItemUpdate {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableOperator(v *string) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *InspectionDisposalItemUpdate) SetCreatedAt(v int64) *InspectionDisposalItemUpdate {
_u.mutation.ResetCreatedAt()
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdate) SetNillableCreatedAt(v *int64) *InspectionDisposalItemUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// AddCreatedAt adds value to the "created_at" field.
func (_u *InspectionDisposalItemUpdate) AddCreatedAt(v int64) *InspectionDisposalItemUpdate {
_u.mutation.AddCreatedAt(v)
return _u
}
// Mutation returns the InspectionDisposalItemMutation object of the builder.
func (_u *InspectionDisposalItemUpdate) Mutation() *InspectionDisposalItemMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *InspectionDisposalItemUpdate) 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 *InspectionDisposalItemUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *InspectionDisposalItemUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *InspectionDisposalItemUpdate) 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 *InspectionDisposalItemUpdate) check() error {
if v, ok := _u.mutation.Qty(); ok {
if err := inspectiondisposalitem.QtyValidator(v); err != nil {
return &ValidationError{Name: "qty", err: fmt.Errorf(`ent: validator failed for field "InspectionDisposalItem.qty": %w`, err)}
}
}
return nil
}
func (_u *InspectionDisposalItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(inspectiondisposalitem.Table, inspectiondisposalitem.Columns, sqlgraph.NewFieldSpec(inspectiondisposalitem.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.RecordID(); ok {
_spec.SetField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedRecordID(); ok {
_spec.AddField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
}
if value, ok := _u.mutation.DisposeType(); ok {
_spec.SetField(inspectiondisposalitem.FieldDisposeType, field.TypeString, value)
}
if value, ok := _u.mutation.Qty(); ok {
_spec.SetField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedQty(); ok {
_spec.AddField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(inspectiondisposalitem.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(inspectiondisposalitem.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(inspectiondisposalitem.FieldOperator, field.TypeString, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedCreatedAt(); ok {
_spec.AddField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{inspectiondisposalitem.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// InspectionDisposalItemUpdateOne is the builder for updating a single InspectionDisposalItem entity.
type InspectionDisposalItemUpdateOne struct {
config
fields []string
hooks []Hook
mutation *InspectionDisposalItemMutation
}
// SetRecordID sets the "record_id" field.
func (_u *InspectionDisposalItemUpdateOne) SetRecordID(v int64) *InspectionDisposalItemUpdateOne {
_u.mutation.ResetRecordID()
_u.mutation.SetRecordID(v)
return _u
}
// SetNillableRecordID sets the "record_id" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableRecordID(v *int64) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetRecordID(*v)
}
return _u
}
// AddRecordID adds value to the "record_id" field.
func (_u *InspectionDisposalItemUpdateOne) AddRecordID(v int64) *InspectionDisposalItemUpdateOne {
_u.mutation.AddRecordID(v)
return _u
}
// SetDisposeType sets the "dispose_type" field.
func (_u *InspectionDisposalItemUpdateOne) SetDisposeType(v string) *InspectionDisposalItemUpdateOne {
_u.mutation.SetDisposeType(v)
return _u
}
// SetNillableDisposeType sets the "dispose_type" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableDisposeType(v *string) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetDisposeType(*v)
}
return _u
}
// SetQty sets the "qty" field.
func (_u *InspectionDisposalItemUpdateOne) SetQty(v int) *InspectionDisposalItemUpdateOne {
_u.mutation.ResetQty()
_u.mutation.SetQty(v)
return _u
}
// SetNillableQty sets the "qty" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableQty(v *int) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetQty(*v)
}
return _u
}
// AddQty adds value to the "qty" field.
func (_u *InspectionDisposalItemUpdateOne) AddQty(v int) *InspectionDisposalItemUpdateOne {
_u.mutation.AddQty(v)
return _u
}
// SetRemark sets the "remark" field.
func (_u *InspectionDisposalItemUpdateOne) SetRemark(v string) *InspectionDisposalItemUpdateOne {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableRemark(v *string) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *InspectionDisposalItemUpdateOne) ClearRemark() *InspectionDisposalItemUpdateOne {
_u.mutation.ClearRemark()
return _u
}
// SetOperator sets the "operator" field.
func (_u *InspectionDisposalItemUpdateOne) SetOperator(v string) *InspectionDisposalItemUpdateOne {
_u.mutation.SetOperator(v)
return _u
}
// SetNillableOperator sets the "operator" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableOperator(v *string) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetOperator(*v)
}
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *InspectionDisposalItemUpdateOne) SetCreatedAt(v int64) *InspectionDisposalItemUpdateOne {
_u.mutation.ResetCreatedAt()
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *InspectionDisposalItemUpdateOne) SetNillableCreatedAt(v *int64) *InspectionDisposalItemUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// AddCreatedAt adds value to the "created_at" field.
func (_u *InspectionDisposalItemUpdateOne) AddCreatedAt(v int64) *InspectionDisposalItemUpdateOne {
_u.mutation.AddCreatedAt(v)
return _u
}
// Mutation returns the InspectionDisposalItemMutation object of the builder.
func (_u *InspectionDisposalItemUpdateOne) Mutation() *InspectionDisposalItemMutation {
return _u.mutation
}
// Where appends a list predicates to the InspectionDisposalItemUpdate builder.
func (_u *InspectionDisposalItemUpdateOne) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemUpdateOne {
_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 *InspectionDisposalItemUpdateOne) Select(field string, fields ...string) *InspectionDisposalItemUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated InspectionDisposalItem entity.
func (_u *InspectionDisposalItemUpdateOne) Save(ctx context.Context) (*InspectionDisposalItem, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *InspectionDisposalItemUpdateOne) SaveX(ctx context.Context) *InspectionDisposalItem {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *InspectionDisposalItemUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *InspectionDisposalItemUpdateOne) 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 *InspectionDisposalItemUpdateOne) check() error {
if v, ok := _u.mutation.Qty(); ok {
if err := inspectiondisposalitem.QtyValidator(v); err != nil {
return &ValidationError{Name: "qty", err: fmt.Errorf(`ent: validator failed for field "InspectionDisposalItem.qty": %w`, err)}
}
}
return nil
}
func (_u *InspectionDisposalItemUpdateOne) sqlSave(ctx context.Context) (_node *InspectionDisposalItem, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(inspectiondisposalitem.Table, inspectiondisposalitem.Columns, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "InspectionDisposalItem.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, inspectiondisposalitem.FieldID)
for _, f := range fields {
if !inspectiondisposalitem.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != inspectiondisposalitem.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.RecordID(); ok {
_spec.SetField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedRecordID(); ok {
_spec.AddField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
}
if value, ok := _u.mutation.DisposeType(); ok {
_spec.SetField(inspectiondisposalitem.FieldDisposeType, field.TypeString, value)
}
if value, ok := _u.mutation.Qty(); ok {
_spec.SetField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedQty(); ok {
_spec.AddField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(inspectiondisposalitem.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(inspectiondisposalitem.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.Operator(); ok {
_spec.SetField(inspectiondisposalitem.FieldOperator, field.TypeString, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedCreatedAt(); ok {
_spec.AddField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
}
_node = &InspectionDisposalItem{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{inspectiondisposalitem.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}